• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_prepare_themes_for_js函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_prepare_themes_for_js函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_prepare_themes_for_js函数的具体用法?PHP wp_prepare_themes_for_js怎么用?PHP wp_prepare_themes_for_js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_prepare_themes_for_js函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: js_vars

 static function js_vars()
 {
     $step_statuses = get_option(self::STEP_STATUS_KEY, array());
     $started = get_option(self::STARTED_KEY, false);
     $jetpack_config = array();
     if (class_exists('Jetpack')) {
         $jetpack_config = array('plugin_active' => true, 'configured' => Jetpack::is_active(), 'logo_url' => plugins_url('jetpack/images/jetpack-logo.png'), 'jumpstart_modules' => array_values(self::jumpstart_modules()), 'additional_modules' => array(), 'active_modules' => array_values(Jetpack::init()->get_active_modules()));
     } else {
         $jetpack_config = array('plugin_active' => false, 'configured' => false, 'logo_url' => '', 'jumpstart_modules' => array(), 'additional_modules' => array(), 'active_modules' => array());
     }
     // set the jetpack step status to "completed" if jetpack is active
     if ($jetpack_config['configured']) {
         $step_statuses['jetpack'] = array('completed' => true);
     }
     if (get_option('show_on_front') == 'page') {
         if (get_option('page_for_posts') == 0 || get_option('page_for_posts') == null) {
             $layout = 'website';
         } else {
             $layout = 'site-blog';
         }
     } else {
         $layout = 'blog';
     }
     $themes = array_slice(array_map(array(__CLASS__, 'normalize_installed_theme'), wp_prepare_themes_for_js()), 0, self::MAX_THEMES);
     return array('base_url' => JETPACK_START_BASE_URL, 'nonce' => wp_create_nonce(Jetpack_Start_EndPoints::AJAX_NONCE), 'debug' => WP_DEBUG ? true : false, 'bloginfo' => array('name' => wp_kses_decode_entities(stripslashes(get_bloginfo('name'))), 'description' => wp_kses_decode_entities(stripslashes(get_bloginfo('description')))), 'site_actions' => array('set_title' => 'jps_set_title', 'set_layout' => 'jps_set_layout', 'set_theme' => 'jps_set_theme', 'install_theme' => 'jps_install_theme', 'get_popular_themes' => 'jps_get_popular_themes', 'configure_jetpack' => 'jps_configure_jetpack', 'activate_jetpack_modules' => 'jps_activate_jetpack_modules', 'deactivate_jetpack_modules' => 'jps_deactivate_jetpack_modules', 'list_jetpack_modules' => 'jps_list_jetpack_modules', 'reset_data' => 'jps_reset_data'), 'step_actions' => array('start' => 'jps_started', 'view' => 'jps_step_view', 'skip' => 'jps_step_skip', 'complete' => 'jps_step_complete'), 'jetpack' => $jetpack_config, 'themes' => $themes, 'started' => $started, 'step_status' => $step_statuses, 'steps' => array('layout' => array('current' => $layout), 'advanced_settings' => array('jetpack_modules_url' => admin_url('admin.php?page=jetpack_modules'), 'widgets_url' => admin_url('widgets.php'), 'themes_url' => admin_url('themes.php'), 'plugins_url' => admin_url('plugins.php'), 'customize_url' => wp_customize_url(), 'new_blog_post_url' => admin_url('post-new.php'), 'manage_posts_url' => admin_url('edit.php'), 'new_page_url' => admin_url('post-new.php?post_type=page'), 'manage_pages_url' => admin_url('edit.php?post_type=page'))));
 }
开发者ID:apennell,项目名称:static_portfolio,代码行数:26,代码来源:class.jetpack-start-end-points.php


示例2: sprintf

        $help_install = '<p>' . sprintf(__('If you would like to see more themes to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. Themes in the WordPress.org Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!'), 'https://wordpress.org/themes/') . '</p>';
    }
    get_current_screen()->add_help_tab(array('id' => 'adding-themes', 'title' => __('Adding Themes'), 'content' => $help_install));
}
// install_themes
// Help tab: Previewing and Customizing
if (current_user_can('edit_theme_options') && current_user_can('customize')) {
    $help_customize = '<p>' . __('Tap or hover on any theme then click the Live Preview button to see a live preview of that theme and change theme options in a separate, full-screen view. You can also find a Live Preview button at the bottom of the theme details screen. Any installed theme can be previewed and customized in this way.') . '</p>' . '<p>' . __('The theme being previewed is fully interactive &mdash; navigate to different pages to see how the theme handles posts, archives, and other page templates. The settings may differ depending on what theme features the theme being previewed supports. To accept the new settings and activate the theme all in one step, click the Save &amp; Activate button above the menu.') . '</p>' . '<p>' . __('When previewing on smaller monitors, you can use the collapse icon at the bottom of the left-hand pane. This will hide the pane, giving you more room to preview your site in the new theme. To bring the pane back, click on the collapse icon again.') . '</p>';
    get_current_screen()->add_help_tab(array('id' => 'customize-preview-themes', 'title' => __('Previewing and Customizing'), 'content' => $help_customize));
}
// edit_theme_options && customize
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="https://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">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('addNew' => __('Add New Theme'), 'search' => __('Search Installed Themes'), 'searchPlaceholder' => __('Search installed themes...'), 'themesFound' => __('Number of Themes found: %d'), 'noThemesFound' => __('No themes found. Try a different search.'))));
add_thickbox();
wp_enqueue_script('theme');
wp_enqueue_script('customize-loader');
require_once ABSPATH . 'wp-admin/admin-header.php';
?>

<div class="wrap">
	<h2><?php 
esc_html_e('Themes');
?>
		<span class="title-count theme-count"><?php 
echo count($themes);
开发者ID:ycms,项目名称:framework,代码行数:31,代码来源:themes.php


示例3: register_controls

 /**
  * Register some default controls.
  *
  * @since 3.4.0
  */
 public function register_controls()
 {
     /* Panel, Section, and Control Types */
     $this->register_panel_type('WP_Customize_Panel');
     $this->register_section_type('WP_Customize_Section');
     $this->register_section_type('WP_Customize_Sidebar_Section');
     $this->register_control_type('WP_Customize_Color_Control');
     $this->register_control_type('WP_Customize_Media_Control');
     $this->register_control_type('WP_Customize_Upload_Control');
     $this->register_control_type('WP_Customize_Image_Control');
     $this->register_control_type('WP_Customize_Background_Image_Control');
     $this->register_control_type('WP_Customize_Cropped_Image_Control');
     $this->register_control_type('WP_Customize_Site_Icon_Control');
     $this->register_control_type('WP_Customize_Theme_Control');
     /* Themes */
     $this->add_section(new WP_Customize_Themes_Section($this, 'themes', array('title' => $this->theme()->display('Name'), 'capability' => 'switch_themes', 'priority' => 0)));
     // Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience).
     $this->add_setting(new WP_Customize_Filter_Setting($this, 'active_theme', array('capability' => 'switch_themes')));
     require_once ABSPATH . 'wp-admin/includes/theme.php';
     // Theme Controls.
     // Add a control for the active/original theme.
     if (!$this->is_theme_active()) {
         $themes = wp_prepare_themes_for_js(array(wp_get_theme($this->original_stylesheet)));
         $active_theme = current($themes);
         $active_theme['isActiveTheme'] = true;
         $this->add_control(new WP_Customize_Theme_Control($this, $active_theme['id'], array('theme' => $active_theme, 'section' => 'themes', 'settings' => 'active_theme')));
     }
     $themes = wp_prepare_themes_for_js();
     foreach ($themes as $theme) {
         if ($theme['active'] || $theme['id'] === $this->original_stylesheet) {
             continue;
         }
         $theme_id = 'theme_' . $theme['id'];
         $theme['isActiveTheme'] = false;
         $this->add_control(new WP_Customize_Theme_Control($this, $theme_id, array('theme' => $theme, 'section' => 'themes', 'settings' => 'active_theme')));
     }
     /* Site Identity */
     $this->add_section('title_tagline', array('title' => __('Site Identity'), 'priority' => 20));
     $this->add_setting('blogname', array('default' => get_option('blogname'), 'type' => 'option', 'capability' => 'manage_options'));
     $this->add_control('blogname', array('label' => __('Site Title'), 'section' => 'title_tagline'));
     $this->add_setting('blogdescription', array('default' => get_option('blogdescription'), 'type' => 'option', 'capability' => 'manage_options'));
     $this->add_control('blogdescription', array('label' => __('Tagline'), 'section' => 'title_tagline'));
     $this->add_setting('site_icon', array('type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage'));
     $this->add_control(new WP_Customize_Site_Icon_Control($this, 'site_icon', array('label' => __('Site Icon'), 'description' => __('The Site Icon is used as a browser and app icon for your site. Icons must be square, and at least 512px wide and tall.'), 'section' => 'title_tagline', 'priority' => 60, 'height' => 512, 'width' => 512)));
     /* Colors */
     $this->add_section('colors', array('title' => __('Colors'), 'priority' => 40));
     $this->add_setting('header_textcolor', array('theme_supports' => array('custom-header', 'header-text'), 'default' => get_theme_support('custom-header', 'default-text-color'), 'sanitize_callback' => array($this, '_sanitize_header_textcolor'), 'sanitize_js_callback' => 'maybe_hash_hex_color'));
     // Input type: checkbox
     // With custom value
     $this->add_control('display_header_text', array('settings' => 'header_textcolor', 'label' => __('Display Header Text'), 'section' => 'title_tagline', 'type' => 'checkbox', 'priority' => 40));
     $this->add_control(new WP_Customize_Color_Control($this, 'header_textcolor', array('label' => __('Header Text Color'), 'section' => 'colors')));
     // Input type: Color
     // With sanitize_callback
     $this->add_setting('background_color', array('default' => get_theme_support('custom-background', 'default-color'), 'theme_supports' => 'custom-background', 'sanitize_callback' => 'sanitize_hex_color_no_hash', 'sanitize_js_callback' => 'maybe_hash_hex_color'));
     $this->add_control(new WP_Customize_Color_Control($this, 'background_color', array('label' => __('Background Color'), 'section' => 'colors')));
     /* Custom Header */
     $this->add_section('header_image', array('title' => __('Header Image'), 'theme_supports' => 'custom-header', 'priority' => 60));
     $this->add_setting(new WP_Customize_Filter_Setting($this, 'header_image', array('default' => get_theme_support('custom-header', 'default-image'), 'theme_supports' => 'custom-header')));
     $this->add_setting(new WP_Customize_Header_Image_Setting($this, 'header_image_data', array('theme_supports' => 'custom-header')));
     $this->add_control(new WP_Customize_Header_Image_Control($this));
     /* Custom Background */
     $this->add_section('background_image', array('title' => __('Background Image'), 'theme_supports' => 'custom-background', 'priority' => 80));
     $this->add_setting('background_image', array('default' => get_theme_support('custom-background', 'default-image'), 'theme_supports' => 'custom-background'));
     $this->add_setting(new WP_Customize_Background_Image_Setting($this, 'background_image_thumb', array('theme_supports' => 'custom-background')));
     $this->add_control(new WP_Customize_Background_Image_Control($this));
     $this->add_setting('background_repeat', array('default' => get_theme_support('custom-background', 'default-repeat'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_repeat', array('label' => __('Background Repeat'), 'section' => 'background_image', 'type' => 'radio', 'choices' => array('no-repeat' => __('No Repeat'), 'repeat' => __('Tile'), 'repeat-x' => __('Tile Horizontally'), 'repeat-y' => __('Tile Vertically'))));
     $this->add_setting('background_position_x', array('default' => get_theme_support('custom-background', 'default-position-x'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_position_x', array('label' => __('Background Position'), 'section' => 'background_image', 'type' => 'radio', 'choices' => array('left' => __('Left'), 'center' => __('Center'), 'right' => __('Right'))));
     $this->add_setting('background_attachment', array('default' => get_theme_support('custom-background', 'default-attachment'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_attachment', array('label' => __('Background Attachment'), 'section' => 'background_image', 'type' => 'radio', 'choices' => array('scroll' => __('Scroll'), 'fixed' => __('Fixed'))));
     // If the theme is using the default background callback, we can update
     // the background CSS using postMessage.
     if (get_theme_support('custom-background', 'wp-head-callback') === '_custom_background_cb') {
         foreach (array('color', 'image', 'position_x', 'repeat', 'attachment') as $prop) {
             $this->get_setting('background_' . $prop)->transport = 'postMessage';
         }
     }
     /* Static Front Page */
     // #WP19627
     // Replicate behavior from options-reading.php and hide front page options if there are no pages
     if (get_pages()) {
         $this->add_section('static_front_page', array('title' => __('Static Front Page'), 'priority' => 120, 'description' => __('Your theme supports a static front page.')));
         $this->add_setting('show_on_front', array('default' => get_option('show_on_front'), 'capability' => 'manage_options', 'type' => 'option'));
         $this->add_control('show_on_front', array('label' => __('Front page displays'), 'section' => 'static_front_page', 'type' => 'radio', 'choices' => array('posts' => __('Your latest posts'), 'page' => __('A static page'))));
         $this->add_setting('page_on_front', array('type' => 'option', 'capability' => 'manage_options'));
         $this->add_control('page_on_front', array('label' => __('Front page'), 'section' => 'static_front_page', 'type' => 'dropdown-pages'));
         $this->add_setting('page_for_posts', array('type' => 'option', 'capability' => 'manage_options'));
         $this->add_control('page_for_posts', array('label' => __('Posts page'), 'section' => 'static_front_page', 'type' => 'dropdown-pages'));
     }
 }
开发者ID:RA2WP,项目名称:RA2WP,代码行数:96,代码来源:class-wp-customize-manager.php


示例4: register_controls

 /**
  * Register some default controls.
  *
  * @since 3.4.0
  */
 public function register_controls()
 {
     /* Control Types (custom control classes) */
     $this->register_control_type('WP_Customize_Color_Control');
     $this->register_control_type('WP_Customize_Media_Control');
     $this->register_control_type('WP_Customize_Upload_Control');
     $this->register_control_type('WP_Customize_Image_Control');
     $this->register_control_type('WP_Customize_Background_Image_Control');
     $this->register_control_type('WP_Customize_Theme_Control');
     /* Themes */
     $this->add_section(new WP_Customize_Themes_Section($this, 'themes', array('title' => $this->theme()->display('Name'), 'capability' => 'switch_themes', 'priority' => 0)));
     // Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience).
     $this->add_setting(new WP_Customize_Filter_Setting($this, 'active_theme', array('capability' => 'switch_themes')));
     require_once ABSPATH . 'wp-admin/includes/theme.php';
     // Theme Controls.
     // Add a control for the active/original theme.
     if (!$this->is_theme_active()) {
         $themes = wp_prepare_themes_for_js(array(wp_get_theme($this->original_stylesheet)));
         $active_theme = current($themes);
         $active_theme['isActiveTheme'] = true;
         $this->add_control(new WP_Customize_Theme_Control($this, $active_theme['id'], array('theme' => $active_theme, 'section' => 'themes', 'settings' => 'active_theme')));
     }
     $themes = wp_prepare_themes_for_js();
     foreach ($themes as $theme) {
         if ($theme['active'] || $theme['id'] === $this->original_stylesheet) {
             continue;
         }
         $theme_id = 'theme_' . $theme['id'];
         $theme['isActiveTheme'] = false;
         $this->add_control(new WP_Customize_Theme_Control($this, $theme_id, array('theme' => $theme, 'section' => 'themes', 'settings' => 'active_theme')));
     }
     /* Site Title & Tagline */
     $this->add_section('title_tagline', array('title' => __('Site Title & Tagline'), 'priority' => 20));
     $this->add_setting('blogname', array('default' => get_option('blogname'), 'type' => 'option', 'capability' => 'manage_options'));
     $this->add_control('blogname', array('label' => __('Site Title'), 'section' => 'title_tagline'));
     $this->add_setting('blogdescription', array('default' => get_option('blogdescription'), 'type' => 'option', 'capability' => 'manage_options'));
     $this->add_control('blogdescription', array('label' => __('Tagline'), 'section' => 'title_tagline'));
     /* Colors */
     $this->add_section('colors', array('title' => __('Colors'), 'priority' => 40));
     $this->add_setting('header_textcolor', array('theme_supports' => array('custom-header', 'header-text'), 'default' => get_theme_support('custom-header', 'default-text-color'), 'sanitize_callback' => array($this, '_sanitize_header_textcolor'), 'sanitize_js_callback' => 'maybe_hash_hex_color'));
     // Input type: checkbox
     // With custom value
     $this->add_control('display_header_text', array('settings' => 'header_textcolor', 'label' => __('Display Header Text'), 'section' => 'title_tagline', 'type' => 'checkbox'));
     $this->add_control(new WP_Customize_Color_Control($this, 'header_textcolor', array('label' => __('Header Text Color'), 'section' => 'colors')));
     // Input type: Color
     // With sanitize_callback
     $this->add_setting('background_color', array('default' => get_theme_support('custom-background', 'default-color'), 'theme_supports' => 'custom-background', 'sanitize_callback' => 'sanitize_hex_color_no_hash', 'sanitize_js_callback' => 'maybe_hash_hex_color'));
     $this->add_control(new WP_Customize_Color_Control($this, 'background_color', array('label' => __('Background Color'), 'section' => 'colors')));
     /* Custom Header */
     $this->add_section('header_image', array('title' => __('Header Image'), 'theme_supports' => 'custom-header', 'priority' => 60));
     $this->add_setting(new WP_Customize_Filter_Setting($this, 'header_image', array('default' => get_theme_support('custom-header', 'default-image'), 'theme_supports' => 'custom-header')));
     $this->add_setting(new WP_Customize_Header_Image_Setting($this, 'header_image_data', array('theme_supports' => 'custom-header')));
     $this->add_control(new WP_Customize_Header_Image_Control($this));
     /* Custom Background */
     $this->add_section('background_image', array('title' => __('Background Image'), 'theme_supports' => 'custom-background', 'priority' => 80));
     $this->add_setting('background_image', array('default' => get_theme_support('custom-background', 'default-image'), 'theme_supports' => 'custom-background'));
     $this->add_setting(new WP_Customize_Background_Image_Setting($this, 'background_image_thumb', array('theme_supports' => 'custom-background')));
     $this->add_control(new WP_Customize_Background_Image_Control($this));
     $this->add_setting('background_repeat', array('default' => get_theme_support('custom-background', 'default-repeat'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_repeat', array('label' => __('Background Repeat'), 'section' => 'background_image', 'type' => 'radio', 'choices' => array('no-repeat' => __('No Repeat'), 'repeat' => __('Tile'), 'repeat-x' => __('Tile Horizontally'), 'repeat-y' => __('Tile Vertically'))));
     $this->add_setting('background_position_x', array('default' => get_theme_support('custom-background', 'default-position-x'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_position_x', array('label' => __('Background Position'), 'section' => 'background_image', 'type' => 'radio', 'choices' => array('left' => __('Left'), 'center' => __('Center'), 'right' => __('Right'))));
     $this->add_setting('background_attachment', array('default' => get_theme_support('custom-background', 'default-attachment'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_attachment', array('label' => __('Background Attachment'), 'section' => 'background_image', 'type' => 'radio', 'choices' => array('scroll' => __('Scroll'), 'fixed' => __('Fixed'))));
     // If the theme is using the default background callback, we can update
     // the background CSS using postMessage.
     if (get_theme_support('custom-background', 'wp-head-callback') === '_custom_background_cb') {
         foreach (array('color', 'image', 'position_x', 'repeat', 'attachment') as $prop) {
             $this->get_setting('background_' . $prop)->transport = 'postMessage';
         }
     }
     /* Nav Menus */
     $locations = get_registered_nav_menus();
     $menus = wp_get_nav_menus();
     $num_locations = count(array_keys($locations));
     if (1 == $num_locations) {
         $description = __('Your theme supports one menu. Select which menu you would like to use.');
     } else {
         $description = sprintf(_n('Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations), number_format_i18n($num_locations));
     }
     $this->add_section('nav', array('title' => __('Navigation'), 'theme_supports' => 'menus', 'priority' => 100, 'description' => $description . "\n\n" . __('You can edit your menu content on the Menus screen in the Appearance section.')));
     if ($menus) {
         $choices = array('' => __('&mdash; Select &mdash;'));
         foreach ($menus as $menu) {
             $choices[$menu->term_id] = wp_html_excerpt($menu->name, 40, '&hellip;');
         }
         foreach ($locations as $location => $description) {
             $menu_setting_id = "nav_menu_locations[{$location}]";
             $this->add_setting($menu_setting_id, array('sanitize_callback' => 'absint', 'theme_supports' => 'menus'));
             $this->add_control($menu_setting_id, array('label' => $description, 'section' => 'nav', 'type' => 'select', 'choices' => $choices));
         }
     }
     /* Static Front Page */
     // #WP19627
     // Replicate behavior from options-reading.php and hide front page options if there are no pages
//.........这里部分代码省略.........
开发者ID:ajspencer,项目名称:NCSSM-SG-WordPress,代码行数:101,代码来源:class-wp-customize-manager.php


示例5: get_installed_themes_assoc

 protected function get_installed_themes_assoc()
 {
     $themes = wp_prepare_themes_for_js();
     $themes_assoc = array();
     foreach ($themes as $theme) {
         $themes_assoc[$theme['id']] = 1;
     }
     return $themes_assoc;
 }
开发者ID:jbeyta,项目名称:joelandsam,代码行数:9,代码来源:class-themes-access.php


示例6: register_controls

 /**
  * Register some default controls.
  *
  * @since 3.4.0
  */
 public function register_controls()
 {
     /* Panel, Section, and Control Types */
     $this->register_panel_type('WP_Customize_Panel');
     $this->register_section_type('WP_Customize_Section');
     $this->register_section_type('WP_Customize_Sidebar_Section');
     $this->register_control_type('WP_Customize_Color_Control');
     $this->register_control_type('WP_Customize_Media_Control');
     $this->register_control_type('WP_Customize_Upload_Control');
     $this->register_control_type('WP_Customize_Image_Control');
     $this->register_control_type('WP_Customize_Background_Image_Control');
     $this->register_control_type('WP_Customize_Background_Position_Control');
     $this->register_control_type('WP_Customize_Cropped_Image_Control');
     $this->register_control_type('WP_Customize_Site_Icon_Control');
     $this->register_control_type('WP_Customize_Theme_Control');
     /* Themes */
     $this->add_section(new WP_Customize_Themes_Section($this, 'themes', array('title' => $this->theme()->display('Name'), 'capability' => 'switch_themes', 'priority' => 0)));
     // Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience).
     $this->add_setting(new WP_Customize_Filter_Setting($this, 'active_theme', array('capability' => 'switch_themes')));
     require_once ABSPATH . 'wp-admin/includes/theme.php';
     // Theme Controls.
     // Add a control for the active/original theme.
     if (!$this->is_theme_active()) {
         $themes = wp_prepare_themes_for_js(array(wp_get_theme($this->original_stylesheet)));
         $active_theme = current($themes);
         $active_theme['isActiveTheme'] = true;
         $this->add_control(new WP_Customize_Theme_Control($this, $active_theme['id'], array('theme' => $active_theme, 'section' => 'themes', 'settings' => 'active_theme')));
     }
     $themes = wp_prepare_themes_for_js();
     foreach ($themes as $theme) {
         if ($theme['active'] || $theme['id'] === $this->original_stylesheet) {
             continue;
         }
         $theme_id = 'theme_' . $theme['id'];
         $theme['isActiveTheme'] = false;
         $this->add_control(new WP_Customize_Theme_Control($this, $theme_id, array('theme' => $theme, 'section' => 'themes', 'settings' => 'active_theme')));
     }
     /* Site Identity */
     $this->add_section('title_tagline', array('title' => __('Site Identity'), 'priority' => 20));
     $this->add_setting('blogname', array('default' => get_option('blogname'), 'type' => 'option', 'capability' => 'manage_options'));
     $this->add_control('blogname', array('label' => __('Site Title'), 'section' => 'title_tagline'));
     $this->add_setting('blogdescription', array('default' => get_option('blogdescription'), 'type' => 'option', 'capability' => 'manage_options'));
     $this->add_control('blogdescription', array('label' => __('Tagline'), 'section' => 'title_tagline'));
     // Add a setting to hide header text if the theme doesn't support custom headers.
     if (!current_theme_supports('custom-header', 'header-text')) {
         $this->add_setting('header_text', array('theme_supports' => array('custom-logo', 'header-text'), 'default' => 1, 'sanitize_callback' => 'absint'));
         $this->add_control('header_text', array('label' => __('Display Site Title and Tagline'), 'section' => 'title_tagline', 'settings' => 'header_text', 'type' => 'checkbox'));
     }
     $this->add_setting('site_icon', array('type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage'));
     $this->add_control(new WP_Customize_Site_Icon_Control($this, 'site_icon', array('label' => __('Site Icon'), 'description' => sprintf(__('The Site Icon is used as a browser and app icon for your site. Icons must be square, and at least %s pixels wide and tall.'), '<strong>512</strong>'), 'section' => 'title_tagline', 'priority' => 60, 'height' => 512, 'width' => 512)));
     $this->add_setting('custom_logo', array('theme_supports' => array('custom-logo'), 'transport' => 'postMessage'));
     $custom_logo_args = get_theme_support('custom-logo');
     $this->add_control(new WP_Customize_Cropped_Image_Control($this, 'custom_logo', array('label' => __('Logo'), 'section' => 'title_tagline', 'priority' => 8, 'height' => $custom_logo_args[0]['height'], 'width' => $custom_logo_args[0]['width'], 'flex_height' => $custom_logo_args[0]['flex-height'], 'flex_width' => $custom_logo_args[0]['flex-width'], 'button_labels' => array('select' => __('Select logo'), 'change' => __('Change logo'), 'remove' => __('Remove'), 'default' => __('Default'), 'placeholder' => __('No logo selected'), 'frame_title' => __('Select logo'), 'frame_button' => __('Choose logo')))));
     $this->selective_refresh->add_partial('custom_logo', array('settings' => array('custom_logo'), 'selector' => '.custom-logo-link', 'render_callback' => array($this, '_render_custom_logo_partial'), 'container_inclusive' => true));
     /* Colors */
     $this->add_section('colors', array('title' => __('Colors'), 'priority' => 40));
     $this->add_setting('header_textcolor', array('theme_supports' => array('custom-header', 'header-text'), 'default' => get_theme_support('custom-header', 'default-text-color'), 'sanitize_callback' => array($this, '_sanitize_header_textcolor'), 'sanitize_js_callback' => 'maybe_hash_hex_color'));
     // Input type: checkbox
     // With custom value
     $this->add_control('display_header_text', array('settings' => 'header_textcolor', 'label' => __('Display Site Title and Tagline'), 'section' => 'title_tagline', 'type' => 'checkbox', 'priority' => 40));
     $this->add_control(new WP_Customize_Color_Control($this, 'header_textcolor', array('label' => __('Header Text Color'), 'section' => 'colors')));
     // Input type: Color
     // With sanitize_callback
     $this->add_setting('background_color', array('default' => get_theme_support('custom-background', 'default-color'), 'theme_supports' => 'custom-background', 'sanitize_callback' => 'sanitize_hex_color_no_hash', 'sanitize_js_callback' => 'maybe_hash_hex_color'));
     $this->add_control(new WP_Customize_Color_Control($this, 'background_color', array('label' => __('Background Color'), 'section' => 'colors')));
     /* Custom Header */
     if (current_theme_supports('custom-header', 'video')) {
         $title = __('Header Media');
         $description = '<p>' . __('If you add a video, the image will be used as a fallback while the video loads.') . '</p>';
         // @todo Customizer sections should support having notifications just like controls do. See <https://core.trac.wordpress.org/ticket/38794>.
         $description .= '<div class="customize-control-notifications-container header-video-not-currently-previewable" style="display: none"><ul>';
         $description .= '<li class="notice notice-info">' . __('This theme doesn\'t support video headers on this page. Navigate to the front page or another page that supports video headers.') . '</li>';
         $description .= '</ul></div>';
         $width = absint(get_theme_support('custom-header', 'width'));
         $height = absint(get_theme_support('custom-header', 'height'));
         if ($width && $height) {
             $control_description = sprintf(__('Upload your video in %1$s format and minimize its file size for best results. Your theme recommends dimensions of %2$s pixels.'), '<code>.mp4</code>', sprintf('<strong>%s &times; %s</strong>', $width, $height));
         } elseif ($width) {
             $control_description = sprintf(__('Upload your video in %1$s format and minimize its file size for best results. Your theme recommends a width of %2$s pixels.'), '<code>.mp4</code>', sprintf('<strong>%s</strong>', $width));
         } else {
             $control_description = sprintf(__('Upload your video in %1$s format and minimize its file size for best results. Your theme recommends a height of %2$s pixels.'), '<code>.mp4</code>', sprintf('<strong>%s</strong>', $height));
         }
     } else {
         $title = __('Header Image');
         $description = '';
         $control_description = '';
     }
     $this->add_section('header_image', array('title' => $title, 'description' => $description, 'theme_supports' => 'custom-header', 'priority' => 60));
     $this->add_setting('header_video', array('theme_supports' => array('custom-header', 'video'), 'transport' => 'postMessage', 'sanitize_callback' => 'absint', 'validate_callback' => array($this, '_validate_header_video')));
     $this->add_setting('external_header_video', array('theme_supports' => array('custom-header', 'video'), 'transport' => 'postMessage', 'sanitize_callback' => 'esc_url_raw', 'validate_callback' => array($this, '_validate_external_header_video')));
     $this->add_setting(new WP_Customize_Filter_Setting($this, 'header_image', array('default' => sprintf(get_theme_support('custom-header', 'default-image'), get_template_directory_uri(), get_stylesheet_directory_uri()), 'theme_supports' => 'custom-header')));
     $this->add_setting(new WP_Customize_Header_Image_Setting($this, 'header_image_data', array('theme_supports' => 'custom-header')));
     /*
      * Switch image settings to postMessage when video support is enabled since
      * it entails that the_custom_header_markup() will be used, and thus selective
//.........这里部分代码省略.........
开发者ID:kucrut,项目名称:wordpress,代码行数:101,代码来源:class-wp-customize-manager.php


示例7: wp_prepare_themes_for_js

    $themes = wp_prepare_themes_for_js();
    foreach ($themes as $theme) {
        echo '<option value="' . $theme['id'] . '"' . ($theme['active'] ? ' selected' : '') . '>' . $theme['name'] . '</option>';
    }
    ?>
                </select>
                <input type="submit" value="Activate">
            </div>
        </form>
        <br>
        <form id="step4remove" action="./installer.php?step=4&amp;theme=remove" method="post">
            <div class="box">
                <h2>Remove Themes</h2>
                <table>
                    <?php 
    $themes = wp_prepare_themes_for_js();
    foreach ($themes as $theme) {
        echo '<tr><td><input id="' . md5($theme['name']) . '"  type="checkbox" name="themes[]" value="' . $theme['id'] . '"' . ($theme['active'] === true ? ' disabled readonly' : '') . '></td><td><label for="' . md5($theme['name']) . '">' . $theme['name'] . '</label></td></tr>' . "\n";
    }
    ?>
                </table>
                <input type="submit" value="Remove Now">
            </div>
        </form>
        <br>
        <form id="step4" action="./installer.php?step=6" method="post">
            <input type="submit" name="next" value="Next">
        </form>
    <?php 
} elseif ($step == 5) {
    ?>
开发者ID:tronsha,项目名称:wp-installer,代码行数:31,代码来源:installer.php


示例8: __

<div class="wrap">
	<p>
		<?php 
echo __('A child theme can be run on any WordPress install with the Runway framework active. You can use Runway to setup custom theme options, menus and many other features of a child theme. Completed themes can be downloaded as a child or standalone version. A standalone theme may be installed on any WordPress install regardless of having Runway active', 'framework');
?>
.
	</p>
	<br>

	<?php 
$themes_list = $developer_tools->search_themes();
$tmp_themes = array();
foreach ($themes_list as $key => $theme) {
    $tmp_themes[] = wp_get_theme($theme['Folder']);
}
$js_themes = wp_prepare_themes_for_js($tmp_themes);
wp_localize_script('themes-manager-themes', '_wpThemeSettings', array('themes' => $js_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('addNew' => __('Add New Theme', 'framework'), 'search' => __('Search Installed Themes', 'framework'), 'searchPlaceholder' => __('Search installed themes...', 'framework'))));
$current_theme = rw_get_theme_data();
// Set the variables
$t = runway_admin_themes_list_prepare($current_theme);
unset($themes_list[$current_theme['Folder']]);
?>
	
	<div class="theme-browser rendered">
		<div class="themes">
			<div class="theme active" tabindex="0" data-themeid="<?php 
echo esc_attr($current_theme['Folder']);
?>
">
				<div class="theme-screenshot">
					<img alt="" src="<?php 
开发者ID:bangtienmanh,项目名称:Runway-Framework,代码行数:31,代码来源:themes-list.php


示例9: wp_ajax_update_theme

/**
 * AJAX handler for updating a theme.
 *
 * @since 4.X.0
 */
function wp_ajax_update_theme()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug'])) {
        wp_send_json_error(array('slug' => '', 'errorCode' => 'no_theme_specified', 'error' => __('No theme specified.')));
    }
    $stylesheet = sanitize_key($_POST['slug']);
    $status = array('update' => 'theme', 'slug' => $stylesheet, 'oldVersion' => sprintf(__('Version %s'), wp_get_theme($stylesheet)->get('Version')), 'newVersion' => '');
    if (!current_user_can('update_themes')) {
        $status['error'] = __('You do not have sufficient permissions to update themes on this site.');
        wp_send_json_error($status);
    }
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $current = get_site_transient('update_themes');
    if (empty($current)) {
        wp_update_themes();
    }
    $upgrader = new Theme_Upgrader(new Automatic_Upgrader_Skin());
    $result = $upgrader->bulk_upgrade(array($stylesheet));
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $status['debug'] = $upgrader->skin->get_upgrade_messages();
    }
    if (is_array($result) && !empty($result[$stylesheet])) {
        // Theme is already at the latest version.
        if (true === $result[$stylesheet]) {
            $status['error'] = $upgrader->strings['up_to_date'];
            wp_send_json_error($status);
        }
        $theme = wp_get_theme($stylesheet);
        if ($theme->get('Version')) {
            $status['theme'] = wp_prepare_themes_for_js(array($theme));
            $status['newVersion'] = sprintf(__('Version %s'), $theme->get('Version'));
        }
        wp_send_json_success($status);
    } else {
        if (is_wp_error($result)) {
            $status['error'] = $result->get_error_message();
            wp_send_json_error($status);
        } else {
            if (is_bool($result) && !$result) {
                global $wp_filesystem;
                $status['errorCode'] = 'unable_to_connect_to_filesystem';
                $status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
                // Pass through the error from WP_Filesystem if one was raised.
                if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
                    $status['error'] = $wp_filesystem->errors->get_error_message();
                }
                wp_send_json_error($status);
            }
        }
    }
    // An unhandled error occurred.
    $status['error'] = __('Update failed.');
    wp_send_json_error($status);
}
开发者ID:ethitter,项目名称:shiny-updates,代码行数:60,代码来源:ajax-actions.php



注:本文中的wp_prepare_themes_for_js函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_print_request_filesystem_credentials_modal函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_prepare_attachment_for_js函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap