How to add icons to post listing (edit.php) in admin

We can style the table with CSS and dashicons. Example: For our video category, we can use for example: .edit-php .wp-list-table tr.category-video td.post-title strong:before { content: “\f126”; color: #ccc; display: inline-block; width: 20px; height: 20px; margin: 0 4px; font-size: 20px; line-height: 20px; font-family: “dashicons”; font-weight: normal; vertical-align: top; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } where we … Read more

What do add_filters() and apply_filter() do?

What are you attempting to filter? I’ll assume you’re trying to add a filter to a filter hook called posts_before. In which case, you need to add your filter to this hook, via add_filter(): function mytheme_filter_posts_before( $where=””, $date) { $where .= ” AND post_date < ‘” . $date . “‘”; return $where; } // Add … Read more

Modify WordPress Rest Api Request/Response

I think I found answer to your question, it is: rest_{$this->post_type}_query filter hook. With this hook you are able to directly edit internal WP_Query parameter. For example, if you’d like to internally sort Posts by post_title by default, then you’d have to write something like this: function order_rest_post_by_post_title($args, $request) { $args[‘orderby’] = ‘post_title’; $args[‘order’] = … Read more

Check if a filter or function has been already been called

You can use a static variable to achieve this: add_filter( ‘the_content’, ‘asdf_the_content’, 99, 1 ); function asdf_the_content( $content ) { static $has_run = false; if ( $has_run ) { return $content; } $has_run = true; // check if the_content has already been // filtered by some other function $content = ucwords( $content ); return $content; … Read more

Filter hook before create order WooCommerce

Stumbled on this looking for the same thing which I’ve now figured out (Woocommerce 3.x)… add_filter( ‘woocommerce_checkout_create_order’, ‘mbm_alter_shipping’, 10, 1 ); function mbm_alter_shipping ($order) { if ($something == $condition) { $address = array( ‘first_name’ => ‘Martin’, ‘last_name’ => ‘Stevens’, ‘company’ => ‘MBM Studio’, ’email’ => ‘[email protected]’, ‘phone’ => ‘777-777-777-777’, ‘address_1′ => ’99 Arcadia Avenue’, ‘address_2’ … Read more

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

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