Does the number of downloads displayed for a plug-in in the WordPress.org plug-in directory include automatic updates?

That’s the total number of downloads. It includes direct downloads in the Repository and installs/updates done in the dashboard. Quotes from Otto comments in this 2010 article about the stats charts in every plugin’s page. […] the download count includes direct downloads as well […] There is no “raw count” anywhere on that version number … Read more

Get a path to a different plugin

My best guess would be: if ( ! is_file( $dir = WPMU_PLUGIN_DIR . ‘/pluginb/pluginb.php’ ) ) { if ( ! is_file( $dir = WP_PLUGIN_DIR . ‘/pluginb/pluginb.php’ ) ) $dir = null; } return $dir; However, the danger here is still the assumption of the plugin’s “basename” – a well written plugin will still function even … Read more

How to Add an Index to Plugin Database table

You can execute arbitrary SQL statements with wpdb::query(), including Data Definition Statements, e.g. function create_index () { global $wpdb ; $sql = “CREATE INDEX my_index ON {$wpdb->prefix}my_table (my_column)” ; $wpdb->query ($sql) ; return ; } Note: Because $wpdb->query() can execute arbitrary SQL, if the statement you pass to it contains ANY user input, then you … Read more

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

Add self-closing shortcode button to TinyMCE in WP 4.6

We start by adding the custom TinyMCE Button: function add_mce_button_custom_em() { // check user permissions if ( !current_user_can( ‘edit_posts’ ) && !current_user_can( ‘edit_pages’ ) ) { return; } // check if WYSIWYG is enabled if ( ‘true’ == get_user_option( ‘rich_editing’ ) ) { add_filter( ‘mce_external_plugins’, ‘add_tinymce_plugin_custom_em’ ); add_filter( ‘mce_buttons’, ‘register_mce_button_custom_em’ ); } } add_action(‘admin_head’, ‘add_mce_button_custom_em’); … 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

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