How to Add a Third Level Sub Menu to the WordPress Admin Menu

No, it is not possible to create third level menu in admin panel. If you look at the definition of add_submenu_page, you need to mention the parent slug name. For eg: add_menu_page ( ‘Test Menu’, ‘Test Menu’, ‘read’, ‘testmainmenu’, ”, ” ); add_submenu_page ( ‘testmainmenu’, ‘Test Menu’, ‘Child1’, ‘read’, ‘child1’, ”); The first parameter of … Read more

Stop a plugin in the activation process when a certain WP version is not met then show error message in admin_notices action hook

I may be late to this party, but to stop plugin activation and have WordPress show an error message where the admin notices go, I simply output an error message and terminate execution. This has the added advantage of playing nice with wp-cli: Example: class testPlugin() { … static function activate() { //[do some stuff … Read more

How to Add WYSIWYG Editor (tinyMCE) to plugin options page compatible with WordPress 3.0 and up?

Pre WP 3.3: http://www.dev4press.com/2010/tutorials/wordpress/tips/add-rich-text-editor-to-your-plugin/ If you are using WP 3.3 or later you might look up wp_editor: http://codex.wordpress.org/Function_Reference/wp_editor $settings = array( ‘teeny’ => true, ‘textarea_rows’ => 15, ‘tabindex’ => 1 ); wp_editor(esc_html( __(get_option(‘whatever_you_need’, ‘whatever’))), ‘terms_wp_content’, $settings);

Is it bad practice to create own table for a plugin?

I rarely disagree with otherwise knowledgeable users, but in this case I can’t help it. In my opinion calling the usage of non-core database tables bad practice per se is just simply wrong. The choice of whether to go with core tables or add your own depends on several factors. A query’s execution time depends … Read more

wp_dequeue_style not working

Okay so I figured this one out. function custom_dequeue() { wp_dequeue_style(‘et-gf-open-sans’); wp_deregister_style(‘et-gf-open-sans’); } add_action( ‘wp_enqueue_scripts’, ‘custom_dequeue’, 9999 ); add_action( ‘wp_head’, ‘custom_dequeue’, 9999 ); @milo was right. The plugin was re-enqueueing it so the deregistering it got that file to stop loading. Then the plugin also had another check, where it would register and enqueue another … Read more

Why is it important to deactivate a plugin before deleting it?

Generally, plugins have some functionality hooked onto the deactivation action. This could be clearing cache, resetting options, you name it. Therefore the best practice is to deactivate them first, so they have the opportunity to clean up and execute whatever functionality they have hooked onto the deactivate event. Now if the plugin is broken and … Read more

Disable /wp-admin/plugin-install.php

There is a constant you can define in wp-config.php to do this. It will also disable the theme edit, however. <?php // somewhere in wp-config.php define(‘DISALLOW_FILE_MODS’, true); That will remove the plugin and theme file editor (which are a terrible idea anyway) and remove the ability to install plugins and themes from the admin area.

How to create custom message on plugin update

This message is created by W3_Total_Cache->in_plugin_update_message() hooked to “in_plugin_update_message-$file”in wp_plugin_update_row(). It does some nifties to parse readme and display info from changelog, but overall you can just echo some stuff as with any other hook.

Turn Off Auto Update for Single Plugin

you place this in your theme’s functions.php // Disable update notification for individual plugins – see my example of plugin block-spam-by-math-reloaded as to how to use this function function filter_plugin_updates( $value ) { unset( $value->response[‘plugin-folder-name/plugin-file-name.php’] ); return $value; } add_filter( ‘site_transient_update_plugins’, ‘filter_plugin_updates’ );