wp_localize_script example


            );

            if ( isset( $_GET['akismet_recheck'] ) && wp_verify_nonce( $_GET['akismet_recheck'], 'akismet_recheck' ) ) {
                $inline_js['start_recheck'] = true;
            }

            if ( apply_filters( 'akismet_enable_mshots', true ) ) {
                $inline_js['enable_mshots'] = true;
            }

            wp_localize_script( 'akismet.js', 'WPAkismet', $inline_js );
        }
    }

    /** * Add help to the Akismet page * * @return false if not the Akismet page */
    public static function admin_help() {
        $current_screen = get_current_screen();

        
'menuItemDeletion'        => __( 'item %s' ),
    /* translators: %s: Item name. */
    'itemsDeleted'            => __( 'Deleted menu item: %s.' ),
    'itemAdded'               => __( 'Menu item added' ),
    'itemRemoved'             => __( 'Menu item removed' ),
    'movedUp'                 => __( 'Menu item moved up' ),
    'movedDown'               => __( 'Menu item moved down' ),
    'movedTop'                => __( 'Menu item moved to the top' ),
    'movedLeft'               => __( 'Menu item moved out of submenu' ),
    'movedRight'              => __( 'Menu item is now a sub-item' ),
);
wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );

/* * Redirect to add screen if there are no menus and this users has either zero, * or more than 1 theme locations. */
if ( 0 === $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) {
    wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) );
}

// Get recently edited nav menu. $recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
// Translate, don't apply markup, sanitize HTML.             $this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file$plugin_data, false, true );
        }

        $total_this_page = $totals[ $status ];

        $js_plugins = array();
        foreach ( $plugins as $key => $list ) {
            $js_plugins[ $key ] = array_keys( $list );
        }

        wp_localize_script(
            'updates',
            '_wpUpdatesItemCounts',
            array(
                'plugins' => $js_plugins,
                'totals'  => wp_get_update_data(),
            )
        );

        if ( ! $orderby ) {
            $orderby = 'Name';
        } else {
            
if ( is_string( $test['test'] ) ) {
                    $health_check_js_variables['site_status']['async'][] = array(
                        'test'      => $test['test'],
                        'has_rest'  => ( isset( $test['has_rest'] ) ? $test['has_rest'] : false ),
                        'completed' => false,
                        'headers'   => isset( $test['headers'] ) ? $test['headers'] : array(),
                    );
                }
            }
        }

        wp_localize_script( 'site-health', 'SiteHealth', $health_check_js_variables );
    }

    /** * Runs a Site Health test directly. * * @since 5.4.0 * * @param callable $callback * @return mixed|void */
    private function perform_test( $callback ) {
        
if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) {
            $status = 'all';
        }

        $this->items = $themes[ $status ];
        WP_Theme::sort_by_name( $this->items );

        $this->has_items = ! empty( $themes['all'] );
        $total_this_page = $totals[ $status ];

        wp_localize_script(
            'updates',
            '_wpUpdatesItemCounts',
            array(
                'themes' => $js_themes,
                'totals' => wp_get_update_data(),
            )
        );

        if ( $orderby ) {
            $orderby = ucfirst( $orderby );
            $order   = strtoupper( $order );

            

    $strings = apply_filters( 'media_view_strings', $strings$post );

    $strings['settings'] = $settings;

    /* * Ensure we enqueue media-editor first, that way media-views * is registered internally before we try to localize it. See #24724. */
    wp_enqueue_script( 'media-editor' );
    wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings );

    wp_enqueue_script( 'media-audiovideo' );
    wp_enqueue_style( 'media-views' );
    if ( is_admin() ) {
        wp_enqueue_script( 'mce-view' );
        wp_enqueue_script( 'image-edit' );
    }
    wp_enqueue_style( 'imgareaselect' );
    wp_plupload_default_settings();

    require_once ABSPATH . WPINC . '/media-template.php';
    
$message,
        __( 'Cannot Authorize Application' ),
        array(
            'response'  => 501,
            'link_text' => __( 'Go Back' ),
            'link_url'  => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(),
        )
    );
}

wp_enqueue_script( 'auth-app' );
wp_localize_script(
    'auth-app',
    'authApp',
    array(
        'site_url'   => site_url(),
        'user_login' => $user->user_login,
        'success'    => $success_url,
        'reject'     => $reject_url ? $reject_url : admin_url(),
    )
);

require_once ABSPATH . 'wp-admin/admin-header.php';

if ( false === $installed_themes ) {
    $installed_themes = array();
}

foreach ( $installed_themes as $theme_slug => $theme_data ) {
    // Ignore child themes.     if ( str_contains( $theme_slug, '/' ) ) {
        unset( $installed_themes[ $theme_slug ] );
    }
}

wp_localize_script(
    'theme',
    '_wpThemeSettings',
    array(
        'themes'          => false,
        'settings'        => array(
            'isInstall'  => true,
            'canInstall' => current_user_can( 'install_themes' ),
            'installURI' => current_user_can( 'install_themes' ) ? self_admin_url( 'theme-install.php' ) : null,
            'adminUrl'   => parse_url( self_admin_url(), PHP_URL_PATH ),
        ),
        'l10n'            => array(
            
$q = $_GET;
    // Let JS handle this.     unset( $q['s'] );
    $vars   = wp_edit_attachments_query_vars( $q );
    $ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' );
    foreach ( $vars as $key => $value ) {
        if ( ! $value || in_array( $key$ignore, true ) ) {
            unset( $vars[ $key ] );
        }
    }

    wp_localize_script(
        'media-grid',
        '_wpMediaGridSettings',
        array(
            'adminUrl'  => parse_url( self_admin_url(), PHP_URL_PATH ),
            'queryVars' => (object) $vars,
        )
    );

    get_current_screen()->add_help_tab(
        array(
            'id'      => 'overview',
            


    /** */
    public function enqueue() {
        wp_enqueue_media();
        wp_enqueue_script( 'customize-views' );

        $this->prepare_control();

        wp_localize_script(
            'customize-views',
            '_wpCustomizeHeader',
            array(
                'data'     => array(
                    'width'         => absint( get_theme_support( 'custom-header', 'width' ) ),
                    'height'        => absint( get_theme_support( 'custom-header', 'height' ) ),
                    'flex-width'    => absint( get_theme_support( 'custom-header', 'flex-width' ) ),
                    'flex-height'   => absint( get_theme_support( 'custom-header', 'flex-height' ) ),
                    'currentImgSrc' => $this->get_current_image_src(),
                ),
                'nonces'   => array(
                    
$help_sidebar_autoupdates .
    '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
);

if ( current_user_can( 'switch_themes' ) ) {
    $themes = wp_prepare_themes_for_js();
} else {
    $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
}
wp_reset_vars( array( 'theme', 'search' ) );

wp_localize_script(
    'theme',
    '_wpThemeSettings',
    array(
        'themes'   => $themes,
        'settings' => array(
            'canInstall'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ),
            'installURI'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
            'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
            'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
        ),
        'l10n'     => array(
            


    /** * Enqueue control related scripts/styles. * * @since 4.1.0 */
    public function enqueue() {
        parent::enqueue();

        $custom_background = get_theme_support( 'custom-background' );
        wp_localize_script(
            'customize-controls',
            '_wpCustomizeBackground',
            array(
                'defaults' => ! empty( $custom_background[0] ) ? $custom_background[0] : array(),
                'nonces'   => array(
                    'add' => wp_create_nonce( 'background-add' ),
                ),
            )
        );
    }
}
array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ),
                array()
            );

            $js_plugins['all'] = array_values( wp_list_pluck( $installed_plugins, 'plugin' ) );
            $upgrade_plugins   = wp_filter_object_list( $installed_plugins, array( 'upgrade' => true ), 'and', 'plugin' );

            if ( $upgrade_plugins ) {
                $js_plugins['upgrade'] = array_values( $upgrade_plugins );
            }

            wp_localize_script(
                'updates',
                '_wpUpdatesItemCounts',
                array(
                    'plugins' => $js_plugins,
                    'totals'  => wp_get_update_data(),
                )
            );
        }
    }

    /** */

function the_custom_header_markup() {
    $custom_header = get_custom_header_markup();
    if ( empty( $custom_header ) ) {
        return;
    }

    echo $custom_header;

    if ( is_header_video_active() && ( has_header_video() || is_customize_preview() ) ) {
        wp_enqueue_script( 'wp-custom-header' );
        wp_localize_script( 'wp-custom-header', '_wpCustomHeaderSettings', get_header_video_settings() );
    }
}

/** * Retrieves background image for custom background. * * @since 3.0.0 * * @return string */
function get_background_image() {
    


/** * Loads localized data on print rather than initialization. * * These localizations require information that may not be loaded even by init. * * @since 2.5.0 */
function wp_just_in_time_script_localization() {

    wp_localize_script(
        'autosave',
        'autosaveL10n',
        array(
            'autosaveInterval' => AUTOSAVE_INTERVAL,
            'blog_id'          => get_current_blog_id(),
        )
    );

    wp_localize_script(
        'mce-view',
        'mceViewL10n',
        
Home | Imprint | This part of the site doesn't use cookies.