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'))));
 }
Esempio n. 2
0
        $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);
Esempio n. 3
0
 /**
  * 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'));
     }
 }
 /**
  * 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
     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'));
     }
 }
Esempio n. 5
0
 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;
 }
 /**
  * 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
      * refresh can be utilized.
      */
     if (current_theme_supports('custom-header', 'video')) {
         $this->get_setting('header_image')->transport = 'postMessage';
         $this->get_setting('header_image_data')->transport = 'postMessage';
     }
     $this->add_control(new WP_Customize_Media_Control($this, 'header_video', array('theme_supports' => array('custom-header', 'video'), 'label' => __('Header Video'), 'description' => $control_description, 'section' => 'header_image', 'mime_type' => 'video', 'button_labels' => array('select' => __('Select Video'), 'change' => __('Change Video'), 'placeholder' => __('No video selected'), 'frame_title' => __('Select Video'), 'frame_button' => __('Choose Video')), 'active_callback' => 'is_header_video_active')));
     $this->add_control('external_header_video', array('theme_supports' => array('custom-header', 'video'), 'type' => 'url', 'description' => __('Or, enter a YouTube URL:'), 'section' => 'header_image', 'active_callback' => 'is_front_page'));
     $this->add_control(new WP_Customize_Header_Image_Control($this));
     $this->selective_refresh->add_partial('custom_header', array('selector' => '#wp-custom-header', 'render_callback' => 'the_custom_header_markup', 'settings' => array('header_video', 'external_header_video', 'header_image'), 'container_inclusive' => true));
     /* 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', 'sanitize_callback' => array($this, '_sanitize_background_setting')));
     $this->add_setting(new WP_Customize_Background_Image_Setting($this, 'background_image_thumb', array('theme_supports' => 'custom-background', 'sanitize_callback' => array($this, '_sanitize_background_setting'))));
     $this->add_control(new WP_Customize_Background_Image_Control($this));
     $this->add_setting('background_preset', array('default' => get_theme_support('custom-background', 'default-preset'), 'theme_supports' => 'custom-background', 'sanitize_callback' => array($this, '_sanitize_background_setting')));
     $this->add_control('background_preset', array('label' => _x('Preset', 'Background Preset'), 'section' => 'background_image', 'type' => 'select', 'choices' => array('default' => _x('Default', 'Default Preset'), 'fill' => __('Fill Screen'), 'fit' => __('Fit to Screen'), 'repeat' => _x('Repeat', 'Repeat Image'), 'custom' => _x('Custom', 'Custom Preset'))));
     $this->add_setting('background_position_x', array('default' => get_theme_support('custom-background', 'default-position-x'), 'theme_supports' => 'custom-background', 'sanitize_callback' => array($this, '_sanitize_background_setting')));
     $this->add_setting('background_position_y', array('default' => get_theme_support('custom-background', 'default-position-y'), 'theme_supports' => 'custom-background', 'sanitize_callback' => array($this, '_sanitize_background_setting')));
     $this->add_control(new WP_Customize_Background_Position_Control($this, 'background_position', array('label' => __('Image Position'), 'section' => 'background_image', 'settings' => array('x' => 'background_position_x', 'y' => 'background_position_y'))));
     $this->add_setting('background_size', array('default' => get_theme_support('custom-background', 'default-size'), 'theme_supports' => 'custom-background', 'sanitize_callback' => array($this, '_sanitize_background_setting')));
     $this->add_control('background_size', array('label' => __('Image Size'), 'section' => 'background_image', 'type' => 'select', 'choices' => array('auto' => __('Original'), 'contain' => __('Fit to Screen'), 'cover' => __('Fill Screen'))));
     $this->add_setting('background_repeat', array('default' => get_theme_support('custom-background', 'default-repeat'), 'sanitize_callback' => array($this, '_sanitize_background_setting'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_repeat', array('label' => __('Repeat Background Image'), 'section' => 'background_image', 'type' => 'checkbox'));
     $this->add_setting('background_attachment', array('default' => get_theme_support('custom-background', 'default-attachment'), 'sanitize_callback' => array($this, '_sanitize_background_setting'), 'theme_supports' => 'custom-background'));
     $this->add_control('background_attachment', array('label' => __('Scroll with Page'), 'section' => 'background_image', 'type' => 'checkbox'));
     // 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', 'preset', 'position_x', 'position_y', 'size', 'repeat', 'attachment') as $prop) {
             $this->get_setting('background_' . $prop)->transport = 'postMessage';
         }
     }
     /*
      * Static Front Page
      * See also https://core.trac.wordpress.org/ticket/19627 which introduces the the static-front-page theme_support.
      * The following replicates behavior from options-reading.php.
      */
     $this->add_section('static_front_page', array('title' => __('Static Front Page'), 'priority' => 120, 'description' => __('Your theme supports a static front page.'), 'active_callback' => array($this, 'has_published_pages')));
     $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', 'allow_addition' => true));
     $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', 'allow_addition' => true));
     /* Custom CSS */
     $this->add_section('custom_css', array('title' => __('Additional CSS'), 'priority' => 200, 'description_hidden' => true, 'description' => sprintf('%s<br /><a href="%s" class="external-link" target="_blank">%s<span class="screen-reader-text">%s</span></a>', __('CSS allows you to customize the appearance and layout of your site with code. Separate CSS is saved for each of your themes. In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key.'), esc_url(__('https://codex.wordpress.org/CSS')), __('Learn more about CSS'), __('(link opens in a new window)'))));
     $custom_css_setting = new WP_Customize_Custom_CSS_Setting($this, sprintf('custom_css[%s]', get_stylesheet()), array('capability' => 'edit_css', 'default' => sprintf("/*\n%s\n*/", __("You can add your own CSS here.\n\nClick the help icon above to learn more."))));
     $this->add_setting($custom_css_setting);
     $this->add_control('custom_css', array('type' => 'textarea', 'section' => 'custom_css', 'settings' => array('default' => $custom_css_setting->id), 'input_attrs' => array('class' => 'code')));
 }
Esempio n. 7
0
    $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) {
    ?>
<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 
Esempio n. 9
0
/**
 * 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);
}