Registration - Force users to complete their profile after they register? How to. Writing Custom Queries in WordPress. With custom queries you can make any data reading and/or manipulation you want. Instantly a world of new possibilities open up. Why Use Custom Queries? The basic functionalities in WordPress are fine for most simple needs, but what would you do if you want to implement some specific needs? Are you writing a plugin maybe? The wpdb Class This global WordPress class is key for using queries. Using query The query function needs a string containing the custom query. Get_results This function gets multiple rows when executing a query. Get_var This will return one variable from the database, but the complete result of the query is cached for later use. Get_row A complete row will be returned as a result of the function, which can be an object, an associative array, or a numerically indexed array. Get_col For getting a column, use this function.
Prepared Queries According to the php.net manual: You can protect SQL queries against SQL injection attacks. Setting Error Messages Cache Control Inserting Data. WordPress Essentials: Interacting With The WordPress Database. Advertisement While you already use many functions in WordPress to communicate with the database, there is an easy and safe way to do this directly, using the $wpdb class. Built on the great ezSQL class1 by Justin Vincent, $wpdb enables you to address queries to any table in your database, and it also helps you handle the returned data. Because this functionality is built into WordPress, there is no need to open a separate database connection (in which case, you would be duplicating code), and there is no need to perform hacks such as modifying a result set after it has been queried. The $wpdb class modularizes and automates a lot of database-related tasks.
In this article, I will show you how to get started with the $wpdb class, how to retrieve data from your WordPress database and how to run more advanced queries that update or delete something in the database. Getting Started <? As you can see, this is a basic SQL query, with some PHP wrapped around it. Get_results() <? Get_row <? Get_col <? WordPress Plugin Pet Peeve #2: Direct Calls to Plugin Files – willnorris.com. This is actually very similar to my first pet peeve of hardcoding the path to wp-content, in that it makes assumptions about where files are placed on the filesystem. Oftentimes, plugins need to handle certain kinds of requests, maybe for some specific protocol, or to handle an AJAX request. Some plugins will do this by making an HTTP request directly to one of the files in the plugin… something like: echo '<script type="text/javascript"> jQuery.get("' . plugins_url('my-plugin/ajax-handler.php') . '"); // do something with AJAX data ...
</script>'; This is not a problem in and of itself, in fact it’s great that the plugin developer is actually using the plugins_url function! The problem arises in the my-plugin/ajax-handler.php file itself. Require_once('../../.. So what is this, and why is it so bad? A couple of points to emphasize before moving on: if your plugin files are not accessing any built-in WordPress functions, classes, or data, calling them directly should be just fine.
jQuery.dForm. The jQuery.dForm plugin generates HTML markup from JavaScript objects and JSON with a focus on HTML forms. Some things you can do: naturally generate JavaScript enhanced markup with your own extensions and custom typesuse JavaScript and JSON instead of HTML markup since your page doesn't run without JS anywayhave an easy way to include jQuery UI elements and other jQuery plugins (some supported out of the box)scaffold forms from business objects of your server side framework Get started Download the latest version 1.1.0 (min) (~7 Kb minified) Include it in your jQuery powered page and try this: Or to quickly load an external form definition: <script type="text/javascript"> $(function() { // Load the form object from path/to/form.json $("#myform").dform('path/to/form.json', function(data) { this //-> Generated $('#myform') data //-> data from path/to/form.json }); </script><form id="myform"></form> Demo: Learn more: Types Will append an empty <span id="the-span"></span> to the selected element.
SimpleModal / Eric Martin / ericmmartin.com. Overview SimpleModal is a lightweight jQuery Plugin which provides a powerful interface for modal dialog development. Think of it as a modal dialog framework. SimpleModal gives you the flexibility to build whatever you can envision, while shielding you from related cross-browser issues inherent with UI development. Usage SimpleModal provides 2 simple ways to invoke a modal dialog. As a chained jQuery function, you can call the modal() function on a jQuery element and a modal dialog will be displayed using the contents of that element.
$("#element-id").modal(); As a stand-alone function, a modal dialog can be created by passing a jQuery object, a DOM element, or a plain string (which can contain HTML) . $.modal("<div><h1>SimpleModal</h1></div>"); Both of the methods described above, also accept an optional options object (nice tongue-twister, huh?). $("#element-id").modal({options}); $.modal("<div><h1>SimpleModal</h1></div>", {options}); Styling For IE6, you might want to apply the PNG fix: Demos.
5 tips for using AJAX in WordPress | Gary Cao. AJAX is used in many WordPress themes and plugins. However, not all of those themes and plugins implement AJAX properly. This article reveals 5 best practices in developing AJAX for WordPress. Warning: This is a long and information-packed article. Be sure to bookmark this post so you can always go back for reference! Table of Content Bad ways to implement AJAX I have read the code of many plugins that implement AJAX. The PHP file that handles the AJAX almost always begin with this line: require_once( "../../../.. What’s wrong with this is that sometimes users set up their folder structure differently, making the relative path declared in the PHP file above invalid. Along with the PHP file above, another PHP file is necessary to output the javascript that makes the AJAX request. Sorry for keeping you off the good part of the article so long. 1. Although wp_localize_script() is created for localization, it also has another great use. 2. 3.
Nonces OK, enough theory. There, all done. 4. 5. How to Customize the WordPress Admin Area. WordPress is one of the best CMSs out there — if not the best (but of course, I’m biased because I’m a WordPress fanatic). It has loads of handy features that make site administration a breeze. WordPress is a publishing platform with a comment system, a GUI for creating, editing and managing posts and pages, handy built-in tools like the "Export" feature to back up your content, user roles and permissions, and more.
But how much of these features do we really use? Though already simple and user-friendly by default, we might want to customize the WordPress Admin interface to make it even simpler and more manageable for our clients, our co-authors, and ourselves. Why Customize the WordPress Admin Interface? Lately, WordPress has reached phenomenally high usage rates. Here is the problem, though. The following image shows the default WordPress Dashboard — the first page you’ll see when you log into the Admin area. The Solution Luckily, WordPress has a solution. WordPress’s functions.php. WordPress Custom Post Types Guide.
One of the most anticipated features of WordPress 3.0 was the ability to add your own custom post types to WordPress, which allows you to display and categorize different types of content outside of the 5 native WordPress content types (i.e. Post, Page, Attachment, and so forth). The addition of this feature is a big step forward in making WordPress a full-fledged CMS, extending outside its normal use as a blogging platform. In this guide, we’ll go through the process of creating and using your own custom post type. More specifically, we will create an "Event" post type for your special events and dates, sort of like a calendar. What is a Custom Post Type? If you’re familiar with WordPress, then I’m sure you’ve already had some exposure to the default WordPress post types used for content creation: Post and Page.
Posts are generally used for content that is updated frequently (blog posts, for example), and pages are generally used for static content (such as the About page of a site). <? Function Reference/wp enqueue script. Function Reference/wp enqueue script Languages: English • Español • Русский • 中文(简体) • 한국어 • (Add your language) Description Links a script file to the generated page at the right time according to the script dependencies, if the script has not been already included and if all the dependencies have been registered.
You could either link a script with a handle previously registered using the wp_register_script() function, or provide this function with all the parameters necessary to link a script. This is the recommended method of linking JavaScript to a WordPress generated page. Usage <? Parameters $handle (string) (required) Name used as a handle for the script. Default: None $src (string) (optional) URL to the script, e.g. Default: false $deps (array) (optional) Array of the handles of all the registered scripts that this script depends on, that is the scripts that must be loaded before this script. Default: array() $ver $in_footer <? A Guide to WordPress Custom Taxonomy. In this guide, we will cover an incredibly great feature of WordPress: Custom taxonomy.
Custom WordPress taxonomies give you unprecedented power in the way you can categorize and relate your WordPress content with each other. Though WordPress taxonomies were introduced in WordPress 2.3, it has been revamped in WordPress 3.0 for WordPress developers. Recently, we had looked at creating custom WordPress post types in the WordPress custom posts guide, and to further our command of WordPress 3.0 site and theme development, we’re going to now discuss custom taxonomies. What is Taxonomy in WordPress? Taxonomy is simply a way of organizing data and, in the WordPress world, a taxonomy is a way of organizing and tying your site content together.
Even though you don’t realize it, you’re probably already very familiar with at least one of the built-in WordPress taxonomies: WordPress tags. A custom taxonomy is exactly what it sounds like — a custom way to relate disparate content together. With: To: <? Сервис для входа в твой сайт через соц. сервисы. Большой обзор лучших плагинов WordPress 2011 - ТопОбзор.
67 542 просм. В данном обзоре мы собрали наиболее важные, лучшие и функциональные плагины, на наш взгляд, для WordPress за 2011 год в 7 категориях: резервное копирование, безопасность, оптимизация;поисковая оптимизация (SEO), статистика; записи, посты, дополнительные модули;интернет-магазины;изображения, фотогалереи, слайдеры;социальные сети, комментарии, закладки, подписка;дополнительные возможности для админпанели. Upd. Кроме того, рекомендуем ознакомитьтся с более свежей подброкой лучших плагинов WordPress за последнее время: Мега-обзор: лучшие плагины WordPress 2012-2013 1.1. W3 Total Cache W3 Total Cache - плагин кэширует данные, создавая статистические страницы. Скачать плагин W3 Total Cache 1.2. WP-SuperCache - еще один плагин для кеширования страниц, при обращении пользователя к конкретной странице блога, сохраняет статистическую копию страницы на сервере.
Скачать плагин WP-SuperCache 1.3. WP-optimize – плагин имеет широкий набор фукций по оптимизации базы WordPress. 1.4. 1.5. 1.6.