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().

Get object for a few selected taxonomies

I am not aware of a function to get only specific term objects for a post type but it is not hard to filter out the ones you want. For example: $taxonomies = get_object_taxonomies( ‘post’, ‘objects’ ); $taxonomies = array_intersect_key($taxonomies,array_flip(array(‘category’,’post_tag’))); var_dump($taxonomies); But since you know the taxonomies you want, you could also just use get_taxonomy( … Read more

A question about add_action()

The emailer::send is the function callback for a publish_post action hook. This action hook accepts only one parameter which is the post ID and it is passed by WordPress. When you define an action hook, you set what parameters are passed to the callback functions. For example: $arg_1 = “The aregument value”; do_action( ‘my_custom_action’, $arg_1 … Read more

Autoloader not finding classes from my plugin

Given the first PHP code snippet you posted, I don’t see that you’re using the class yet, which explains why you’re not seeing your classes in the autoload error log that you’re debugging with. Note that use will not trigger PHP’s autoloader. use My_Plugin\Includes; You need to actually instantiate a class, check that it exists, … Read more

Override static method in WC_Shortcodes class (shortcode) [closed]

This is how you can (or should) remove the default Shortcode: // Hook after `WC_Shortcodes::init()` is executed. add_action( ‘init’, function(){ // Remove the shortcode. remove_shortcode( ‘product_categories’ ); // Add it back, but using our callback. add_shortcode( ‘product_categories’, ‘my_product_categories_shortcode’ ); }, 11 ); And here’s how you can modify the default Shortcode’s output: function my_product_categories_shortcode( $atts … Read more

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