Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Add custom columns to admin comments grid
- * * Rate that user set.
- */
- add_filter( 'manage_edit-comments_columns', function( $default ) {
- $columns['smr_comment_rate'] = __( 'Rate', 'txtdmn' );
- return array_slice( $default, 0, 3, true ) + $columns + array_slice( $default, 2, NULL, true );
- });
- /**
- * Remove an object filter.
- *
- * @param string $tag Hook name.
- * @param string $class Class name. Use 'Closure' for anonymous functions.
- * @param string|void $method Method name. Leave empty for anonymous functions.
- * @param string|int|void $priority Priority
- * @return void
- */
- function remove_object_filter( $tag, $class, $method = NULL, $priority = NULL ) {
- $filters = $GLOBALS['wp_filter'][ $tag ];
- if ( empty ( $filters ) ) {
- return;
- }
- foreach ( $filters as $p => $filter ) {
- if ( ! is_null($priority) && ( (int) $priority !== (int) $p ) ) continue;
- $remove = FALSE;
- foreach ( $filter as $identifier => $function ) {
- $function = $function['function'];
- if (
- is_array( $function )
- && (
- is_a( $function[0], $class )
- || ( is_array( $function ) && $function[0] === $class )
- )
- ) {
- $remove = ( $method && ( $method === $function[1] ) );
- } elseif ( $function instanceof Closure && $class === 'Closure' ) {
- $remove = TRUE;
- }
- if ( $remove ) {
- unset( $GLOBALS['wp_filter'][$tag][$p][$identifier] );
- }
- }
- }
- }
- // remove a static method
- remove_object_filter( 'a_filter_hook', 'AClass', 'a_static_method', 10 );
- // remove a dynamic method
- remove_object_filter( 'a_filter_hook', 'AClass', 'a_dynamic_method', 10 );
- // remove a closure
- remove_object_filter( 'a_filter_hook', 'Closure', NULL, 10 );
- add_filter( 'manage_edit-comments_columns', function( $default ) {
- unset( $default['smr_comment_rate'] );
- return $default;
- }, 11, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement