本文整理汇总了PHP中wp_get_themes函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_themes函数的具体用法?PHP wp_get_themes怎么用?PHP wp_get_themes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_themes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show_box1
function show_box1()
{
$android_Theme = get_option('cart_android_theme');
$iphone_Theme = get_option('cart_iphone_theme');
$ipad_Theme = get_option('cart_ipad_theme');
$themes = wp_get_themes();
?>
<div class="inside">
<p><?php
_e('Android Phone Theme Setup', 'WP-OliveCart');
?>
</p>
<select name="android_theme">
<?php
foreach ($themes as $theme) {
if ($android_Theme == $theme['Name'] || $android_Theme == '' && $theme['Name'] == get_current_theme()) {
echo '<option value="' . $theme['Name'] . '" selected="selected">' . $theme['Name'] . '</option>';
} else {
echo '<option value="' . $theme['Name'] . '">' . $theme['Name'] . '</option>';
}
}
?>
</select>
</div>
<?php
}
示例2: gitium_update_versions
function gitium_update_versions()
{
// get all themes from WP
$all_themes = wp_get_themes(array('allowed' => true));
foreach ($all_themes as $theme_name => $theme) {
$theme_versions[$theme_name] = array('name' => $theme->Name, 'version' => null, 'msg' => '');
$theme_versions[$theme_name]['msg'] = '`' . $theme->Name . '`';
$version = $theme->Version;
if (!empty($version)) {
$theme_versions[$theme_name]['msg'] .= " version {$version}";
$theme_versions[$theme_name]['version'] .= $version;
}
}
if (!empty($theme_versions)) {
$new_versions['themes'] = $theme_versions;
}
// get all plugins from WP
if (!function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = get_plugins();
foreach ($all_plugins as $name => $data) {
$plugin_versions[$name] = array('name' => $data['Name'], 'version' => null, 'msg' => '');
$plugin_versions[$name]['msg'] = "`{$data['Name']}`";
if (!empty($data['Version'])) {
$plugin_versions[$name]['msg'] .= ' version ' . $data['Version'];
$plugin_versions[$name]['version'] .= $data['Version'];
}
}
if (!empty($plugin_versions)) {
$new_versions['plugins'] = $plugin_versions;
}
set_transient('gitium_versions', $new_versions);
return $new_versions;
}
示例3: sb_switch_to_default_theme
function sb_switch_to_default_theme()
{
$themes = wp_get_themes();
$wp_theme = '';
foreach ($themes as $theme) {
$author_uri = $theme->get('AuthorURI');
if (false !== strrpos($author_uri, 'wordpress.org')) {
$wp_theme = $theme;
break;
}
}
if (empty($wp_theme)) {
foreach ($themes as $theme) {
$text_domain = $theme->get('TextDomain');
if (false === strrpos($text_domain, 'sb-theme')) {
$wp_theme = $theme;
break;
}
}
}
$theme = $wp_theme;
if (!empty($theme)) {
switch_theme($theme->get('TextDomain'));
}
}
示例4: jptb_register_settings
function jptb_register_settings()
{
add_settings_section('jptb_theme_choice', __('Which Themes Do You Want To Show?', 'jptb'), array($this, 'themeChoice_HTML'), 'jptb_settings');
add_settings_section('jptb_other_options', __('Additional Options', 'jptb'), array($this, 'other_options_HTML'), 'jptb_settings');
$themes = wp_get_themes();
foreach ($themes as $theme) {
//the preperation
$themename = $theme['Name'];
$noSpaceName = strtr($themename, " -", "__");
$nocapsname = strtolower($noSpaceName);
$uniqueOptionName = "jptb_" . $nocapsname;
//This will have to loop, make a create settings field function and pass the field ID
add_settings_field($uniqueOptionName, $themename, array($this, 'Theme_field_HTML'), 'jptb_settings', 'jptb_theme_choice', $uniqueOptionName);
register_setting('jptb_settings', $uniqueOptionName);
}
//LABEL TEXT TO USE
add_settings_field('jptb_label', __('Label For Theme Bar', 'jptb'), array($this, 'label_cb'), 'jptb_settings', 'jptb_other_options');
register_setting('jptb_settings', 'jptb_label');
//MAIN BG COLOUR
add_settings_field('jptb_bg_colour', __('Background Colour', 'jptb'), array($this, 'bg_cb'), 'jptb_settings', 'jptb_other_options');
register_setting('jptb_settings', 'jptb_bg_colour');
//MAIN TXT COLOUR
add_settings_field('jptb_text_colour', __('Text Colour', 'jptb'), array($this, 'txt_cb'), 'jptb_settings', 'jptb_other_options');
register_setting('jptb_settings', 'jptb_text_colour');
//LABEL BG COLOUR
add_settings_field('jptb_label_bg_colour', __('Label Background Colour', 'jptb'), array($this, 'label_bg_cb'), 'jptb_settings', 'jptb_other_options');
register_setting('jptb_settings', 'jptb_label_bg_colour');
//LABEL TEXT COLOR
add_settings_field('jptb_label_text_colour', __('Label Text Colour', 'jptb'), array($this, 'label_txt_cb'), 'jptb_settings', 'jptb_other_options');
register_setting('jptb_settings', 'jptb_label_text_colour');
//LABEL TEXT COLOR
add_settings_field('jptb_mod_switch', __('Update Theme Mods', 'jptb'), array($this, 'mod_switch_cb'), 'jptb_settings', 'jptb_other_options');
register_setting('jptb_settings', 'jptb_mod_switch');
}
示例5: get_post_templates
function get_post_templates()
{
$themes = wp_get_themes();
$theme = get_option('template');
$templates = $themes[$theme]['Template Files'];
$post_templates = array();
if (is_array($templates)) {
$base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()));
foreach ($templates as $template) {
$basename = str_replace($base, '', $template);
if ($basename != 'functions.php') {
// don't allow template files in subdirectories
if (false !== strpos($basename, '/')) {
continue;
}
if ($basename == 'post_templates.php') {
continue;
}
$template_data = implode('', file($template));
$name = '';
if (preg_match('|Single Post Template:(.*)$|mi', $template_data, $name)) {
$name = _cleanup_header_comment($name[1]);
}
if (!empty($name)) {
$post_templates[trim($basename)] = $name;
}
}
}
}
return $post_templates;
}
示例6: prepare_items
/**
* @access public
*/
public function prepare_items() {
$themes = wp_get_themes( array( 'allowed' => true ) );
if ( ! empty( $_REQUEST['s'] ) )
$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) );
if ( ! empty( $_REQUEST['features'] ) )
$this->features = $_REQUEST['features'];
if ( $this->search_terms || $this->features ) {
foreach ( $themes as $key => $theme ) {
if ( ! $this->search_theme( $theme ) )
unset( $themes[ $key ] );
}
}
unset( $themes[ get_option( 'stylesheet' ) ] );
WP_Theme::sort_by_name( $themes );
$per_page = 36;
$page = $this->get_pagenum();
$start = ( $page - 1 ) * $per_page;
$this->items = array_slice( $themes, $start, $per_page, true );
$this->set_pagination_args( array(
'total_items' => count( $themes ),
'per_page' => $per_page,
'infinite_scroll' => true,
) );
}
示例7: pre_set_site_transient_update_themes
public function pre_set_site_transient_update_themes($data)
{
//
// Only run after other themes are checked.
//
if (empty($data->checked)) {
return $data;
}
Themeco_Update_Api::refresh();
$update_cache = Themeco_Update_Api::get_update_cache();
if (!isset($update_cache['themes']) || !isset($update_cache['themes']['x'])) {
return $data;
}
$themes = is_multisite() ? $this->multisite_get_themes() : wp_get_themes();
if (isset($themes['x'])) {
$remote = $update_cache['themes']['x'];
if (version_compare($remote['new_version'], $themes['x']->get('Version'), '<=')) {
return $data;
}
if (!$remote['package']) {
$remote['new_version'] = $remote['new_version'] . '<br/>' . X_Update_API::get_validation_html_theme_updates();
}
$data->response['x'] = $remote;
}
return $data;
}
示例8: hellJustFrozeOver
function hellJustFrozeOver()
{
$error = error_get_last();
$currentTheme = wp_get_theme();
if ($error) {
$foundOneFromTwentySeries = false;
$themes = wp_get_themes(array('errors' => false, 'allowed' => null, 'blog_id' => 0));
foreach ($themes as $slug => $theme) {
if (strpos($slug, 'twenty') !== false) {
switch_theme($theme->get_stylesheet());
$foundOneFromTwentySeries = true;
break;
}
}
if (!$foundOneFromTwentySeries) {
//dang, no theme from twenty series was present
foreach ($themes as $slug => $theme) {
if ($theme->get_stylesheet() != $currentTheme->get_stylesheet()) {
switch_theme($theme->get_stylesheet());
break;
}
}
}
$fatalErrorMessage = "Your <b>{$currentTheme->Name}</b> theme threw a fatal error on <b>line #{$error['line']}</b> in {$error['file']}. The error message was: <b>{$error['message']}</b>. Please fix it.'";
update_option('fatalsafe', $fatalErrorMessage);
echo "<h1>Don't Panic! Refresh This Page To Get Some Oxygen</h1>";
}
}
示例9: activate_demo_extension_admin_notice
/**
* Activate admin notice
*/
public function activate_demo_extension_admin_notice()
{
global $blog_id;
$themes = wp_get_themes($blog_id);
if ('layerswp' !== get_template()) {
?>
<div class="updated is-dismissible error">
<p><?php
_e(sprintf("Layers is required to use the Demo Extension. <a href=\"%s\" target=\"_blank\">Click here</a> to get it.", isset($themes['layerswp']) ? admin_url('themes.php?s=layerswp') : "http://www.layerswp.com"), LAYERS_DEMO_EXTENSION_SLUG);
?>
</p>
</div>
<?php
} else {
if (FALSE !== $this->update_required) {
?>
<div class="updated is-dismissible error">
<p><?php
_e(sprintf("Demo Extension requires Layers Version " . $this->update_required . ". <a href=\"%s\" target=\"_blank\">Click here</a> to get the Layers Updater.", "http://www.layerswp.com/download/layers-updater"), LAYERS_DEMO_EXTENSION_SLUG);
?>
</p>
</div>
<?php
}
}
}
示例10: outputThemeList
protected function outputThemeList()
{
$themes = wp_get_themes();
foreach ($themes as $directory => $theme) {
$mark = get_template() === $directory ? '*' : ' ';
$this->line("{$mark} {$theme->name} [{$theme->version}] '{$directory}'");
}
}
示例11: getThemes
function getThemes($args)
{
if (function_exists("wp_get_themes")) {
return wp_get_themes($args);
} else {
return get_themes();
}
}
示例12: get_themes
function get_themes()
{
if (false === ($result = get_transient('sk_' . SK_CACHE_PREFIX . '_get_themes'))) {
$result = wp_get_themes(array('allowed' => true));
set_transient('sk_' . SK_CACHE_PREFIX . '_get_themes', $result, $this->cache_time);
}
return count($result);
}
示例13: get_avaiable_themes
public function get_avaiable_themes()
{
if (function_exists('wp_get_themes')) {
$this->avaiable_themes = wp_get_themes();
} else {
$this->avaiable_themes = get_themes();
}
}
示例14: utilities_page
/**
* Utilities Page
*/
function utilities_page()
{
$themes = wp_get_themes();
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div>
<h2>Make Exporter for Theme Foundry</h2>
<?php
echo $this->error . "<br>";
?>
<form action="" method="post" enctype="multipart/form-data">
<?php
if (current_user_can('manage_options')) {
wp_nonce_field('export');
if (isset($_POST['import_theme'])) {
if (wp_verify_nonce($_REQUEST['_wpnonce'], 'import')) {
$import_theme = esc_attr($_POST['import_theme']);
if (strlen($_FILES['themeMods']['tmp_name']) > 0) {
$mods = file_get_contents($_FILES['themeMods']['tmp_name']);
$modArr = json_decode(sanitize_text_field($mods), true);
if (is_array($modArr)) {
update_option('theme_mods_' . $import_theme, $modArr);
} else {
echo "Theme modifications in uploaded file are not valid";
}
}
} else {
echo "Possible resubmit or action not authorized.";
}
}
echo "<p>Choose theme to export modifications:</p>";
echo "<p><select id='export_theme' name='export_theme'>";
foreach ($themes as $theme_slug => $theme) {
echo "<option value='" . $theme_slug . "'>" . $theme->Name . "</option>";
}
echo "</select></p>";
echo '<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Export modifications"></p>';
echo '</form><form method="post" enctype="multipart/form-data">';
wp_nonce_field('import');
echo "<p>Warning! Importing theme modifications will overwrite current theme customizations. Please export if you want to save them.<br>Please select theme to import modifications:</p>";
echo "<p><select id='import_theme' name='import_theme'>";
foreach ($themes as $theme_slug => $theme) {
echo "<option value='" . $theme_slug . "'>" . $theme->Name . "</option>";
}
echo "</select></p>";
echo "<p>Choose modification file:</p>";
echo '<input type="file" name="themeMods">';
echo '<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Import modifications"></p>';
} else {
echo "Not enough permissions. Please contact administrator to allow to manage options";
}
?>
</form>
</div>
<?php
}
示例15: prepare_items
/**
*
* @global string $status
* @global array $totals
* @global int $page
* @global string $orderby
* @global string $order
* @global string $s
*/
public function prepare_items()
{
global $status, $totals, $page, $orderby, $order, $s;
wp_reset_vars(array('orderby', 'order', 's'));
$themes = array('all' => apply_filters('all_themes', wp_get_themes()), 'search' => array(), 'enabled' => array(), 'disabled' => array(), 'upgrade' => array(), 'broken' => $this->is_site_themes ? array() : wp_get_themes(array('errors' => true)));
if ($this->is_site_themes) {
$themes_per_page = $this->get_items_per_page('site_themes_network_per_page');
$allowed_where = 'site';
} else {
$themes_per_page = $this->get_items_per_page('themes_network_per_page');
$allowed_where = 'network';
}
$maybe_update = current_user_can('update_themes') && !$this->is_site_themes && ($current = get_site_transient('update_themes'));
foreach ((array) $themes['all'] as $key => $theme) {
if ($this->is_site_themes && $theme->is_allowed('network')) {
unset($themes['all'][$key]);
continue;
}
if ($maybe_update && isset($current->response[$key])) {
$themes['all'][$key]->update = true;
$themes['upgrade'][$key] = $themes['all'][$key];
}
$filter = $theme->is_allowed($allowed_where, $this->site_id) ? 'enabled' : 'disabled';
$themes[$filter][$key] = $themes['all'][$key];
}
if ($s) {
$status = 'search';
$themes['search'] = array_filter(array_merge($themes['all'], $themes['broken']), array($this, '_search_callback'));
}
$totals = array();
foreach ($themes as $type => $list) {
$totals[$type] = count($list);
}
if (empty($themes[$status]) && !in_array($status, array('all', 'search'))) {
$status = 'all';
}
$this->items = $themes[$status];
WP_Theme::sort_by_name($this->items);
$this->has_items = !empty($themes['all']);
$total_this_page = $totals[$status];
wp_localize_script('updates', '_wpUpdatesItemCounts', array('themes' => $totals, 'totals' => wp_get_update_data()));
if ($orderby) {
$orderby = ucfirst($orderby);
$order = strtoupper($order);
if ($orderby === 'Name') {
if ('ASC' === $order) {
$this->items = array_reverse($this->items);
}
} else {
uasort($this->items, array($this, '_order_callback'));
}
}
$start = ($page - 1) * $themes_per_page;
if ($total_this_page > $themes_per_page) {
$this->items = array_slice($this->items, $start, $themes_per_page, true);
}
$this->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $themes_per_page));
}