本文整理汇总了PHP中wp_customize_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_customize_url函数的具体用法?PHP wp_customize_url怎么用?PHP wp_customize_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_customize_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: after
/**
* Modify the install actions.
*
* @since 1.0.0
*/
public function after()
{
if (empty($this->upgrader->result['destination_name'])) {
return;
}
$theme_info = $this->upgrader->theme_info();
if (empty($theme_info)) {
return;
}
$name = $theme_info->display('Name');
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$activate_link = add_query_arg(array('action' => 'activate', 'template' => urlencode($template), 'stylesheet' => urlencode($stylesheet)), admin_url('themes.php'));
$activate_link = wp_nonce_url($activate_link, 'switch-theme_' . $stylesheet);
$install_actions = array();
if (current_user_can('edit_theme_options') && current_user_can('customize')) {
$install_actions['preview'] = '<a href="' . wp_customize_url($stylesheet) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __('Live Preview', 'envato-market') . '</span><span class="screen-reader-text">' . sprintf(__('Live Preview “%s”', 'envato-market'), $name) . '</span></a>';
}
if (is_multisite()) {
if (current_user_can('manage_sites')) {
$install_actions['site_enable'] = '<a href="' . esc_url(network_admin_url(wp_nonce_url('site-themes.php?id=' . get_current_blog_id() . '&action=enable&theme=' . urlencode($stylesheet), 'enable-theme_' . $stylesheet))) . '" target="_parent">' . __('Site Enable', 'envato-market') . '</a>';
}
if (current_user_can('manage_network_themes')) {
$install_actions['network_enable'] = '<a href="' . esc_url(network_admin_url(wp_nonce_url('themes.php?action=enable&theme=' . urlencode($stylesheet) . '&paged=1&s', 'enable-theme_' . $stylesheet))) . '" target="_parent">' . __('Network Enable', 'envato-market') . '</a>';
}
}
$install_actions['activate'] = '<a href="' . esc_url($activate_link) . '" class="activatelink"><span aria-hidden="true">' . __('Activate', 'envato-market') . '</span><span class="screen-reader-text">' . sprintf(__('Activate “%s”', 'envato-market'), $name) . '</span></a>';
$install_actions['themes_page'] = '<a href="' . esc_url(admin_url('admin.php?page=' . envato_market()->get_slug() . '&tab=themes')) . '" target="_parent">' . __('Return to Theme Installer', 'envato-market') . '</a>';
if (!$this->result || is_wp_error($this->result) || is_multisite() || !current_user_can('switch_themes')) {
unset($install_actions['activate'], $install_actions['preview']);
}
if (!empty($install_actions)) {
$this->feedback(implode(' | ', $install_actions));
}
}
示例2: 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'))));
}
示例3: settings_box
/**
* Create Metabox which links to and explains the WordPress customizer.
*
* @uses wp_customize_url()
* @since 1.0.2
*/
function settings_box()
{
$customizer_link = wp_customize_url(get_stylesheet());
echo '<p>';
_e('The Genesis Bacon Bar is controlled by the WordPress Customizer. ', 'baconbar');
_e('You can edit the content, display options, and look and feel in real-time.', 'baconbar');
echo '</p>';
echo '<p>';
echo '<a class="button" href="' . $customizer_link . '">' . __('Customize Now', 'baconbar') . '</a>';
echo '</p>';
}
示例4: wp_toolbar_experiments_customize_menu
/**
* Adds the "Customize" link to the Toolbar.
*
* Core makes the critical mistake of returning if is_admin() in the function instead of in WP_Admin_Bar::add_menus(), so we have to overwrite the entire function.
*
* @since 4.4.0
*
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
*/
function wp_toolbar_experiments_customize_menu($wp_admin_bar)
{
// Don't show for users who can't access the customizer.
if (!current_user_can('customize')) {
return;
}
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$customize_url = add_query_arg('url', urlencode($current_url), wp_customize_url());
$wp_admin_bar->add_menu(array('id' => 'customize', 'title' => __('Customize'), 'href' => $customize_url, 'meta' => array('class' => 'hide-if-no-customize')));
add_action('wp_before_admin_bar_render', 'wp_customize_support_script');
}
示例5: tagline_notice
/**
* Notify about the default tagline if the user hasn't changed it
*/
public function tagline_notice()
{
$current_url = is_ssl() ? 'https://' : 'http://';
$current_url .= sanitize_text_field($_SERVER['SERVER_NAME']) . sanitize_text_field($_SERVER['REQUEST_URI']);
$customize_url = add_query_arg(array('url' => urlencode($current_url)), wp_customize_url());
$info_message = sprintf(__('You still have the default WordPress tagline, even an empty one is probably better. %1$sYou can fix this in the customizer%2$s.', 'wordpress-seo'), '<a href="' . esc_attr($customize_url) . '">', '</a>');
$notification_options = array('type' => Yoast_Notification::ERROR, 'id' => 'wpseo-dismiss-tagline-notice', 'capabilities' => 'manage_options');
$tagline_notification = new Yoast_Notification($info_message, $notification_options);
$notification_center = Yoast_Notification_Center::get();
if ($this->has_default_tagline()) {
$notification_center->add_notification($tagline_notification);
} else {
$notification_center->remove_notification($tagline_notification);
}
}
示例6: after
/**
* @access public
*/
public function after()
{
if (empty($this->upgrader->result['destination_name'])) {
return;
}
$theme_info = $this->upgrader->theme_info();
if (empty($theme_info)) {
return;
}
$name = $theme_info->display('Name');
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$activate_link = add_query_arg(array('action' => 'activate', 'template' => urlencode($template), 'stylesheet' => urlencode($stylesheet)), admin_url('themes.php'));
$activate_link = wp_nonce_url($activate_link, 'switch-theme_' . $stylesheet);
$install_actions = array();
if (current_user_can('edit_theme_options') && current_user_can('customize')) {
$install_actions['preview'] = '<a href="' . wp_customize_url($stylesheet) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __('Live Preview') . '</span><span class="screen-reader-text">' . sprintf(__('Live Preview “%s”'), $name) . '</span></a>';
}
$install_actions['activate'] = '<a href="' . esc_url($activate_link) . '" class="activatelink"><span aria-hidden="true">' . __('Activate') . '</span><span class="screen-reader-text">' . sprintf(__('Activate “%s”'), $name) . '</span></a>';
if (is_network_admin() && current_user_can('manage_network_themes')) {
$install_actions['network_enable'] = '<a href="' . esc_url(wp_nonce_url('themes.php?action=enable&theme=' . urlencode($stylesheet), 'enable-theme_' . $stylesheet)) . '" target="_parent">' . __('Network Enable') . '</a>';
}
if ($this->type == 'web') {
$install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
} elseif (current_user_can('switch_themes') || current_user_can('edit_theme_options')) {
$install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" target="_parent">' . __('Return to Themes page') . '</a>';
}
if (!$this->result || is_wp_error($this->result) || is_network_admin() || !current_user_can('switch_themes')) {
unset($install_actions['activate'], $install_actions['preview']);
}
/**
* Filters the list of action links available following a single theme installation.
*
* @since 2.8.0
*
* @param array $install_actions Array of theme action links.
* @param object $api Object containing WordPress.org API theme data.
* @param string $stylesheet Theme directory name.
* @param WP_Theme $theme_info Theme object.
*/
$install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
if (!empty($install_actions)) {
$this->feedback(implode(' | ', (array) $install_actions));
}
}
示例7: js_vars
static function js_vars()
{
$step_statuses = get_option(self::STEP_STATUS_KEY, array());
$started = get_option(self::STARTED_KEY, false);
$contact_page_id = get_option(self::CONTACTPAGE_ID_KEY, false);
if ($contact_page_id) {
$contact_page_info = self::contact_page_to_json($contact_page_id);
} else {
$contact_page_info = null;
}
$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);
}
return array('base_url' => JETPACK_ONBOARDING_BASE_URL, 'site_url' => site_url(), 'nonce' => wp_create_nonce(Jetpack_Onboarding_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' => 'jpo_set_title', 'set_layout' => 'jpo_set_layout', 'set_theme' => 'jpo_set_theme', 'install_theme' => 'jpo_install_theme', 'get_popular_themes' => 'jpo_get_popular_themes', 'configure_jetpack' => 'jpo_configure_jetpack', 'activate_jetpack_modules' => 'jpo_activate_jetpack_modules', 'deactivate_jetpack_modules' => 'jpo_deactivate_jetpack_modules', 'list_jetpack_modules' => 'jpo_list_jetpack_modules', 'reset_data' => 'jpo_reset_data', 'build_contact_page' => 'jpo_build_contact_page'), 'step_actions' => array('start' => 'jpo_started', 'disable' => 'jpo_disabled', 'view' => 'jpo_step_view', 'skip' => 'jpo_step_skip', 'complete' => 'jpo_step_complete'), 'jetpack' => $jetpack_config, 'started' => $started, 'step_status' => $step_statuses, 'steps' => array('layout' => self::get_layout(), 'contact_page' => $contact_page_info, 'advanced_settings' => array('jetpack_modules_url' => admin_url('admin.php?page=jetpack_modules'), 'jetpack_dash' => admin_url('admin.php?page=jetpack'), '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'))));
}
示例8: after
/**
* @access public
*/
public function after()
{
$this->decrement_update_count('theme');
$update_actions = array();
if (!empty($this->upgrader->result['destination_name']) && ($theme_info = $this->upgrader->theme_info())) {
$name = $theme_info->display('Name');
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$activate_link = add_query_arg(array('action' => 'activate', 'template' => urlencode($template), 'stylesheet' => urlencode($stylesheet)), admin_url('themes.php'));
$activate_link = wp_nonce_url($activate_link, 'switch-theme_' . $stylesheet);
if (get_stylesheet() == $stylesheet) {
if (current_user_can('edit_theme_options') && current_user_can('customize')) {
$update_actions['preview'] = '<a href="' . wp_customize_url($stylesheet) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __('Customize') . '</span><span class="screen-reader-text">' . sprintf(__('Customize “%s”'), $name) . '</span></a>';
}
} elseif (current_user_can('switch_themes')) {
if (current_user_can('edit_theme_options') && current_user_can('customize')) {
$update_actions['preview'] = '<a href="' . wp_customize_url($stylesheet) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __('Live Preview') . '</span><span class="screen-reader-text">' . sprintf(__('Live Preview “%s”'), $name) . '</span></a>';
}
$update_actions['activate'] = '<a href="' . esc_url($activate_link) . '" class="activatelink"><span aria-hidden="true">' . __('Activate') . '</span><span class="screen-reader-text">' . sprintf(__('Activate “%s”'), $name) . '</span></a>';
}
if (!$this->result || is_wp_error($this->result) || is_network_admin()) {
unset($update_actions['preview'], $update_actions['activate']);
}
}
$update_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" target="_parent">' . __('Return to Themes page') . '</a>';
/**
* Filter the list of action links available following a single theme update.
*
* @since 2.8.0
*
* @param array $update_actions Array of theme action links.
* @param string $theme Theme directory name.
*/
$update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
if (!empty($update_actions)) {
$this->feedback(implode(' | ', (array) $update_actions));
}
}
示例9: shoestrap_footer_icon
function shoestrap_footer_icon()
{
?>
<?php
if (current_user_can('edit_theme_options')) {
?>
<style>
</style>
<div id="shoestrap_icon">
<?php
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$href = add_query_arg('url', urlencode($current_url), wp_customize_url());
?>
<a href="<?php
echo $href;
?>
"><i class="icon-cogs"></i></a>
</div>
<?php
}
?>
</div>
<?php
}
示例10: display_rows
function display_rows()
{
$themes = $this->items;
foreach ($themes as $theme) {
?>
<div class="available-theme"><?php
$template = $theme->get_template();
$stylesheet = $theme->get_stylesheet();
$title = $theme->display('Name');
$version = $theme->display('Version');
$author = $theme->display('Author');
$activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $stylesheet);
$preview_link = esc_url(add_query_arg(array('preview' => 1, 'template' => urlencode($template), 'stylesheet' => urlencode($stylesheet), 'preview_iframe' => true, 'TB_iframe' => 'true'), home_url('/')));
$actions = array();
$actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="' . esc_attr(sprintf(__('Activate “%s”'), $title)) . '">' . __('Activate') . '</a>';
$actions['preview'] = '<a href="' . $preview_link . '" class="hide-if-customize" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '">' . __('Preview') . '</a>';
if (current_user_can('edit_theme_options')) {
$actions['preview'] .= '<a href="' . wp_customize_url($stylesheet) . '" class="load-customize hide-if-no-customize">' . __('Live Preview') . '</a>';
}
if (!is_multisite() && current_user_can('delete_themes')) {
$actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode($stylesheet), 'delete-theme_' . $stylesheet) . '" onclick="' . "return confirm( '" . esc_js(sprintf(__("You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete."), $title)) . "' );" . '">' . __('Delete') . '</a>';
}
$actions = apply_filters('theme_action_links', $actions, $theme);
$delete_action = isset($actions['delete']) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : '';
unset($actions['delete']);
?>
<a href="<?php
echo $preview_link;
?>
" class="screenshot hide-if-customize">
<?php
if ($screenshot = $theme->get_screenshot()) {
?>
<img src="<?php
echo esc_url($screenshot);
?>
" alt="" />
<?php
}
?>
</a>
<a href="<?php
echo wp_customize_url($stylesheet);
?>
" class="screenshot load-customize hide-if-no-customize">
<?php
if ($screenshot = $theme->get_screenshot()) {
?>
<img src="<?php
echo esc_url($screenshot);
?>
" alt="" />
<?php
}
?>
</a>
<h3><?php
echo $title;
?>
</h3>
<div class="theme-author"><?php
printf(__('By %s'), $author);
?>
</div>
<div class="action-links">
<ul>
<?php
foreach ($actions as $action) {
?>
<li><?php
echo $action;
?>
</li>
<?php
}
?>
<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php
_e('Details');
?>
</a></li>
</ul>
<?php
echo $delete_action;
?>
<?php
theme_update_available($theme);
?>
</div>
<div class="themedetaildiv hide-if-js">
<p><strong><?php
_e('Version: ');
?>
</strong><?php
echo $version;
?>
</p>
//.........这里部分代码省略.........
示例11: wp_welcome_panel
/**
* Displays a welcome panel to introduce users to WordPress.
*
* @since 3.3.0
*/
function wp_welcome_panel()
{
?>
<div class="welcome-panel-content">
<h3><?php
_e('Welcome to WordPress!');
?>
</h3>
<p class="about-description"><?php
_e('We’ve assembled some links to get you started:');
?>
</p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<?php
if (current_user_can('customize')) {
?>
<h4><?php
_e('Get Started');
?>
</h4>
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php
echo wp_customize_url();
?>
"><?php
_e('Customize Your Site');
?>
</a>
<?php
}
?>
<a class="button button-primary button-hero hide-if-customize" href="<?php
echo admin_url('themes.php');
?>
"><?php
_e('Customize Your Site');
?>
</a>
<?php
if (current_user_can('install_themes') || current_user_can('switch_themes') && count(wp_get_themes(array('allowed' => true))) > 1) {
?>
<p class="hide-if-no-customize"><?php
printf(__('or, <a href="%s">change your theme completely</a>'), admin_url('themes.php'));
?>
</p>
<?php
}
?>
</div>
<div class="welcome-panel-column">
<h4><?php
_e('Next Steps');
?>
</h4>
<ul>
<?php
if ('page' == get_option('show_on_front') && !get_option('page_for_posts')) {
?>
<li><?php
printf('<a href="%s" class="welcome-icon welcome-edit-page">' . __('Edit your front page') . '</a>', get_edit_post_link(get_option('page_on_front')));
?>
</li>
<li><?php
printf('<a href="%s" class="welcome-icon welcome-add-page">' . __('Add additional pages') . '</a>', admin_url('post-new.php?post_type=page'));
?>
</li>
<?php
} elseif ('page' == get_option('show_on_front')) {
?>
<li><?php
printf('<a href="%s" class="welcome-icon welcome-edit-page">' . __('Edit your front page') . '</a>', get_edit_post_link(get_option('page_on_front')));
?>
</li>
<li><?php
printf('<a href="%s" class="welcome-icon welcome-add-page">' . __('Add additional pages') . '</a>', admin_url('post-new.php?post_type=page'));
?>
</li>
<li><?php
printf('<a href="%s" class="welcome-icon welcome-write-blog">' . __('Add a blog post') . '</a>', admin_url('post-new.php'));
?>
</li>
<?php
} else {
?>
<li><?php
printf('<a href="%s" class="welcome-icon welcome-write-blog">' . __('Write your first blog post') . '</a>', admin_url('post-new.php'));
?>
</li>
<li><?php
printf('<a href="%s" class="welcome-icon welcome-add-page">' . __('Add an About page') . '</a>', admin_url('post-new.php?post_type=page'));
?>
</li>
<?php
}
?>
//.........这里部分代码省略.........
示例12: wp_prepare_themes_for_js
/**
* Prepare themes for JavaScript.
*
* @since 3.8.0
*
* @param array $themes Optional. Array of WP_Theme objects to prepare.
* Defaults to all allowed themes.
*
* @return array An associative array of theme data, sorted by name.
*/
function wp_prepare_themes_for_js($themes = null)
{
$current_theme = get_stylesheet();
/**
* Filter theme data before it is prepared for JavaScript.
*
* Passing a non-empty array will result in wp_prepare_themes_for_js() returning
* early with that value instead.
*
* @since 4.2.0
*
* @param array $prepared_themes An associative array of theme data. Default empty array.
* @param null|array $themes An array of WP_Theme objects to prepare, if any.
* @param string $current_theme The current theme slug.
*/
$prepared_themes = (array) apply_filters('pre_prepare_themes_for_js', array(), $themes, $current_theme);
if (!empty($prepared_themes)) {
return $prepared_themes;
}
// Make sure the current theme is listed first.
$prepared_themes[$current_theme] = array();
if (null === $themes) {
$themes = wp_get_themes(array('allowed' => true));
if (!isset($themes[$current_theme])) {
$themes[$current_theme] = wp_get_theme();
}
}
$updates = array();
if (current_user_can('update_themes')) {
$updates_transient = get_site_transient('update_themes');
if (isset($updates_transient->response)) {
$updates = $updates_transient->response;
}
}
WP_Theme::sort_by_name($themes);
$parents = array();
/** @type WP_Theme $theme */
foreach ($themes as $theme) {
$slug = $theme->get_stylesheet();
$encoded_slug = urlencode($slug);
$parent = false;
if ($theme->parent()) {
$parent = $theme->parent()->display('Name');
$parents[$slug] = $theme->parent()->get_stylesheet();
}
$prepared_themes[$slug] = array('id' => $slug, 'name' => $theme->display('Name'), 'screenshot' => array($theme->get_screenshot()), 'description' => $theme->display('Description'), 'author' => $theme->display('Author', false, true), 'authorAndUri' => $theme->display('Author'), 'version' => $theme->display('Version'), 'tags' => $theme->display('Tags'), 'parent' => $parent, 'active' => $slug === $current_theme, 'hasUpdate' => isset($updates[$slug]), 'update' => get_theme_update_available($theme), 'actions' => array('activate' => current_user_can('switch_themes') ? wp_nonce_url(admin_url('themes.php?action=activate&stylesheet=' . $encoded_slug), 'switch-theme_' . $slug) : null, 'customize' => current_user_can('edit_theme_options') && current_user_can('customize') ? wp_customize_url($slug) : null, 'preview' => add_query_arg(array('preview' => 1, 'template' => urlencode($theme->get_template()), 'stylesheet' => urlencode($slug), 'preview_iframe' => true, 'TB_iframe' => true), home_url('/')), 'delete' => current_user_can('delete_themes') ? wp_nonce_url(admin_url('themes.php?action=delete&stylesheet=' . $encoded_slug), 'delete-theme_' . $slug) : null));
}
// Remove 'delete' action if theme has an active child
if (!empty($parents) && array_key_exists($current_theme, $parents)) {
unset($prepared_themes[$parents[$current_theme]]['actions']['delete']);
}
/**
* Filter the themes prepared for JavaScript, for themes.php.
*
* Could be useful for changing the order, which is by name by default.
*
* @since 3.8.0
*
* @param array $prepared_themes Array of themes.
*/
$prepared_themes = apply_filters('wp_prepare_themes_for_js', $prepared_themes);
$prepared_themes = array_values($prepared_themes);
return array_filter($prepared_themes);
}
示例13: setSections
public function setSections()
{
/**
Used within different fields. Simply examples. Search for ACTUAL DECLARATION for field examples
* */
// Background Patterns Reader
$sample_patterns_path = ReduxFramework::$_dir . '../sample/patterns/';
$sample_patterns_url = ReduxFramework::$_url . '../sample/patterns/';
$sample_patterns = array();
if (is_dir($sample_patterns_path)) {
if ($sample_patterns_dir = opendir($sample_patterns_path)) {
$sample_patterns = array();
while (($sample_patterns_file = readdir($sample_patterns_dir)) !== false) {
if (stristr($sample_patterns_file, '.png') !== false || stristr($sample_patterns_file, '.jpg') !== false) {
$name = explode('.', $sample_patterns_file);
$name = str_replace('.' . end($name), '', $sample_patterns_file);
$sample_patterns[] = array('alt' => $name, 'img' => $sample_patterns_url . $sample_patterns_file);
}
}
}
}
ob_start();
$ct = wp_get_theme();
$this->theme = $ct;
$item_name = $this->theme->get('Name');
$tags = $this->theme->Tags;
$screenshot = $this->theme->get_screenshot();
$class = $screenshot ? 'has-screenshot' : '';
$customize_title = sprintf(__('Customize “%s”', 'redux-framework-demo'), $this->theme->display('Name'));
?>
<div id="current-theme" class="<?php
echo esc_attr($class);
?>
">
<?php
if ($screenshot) {
?>
<?php
if (current_user_can('edit_theme_options')) {
?>
<a href="<?php
echo wp_customize_url();
?>
" class="load-customize hide-if-no-customize" title="<?php
echo esc_attr($customize_title);
?>
">
<img src="<?php
echo esc_url($screenshot);
?>
" alt="<?php
esc_attr_e('Current theme preview');
?>
" />
</a>
<?php
}
?>
<img class="hide-if-customize" src="<?php
echo esc_url($screenshot);
?>
" alt="<?php
esc_attr_e('Current theme preview');
?>
" />
<?php
}
?>
<h4><?php
echo $this->theme->display('Name');
?>
</h4>
<div>
<ul class="theme-info">
<li><?php
printf(__('By %s', 'redux-framework-demo'), $this->theme->display('Author'));
?>
</li>
<li><?php
printf(__('Version %s', 'redux-framework-demo'), $this->theme->display('Version'));
?>
</li>
<li><?php
echo '<strong>' . __('Tags', 'redux-framework-demo') . ':</strong> ';
printf($this->theme->display('Tags'));
?>
</li>
</ul>
<p class="theme-description"><?php
echo $this->theme->display('Description');
?>
</p>
<?php
if ($this->theme->parent()) {
printf(' <p class="howto">' . __('This <a href="%1$s">child theme</a> requires its parent theme, %2$s.') . '</p>', __('http://codex.wordpress.org/Child_Themes', 'redux-framework-demo'), $this->theme->parent()->display('Name'));
}
?>
//.........这里部分代码省略.........
示例14: setSections
public function setSections()
{
/**
* Used within different fields. Simply examples. Search for ACTUAL DECLARATION for field examples
* */
// Background Patterns Reader
$sample_patterns_path = ReduxFramework::$_dir . '../sample/patterns/';
$sample_patterns_url = ReduxFramework::$_url . '../sample/patterns/';
$sample_patterns = array();
if (is_dir($sample_patterns_path)) {
if ($sample_patterns_dir = opendir($sample_patterns_path)) {
$sample_patterns = array();
while (($sample_patterns_file = readdir($sample_patterns_dir)) !== false) {
if (stristr($sample_patterns_file, '.png') !== false || stristr($sample_patterns_file, '.jpg') !== false) {
$name = explode('.', $sample_patterns_file);
$name = str_replace('.' . end($name), '', $sample_patterns_file);
$sample_patterns[] = array('alt' => $name, 'img' => $sample_patterns_url . $sample_patterns_file);
}
}
}
}
ob_start();
$ct = wp_get_theme();
$this->theme = $ct;
$item_name = $this->theme->get('Name');
$tags = $this->theme->Tags;
$screenshot = $this->theme->get_screenshot();
$class = $screenshot ? 'has-screenshot' : '';
$customize_title = sprintf(__('Customize “%s”', 'redux-framework-demo'), $this->theme->display('Name'));
?>
<div id="current-theme" class="<?php
echo esc_attr($class);
?>
">
<?php
if ($screenshot) {
?>
<?php
if (current_user_can('edit_theme_options')) {
?>
<a href="<?php
echo wp_customize_url();
?>
" class="load-customize hide-if-no-customize"
title="<?php
echo esc_attr($customize_title);
?>
">
<img src="<?php
echo esc_url($screenshot);
?>
"
alt="<?php
esc_attr_e('Current theme preview', 'redux-framework-demo');
?>
"/>
</a>
<?php
}
?>
<img class="hide-if-customize" src="<?php
echo esc_url($screenshot);
?>
"
alt="<?php
esc_attr_e('Current theme preview', 'redux-framework-demo');
?>
"/>
<?php
}
?>
<h4><?php
echo $this->theme->display('Name');
?>
</h4>
<div>
<ul class="theme-info">
<li><?php
printf(__('By %s', 'redux-framework-demo'), $this->theme->display('Author'));
?>
</li>
<li><?php
printf(__('Version %s', 'redux-framework-demo'), $this->theme->display('Version'));
?>
</li>
<li><?php
echo '<strong>' . __('Tags', 'redux-framework-demo') . ':</strong> ';
printf($this->theme->display('Tags'));
?>
</li>
</ul>
<p class="theme-description"><?php
echo $this->theme->display('Description');
?>
</p>
<?php
if ($this->theme->parent()) {
printf(' <p class="howto">' . __('This <a href="%1$s">child theme</a> requires its parent theme, %2$s.', 'redux-framework-demo') . '</p>', __('http://codex.wordpress.org/Child_Themes', 'redux-framework-demo'), $this->theme->parent()->display('Name'));
//.........这里部分代码省略.........
示例15: tagline_notice
/**
* Notify about the default tagline if the user hasn't changed it
*/
public function tagline_notice()
{
if (current_user_can('manage_options') && $this->has_default_tagline() && !$this->seen_tagline_notice()) {
// Only add the notice on GET requests and not in the customizer to prevent faulty return url.
if ('GET' !== filter_input(INPUT_SERVER, 'REQUEST_METHOD') || is_customize_preview()) {
return;
}
$current_url = is_ssl() ? 'https://' : 'http://';
$current_url .= sanitize_text_field($_SERVER['SERVER_NAME']) . sanitize_text_field($_SERVER['REQUEST_URI']);
$customize_url = add_query_arg(array('url' => urlencode($current_url)), wp_customize_url());
$info_message = sprintf(__('You still have the default WordPress tagline, even an empty one is probably better. %1$sYou can fix this in the customizer%2$s.', 'ymbeseo'), '<a href="' . esc_attr($customize_url) . '">', '</a>');
$notification_options = array('type' => 'error', 'id' => 'wpseo-dismiss-tagline-notice', 'nonce' => wp_create_nonce('wpseo-dismiss-tagline-notice'));
Yoast_Notification_Center::get()->add_notification(new Yoast_Notification($info_message, $notification_options));
}
}