本文整理汇总了PHP中WP_Theme::get_stylesheet方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Theme::get_stylesheet方法的具体用法?PHP WP_Theme::get_stylesheet怎么用?PHP WP_Theme::get_stylesheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Theme
的用法示例。
在下文中一共展示了WP_Theme::get_stylesheet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: twentythirteen_switch_theme
/**
* Prevent switching to Twenty Thirteen on old versions of WordPress. Switches
* to the previously activated theme or the default theme.
*
* @since Twenty Thirteen 1.0
*
* @param string $theme_name The theme name.
* @param WP_Theme $theme The theme object.
* @return void
*/
function twentythirteen_switch_theme($theme_name, $theme)
{
if ('twentythirteen' != $theme->get_template()) {
switch_theme($theme->get_template(), $theme->get_stylesheet());
} elseif ('twentythirteen' != WP_DEFAULT_THEME) {
switch_theme(WP_DEFAULT_THEME);
}
unset($_GET['activated']);
add_action('admin_notices', 'twentythirteen_upgrade_notice');
}
示例2: get_switched_theme
/**
* Get the switched theme object.
*
* @return WP_Theme|bool
* @since 0.1
*/
public function get_switched_theme()
{
if (!is_null($this->switched_theme)) {
return $this->switched_theme;
}
$cts = Conditional_Themes_Manager::get_all();
if (is_array($cts) && !empty($cts)) {
foreach ($cts as $ct) {
if (!is_null($this->original_theme)) {
if ($ct->theme === $this->original_theme->get_stylesheet()) {
continue;
}
}
if (!empty($ct->condition) && is_callable($ct->condition)) {
$ct->condition = call_user_func($ct->condition);
$ct->condition = (bool) $ct->condition;
}
if (is_bool($ct->condition) && $ct->condition) {
$theme = wp_get_theme($ct->theme);
if ($theme->exists() && $theme->is_allowed()) {
$this->switched_theme = $theme;
break;
}
}
}
}
if (empty($this->switched_theme)) {
$this->switched_theme = FALSE;
}
return $this->switched_theme;
}
示例3: get_theme_info_html
protected function get_theme_info_html(WP_Theme $theme)
{
$name = $theme->display('Name');
$version = $theme->display('Version');
$description = $theme->display('Description');
$desc_title = esc_attr($theme->get('Description'));
$author = $theme->display('Author');
$screenshot = $theme->get_screenshot();
$thumbnail_style = $screenshot !== false ? sprintf('style="background-image:url(%s);"', $screenshot) : '';
$theme_url = network_admin_url(add_query_arg('theme', $theme->get_stylesheet(), 'themes.php'));
$version_label = __('Version:', 'wtaiu');
$author_label = __('By', 'wtaiu');
$output = <<<OUTPUT
<div class="theme-info" title="{$desc_title}">
<a href="{$theme_url}" class="theme-screenshot" {$thumbnail_style}></a>
<div class="theme-info-wrap">
<h3 class="theme-info-header" title="{$name}">
<a href="{$theme_url}" class="theme-name">{$name}</a>
</h3>
<p class="theme-version">{$version_label} {$version}</p>
<p class="theme-author">{$author_label} {$author}</p>
</div>
</div>
OUTPUT;
return $output;
}
示例4: check_for_update
/**
* Check for a plugin update.
*
* @since 1.0
*
* @param object $transient
*
* @return object
*/
public function check_for_update($transient)
{
if (empty($transient->checked) || empty($this->key)) {
return $transient;
}
try {
$info = $this->get_latest_version($this->key);
} catch (Exception $e) {
return $transient;
}
if (!is_wp_error($info) && version_compare($info->version, $this->version, '>')) {
$info->upgrade_notice = 'upgrade';
$stylesheet = $this->theme->get_stylesheet();
$transient->response[$stylesheet] = array('new_version' => $info->version, 'package' => $info->package, 'slug' => $stylesheet, 'theme' => $stylesheet, 'url' => add_query_arg('ID', $this->product_id, $this->generate_endpoint_url('changelog')));
if (!empty($info->upgrade_notice)) {
$transient->response[$stylesheet]['upgrade_notice'] = $info->upgrade_notice;
}
}
return $transient;
}
示例5: basename
/**
* @ticket 21749
*/
function test_wp_theme_uris_with_spaces()
{
$theme = new WP_Theme('theme with spaces', $this->theme_root . '/subdir');
// Make sure subdir/ is considered part of the stylesheet, as we must avoid encoding /'s.
$this->assertEquals('subdir/theme with spaces', $theme->get_stylesheet());
// Check that in a URI path, we have raw url encoding (spaces become %20)
// Don't try to verify the complete URI path. get_theme_root_uri() breaks down quickly.
$this->assertEquals('theme%20with%20spaces', basename($theme->get_stylesheet_directory_uri()));
$this->assertEquals('theme%20with%20spaces', basename($theme->get_template_directory_uri()));
// Check that wp_customize_url() uses url encoding, as it is a query arg (spaces become +)
$this->assertEquals(admin_url('customize.php?theme=theme+with+spaces'), wp_customize_url('theme with spaces'));
}
示例6: single_row
/**
* @global string $status
* @global int $page
* @global string $s
* @global array $totals
* @param WP_Theme $theme
*/
public function single_row($theme)
{
$status = 'all';
$stylesheet = $theme->get_stylesheet();
remove_action("after_theme_row_{$stylesheet}", 'wp_theme_update_row', 10, 2);
$theme_key = urlencode($stylesheet);
/**
* Filter the action links that show up under each theme row.
*
* @since 5.0.0
*
* @param array Array of action links
* @param WP_Theme $theme WP_Theme object
* @param string $status Status of the theme.
*/
$actions = apply_filters('mpsum_theme_action_links', array(), $theme, 'all');
$checkbox_id = "checkbox_" . md5($theme->get('Name'));
$checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select', 'stops-core-theme-and-plugin-updates') . " " . $theme->display('Name') . "</label>";
$id = sanitize_html_class($theme->get_stylesheet());
$class = 'active';
$theme_options = MPSUM_Updates_Manager::get_options('themes');
if (false !== ($key = array_search($stylesheet, $theme_options))) {
$class = 'inactive';
}
echo "<tr id='{$id}' class='{$class}'>";
list($columns, $hidden) = $this->get_column_info();
foreach ($columns as $column_name => $column_display_name) {
$style = '';
if (in_array($column_name, $hidden)) {
$style = ' style="display:none;"';
}
switch ($column_name) {
case 'cb':
echo "<th scope='row' class='check-column'>{$checkbox}</th>";
break;
case 'name':
echo "<td class='theme-title'{$style}><strong>" . $theme->display('Name') . "</strong>";
echo $this->row_actions($actions, true);
echo "</td>";
break;
case 'description':
echo "<td class='column-description desc'{$style}>";
if ($theme->errors()) {
$pre = $status == 'broken' ? __('Broken Theme:', 'stops-core-theme-and-plugin-updates') . ' ' : '';
echo '<p><strong class="attention">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
}
echo "<div class='theme-description'><p>" . $theme->display('Description') . "</p></div>\n\t\t\t\t\t\t<div class='second theme-version-author-uri'>";
$theme_meta = array();
if ($theme->get('Version')) {
$theme_meta[] = sprintf(__('Version %s', 'stops-core-theme-and-plugin-updates'), $theme->display('Version'));
}
$theme_meta[] = sprintf(__('By %s', 'stops-core-theme-and-plugin-updates'), $theme->display('Author'));
if ($theme->get('ThemeURI')) {
$theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__('Visit theme homepage', 'stops-core-theme-and-plugin-updates') . '">' . __('Visit Theme Site', 'stops-core-theme-and-plugin-updates') . '</a>';
}
/**
* Filter the array of row meta for each theme in the Multisite themes
* list table.
*
* @since 3.1.0
*
* @param array $theme_meta An array of the theme's metadata,
* including the version, author, and
* theme URI.
* @param string $stylesheet Directory name of the theme.
* @param WP_Theme $theme WP_Theme object.
* @param string $status Status of the theme.
*/
$theme_meta = apply_filters('theme_row_meta', $theme_meta, $stylesheet, $theme, $status);
echo implode(' | ', $theme_meta);
echo "</div></td>";
break;
default:
echo "<td class='{$column_name} column-{$column_name}'{$style}>";
/**
* Fires inside each custom column of the Multisite themes list table.
*
* @since 3.1.0
*
* @param string $column_name Name of the column.
* @param string $stylesheet Directory name of the theme.
* @param WP_Theme $theme Current WP_Theme object.
*/
do_action('manage_themes_custom_column', $column_name, $stylesheet, $theme);
echo "</td>";
}
}
echo "</tr>";
if ($this->is_site_themes) {
remove_action("after_theme_row_{$stylesheet}", 'wp_theme_update_row');
}
/**
* Fires after each row in the Multisite themes list table.
//.........这里部分代码省略.........
示例7: get_theme_update_available
/**
* Retrieve the update link if there is a theme update available.
*
* Will return a link if there is an update available.
*
* @since 3.8.0
*
* @staticvar object $themes_update
*
* @param WP_Theme $theme WP_Theme object.
* @return false|string HTML for the update link, or false if invalid info was passed.
*/
function get_theme_update_available($theme)
{
static $themes_update = null;
if (!current_user_can('update_themes')) {
return false;
}
if (!isset($themes_update)) {
$themes_update = get_site_transient('update_themes');
}
if (!$theme instanceof WP_Theme) {
return false;
}
$stylesheet = $theme->get_stylesheet();
$html = '';
if (isset($themes_update->response[$stylesheet])) {
$update = $themes_update->response[$stylesheet];
$theme_name = $theme->display('Name');
$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']);
//Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
$update_url = wp_nonce_url(admin_url('update.php?action=upgrade-theme&theme=' . urlencode($stylesheet)), 'upgrade-theme_' . $stylesheet);
if (!is_multisite()) {
if (!current_user_can('update_themes')) {
/* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number */
$html = sprintf('<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.') . '</strong></p>', $theme_name, esc_url($details_url), sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version']))), $update['new_version']);
} elseif (empty($update['package'])) {
/* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number */
$html = sprintf('<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>') . '</strong></p>', $theme_name, esc_url($details_url), sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version']))), $update['new_version']);
} else {
/* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */
$html = sprintf('<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.') . '</strong></p>', $theme_name, esc_url($details_url), sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version']))), $update['new_version'], $update_url, sprintf('aria-label="%s" id="update-theme" data-slug="%s"', esc_attr(sprintf(__('Update %s now'), $theme_name)), $stylesheet));
}
}
}
return $html;
}
示例8: single_row
/**
* @global string $status
* @global array $totals
*
* @param WP_Theme $theme
*/
public function single_row($theme)
{
global $status, $totals;
if ($this->is_site_themes) {
$allowed = $theme->is_allowed('site', $this->site_id);
} else {
$allowed = $theme->is_allowed('network');
}
$stylesheet = $theme->get_stylesheet();
$class = !$allowed ? 'inactive' : 'active';
$id = sanitize_html_class($theme->get_stylesheet());
if (!empty($totals['upgrade']) && !empty($theme->update)) {
$class .= ' update';
}
echo "<tr id='{$id}' class='{$class}'>";
$this->single_row_columns($theme);
echo "</tr>";
if ($this->is_site_themes) {
remove_action("after_theme_row_{$stylesheet}", 'wp_theme_update_row');
}
/**
* Fires after each row in the Multisite themes list table.
*
* @since 3.1.0
*
* @param string $stylesheet Directory name of the theme.
* @param WP_Theme $theme Current WP_Theme object.
* @param string $status Status of the theme.
*/
do_action('after_theme_row', $stylesheet, $theme, $status);
/**
* Fires after each specific row in the Multisite themes list table.
*
* The dynamic portion of the hook name, `$stylesheet`, refers to the
* directory name of the theme, most often synonymous with the template
* name of the theme.
*
* @since 3.5.0
*
* @param string $stylesheet Directory name of the theme.
* @param WP_Theme $theme Current WP_Theme object.
* @param string $status Status of the theme.
*/
do_action("after_theme_row_{$stylesheet}", $stylesheet, $theme, $status);
}
示例9: switch_theme
/**
* Theme switched
*
* @since 0.1.0
*
* @param string $new_name
* @param WP_Theme $new_theme
*/
public function switch_theme($new_name, WP_Theme $new_theme)
{
// Insert activity
wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $new_theme->get_stylesheet(), 'object_name' => $new_name, 'object_id' => 0, 'action' => 'activate'));
}
示例10: wp_theme_update_row
/**
*
* @param string $theme_key
* @param WP_Theme $theme
* @return false|void
*/
function wp_theme_update_row($theme_key, $theme)
{
$current = get_site_transient('update_themes');
if (!isset($current->response[$theme_key])) {
return false;
}
$r = $current->response[$theme_key];
$theme_name = $theme['Name'];
$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $current->response[$theme_key]['url']);
$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
$active = $theme->is_allowed('network') ? ' active' : '';
echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr($theme->get_stylesheet() . '-update') . '" data-slug="' . esc_attr($theme->get_stylesheet()) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
if (!current_user_can('update_themes')) {
/* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */
printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'), $theme_name, esc_url($details_url), esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])), $r['new_version']);
} elseif (empty($r['package'])) {
/* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */
printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), $theme_name, esc_url($details_url), esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])), $r['new_version']);
} else {
/* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */
printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.'), $theme_name, esc_url($details_url), esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $r['new_version'])), $r['new_version'], wp_nonce_url(self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key), esc_attr(sprintf(__('Update %s now'), $theme_name)));
}
/**
* Fires at the end of the update message container in each
* row of the themes list table.
*
* The dynamic portion of the hook name, `$theme_key`, refers to
* the theme slug as found in the WordPress.org themes repository.
*
* @since 3.1.0
*
* @param WP_Theme $theme The WP_Theme object.
* @param array $r {
* An array of metadata about the available theme update.
*
* @type string $new_version New theme version.
* @type string $url Theme URL.
* @type string $package Theme update package URL.
* }
*/
do_action("in_theme_update_message-{$theme_key}", $theme, $r);
echo '</div></td></tr>';
}
示例11: single_row
/**
* @global string $status
* @global int $page
* @global string $s
* @global array $totals
* @param WP_Theme $theme
*/
public function single_row($theme)
{
global $status, $page, $s, $totals;
$context = $status;
if ($this->is_site_themes) {
$url = "site-themes.php?id={$this->site_id}&";
$allowed = $theme->is_allowed('site', $this->site_id);
} else {
$url = 'themes.php?';
$allowed = $theme->is_allowed('network');
}
// Pre-order.
$actions = array('enable' => '', 'disable' => '', 'edit' => '', 'delete' => '');
$stylesheet = $theme->get_stylesheet();
$theme_key = urlencode($stylesheet);
if (!$allowed) {
if (!$theme->errors()) {
$actions['enable'] = '<a href="' . esc_url(wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $stylesheet)) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ($this->is_site_themes ? __('Enable') : __('Network Enable')) . '</a>';
}
} else {
$actions['disable'] = '<a href="' . esc_url(wp_nonce_url($url . 'action=disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $stylesheet)) . '" title="' . esc_attr__('Disable this theme') . '">' . ($this->is_site_themes ? __('Disable') : __('Network Disable')) . '</a>';
}
if (current_user_can('edit_themes')) {
$actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
}
if (!$allowed && current_user_can('delete_themes') && !$this->is_site_themes && $stylesheet != get_option('stylesheet') && $stylesheet != get_option('template')) {
$actions['delete'] = '<a href="' . esc_url(wp_nonce_url('themes.php?action=delete-selected&checked[]=' . $theme_key . '&theme_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-themes')) . '" title="' . esc_attr__('Delete this theme') . '" class="delete">' . __('Delete') . '</a>';
}
/**
* Filter the action links displayed for each theme in the Multisite
* themes list table.
*
* The action links displayed are determined by the theme's status, and
* which Multisite themes list table is being displayed - the Network
* themes list table (themes.php), which displays all installed themes,
* or the Site themes list table (site-themes.php), which displays the
* non-network enabled themes when editing a site in the Network admin.
*
* The default action links for the Network themes list table include
* 'Network Enable', 'Network Disable', 'Edit', and 'Delete'.
*
* The default action links for the Site themes list table include
* 'Enable', 'Disable', and 'Edit'.
*
* @since 2.8.0
*
* @param array $actions An array of action links.
* @param WP_Theme $theme The current WP_Theme object.
* @param string $context Status of the theme.
*/
$actions = apply_filters('theme_action_links', array_filter($actions), $theme, $context);
/**
* Filter the action links of a specific theme in the Multisite themes
* list table.
*
* The dynamic portion of the hook name, `$stylesheet`, refers to the
* directory name of the theme, which in most cases is synonymous
* with the template name.
*
* @since 3.1.0
*
* @param array $actions An array of action links.
* @param WP_Theme $theme The current WP_Theme object.
* @param string $context Status of the theme.
*/
$actions = apply_filters("theme_action_links_{$stylesheet}", $actions, $theme, $context);
$class = !$allowed ? 'inactive' : 'active';
$checkbox_id = "checkbox_" . md5($theme->get('Name'));
$checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
$id = sanitize_html_class($theme->get_stylesheet());
if (!empty($totals['upgrade']) && !empty($theme->update)) {
$class .= ' update';
}
echo "<tr id='{$id}' class='{$class}'>";
list($columns, $hidden) = $this->get_column_info();
foreach ($columns as $column_name => $column_display_name) {
$style = '';
if (in_array($column_name, $hidden)) {
$style = ' style="display:none;"';
}
switch ($column_name) {
case 'cb':
echo "<th scope='row' class='check-column'>{$checkbox}</th>";
break;
case 'name':
echo "<td class='theme-title'{$style}><strong>" . $theme->display('Name') . "</strong>";
echo $this->row_actions($actions, true);
echo "</td>";
break;
case 'description':
echo "<td class='column-description desc'{$style}>";
if ($theme->errors()) {
$pre = $status == 'broken' ? __('Broken Theme:') . ' ' : '';
//.........这里部分代码省略.........
示例12: theme_action_links
/**
* Outputs the theme action links beneath each theme row.
*
* Outputs the theme action links beneath each theme row.
*
* @since 5.0.0
* @access public
* @see __construct
* @internal uses mpsum_theme_action_links filter
*
* @param array $settings Array of settings to output.
* @param WP_Theme $theme The theme object to take action on.
*/
public function theme_action_links($settings, $theme)
{
$stylesheet = $theme->get_stylesheet();
$theme_options = MPSUM_Updates_Manager::get_options('themes');
if (false !== ($key = array_search($stylesheet, $theme_options))) {
$enable_url = add_query_arg(array('action' => 'allow-update-selected', '_mpsum' => wp_create_nonce('mpsum_theme_update'), 'checked' => array($stylesheet)));
$enable_url = remove_query_arg('disabled', $enable_url);
$settings[] = sprintf('<a href="%s">%s</a>', esc_url($enable_url), esc_html__('Allow Updates', 'stops-core-theme-and-plugin-updates'));
} else {
//Disable Link
$disable_url = add_query_arg(array('action' => 'disallow-update-selected', '_mpsum' => wp_create_nonce('mpsum_theme_update'), 'checked' => array($stylesheet)));
$disable_url = remove_query_arg('disabled', $disable_url);
$settings[] = sprintf('<a href="%s">%s</a>', esc_url($disable_url), esc_html__('Disallow Updates', 'stops-core-theme-and-plugin-updates'));
//Automatic Link
$theme_automatic_options = MPSUM_Updates_Manager::get_options('themes_automatic');
$core_options = MPSUM_Updates_Manager::get_options('core');
if (isset($core_options['automatic_theme_updates']) && 'individual' == $core_options['automatic_theme_updates']) {
if (in_array($stylesheet, $theme_automatic_options)) {
//Disable Link
$disable_automatic_url = add_query_arg(array('action' => 'disallow-automatic-selected', '_mpsum' => wp_create_nonce('mpsum_theme_update'), 'checked' => array($stylesheet)));
$settings[] = sprintf('<a href="%s">%s</a>', esc_url($disable_automatic_url), esc_html__('Disallow Automatic Updates', 'stops-core-theme-and-plugin-updates'));
} else {
//Enable Link
$enable_automatic_url = add_query_arg(array('action' => 'allow-automatic-selected', '_mpsum' => wp_create_nonce('mpsum_theme_update'), 'checked' => array($stylesheet)));
$settings[] = sprintf('<a href="%s">%s</a>', esc_url($enable_automatic_url), esc_html__('Enable Automatic Updates', 'stops-core-theme-and-plugin-updates'));
}
}
}
return $settings;
}
示例13: hooks_switch_theme
public function hooks_switch_theme($new_name, WP_Theme $new_theme)
{
aal_insert_log(array('action' => 'activated', 'object_type' => 'Theme', 'object_subtype' => $new_theme->get_stylesheet(), 'object_id' => 0, 'object_name' => $new_name));
}
示例14: column_default
/**
* Handles default column output.
*
* @since 4.3.0
* @access public
*
* @param WP_Theme $theme The current WP_Theme object.
* @param string $column_name The current column name.
*/
public function column_default($theme, $column_name)
{
$stylesheet = $theme->get_stylesheet();
/**
* Fires inside each custom column of the Multisite themes list table.
*
* @since 3.1.0
*
* @param string $column_name Name of the column.
* @param string $stylesheet Directory name of the theme.
* @param WP_Theme $theme Current WP_Theme object.
*/
do_action('manage_themes_custom_column', $column_name, $stylesheet, $theme);
}
示例15: get_theme_update_available
/**
* Retrieve the update link if there is a theme update available.
*
* Will return a link if there is an update available.
*
* @since 3.8.0
*
* @param WP_Theme $theme WP_Theme object.
* @return false|string HTML for the update link, or false if invalid info was passed.
*/
function get_theme_update_available($theme)
{
static $themes_update;
if (!current_user_can('update_themes')) {
return false;
}
if (!isset($themes_update)) {
$themes_update = get_site_transient('update_themes');
}
if (!$theme instanceof WP_Theme) {
return false;
}
$stylesheet = $theme->get_stylesheet();
$html = '';
if (isset($themes_update->response[$stylesheet])) {
$update = $themes_update->response[$stylesheet];
$theme_name = $theme->display('Name');
$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']);
//Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
$update_url = wp_nonce_url(admin_url('update.php?action=upgrade-theme&theme=' . urlencode($stylesheet)), 'upgrade-theme_' . $stylesheet);
$update_onclick = 'onclick="if ( confirm(\'' . esc_js(__("Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update.")) . '\') ) {return true;}return false;"';
if (!is_multisite()) {
if (!current_user_can('update_themes')) {
$html = sprintf('<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.') . '</strong></p>', $theme_name, esc_url($details_url), esc_attr($theme['Name']), $update['new_version']);
} elseif (empty($update['package'])) {
$html = sprintf('<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>') . '</strong></p>', $theme_name, esc_url($details_url), esc_attr($theme['Name']), $update['new_version']);
} else {
$html = sprintf('<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.') . '</strong></p>', $theme_name, esc_url($details_url), esc_attr($theme['Name']), $update['new_version'], $update_url, $update_onclick);
}
}
}
return $html;
}