doing_filter example

return false;
    }

    // Special handling for programmatically created image tags.     if ( 'the_post_thumbnail' === $context || 'wp_get_attachment_image' === $context ) {
        /* * Skip programmatically created images within post content as they need to be handled together with the other * images within the post content. * Without this clause, they would already be counted below which skews the number and can result in the first * post content image being lazy-loaded only because there are images elsewhere in the post content. */
        if ( doing_filter( 'the_content' ) ) {
            return false;
        }

        // Conditionally skip lazy-loading on images before the loop.         if (
            // Only apply for main query but before the loop.             $wp_query->before_loop && $wp_query->is_main_query()
            /* * Any image before the loop, but after the header has started should not be lazy-loaded, * except when the footer has already started which can happen when the current template * does not include any loop. */


    // Special handling for programmatically created image tags.     if ( 'the_post_thumbnail' === $context || 'wp_get_attachment_image' === $context || 'widget_media_image' === $context ) {
        /* * Skip programmatically created images within post content as they need to be handled together with the other * images within the post content. * Without this clause, they would already be considered below which skews the image count and can result in * the first post content image being lazy-loaded or an image further down the page being marked as a high * priority. */
        if ( doing_filter( 'the_content' ) ) {
            return $loading_attrs;
        }

        // Conditionally skip lazy-loading on images before the loop.         if (
            // Only apply for main query but before the loop.             $wp_query->before_loop && $wp_query->is_main_query()
            /* * Any image before the loop, but after the header has started should not be lazy-loaded, * except when the footer has already started which can happen when the current template * does not include any loop. */

function doing_action( $hook_name = null ) {
    return doing_filter( $hook_name );
}

/** * Retrieves the number of times an action has been fired during the current request. * * @since 2.1.0 * * @global int[] $wp_actions Stores the number of times each action was triggered. * * @param string $hook_name The name of the action hook. * @return int The number of times the action hook has been fired. */

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. */
Home | Imprint | This part of the site doesn't use cookies.