本文整理汇总了PHP中wp_get_theme函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_theme函数的具体用法?PHP wp_get_theme怎么用?PHP wp_get_theme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_theme函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: siw_wc_checkout_scripts_js
function siw_wc_checkout_scripts_js()
{
wp_register_script('siw-wc-checkout-scripts', get_stylesheet_directory_uri() . '/assets/js/siw-wc-checkout-scripts.js', array('jquery'), wp_get_theme()->version, TRUE);
$site_url = site_url();
$parameters = array('ajax_url' => get_stylesheet_directory_uri() . '/siw-ajax.php');
wp_localize_script('siw-wc-checkout-scripts', 'parameters', $parameters);
}
示例2: memberlite_update_themes_filter
/**
* Infuse theme update details when WordPress runs its update checker.
*
* @since 2.0
*
* @param object $value The WordPress update object.
* @return object $value Amended WordPress update object on success, default if object is empty.
*/
function memberlite_update_themes_filter($value)
{
// If no update object exists, return early.
if (empty($value)) {
return $value;
}
// get update_info information
$update_info = memberlite_getUpdateInfo();
// no info?
if (empty($update_info)) {
return $value;
}
//get data for theme
$theme_file_abs = ABSPATH . 'wp-content/themes/' . $update_info['Slug'];
$theme_file = $theme_file_abs . "/style.css";
$theme_data = wp_get_theme($update_info['Slug']);
//compare versions
if (!empty($update_info['License']) && version_compare($theme_data['Version'], $update_info['Version'], '<')) {
$value->response[$update_info['Slug']] = array('theme' => $update_info['Slug'], 'new_version' => $update_info['Version'], 'url' => $update_info['ThemeURI'], 'package' => $update_info['Download']);
//get license key if one is available
$key = get_option("pmpro_license_key", "");
if (!empty($key) && pmpro_license_isValid($key, "plus")) {
$value->response[$update_info['Slug']]['package'] = add_query_arg("key", $key, $value->response[$update_info['Slug']]['package']);
} else {
global $memberlite_license_error;
//only want to show this once
if (empty($memberlite_license_error)) {
$memberlite_license_error = true;
echo "<div class='error'><p>" . sprintf(__('A valid PMPro Plus license key is required to update Memberlite. <a href="%s">Please validate your PMPro Plus license key</a>.', 'memberlite'), admin_url('options-general.php?page=pmpro_license_settings')) . "</p></div>";
}
}
}
// Return the update object.
return $value;
}
示例3: start_previewing_theme
/**
* Start previewing the selected theme.
*
* Adds filters to change the current theme.
*
* @since 3.4.0
*/
public function start_previewing_theme()
{
if ($this->is_preview() || false === $this->theme || $this->theme && !$this->theme->exists()) {
return;
}
// Initialize $theme and $original_stylesheet if they do not yet exist.
if (!isset($this->theme)) {
$this->theme = wp_get_theme($_REQUEST['theme']);
if (!$this->theme->exists()) {
$this->theme = false;
return;
}
}
$this->original_stylesheet = get_stylesheet();
$this->previewing = true;
add_filter('template', array($this, 'get_template'));
add_filter('stylesheet', array($this, 'get_stylesheet'));
add_filter('pre_option_current_theme', array($this, 'current_theme'));
// @link: http://core.trac.wordpress.org/ticket/20027
add_filter('pre_option_stylesheet', array($this, 'get_stylesheet'));
add_filter('pre_option_template', array($this, 'get_template'));
// Handle custom theme roots.
add_filter('pre_option_stylesheet_root', array($this, 'get_stylesheet_root'));
add_filter('pre_option_template_root', array($this, 'get_template_root'));
do_action('start_previewing_theme');
}
示例4: jbaths_scripts
/**
* Enqueue scripts and styles.
*/
function jbaths_scripts()
{
$theme = wp_get_theme();
// wtf
wp_enqueue_style('wtf-forms', get_template_directory_uri() . '/css/wtf-forms.css', array(), '2.2.0');
// and then
wp_enqueue_style('jbaths', get_stylesheet_uri(), array(), $theme->Version . '.1');
// store locator plus - specialty css
if (is_page('find-a-showroom')) {
wp_enqueue_style('jbaths-slp', get_template_directory_uri() . '/css/slp-baths.css', array(), $theme->Version);
// store locator plus
}
if (!is_admin()) {
wp_register_script('jbaths.modernizr', get_stylesheet_directory_uri() . '/js/modernizr.min.js', array(), '2.8.3', true);
wp_register_script('jquery.cookie', get_stylesheet_directory_uri() . '/js/jquery.cookie.js', array('jquery'), $theme->Version);
wp_register_script('scrollupforwhat', get_stylesheet_directory_uri() . '/js/jquery.scrollupforwhat.min.js', array('jquery'), '1.2', true);
wp_register_script('matchHeight', get_template_directory_uri() . '/js/jquery.matchHeight.js', array('jquery'), '0.5.2', true);
$jbaths_deps = array('jquery', 'jbaths.modernizr', 'jquery.cookie', 'scrollupforwhat', 'matchHeight');
if (is_singular('bathtubs') || is_singular('faucets')) {
if (get_option('ultimate_row') == "enable") {
//$jbaths_deps[] = 'ultimate-row-bg';
}
}
wp_enqueue_script('jbaths', get_template_directory_uri() . '/js/baths.js', $jbaths_deps, '20140718', true);
}
wp_enqueue_script('skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true);
// Omniture SiteCatalyst
wp_enqueue_script('sitecatalyst', get_template_directory_uri() . '/js/s_code.js', array(), $theme->Version, true);
if (is_singular('post') && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
}
示例5: avada_child_scripts
function avada_child_scripts()
{
if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
$theme_info = wp_get_theme();
wp_enqueue_style('avada-child-stylesheet', get_template_directory_uri() . '/style.css', array(), $theme_info->get('Version'));
}
}
示例6: display
function display()
{
$browser = new SendPress_Browser();
if (get_bloginfo('version') < '3.4') {
$theme_data = get_theme_data(get_stylesheet_directory() . '/style.css');
$theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
} else {
$theme_data = wp_get_theme();
$theme = $theme_data->Name . ' ' . $theme_data->Version;
}
// Try to identify the hosting provider
$host = false;
if (defined('WPE_APIKEY')) {
$host = 'WP Engine';
} elseif (defined('PAGELYBIN')) {
$host = 'Pagely';
}
$request['cmd'] = '_notify-validate';
$params = array('sslverify' => false, 'timeout' => 60, 'body' => $request);
$response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params);
if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
} else {
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
}
return $this->display_output($browser, $theme, $host, $WP_REMOTE_POST);
}
示例7: register_meta_boxes
/**
* Add the various registered meta boxes.
* @access public
* @since 6.0.0
* @return void
*/
public function register_meta_boxes()
{
$defaults = array('id' => 'woothemes-settings', 'title' => sprintf(__('%s Settings', 'woothemes'), wp_get_theme()->__get('Name')), 'callback' => array($this, 'meta_box_content'), 'page' => 'all', 'context' => 'normal', 'priority' => 'default', 'callback_args' => '');
$settings = array('id' => 'woothemes-settings', 'title' => sprintf(__('%s Settings', 'woothemes'), wp_get_theme()->__get('Name')), 'callback' => array($this, 'meta_box_content'), 'page' => 'all', 'context' => 'normal', 'priority' => 'default', 'callback_args' => '');
// Allow child themes/plugins to filter these settings.
$settings = apply_filters('woothemes_metabox_settings', $settings, $settings['page'], $settings['id']);
$meta_boxes = array('woothemes-settings' => $settings);
$meta_boxes = (array) apply_filters('wf_meta_boxes', $meta_boxes);
// Loop through and set up the meta boxes.
if (0 < count($meta_boxes)) {
$global_boxes = array();
foreach ($meta_boxes as $k => $v) {
if (!isset($v['page'])) {
$meta_boxes[$k]['page'] = 'all';
}
// If we want this box to apply to all post types, store it for later to avoid doing a loop within a loop (nasty).
if ('all' == $v['page']) {
$global_boxes[$k] = $v;
} else {
$v = wp_parse_args($v, $defaults);
add_meta_box($v['id'], $v['title'], array($this, 'meta_box_content'), $v['page'], $v['context'], $v['priority'], $v['callback_args']);
}
}
// Maybe process global boxes.
if (0 < count($global_boxes)) {
foreach ($global_boxes as $k => $v) {
$v = wp_parse_args($v, $defaults);
foreach (get_post_types() as $i => $j) {
add_meta_box($v['id'], $v['title'], array($this, 'meta_box_content'), $j, $v['context'], $v['priority'], $v['callback_args']);
}
}
}
}
}
示例8: constants
/**
* Define all of the constants for our theme, framework including
* version numbers, paths, etc.
*
* @author Richard Tape
* @package Incipio
* @since 1.0
* @param None
* @return None
*/
function constants()
{
//Define our framework version
define('INCIPIO_VERSION', '1.0');
//Define theme-related constants with support for WP < 3.4
if (function_exists('wp_get_theme')) {
//We're using WordPress version 3.4+
$theme_data = wp_get_theme();
if (!defined('THEMENAME')) {
define('THEMENAME', $theme_data->Template);
}
if (!defined('THEMEVERSION')) {
define('THEMEVERSION', $theme_data->Version);
}
} else {
//We're using WP < 3.4 so don't have access to the wp_get_theme class
$theme_data = get_theme_data(get_template_directory() . '/style.css');
if (!defined('THEMENAME')) {
define('THEMENAME', $theme_data['Template']);
}
if (!defined('THEMEVERSION')) {
define('THEMEVERSION', $theme_data['Version']);
}
}
}
示例9: check_for_update
function check_for_update()
{
$theme = wp_get_theme($this->theme_slug);
$update_data = get_transient($this->response_key);
if (false === $update_data) {
$failed = false;
$api_params = array('edd_action' => 'get_version', 'license' => $this->license, 'name' => $this->item_name, 'slug' => $this->theme_slug, 'author' => $this->author);
$response = wp_remote_post($this->remote_api_url, array('timeout' => 15, 'body' => $api_params));
// make sure the response was successful
if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
$failed = true;
}
$update_data = json_decode(wp_remote_retrieve_body($response));
if (!is_object($update_data)) {
$failed = true;
}
// if the response failed, try again in 30 minutes
if ($failed) {
$data = new stdClass();
$data->new_version = $theme->get('Version');
set_transient($this->response_key, $data, strtotime('+30 minutes'));
return false;
}
// if the status is 'ok', return the update arguments
if (!$failed) {
$update_data->sections = maybe_unserialize($update_data->sections);
set_transient($this->response_key, $update_data, strtotime('+12 hours'));
}
}
if (version_compare($theme->get('Version'), $update_data->new_version, '>=')) {
return false;
}
return (array) $update_data;
}
示例10: coni_body_classes
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function coni_body_classes($classes)
{
$coni_theme_data = wp_get_theme();
$classes[] = sanitize_title($coni_theme_data['Name']);
$classes[] = 'v' . $coni_theme_data['Version'];
return $classes;
}
示例11: upgrade_theme
/**
* Upgrades theme to its latest version
*
* @since 1.0
* @access public
*
* @param string Name of the theme. If not set checks for updates for the current theme. Default ''.
* @param bool Allow API calls to be cached. Default true.
* @return object A stdClass object.
*/
public function upgrade_theme($theme_name = '', $allow_cache = true)
{
$result = new stdClass();
$result->success = false;
if (empty($theme_name)) {
$theme_name = function_exists('wp_get_theme') ? wp_get_theme()->Name : get_current_theme();
}
$installed_theme = $this->is_theme_installed($theme_name);
if ($installed_theme == null) {
$result->errors = array("'{$theme_name}' theme is not installed");
return $result;
}
$purchased_themes = $this->api->wp_list_themes($allow_cache);
$marketplace_theme_data = null;
if ($errors = $this->api->api_errors()) {
$result->errors = array();
foreach ($errors as $k => $v) {
array_push($result->errors, $v);
}
return $result;
}
foreach ($purchased_themes as $purchased) {
if ($this->is_matching_themes($installed_theme, $purchased) && $this->is_newer_version_available($installed_theme['Version'], $purchased->version)) {
$marketplace_theme_data = $purchased;
break;
}
}
if ($marketplace_theme_data == null) {
$result->errors = array("There is no update available for '{$theme_name}'");
return $result;
}
$result->success = $this->do_upgrade_theme($installed_theme['Title'], $marketplace_theme_data->item_id);
$result->installation_feedback = $this->installation_feedback;
return $result;
}
示例12: audiotheme_version_compare
/**
* Compare two version numbers.
*
* This function abstracts the logic for determining the current version
* number for various packages, so the only version number that needs to be
* known is the one to compare against.
*
* Basically serves as a wrapper for the native PHP version_compare()
* function, but allows a known package to be passed as the first parameter.
*
* @since 1.0.0
* @see PHP docs for version_compare()
* @uses version_compare()
*
* @param string $version A package identifier or version number to compare against.
* @param string $version2 The version number to compare to.
* @param string $operator Optional. Relationship to test. <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
* @return mixed True or false if operator is supplied. -1, 0, or 1 if operator is empty.
*/
function audiotheme_version_compare($version, $version2, $operator = null)
{
switch ($version) {
case 'audiotheme':
$version = AUDIOTHEME_VERSION;
break;
case 'php':
$version = phpversion();
break;
case 'stylesheet':
// Child theme if it exists, otherwise same as template.
$theme = wp_get_theme();
$version = $theme->get('Version');
break;
case 'template':
// Parent theme.
$theme = wp_get_theme(get_template());
$version = $theme->get('Version');
break;
case 'wp':
$version = get_bloginfo('version');
break;
}
return version_compare($version, $version2, $operator);
}
示例13: genesisstyletrump_load_stylesheet
/**
* Move Genesis child theme style sheet to a much later priority to give any plugins a chance to load first.
*
* @since 1.0.0
*/
function genesisstyletrump_load_stylesheet()
{
// Get name of current theme
$theme = wp_get_theme();
// Check to see if known themes with parallax scripts are active
// If so, set an earlier priority ($priority) for the main stylesheet
// and specify the additional function ($theme_function_that_loads_parallax_elements) to hook to wp_enqueue_scripts
switch ($theme) {
case 'Parallax Pro Theme':
$priority = 14;
$theme_function_that_loads_parallax_elements = 'parallax_css';
break;
case 'Altitude Pro Theme':
$priority = 14;
$theme_function_that_loads_parallax_elements = 'altitude_css';
break;
case 'Cafe Pro Theme':
$priority = 14;
$theme_function_that_loads_parallax_elements = 'cafe_css';
break;
default:
$priority = 999;
$theme_function_that_loads_parallax_elements = null;
}
remove_action('genesis_meta', 'genesis_load_stylesheet');
add_action('wp_enqueue_scripts', 'genesis_enqueue_main_stylesheet', $priority);
// If there is an additional function defined, hook it to wp_enqueue_scripts
if (!is_null($theme_function_that_loads_parallax_elements)) {
add_action('wp_enqueue_scripts', $theme_function_that_loads_parallax_elements, $priority);
}
}
示例14: optionsframework_options
/**
* Defines an array of options that will be used to generate the settings page and be saved in the database.
* When creating the "id" fields, make sure to use all lowercase and no spaces.
*
*/
function optionsframework_options()
{
$themename = 'wp_get_theme' ? wp_get_theme() : wp_get_theme();
$themename = $themename['Name'];
$shortname = "of";
//Stylesheet Reader
$alt_stylesheets = array("black" => "black", "brown" => "brown", "blue" => "blue", "green" => "green", "pink" => "pink", "purple" => "purple", "red" => "red", "yellow" => "yellow");
// Test data
$test_array = array("one" => "One", "two" => "Two", "three" => "Three", "four" => "Four", "five" => "Five");
// Multicheck Array
$multicheck_array = array("one" => "French Toast", "two" => "Pancake", "three" => "Omelette", "four" => "Crepe", "five" => "Waffle");
// Multicheck Defaults
$multicheck_defaults = array("one" => "1", "five" => "1");
// Background Defaults
$background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat', 'position' => 'top center', 'attachment' => 'scroll');
// Pull all the categories into an array
$options_categories = array();
$options_categories_obj = get_categories();
foreach ($options_categories_obj as $category) {
$options_categories[$category->cat_ID] = $category->cat_name;
}
// Pull all the pages into an array
$options_pages = array();
$options_pages_obj = get_pages('sort_column=post_parent,menu_order');
$options_pages[''] = 'Select a page:';
foreach ($options_pages_obj as $page) {
$options_pages[$page->ID] = $page->post_title;
}
// If using image radio buttons, define a directory path
$imagepath = get_stylesheet_directory_uri() . '/images/';
$options = array(array("name" => __("General Settings", "wrockmetro"), "type" => "heading"), array("name" => __("Custom Favicon URL", "wrockmetro"), "desc" => "Specify a 16px x 16px image that will represent your website's favicon.", "id" => "wrockmetro_favicon", "type" => "upload"), array("name" => __("Latest Posts", "wrockmetro"), "desc" => "Show 5 Latest Posts with Thumbnail in Sidebar.", "id" => "wrockmetro_activate_ltposts", "std" => "1", "type" => "checkbox"), array("name" => __("Show Author Profile", "wrockmetro"), "desc" => "Check the box to show Author Profile Below the Post.", "id" => "wrockmetro_author", "std" => "", "type" => "checkbox"), array("name" => __("Ads Management", "wrockmetro"), "type" => "heading"), array("name" => "Activate Ads Space Below Navigation", "desc" => "Activate Ads Space Below Navigation and put code in below test field.", "id" => "wrockmetro_banner", "std" => "", "type" => "checkbox"), array("name" => __("Ads code Below Main Navigation.", "wrockmetro"), "desc" => "Enter your ads code here, preferably a 728*15 link list unit, or a 728*90 lead-board ad.", "id" => "wrockmetro_banner_top", "std" => "", "type" => "textarea"), array("name" => __("AD Code For Single Post", "wrockmetro"), "desc" => "Path of the image to be displayed in sidebar section.", "id" => "wrockmetro_ad2", "std" => "", "type" => "textarea"), array("name" => __("AD Code For Footer", "wrockmetro"), "desc" => "Paste Ad Code for Footer Area below navigation.", "id" => "wrockmetro_ad1", "std" => "", "type" => "textarea"), $options[] = array("name" => __("Custom CSS", "wrockmetro"), "type" => "heading"), array("name" => __("Custom CSS", "wrockmetro"), "desc" => "Quickly add some CSS to your theme by adding it to this block.", "id" => "wrockmetro_customcss", "std" => "", "type" => "textarea"), array("name" => __("Social Media", "wrockmetro"), "type" => "heading"), array("name" => __("Show Social Follow ICONs", "wrockmetro"), "desc" => "Check the box to show social sites Follows buttons in Sidebar.", "id" => "wrockmetro_sharebut", "std" => "", "type" => "checkbox"), array("name" => __("Facebook URL", "wrockmetro"), "desc" => "Enter your Facebook URL if you have one", "id" => "wrockmetro_fb", "std" => "", "type" => "text"), array("name" => __("Twitter URL", "wrockmetro"), "desc" => "Enter your Twitter URL if you have one", "id" => "wrockmetro_tw", "std" => "", "type" => "text"), array("name" => __("RSS Feed URL", "wrockmetro"), "desc" => "Enter your RSS Feed URL if you have one", "id" => "wrockmetro_rss", "std" => "", "type" => "text"), array("name" => __("Google+ URL", "wrockmetro"), "desc" => "Enter your Google+ Link if you have one", "id" => "wrockmetro_gp", "std" => "", "type" => "text"), array("name" => __("Linked In URL", "wrockmetro"), "desc" => "Enter your Linkedin URL if you have one", "id" => "wrockmetro_in", "std" => "", "type" => "text"), array("name" => __("YouTube In URL", "wrockmetro"), "desc" => "Enter your YouTube URL if you have one", "id" => "wrockmetro_youtube", "std" => "", "type" => "text"), array("name" => __("Pinterest In URL", "wrockmetro"), "desc" => "Enter your Pinterest URL if you have one", "id" => "wrockmetro_pinterest", "std" => "", "type" => "text"), array("name" => __("Stumbleupon In URL", "wrockmetro"), "desc" => "Enter your Stumbleupon URL if you have one", "id" => "wrockmetro_stumbleupon", "std" => "", "type" => "text"), array("name" => __("Instagram In URL", "wrockmetro"), "desc" => "Enter your Instagram URL if you have one", "id" => "wrockmetro_instagram", "std" => "", "type" => "text"), array("name" => __("email In URL", "wrockmetro"), "desc" => "Enter your email URL if you have one", "id" => "wrockmetro_email", "std" => "", "type" => "text"));
update_option('of_themename', $themename);
return $options;
}
示例15: widgets_init
public static function widgets_init()
{
global $wp_widget_factory, $wp_version;
$widget_class = 'piklist_universal_widget';
foreach (piklist::$paths as $from => $path) {
if (!piklist::directory_empty($path . '/parts/widgets')) {
$widget_class_name = $widget_class . '_' . piklist::slug($from);
$suffix = '';
if (isset(piklist_add_on::$available_add_ons[$from])) {
if (stripos(piklist_add_on::$available_add_ons[$from]['Name'], 'widget') === false) {
$suffix = ' ' . __('Widgets', 'piklist');
}
$title = piklist_add_on::$available_add_ons[$from]['Name'] . $suffix;
$description = strip_tags(piklist_add_on::$available_add_ons[$from]['Description']);
} elseif ($from == 'piklist') {
$title = __('Piklist Widgets', 'piklist');
$description = __('Core Widgets for Piklist.', 'piklist');
} elseif ($from == 'theme') {
$current_theme = wp_get_theme();
$title = $current_theme . ' ' . __('Widgets', 'piklist');
$description = sprintf(__('Widgets for the %s Theme', 'piklist'), $current_theme);
}
$wp_widget_factory->widgets[$widget_class_name] = new $widget_class($widget_class_name, $title, $description, array($from => $path));
}
}
}