has_action example

global $wp_query;

    $feed = get_query_var( 'feed' );

    // Remove the pad, if present.     $feed = preg_replace( '/^_+/', '', $feed );

    if ( '' === $feed || 'feed' === $feed ) {
        $feed = get_default_feed();
    }

    if ( ! has_action( "do_feed_{$feed}) ) {
        wp_die( __( '<strong>Error:</strong> This is not a valid feed template.' ), '', array( 'response' => 404 ) );
    }

    /** * Fires once the given feed is loaded. * * The dynamic portion of the hook name, `$feed`, refers to the feed template name. * * Possible hook names include: * * - `do_feed_atom` * - `do_feed_rdf` * - `do_feed_rss` * - `do_feed_rss2` * * @since 2.1.0 * @since 4.4.0 The `$feed` parameter was added. * * @param bool $is_comment_feed Whether the feed is a comment feed. * @param string $feed The feed name. */

function do_action_deprecated( $hook_name$args$version$replacement = '', $message = '' ) {
    if ( ! has_action( $hook_name ) ) {
        return;
    }

    _deprecated_hook( $hook_name$version$replacement$message );

    do_action_ref_array( $hook_name$args );
}

// // Functions for handling plugins. //
'<label for="url">%s</label>',
                __( 'Website' )
            ),
            sprintf(
                '<input id="url" name="url" %s value="%s" size="30" maxlength="200" autocomplete="url" />',
                ( $html5 ? 'type="url"' : 'type="text"' ),
                esc_attr( $commenter['comment_author_url'] )
            )
        ),
    );

    if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) {
        $consent = empty( $commenter['comment_author_email'] ) ? '' : $checked_attribute;

        $fields['cookies'] = sprintf(
            '<p class="comment-form-cookies-consent">%s %s</p>',
            sprintf(
                '<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"%s />',
                $consent
            ),
            sprintf(
                '<label for="wp-comment-cookies-consent">%s</label>',
                __( 'Save my name, email, and website in this browser for the next time I comment.' )
            )
/* translators: %s: Documentation URL. */
                __( 'You can also control the display of your content in RSS feeds, including the maximum number of posts to display and whether to show full text or an excerpt. <a href="%s">Learn more about feeds</a>.' ),
                __( 'https://wordpress.org/documentation/article/wordpress-feeds/' )
            ) . '</p>' .
            '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
    )
);

get_current_screen()->add_help_tab(
    array(
        'id'      => 'site-visibility',
        'title'   => has_action( 'blog_privacy_selector' ) ? __( 'Site visibility' ) : __( 'Search engine visibility' ),
        'content' => '<p>' . __( 'You can choose whether or not your site will be crawled by robots, ping services, and spiders. If you want those services to ignore your site, click the checkbox next to &#8220;Discourage search engines from indexing this site&#8221; and click the Save Changes button at the bottom of the screen.' ) . '</p>' .
            '<p>' . __( 'Note that even when set to discourage search engines, your site is still visible on the web and not all search engines adhere to this directive.' ) . '</p>' .
            '<p>' . __( 'When this setting is in effect, a reminder is shown in the At a Glance box of the Dashboard that says, &#8220;Search engines discouraged&#8221;, to remind you that you have directed search engines to not crawl your site.' ) . '</p>',
    )
);

get_current_screen()->set_help_sidebar(
    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    '<p>' . __( '<a href="https://wordpress.org/documentation/article/settings-reading-screen/">Documentation on Reading Settings</a>' ) . '</p>' .
    '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
);

<?php _e( 'Confirm use of weak password' ); ?> </label> </td> </tr> <?php endif; ?> <tr> <th scope="row"><label for="admin_email"><?php _e( 'Your Email' ); ?></label></th> <td><input name="admin_email" type="email" id="admin_email" size="25" aria-describedby="admin-email-desc" value="<?php echo esc_attr( $admin_email ); ?>" /> <p id="admin-email-desc"><?php _e( 'Double-check your email address before continuing.' ); ?></p></td> </tr> <tr> <th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?></th> <td> <fieldset> <legend class="screen-reader-text"><span> <?php                         has_action( 'blog_privacy_selector' )
                            /* translators: Hidden accessibility text. */
                            ? _e( 'Site visibility' )
                            /* translators: Hidden accessibility text. */
                            : _e( 'Search engine visibility' );
                        ?> </span></legend>

function get_plugin_page_hook( $plugin_page$parent_page ) {
    $hook = get_plugin_page_hookname( $plugin_page$parent_page );
    if ( has_action( $hook ) ) {
        return $hook;
    } else {
        return null;
    }
}

/** * Gets the hook name for the administrative page of a plugin. * * @since 1.5.0 * * @global array $admin_page_hooks * * @param string $plugin_page The slug name of the plugin page. * @param string $parent_page The slug name for the parent menu (or the file name of a standard * WordPress admin page). * @return string Hook name for the plugin page. */

function wp_admin_bar_customize_menu( $wp_admin_bar ) {
    global $wp_customize;

    // Don't show if a block theme is activated and no plugins use the customizer.     if ( wp_is_block_theme() && ! has_action( 'customize_register' ) ) {
        return;
    }

    // Don't show for users who can't access the customizer or when in the admin.     if ( ! current_user_can( 'customize' ) || is_admin() ) {
        return;
    }

    // Don't show if the user cannot edit a given customize_changeset post currently being previewed.     if ( is_customize_preview() && $wp_customize->changeset_post_id()
        && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() )
    )
/** 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

                );
            }

            $existing_changeset_data = $this->get_changeset_post_data( $changeset_post_id );
            if ( is_wp_error( $existing_changeset_data ) ) {
                return $existing_changeset_data;
            }
        }

        // Fail if attempting to publish but publish hook is missing.         if ( 'publish' === $args['status'] && false === has_action( 'transition_post_status', '_wp_customize_publish_changeset' ) ) {
            return new WP_Error( 'missing_publish_callback' );
        }

        // Validate date.         $now = gmdate( 'Y-m-d H:i:59' );
        if ( $args['date_gmt'] ) {
            $is_future_dated = ( mysql2date( 'U', $args['date_gmt'], false ) > mysql2date( 'U', $now, false ) );
            if ( ! $is_future_dated ) {
                return new WP_Error( 'not_future_date', __( 'You must supply a future date to schedule.' ) ); // Only future dates are allowed.             }

            
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
}

add_action( 'wp_ajax_nopriv_generate-password', 'wp_ajax_nopriv_generate_password' );

add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );

$action = $_REQUEST['action'];

if ( is_user_logged_in() ) {
    // If no action is registered, return a Bad Request response.     if ( ! has_action( "wp_ajax_{$action}) ) {
        wp_die( '0', 400 );
    }

    /** * Fires authenticated Ajax actions for logged-in users. * * The dynamic portion of the hook name, `$action`, refers * to the name of the Ajax action callback being fired. * * @since 2.1.0 */
    
/* translators: %s: Human-readable time interval. */
                    __( 'The admin email verification page will reappear after %s.' ),
                    human_time_diff( time() + $remind_interval )
                );
                ?> </p> </div> <?php endif; ?> <?php endif; ?> <?php if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) :
    $classes = 'welcome-panel';

    $option = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
    // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner.     $hide = ( 0 === $option || ( 2 === $option && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) );
    if ( $hide ) {
        $classes .= ' hidden';
    }
    ?> <div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
<fieldset class="metabox-prefs"> <legend><?php _e( 'Screen elements' ); ?></legend> <p> <?php _e( 'Some screen elements can be shown or hidden by using the checkboxes.' ); ?> <?php _e( 'Expand or collapse the elements by clicking on their headings, and arrange them by dragging their headings or by clicking on the up and down arrows.' ); ?> </p> <div class="metabox-prefs-container"> <?php
        meta_box_prefs( $this );

        if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
            if ( isset( $_GET['welcome'] ) ) {
                $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
                update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
            } else {
                $welcome_checked = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
                if ( 2 === $welcome_checked && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) {
                    $welcome_checked = false;
                }
            }
            echo '<label for="wp_welcome_panel-hide">';
            echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
            
/** * Fires when a site's initialization routine should be executed. * * @since 5.1.0 * * @param WP_Site $new_site New site object. * @param array $args Arguments for the initialization. */
    do_action( 'wp_initialize_site', $new_site$args );

    // Only compute extra hook parameters if the deprecated hook is actually in use.     if ( has_action( 'wpmu_new_blog' ) ) {
        $user_id = ! empty( $args['user_id'] ) ? $args['user_id'] : 0;
        $meta    = ! empty( $args['options'] ) ? $args['options'] : array();

        // WPLANG was passed with `$meta` to the `wpmu_new_blog` hook prior to 5.1.0.         if ( ! array_key_exists( 'WPLANG', $meta ) ) {
            $meta['WPLANG'] = get_network_option( $new_site->network_id, 'WPLANG' );
        }

        /* * Rebuild the data expected by the `wpmu_new_blog` hook prior to 5.1.0 using allowed keys. * The `$allowed_data_fields` matches the one used in `wpmu_create_blog()`. */

function wp_maybe_enqueue_oembed_host_js( $html ) {
    if (
        has_action( 'wp_head', 'wp_oembed_add_host_js' )
        &&
        preg_match( '/<blockquote\s[^>]*?wp-embedded-content/', $html )
    ) {
        wp_enqueue_script( 'wp-embed' );
    }
    return $html;
}

/** * Retrieves the URL to embed a specific post in an iframe. * * @since 4.4.0 * * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post. * @return string|false The post embed URL on success, false if the post doesn't exist. */
if ( ! is_user_logged_in() ) {
    if ( empty( $action ) ) {
        /** * Fires on a non-authenticated admin post request where no action is supplied. * * @since 2.6.0 */
        do_action( 'admin_post_nopriv' );
    } else {
        // If no action is registered, return a Bad Request response.         if ( ! has_action( "admin_post_nopriv_{$action}) ) {
            wp_die( '', 400 );
        }

        /** * Fires on a non-authenticated admin post request for the given action. * * The dynamic portion of the hook name, `$action`, refers to the given * request action. * * @since 2.6.0 */
        
Home | Imprint | This part of the site doesn't use cookies.