has_filter example


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. */
/* * The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant * or the `automatic_updater_disabled` filter, * or by `wp_is_file_mod_allowed( 'automatic_updater' )`. * See `WP_Automatic_Updater::is_disabled()`. */
        $can_set_update_option = false;
    }

    // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter?     if ( has_filter( 'allow_major_auto_core_updates' ) ) {
        $can_set_update_option = false;
    }

    /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
    $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev );
    /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
    $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
    /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
    $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major );

    $auto_update_settings = array(
        
/** This filter is documented in wp-admin/my-sites.php */
        echo apply_filters( 'myblogs_options', '', $user_blog );

        echo '</li>';

        restore_current_blog();
    }
    ?> </ul> <?php     if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) {
        ?> <input type="hidden" name="action" value="updateblogsettings" /> <?php         wp_nonce_field( 'update-my-sites' );
        submit_button();
    }
    ?> </form> <?php endif; ?> </div> <?php
            $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
            // Old WP installs may not have AUTH_SALT defined.             $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand();

            $placeholder = '{' . hash_hmac( $algouniqid( $salt, true )$salt ) . '}';
        }

        /* * Add the filter to remove the placeholder escaper. Uses priority 0, so that anything * else attached to this filter will receive the query with the placeholder string removed. */
        if ( false === has_filter( 'query', array( $this, 'remove_placeholder_escape' ) ) ) {
            add_filter( 'query', array( $this, 'remove_placeholder_escape' ), 0 );
        }

        return $placeholder;
    }

    /** * Adds a placeholder escape string, to escape anything that resembles a printf() placeholder. * * @since 4.8.3 * * @param string $query The query to escape. * @return string The query with the placeholder escape string inserted where necessary. */

        $content = apply_filters( 'the_editor_content', $content$default_editor );

        // Remove the filter as the next editor on the same page may not need it.         if ( self::$this_tinymce ) {
            remove_filter( 'the_editor_content', 'format_for_editor' );
        }

        // Back-compat for the `htmledit_pre` and `richedit_pre` filters.         if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) {
            /** This filter is documented in wp-includes/deprecated.php */
            $content = apply_filters_deprecated( 'htmledit_pre', array( $content ), '4.3.0', 'format_for_editor' );
        } elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) ) {
            /** This filter is documented in wp-includes/deprecated.php */
            $content = apply_filters_deprecated( 'richedit_pre', array( $content ), '4.3.0', 'format_for_editor' );
        }

        if ( false !== stripos( $content, 'textarea' ) ) {
            $content = preg_replace( '%</textarea%i', '&lt;/textarea', $content );
        }

        

    public function check_wp_version_check_exists() {
        if ( ! is_admin() || ! is_user_logged_in() || ! current_user_can( 'update_core' ) || ! isset( $_GET['health-check-test-wp_version_check'] ) ) {
            return;
        }

        echo ( has_filter( 'wp_version_check', 'wp_version_check' ) ? 'yes' : 'no' );

        die();
    }

    /** * Tests for WordPress version and outputs it. * * Gives various results depending on what kind of updates are available, if any, to encourage * the user to install security updates as a priority. * * @since 5.2.0 * * @return array The test result. */
// Use oEmbed to get the HTML.         $html = wp_oembed_get( $url$attr );

        if ( $post_id ) {
            if ( $html ) {
                update_post_meta( $post_id$cachekey$html );
                update_post_meta( $post_id$cachekey_timetime() );
            } elseif ( ! $cache ) {
                update_post_meta( $post_id$cachekey, '{{unknown}}' );
            }
        } else {
            $has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );

            if ( $has_kses ) {
                // Prevent KSES from corrupting JSON in post_content.                 kses_remove_filters();
            }

            $insert_post_args = array(
                'post_name'   => $key_suffix,
                'post_status' => 'publish',
                'post_type'   => 'oembed_cache',
            );

            

function do_blocks( $content ) {
    $blocks = parse_blocks( $content );
    $output = '';

    foreach ( $blocks as $block ) {
        $output .= render_block( $block );
    }

    // If there are blocks in this content, we shouldn't run wpautop() on it later.     $priority = has_filter( 'the_content', 'wpautop' );
    if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) {
        remove_filter( 'the_content', 'wpautop', $priority );
        add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 );
    }

    return $output;
}

/** * If do_blocks() needs to remove wpautop() from the `the_content` filter, this re-adds it afterwards, * for subsequent `the_content` usage. * * @since 5.0.0 * @access private * * @param string $content The post content running through this filter. * @return string The unmodified content. */

    do_action( 'edit_form_before_permalink', $post );
    ?> <div class="inside"> <?php     if ( $viewable ) :
        $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';

        // As of 4.4, the Get Shortlink button is hidden by default.         if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
            $shortlink = wp_get_shortlink( $post->ID, 'post' );

            if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
                $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
                    '<button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' .
                    __( 'Get Shortlink' ) .
                    '</button>';
            }
        }

        if ( $post_type_object->public
            
// Make sure that the comment post ID is valid (if specified).     if ( ! empty( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) {
        if ( $wp_error ) {
            return new WP_Error( 'invalid_post_id', __( 'Invalid post ID.' ) );
        } else {
            return false;
        }
    }

    $filter_comment = false;
    if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
        $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
    }

    if ( $filter_comment ) {
        add_filter( 'pre_comment_content', 'wp_filter_kses' );
    }

    // Escape data pulled from DB.     $comment = wp_slash( $comment );

    $old_status = $comment['comment_approved'];

    


    // Find all registered tag names in $content.     preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content$matches );
    $tagnames = array_intersect( array_keys( $shortcode_tags )$matches[1] );

    if ( empty( $tagnames ) ) {
        return $content;
    }

    // Ensure this context is only added once if shortcodes are nested.     $has_filter = has_filter( 'wp_get_attachment_image_context', '_filter_do_shortcode_context' );
    $filter_added = false;

    if ( ! $has_filter ) {
        $filter_added = add_filter( 'wp_get_attachment_image_context', '_filter_do_shortcode_context' );
    }

    $content = do_shortcodes_in_html_tags( $content$ignore_html$tagnames );

    $pattern = get_shortcode_regex( $tagnames );
    $content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content );

    

    public function get_columns() {
        $sites_columns = array(
            'cb'          => '<input type="checkbox" />',
            'blogname'    => __( 'URL' ),
            'lastupdated' => __( 'Last Updated' ),
            'registered'  => _x( 'Registered', 'site' ),
            'users'       => __( 'Users' ),
        );

        if ( has_filter( 'wpmublogsaction' ) ) {
            $sites_columns['plugins'] = __( 'Actions' );
        }

        /** * Filters the displayed site columns in Sites list table. * * @since MU (3.0.0) * * @param string[] $sites_columns An array of displayed site columns. Default 'cb', * 'blogname', 'lastupdated', 'registered', 'users'. */
        
$this->query_string = '';
        foreach ( (array) array_keys( $this->query_vars ) as $wpvar ) {
            if ( '' != $this->query_vars[ $wpvar ] ) {
                $this->query_string .= ( strlen( $this->query_string ) < 1 ) ? '' : '&';
                if ( ! is_scalar( $this->query_vars[ $wpvar ] ) ) { // Discard non-scalars.                     continue;
                }
                $this->query_string .= $wpvar . '=' . rawurlencode( $this->query_vars[ $wpvar ] );
            }
        }

        if ( has_filter( 'query_string' ) ) {  // Don't bother filtering and parsing if no plugins are hooked in.             /** * Filters the query string before parsing. * * @since 1.5.0 * @deprecated 2.1.0 Use {@see 'query_vars'} or {@see 'request'} filters instead. * * @param string $query_string The query string to modify. */
            $this->query_string = apply_filters_deprecated(
                'query_string',
                array( $this->query_string ),
                

function has_filter( $hook_name$callback = false ) {
    global $wp_filter;

    if ( ! isset( $wp_filter[ $hook_name ] ) ) {
        return false;
    }

    return $wp_filter[ $hook_name ]->has_filter( $hook_name$callback );
}

/** * Removes a callback function from a filter hook. * * This can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. * * To remove a hook, the `$callback` and `$priority` arguments must match * when the hook was added. This goes for both filters and actions. No warning * will be given on removal failure. * * @since 1.2.0 * * @global WP_Hook[] $wp_filter Stores all of the filters and actions. * * @param string $hook_name The filter hook to which the function to be removed is hooked. * @param callable|string|array $callback The callback to be removed from running when the filter is applied. * This function can be called unconditionally to speculatively remove * a callback that may or may not exist. * @param int $priority Optional. The exact priority used when adding the original * filter callback. Default 10. * @return bool Whether the function existed before it was removed. */
return false;
        }

        $this->is_previewed              = true;
        $this->_original_value           = $this->value();
        $this->original_nav_menu_term_id = $this->_original_value['nav_menu_term_id'];
        $this->_previewed_blog_id        = get_current_blog_id();

        add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_wp_get_nav_menu_items' ), 10, 3 );

        $sort_callback = array( __CLASS__, 'sort_wp_get_nav_menu_items' );
        if ( ! has_filter( 'wp_get_nav_menu_items', $sort_callback ) ) {
            add_filter( 'wp_get_nav_menu_items', array( __CLASS__, 'sort_wp_get_nav_menu_items' ), 1000, 3 );
        }

        // @todo Add get_post_metadata filters for plugins to add their data.
        return true;
    }

    /** * Filters the wp_get_nav_menu_items() result to supply the previewed menu items. * * @since 4.3.0 * * @see wp_get_nav_menu_items() * * @param WP_Post[] $items An array of menu item post objects. * @param WP_Term $menu The menu object. * @param array $args An array of arguments used to retrieve menu item objects. * @return WP_Post[] Array of menu item objects. */
Home | Imprint | This part of the site doesn't use cookies.