background preloader

Wordpress

Facebook Twitter

5 tips for using AJAX in WordPress - WordPress Hardcore. 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! The links below makes it easier to navigate this article. 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. AJAX in Plugins. AJAX in Plugins Languages: English • 日本語 • (Add your language) Introduction This article, aimed at plugin developers, describes how to add Ajax to a plugin. Before reading this article, you should be familiar with the following: Ajax - Overview of the technology Writing a Plugin - How to write a plugin Plugin API - Filters and actions - what they are and how to use them How to add HTML to the appropriate WordPress page, post, or screen -- for instance, if you want to add Ajax to administration screens you create, you will need to understand how to add administration menus to WordPress; if you want to add Ajax to the display of a single post, you'll need to figure out the right filters and actions to add HTML to that spot on viewer-facing blog screens.

Ajax on the Administration Side Here's a short example. Then, set up a PHP function that will handle that request: <? That's it! Separate Javascript File With external files, we must enqueue them in PHP so they are included on the page. <? List of all WP action hooks and filters -- Adam Brown, BYU Political Science. WordPress coders, theme authors, and plugin developers use the hooks listed below to change how WordPress behaves without needing to edit any PHP source files. Use this index to identify the WordPress hooks that you need.

Click a column name to sort. For a specific WordPress hook's version history and file locations, click on the hook's name. If a hook is not in the most recent version (4.1), then it is deprecated. Do not use it. Viewing options: View all hooks • View action hooks • View filter hooks • View deprecated hooks Important warning about variable hooks Some hooks have variables in their names. Installation « Subscribe2 Plugin. BuddyPress. BuddyPress lets users sign-up and start creating profiles, posting messages, making connections, creating and interacting in groups, and much more. A social network in a box, BuddyPress lets you easily build a community for your company, school, sports team, or other niche community. Plugins: Adding So Much More BuddyPress boasts an ever growing array of new features developed by an awesome plugin development community. There are more than 330 BuddyPress plugins available, and the list is growing every day. More Information Visit the BuddyPress website for more information about BuddyPress.

Languages: Also available in English (Australia), Español, Français, Português do Brasil, Svenska, and 2 other languages.