difference between add_options and register_setting

register_setting() uses Settings API, which is just an API for options.php, is easier to use, more secure and preffered way of storing options since WordPress 2.7. If you need to store only a few options or doing simple plugin just for yourself – it’s really up to you which one to use 🙂 Here’s the … Read more

How to customize a plugin whilst maintaining ability to upgrade

Many plugins use /wp-content/custom-plugin-folder/ to store customized plugin data (WPTouch comes to mind). Just use the constants WP_CONTENT_URL and WP_CONTENT_DIR Docs to check for the existence of your folder and retrieve any available skins. The following article, although not directly related to this Question, explains the importance for plugins/themes to search for translations first in … Read more

How can I add a featured image to a page?

Eek! A 33% acceptance rate isn’t really going to do you any favours but lucky for you WordPress’ in-built post-thumbnail featured image functionality works for posts, custom post types and pages too. Add the following line into your theme functions.php file: add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘page’ ) ); Then in your page.php file and I … Read more

Shared functionality in plugins and themes

Actions & Filters The imho best way is to use an action to bring plugin functions into themes. Example #1 Here’s a little plugin to test this. <?php /** Plugin Name: (#68117) Print Hello! */ function wpse68117_print_hello() { echo “Hello World!”; } add_action( ‘wpse68117_say’, ‘wpse68117_print_hello’ ); Inside the theme: <?php /** Template Name: Test »Print … Read more

Security and .htaccess

UPDATE: When I first posted my answer I missed the crux of the question; my answer was about .htaccess security in general and is now listed below the double line (look down if it interests you.) Unfortunately I don’t have specific experience with securing /wp-admin/ using .htaccess so I’ll simply list the two resources I … Read more

Combine multiple plugins into one?

Go through each plugin file and remove the plugin header. Create a loader.php file. Something like this: <?php /* Plugin Name: Combined Plugin Description: Contains plugin a, plugin b and plugin c */ include dirname(__FILE__) . ‘/plugin-a.php’; include dirname(__FILE__) . ‘/plugin-b.php’; include dirname(__FILE__) . ‘/plugin-c.php’;

How can I call a function from one plugin within another plugin?

Maybe you should try calling the functions of your plugin using the plugins_loaded action. Plugin A class PluginA { public function func_a() { // do stuff } } Plugin B class PluginB { function functB() { if (class_exists(‘PluginA’)) { //do stuff that depends of PluginA } } } add_action(‘plugins_loaded’, ‘call_plugin_a_using_plugin_b’); function call_plugin_a_using_plugin_b() { PluginB::functB(); } … Read more

How to roll back a WordPress plugin update?

Unless the plugin has made significant database changes, you could follow these steps to downgrade it: Download and extract the old version from the plugin repository Disable the plugin Log on to your server with FTP or SSH Upload the old plugin directory to wp-content/plugins/. (You would want to overwrite the newer version.) Reactivate the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)