wp_is_json_request example

?> <style> #dark-mode-toggler > span { margin-<?php echo is_rtl() ? 'right' : 'left'; ?>: 5px; } #dark-mode-toggler > span::before { content: '<?php esc_attr_e( 'Off', 'twentytwentyone' ); ?>'; } #dark-mode-toggler[aria-pressed="true"] > span::before { content: '<?php esc_attr_e( 'On', 'twentytwentyone' ); ?>'; } <?php if ( is_admin() || wp_is_json_request() ) : ?> .components-editor-notices__pinned ~ .edit-post-visual-editor #dark-mode-toggler { z-index: 20; } .is-dark-theme.is-dark-theme #dark-mode-toggler:not(:hover):not(:focus) { color: var(--global--color-primary); } @media only screen and (max-width: 782px) { #dark-mode-toggler { margin-top: 32px; } }
if ( $ssl ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $http_args = array(
            'timeout'    => 15,
            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
        );
        $request   = wp_remote_get( $url$http_args );

        if ( $ssl && is_wp_error( $request ) ) {
            if ( ! wp_is_json_request() ) {
                trigger_error(
                    sprintf(
                        /* translators: %s: Support forums URL. */
                        __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
                        __( 'https://wordpress.org/support/forums/' )
                    ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
                    headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
                );
            }

            $request = wp_remote_get( $http_url$http_args );
        }

function is_admin_bar_showing() {
    global $show_admin_bar$pagenow;

    // For all these types of requests, we never want an admin bar.     if ( defined( 'XMLRPC_REQUEST' ) || defined( 'DOING_AJAX' ) || defined( 'IFRAME_REQUEST' ) || wp_is_json_request() ) {
        return false;
    }

    if ( is_embed() ) {
        return false;
    }

    // Integrated into the admin.     if ( is_admin() ) {
        return true;
    }

    


    if ( wp_doing_ajax() ) {
        /** * Filters the callback for killing WordPress execution for Ajax requests. * * @since 3.4.0 * * @param callable $callback Callback function name. */
        $callback = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
    } elseif ( wp_is_json_request() ) {
        /** * Filters the callback for killing WordPress execution for JSON requests. * * @since 5.1.0 * * @param callable $callback Callback function name. */
        $callback = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' );
    } elseif ( defined( 'REST_REQUEST' ) && REST_REQUEST && wp_is_jsonp_request() ) {
        /** * Filters the callback for killing WordPress execution for JSONP REST requests. * * @since 5.2.0 * * @param callable $callback Callback function name. */
if ( $log_path ) {
            ini_set( 'log_errors', 1 );
            ini_set( 'error_log', $log_path );
        }
    } else {
        error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
    }

    if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || defined( 'MS_FILES_REQUEST' )
        || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING )
        || wp_doing_ajax() || wp_is_json_request()
    ) {
        ini_set( 'display_errors', 0 );
    }
}

/** * Sets the location of the language directory. * * To set directory manually, define the `WP_LANG_DIR` constant * in wp-config.php. * * If the language directory exists within `WP_CONTENT_DIR`, it * is used. Otherwise the language directory is assumed to live * in `WPINC`. * * @since 3.0.0 * @access private */
if (
        isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] &&
        ( ! empty( $_GET['wp_lang'] ) || ! empty( $_COOKIE['wp_lang'] ) )
    ) {
        if ( ! empty( $_GET['wp_lang'] ) ) {
            $determined_locale = sanitize_locale_name( $_GET['wp_lang'] );
        } else {
            $determined_locale = sanitize_locale_name( $_COOKIE['wp_lang'] );
        }
    } elseif (
        is_admin() ||
        ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() )
    ) {
        $determined_locale = get_user_locale();
    }

    if ( ! $determined_locale ) {
        $determined_locale = get_locale();
    }

    /** * Filters the locale for the current request. * * @since 5.0.0 * * @param string $locale The locale. */
Home | Imprint | This part of the site doesn't use cookies.