Let plugin check if taxonomy is already registered by another plugin

The problem is that the function is defined whether you use it or not. What you want is the PHP function function_exists if ( !taxonomy_exists( ‘my_taxonomy’ ) && !function_exists(‘register_taxonomy_my_taxonomy’) ) { add_action( ‘init’, ‘register_taxonomy_my_taxonomy’ ); function register_taxonomy_my_taxonomy() { … } You should be able to create a reusable library (class) that would take care of … Read more

WordPress plugin development OOP style

Change ma_admin_options_init() to: public function ma_admin_options_init(){ register_setting(‘ma_admin_styler’, ‘ma_admin_styler’, array( $this,’ma_admin_styler_validate’)); add_settings_section(‘main_section’, ”, array( $this,’section_text_default’), ‘ma_admin_styler’); add_settings_field(‘error_font_color’, ‘Error Font Color’, array( $this,’ma_error_font_color’), ‘ma_admin_styler’, ‘main_section’); } The fourth parameter of add_settings_section() and add_settings_field() is $page and that needs to match the page ID set in add_options_page().

I18n not working in plugin

The problem I was encountering was a result of not realizing that the 3rd parameter for load_plugin_textdomain should be a relative path to the language directory from WP_PLUGIN_DIR. Since plugin_dir_path returns an absolute path, things broke. Changing the hooked function as follows solved the problem: add_action(‘plugins_loaded’, array(‘PluginName’, ‘loadTextDomain’)); class PluginName { public static function loadTextDomain() … Read more

Is there an admin hook that will let me read GET variable before it’s too late to set the header Location

You can check the $current_screen on the current_screen action, and redirect after checking some GET conditions: function wpd_current_screen( $current_screen ) { if ( ‘toplevel_page_your_menu_item_id’ == $current_screen->base ) { // check some condition and wp_redirect( admin_url() ); exit; } } add_action( ‘current_screen’, ‘wpd_current_screen’ );