Add whitespace between Chinese and other letters

Interesting question. This could be a useful part of a specific language file. It cannot be done in CSS, because CSS is (mostly) character agnostic. But using a filter and PHP it is possible and on topic: add_filter( ‘the_content’, ‘t5_chinese_spacing’ ); function t5_chinese_spacing( $content ) { return preg_replace( ‘~([^\p{Han}]*)(\p{Han}+)([^\p{Han}])~imUxu’, ‘\1 \2 \3’, $content ); } … Read more

What hook do I use to edit the post statuses option in admin?

You can use the filter views_edit-post (or views_edit-{custom-post-type}) to modify the available “views”: add_filter(‘views_edit-post’, ‘cyb_remove_pending_filter’ ); function cyb_remove_pending_filter( $views ) { if( isset( $views[‘pending’] ) ) { unset( $views[‘pending’] ); } return $views; } In the above filter you need inlude the user rules you want to apply. For exmple, if you want to remove … Read more

Passing Additional Parameters to add_filter Callable

The second parameter in add_filter is a function with accepted arguments, not returned values. This is an example how I pass my custom array $args to change an existing array $filter_args: add_filter( ‘woocommerce_dropdown_variation_attribute_options_args’, function( $filter_args ) use ( $args ) { return eswc_var_dropdown_args( $filter_args, $args ); } ); function eswc_var_dropdown_args( $filter_args, $args ) { $filter_args[‘show_option_none’] … Read more

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.