add_filter example


    public function __construct( $screen$columns = array() ) {
        if ( is_string( $screen ) ) {
            $screen = convert_to_screen( $screen );
        }

        $this->_screen = $screen;

        if ( ! empty( $columns ) ) {
            $this->_columns = $columns;
            add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );
        }
    }

    /** * Gets a list of all, hidden, and sortable columns. * * @since 3.1.0 * * @return array */
    protected function get_column_info() {
        
if ( $pagination_arrow ) {
        $label = $pagination_arrow . $label;
    }
    $content = '';
    // Check if the pagination is for Query that inherits the global context     // and handle appropriately.     if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
        $filter_link_attributes = static function() use ( $wrapper_attributes ) {
            return $wrapper_attributes;
        };

        add_filter( 'previous_posts_link_attributes', $filter_link_attributes );
        $content = get_previous_posts_link( $label );
        remove_filter( 'previous_posts_link_attributes', $filter_link_attributes );
    } elseif ( 1 !== $page ) {
        $content = sprintf(
            '<a href="%1$s" %2$s>%3$s</a>',
            esc_url( add_query_arg( $page_key$page - 1 ) ),
            $wrapper_attributes,
            $label
        );
    }
    return $content;
}
if ( $this->is_preview() ) {
            add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
        }

        /* * Note that the widgets component in the customizer will also do * the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). */
        add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) );

        add_filter( 'display_media_states', array( $this, 'display_media_state' ), 10, 2 );
    }

    /** * Get schema for properties of a widget instance (item). * * @since 4.8.0 * * @see WP_REST_Controller::get_item_schema() * @see WP_REST_Controller::get_additional_fields() * @link https://core.trac.wordpress.org/ticket/35574 * * @return array Schema for properties. */
/** * Gets URL. * * @param string $url * @param string $username * @param string $password * @param bool $head * @return array */
    public function get_page( $url$username = '', $password = '', $head = false ) {
        // Increase the timeout.         add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );

        $headers = array();
        $args    = array();
        if ( true === $head ) {
            $args['method'] = 'HEAD';
        }
        if ( ! empty( $username ) && ! empty( $password ) ) {
            $headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password);
        }

        $args['headers'] = $headers;

        

$avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults );
$default         = get_option( 'avatar_default', 'mystery' );
$avatar_list     = '';

// Force avatars on to display these choices. add_filter( 'pre_option_show_avatars', '__return_true', 100 );

foreach ( $avatar_defaults as $default_key => $default_name ) {
    $selected     = ( $default === $default_key ) ? 'checked="checked" ' : '';
    $avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr( $default_key ) . "' {$selected}/> ";
    $avatar_list .= get_avatar( $user_email, 32, $default_key, '', array( 'force_default' => true ) );
    $avatar_list .= ' ' . $default_name . '</label>';
    $avatar_list .= '<br />';
}

remove_filter( 'pre_option_show_avatars', '__return_true', 100 );

if ( 'core/image' === $inner_block['blockName'] ) {
                if ( ! isset( $parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] ) && isset( $inner_block['attrs']['id'] ) ) {
                    $parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] = esc_attr( $inner_block['attrs']['id'] );
                }
            }
        }
    }

    return $parsed_block;
}

add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );

/** * Adds a style tag for the --wp--style--unstable-gallery-gap var. * * The Gallery block needs to recalculate Image block width based on * the current gap setting in order to maintain the number of flex columns * so a css var is added to allow this. * * @param array $attributes Attributes of the block being rendered. * @param string $content Content of the block being rendered. * @return string The content of the block being rendered. */


        if ( ! empty( $request['mime_type'] ) ) {
            $parts = explode( '/', $request['mime_type'] );
            if ( isset( $media_types[ $parts[0] ] ) && in_array( $request['mime_type']$media_types[ $parts[0] ], true ) ) {
                $query_args['post_mime_type'] = $request['mime_type'];
            }
        }

        // Filter query clauses to include filenames.         if ( isset( $query_args['s'] ) ) {
            add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
        }

        return $query_args;
    }

    /** * Checks if a given request has access to create an attachment. * * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error Boolean true if the attachment may be created, or a WP_Error if not. */

function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
    global $error$interim_login$action;

    // Don't index any of these forms.     add_filter( 'wp_robots', 'wp_robots_sensitive_page' );
    add_action( 'login_head', 'wp_strict_cross_origin_referrer' );

    add_action( 'login_head', 'wp_login_viewport_meta' );

    if ( ! is_wp_error( $wp_error ) ) {
        $wp_error = new WP_Error();
    }

    // Shake it!     $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password', 'retrieve_password_email_failure' );
    /** * Filters the error codes array for shaking the login form. * * @since 3.0.0 * * @param string[] $shake_error_codes Error codes that shake the login form. */

    function wxr_filter_postmeta( $return_me$meta_key ) {
        if ( '_edit_lock' === $meta_key ) {
            $return_me = true;
        }
        return $return_me;
    }
    add_filter( 'wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2 );

    echo '<?xml version="1.0" encoding="' . get_bloginfo( 'charset' ) . "\" ?>\n";

    ?> <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. --> <!-- It contains information about your site's posts, pages, comments, categories, and other content. --> <!-- You may use this file to transfer that content from one site to another. --> <!-- This file is not intended to serve as a complete backup of your site. --> <!-- To import this information into a WordPress site follow these steps: --> <!-- 1. Log in to that site as an administrator. --> <!-- 2. Go to Tools: Import in the WordPress admin panel. --> <!-- 3. Install the "WordPress" importer from the list. --> <!-- 4. Activate & Run Importer. --> <!-- 5. Upload this file using the form provided on that page. --> <!-- 6. You will first be asked to map the authors in this export file to users --> <!-- on the site. For each author, you may choose to map to an --> <!-- existing user on the site or to create a new user. --> <!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. --> <!-- contained in this file into your site. -->
// Let's roll. header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );

wp_user_settings();
_wp_admin_html_begin();

$body_class = 'wp-core-ui wp-customizer js';

if ( wp_is_mobile() ) :
    $body_class .= ' mobile';
    add_filter( 'admin_viewport_meta', '_customizer_mobile_viewport_meta' );
endif;

if ( $wp_customize->is_ios() ) {
    $body_class .= ' ios';
}

if ( is_rtl() ) {
    $body_class .= ' rtl';
}
$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );

$src = wp_get_attachment_url( $attachment->ID );
        }

        if ( empty( $src ) ) {
            return;
        }

        $youtube_pattern = '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#';
        $vimeo_pattern   = '#^https?://(.+\.)?vimeo\.com/.*#';

        if ( $attachment || preg_match( $youtube_pattern$src ) || preg_match( $vimeo_pattern$src ) ) {
            add_filter( 'wp_video_shortcode', array( $this, 'inject_video_max_width_style' ) );

            echo wp_video_shortcode(
                array_merge(
                    $instance,
                    compact( 'src' )
                ),
                $instance['content']
            );

            remove_filter( 'wp_video_shortcode', array( $this, 'inject_video_max_width_style' ) );
        } else {
            

    if ( $pagination_arrow ) {
        $label .= $pagination_arrow;
    }
    $content = '';

    // Check if the pagination is for Query that inherits the global context.     if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
        $filter_link_attributes = static function() use ( $wrapper_attributes ) {
            return $wrapper_attributes;
        };
        add_filter( 'next_posts_link_attributes', $filter_link_attributes );
        // Take into account if we have set a bigger `max page`         // than what the query has.         global $wp_query;
        if ( $max_page > $wp_query->max_num_pages ) {
            $max_page = $wp_query->max_num_pages;
        }
        $content = get_next_posts_link( $label$max_page );
        remove_filter( 'next_posts_link_attributes', $filter_link_attributes );
    } elseif ( ! $max_page || $max_page > $page ) {
        $custom_query           = new WP_Query( build_query_vars_from_query_block( $block$page ) );
        $custom_query_max_pages = (int) $custom_query->max_num_pages;
        
    if ( empty( $args['auth_callback'] ) ) {
        if ( is_protected_meta( $meta_key$object_type ) ) {
            $args['auth_callback'] = '__return_false';
        } else {
            $args['auth_callback'] = '__return_true';
        }
    }

    // Back-compat: old sanitize and auth callbacks are applied to all of an object type.     if ( is_callable( $args['sanitize_callback'] ) ) {
        if ( ! empty( $object_subtype ) ) {
            add_filter( "sanitize_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['sanitize_callback'], 10, 4 );
        } else {
            add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 3 );
        }
    }

    if ( is_callable( $args['auth_callback'] ) ) {
        if ( ! empty( $object_subtype ) ) {
            add_filter( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['auth_callback'], 10, 6 );
        } else {
            add_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
        }
    }
// Add support for link color control.         add_theme_support( 'link-color' );

        // Add support for experimental cover block spacing.         add_theme_support( 'custom-spacing' );

        // Add support for custom units.         // This was removed in WordPress 5.6 but is still required to properly support WP 5.5.         add_theme_support( 'custom-units' );

        // Remove feed icon link from legacy RSS widget.         add_filter( 'rss_widget_feed_link', '__return_empty_string' );
    }
}
add_action( 'after_setup_theme', 'twenty_twenty_one_setup' );

/** * Registers widget area. * * @since Twenty Twenty-One 1.0 * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar * * @return void */

function update_sitemeta_cache( $site_ids ) {
    // Ensure this filter is hooked in even if the function is called early.     if ( ! has_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ) ) {
        add_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' );
    }
    return update_meta_cache( 'blog', $site_ids );
}

/** * Retrieves a list of sites matching requested arguments. * * @since 4.6.0 * @since 4.8.0 Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters. * * @see WP_Site_Query::parse_query() * * @param string|array $args Optional. Array or string of arguments. See WP_Site_Query::__construct() * for information on accepted arguments. Default empty array. * @return array|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', * or the number of sites when 'count' is passed as a query var. */
Home | Imprint | This part of the site doesn't use cookies.