Is it possible to use object in add_action?

You can do this: class testclass { function test() { echo ‘howdy’; } } add_action(‘wp_head’,array(‘testclass’,’test’)); Or this: $t = new testclass(); add_action(‘wp_head’,array($t,’test’)); It doesn’t work like… $t = new testclass(); add_action(‘wp_head’,’t’); // or this either, for good measure $t = new testclass(); add_action(‘wp_head’,array(‘t’)); .. but I am not sure what you are trying to accomplish … Read more

Remove description from on Home

wp_get_document_title() has some interesting filters – pre_get_document_title and document_title_parts. /** * Filter the parts of the document title. * * @since 4.4.0 * * @param array $title { * The document title parts. * * @type string $title Title of the viewed page. * @type string $page Optional. Page number if paginated. * @type string … Read more

How to add filter to __() and _e()?

The filter name is gettext, and you would add it like this: add_filter( ‘gettext’, ‘my_wp_text_email_filtering’, 10, 3 ); function my_wp_text_email_filtering( $translated, $text, $domain ) { return FilterTextOfEmail( $translated ); } The $text argument is there also in case you want to access the pre-translated text.

How to check if a hook is hooked or not?

Sure, that’s called has_action, which is an alias of has_filter. Usage: if ( has_action(‘hook_name’) ) { throw new \Exception(‘You cannot hook to a protected action.’); } else { do_action(‘hook_name’); } These two functions access the global array $wp_filter that stores all of the filters / actions

How to hook into unregistering a widget instance?

Yes, this can be done. Ultimately, adding and removing a widget to/from a sidebar means updating an option in the database with a call like this: update_option( ‘sidebars_widgets’, array( … ) ) If you look at the code of update_option you see that there is a filter called just before the actual update. So if … Read more

Is there a way to add another row to the tinyMCE kitchen sink toggle?

Yes! Use the mce_buttons_2 filter to add buttons to the second row. Use the mce_buttons_3 filter to add buttons to the third row. Here’s an example of what I use: function mytheme_mce_buttons_row_3($buttons) { $buttons[] = ‘fontselect’; $buttons[] = ‘fontsizeselect’; $buttons[] = ‘code’; $buttons[] = ‘sup’; $buttons[] = ‘sub’; $buttons[] = ‘backcolor’; $buttons[] = ‘separator’; $buttons[] … Read more

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