Where should I use get_option in a plugin

Both ways are almost equal, the first will be slightly faster, because the callback is called only if the check equals to TRUE. Note you cannot test an option like this, unless the option name is really ‘my_option[option_1]’. What you probably want is: if ( $test = get_option(‘my_option’) and 1 === $test[‘option_1’] ) add_action(); An … Read more

How can I modify what is being output in wp_head, whether by a theme or WordPress in general?

First: don’t enqueue custom versions of WordPress core-bundled scripts, including (and especially) jQuery. Second, to answer your question: those Plugin scripts and stylesheets are enqueued, using add_action(), via a callback hooked into one of the following action hooks: wp_head wp_enqueue_scripts wp_print_scripts wp_print_styles (There are others, but those are the most likely.) Inside the callback, the … Read more

How to avoid plugin name conflicts from the upgrade notifier?

You can remove you plugin from the updateble list with: add_action( ‘plugins_loaded’, function(){ add_filter( ‘site_transient_update_plugins’, function ( $value ) { if( isset( $value->response[‘google-analytics/google-analytics.php’] ) ) unset( $value->response[‘google-analytics/google-analytics.php’] ); return $value; }); }); Adding this filter will eliminate our homonymous plugin altogether from update checks. And it supposes that we are doing the updates manually via … Read more

Plugin update error message

I know this is kind of a backwards way of doing it, but I suppose if you disable the possibility to upgrade the plugin, then you don’t need to worry about the plugin being overwritten. Change the plugin version number (in the plugins main file comment header) to something ridiculously high so it won’t recommend … Read more

WordPress plugin from own server

All Credit to the following post goes to Abid Omar. The full tutorial can be found on Tuts+: A Guide to the WordPress HTTP API: Automatic Plugin Updates View Plugin On Github The gist is to create a new class which will post an external file ( API ) and return plugin to download if … Read more

How to remove duplicate sub-menu name for top level menu items in a plugin?

If you dont want ‘TopLevel’ menu to represent a custom page you can use: add_menu_page( ‘TopLevel’, ‘TopLevel’, ‘MENU_CAP_LVL’, ‘MENU_SLUG’, ‘MENU_CB’ ); add_submenu_page( ‘MENU_SLUG’, ‘SubMenu’, ‘SubMenu’, ‘MENU_CAP_LVL’, ‘SUB_MENU_SLUG’, ‘SUB_MENU_CB’ ); add_submenu_page( ‘MENU_SLUG’, ‘SubMenu-A’, ‘SubMenu-A’, ‘MENU_CAP_LVL’, ‘SUB_MENU_A_SLUG’, ‘SUB_MENU_A_CB’ ); remove_submenu_page(‘MENU_SLUG’,’MENU_SLUG’); In this way click on “TopMenu” will forward to the 1st “SubMenu” and prevent “TopLevel” from being … Read more

How can I have two different urls for the same page that load two different templates?

You could accomplish this with a rewrite endpoint and a template filter. First, register a new rewrite endpoint for the page post type: function wpd_app_view_rewrite_endpoint() { add_rewrite_endpoint( ‘app-view’, EP_PAGES ); } add_action( ‘init’, ‘wpd_app_view_rewrite_endpoint’ ); Don’t forget to flush rewrite rules after adding this (or just visit the Permalinks > Settings page to do this … Read more

Self Develop or Plugin as first option?

There are several things I consider when making such choice (in no particular order): does task involve general functionality (plugin) or processing my specific content (develop) is there the plugin for the task from known developer and well-maintained (plugin) or there is fractured field of numerous plugins (develop) do I want full range of related … Read more

How to make search engine index PDF files? [closed]

The standard WordPress search is pretty basic and only search the database, there are some plugins that extend the search functionality to search even more parts of the database like: Search Everything Search Unleashed but they do not have the ability to search files. There is one plugin that i know of that claims to … Read more

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