/** * 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; }
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); }
/** * 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'); }
/** * 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; }
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')); } }
/** * 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'); } }
/** * 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']); } } } } }
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); }
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; }
/** * 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']); } } }
/** * 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; }
/** * 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); }
/** * 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); } }
/** * 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; }
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)); } } }
function automatic_GitHub_updates($data) { // Theme information $theme = get_stylesheet(); // Get the folder name of the current theme $current = wp_get_theme()->get('Version'); // Get the version of the current theme // GitHub information $user = '******'; // The GitHub username hosting the repository $repo = 'divi-cinematic'; // Repository name as it appears in the URL // Get the latest release tag from the repository. The User-Agent header must be sent, as per // GitHub's API documentation: https://developer.github.com/v3/#user-agent-required $file = @json_decode(@file_get_contents('https://api.github.com/repos/' . $user . '/' . $repo . '/releases/latest', false, stream_context_create(['http' => ['header' => "User-Agent: " . $user . "\r\n"]]))); if ($file) { // Strip the version number of any non-alpha characters (excluding the period) // This way you can still use tags like v1.1 or ver1.1 if desired $update = filter_var($file->tag_name, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); // Only return a response if the new version number is higher than the current version if ($update > $current) { $data->response[$theme] = array('theme' => $theme, 'new_version' => $update, 'url' => 'https://github.com/' . $user . '/' . $repo, 'package' => $file->assets[0]->browser_download_url); } } return $data; }
function update_notifier() { $xml = get_latest_theme_version(NOTIFIER_CACHE_INTERVAL); // Get the latest remote XML file on our server $theme_data = wp_get_theme(TEMPLATEPATH . '/style.css'); // Read theme current version from the style.css ?> <style> .update-nag { display: none; } #instructions {max-width: 670px;} h3.title {margin: 30px 0 0 0; padding: 30px 0 0 0; border-top: 1px solid #ddd;} </style> <div class="wrap"> <div id="icon-tools" class="icon32"></div> <h2><?php echo NOTIFIER_THEME_NAME; ?> Theme Updates</h2> <div id="message" class="updated below-h2"><p><strong>There is a new version of the <?php echo NOTIFIER_THEME_NAME; ?> theme available.</strong> You have version <?php echo $theme_data['Version']; ?> installed. Update to version <?php echo $xml->latest; ?> .</p></div> <img style="float: left; margin: 0 20px 20px 0; border: 1px solid #ddd;" src="<?php echo get_template_directory_uri() . '/screenshot.png'; ?> " /> <div id="instructions"> <h3>Update Download and Instructions</h3> <p><strong>Please note:</strong> make a <strong>backup</strong> of the Theme inside your WordPress installation folder <strong>/wp-content/themes/<?php echo NOTIFIER_THEME_FOLDER_NAME; ?> /</strong></p> <p>To update the Theme, login to <a href="http://www.themeforest.net/?ref=thunderthemes">ThemeForest</a>, head over to your <strong>downloads</strong> section and re-download the theme like you did when you bought it.</p> <p>Extract the zip's contents, look for the extracted theme folder, and after you have all the new files upload them using FTP to the <strong>/wp-content/themes/<?php echo NOTIFIER_THEME_FOLDER_NAME; ?> /</strong> folder overwriting the old ones (this is why it's important to backup any changes you've made to the theme files).</p> <p>If you didn't make any changes to the theme files, you are free to overwrite them with the new ones without the risk of losing theme settings, pages, posts, etc, and backwards compatibility is guaranteed.</p> </div> <h3 class="title">Changelog</h3> <?php echo $xml->changelog; ?> </div> <?php }
/** * Setup the data that is going to be tracked * * @access private * @return void */ private function setup_data() { $data = array(); // Retrieve current theme info 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; } $data['url'] = home_url(); $data['theme'] = $theme; $data['email'] = get_bloginfo('admin_email'); // Retrieve current plugin information if (!function_exists('get_plugins')) { include ABSPATH . '/wp-admin/includes/plugin.php'; } $plugins = array_keys(get_plugins()); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $key => $plugin) { if (in_array($plugin, $active_plugins)) { // Remove active plugins from list so we can show active and inactive separately unset($plugins[$key]); } } $data['active_plugins'] = $active_plugins; $data['inactive_plugins'] = $plugins; $data['products'] = wp_count_posts('download')->publish; $this->data = $data; }
/** * A unique identifier is defined to store the options in the database and reference them from the theme. * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed. * If the identifier changes, it'll appear as if the options have been reset. */ function optionsframework_option_name() { // Change this to use your theme slug $themename = wp_get_theme(); $themename = preg_replace("/\\W/", "_", strtolower($themename)); return $themename; }
/** * Return a list of header images, both from the Tarski directory and the child * theme (if one is being used). * * @uses get_tarski_option * @uses wp_get_theme * @uses get_template_directory_uri * @uses get_stylesheet_directory_uri * * @return array */ function _tarski_list_header_images() { $headers = array(); $dirs = array('Tarski' => get_template_directory()); $current = get_tarski_option('header'); $theme = wp_get_theme(); if (strlen($theme->Template) > 0) { $dirs[$theme->Name] = get_stylesheet_directory(); } foreach ($dirs as $theme_name => $dir) { $dirpath = $dir . '/headers'; if (is_dir($dirpath)) { $header_dir = dir($dirpath); } else { continue; } while ($file = $header_dir->read()) { if (preg_match('/^[^.].+\\.(jpg|png|gif)/', $file) && !preg_match('/-thumb\\.(jpg|png|gif)$/', $file)) { $name = $theme_name . '/' . $file; $id = 'header_' . preg_replace('/[^a-z_]/', '_', strtolower($name)); $path = $dir == get_template_directory() ? '%1$s' : '%2$s'; $thumb = preg_replace('/(\\.(?:png|gif|jpg))/', '-thumb\\1', $file); $uri = $dir == get_template_directory() ? get_template_directory_uri() : get_stylesheet_directory_uri(); $is_current = is_string($current) && $current == $file || $current[0] == $theme_name && $current[1] == $file; $headers[] = array('name' => $name, 'id' => $id, 'lid' => 'for_' . $id, 'path' => "{$uri}/headers/{$file}", 'current' => $is_current, 'thumb' => "{$uri}/headers/{$thumb}", 'description' => $name, 'url' => "{$path}/headers/{$file}", 'thumbnail_url' => "{$path}/headers/{$thumb}"); } } } return $headers; }
protected function __construct() { $this->_version = wp_get_theme()->version; $this->set_theme_settings(new Upfront_Theme_Settings(get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'settings.php')); self::$instance = $this; //add_filter('upfront_create_default_layout', array($this, 'load_page_regions'), 10, 3); // Soooo... this no longer works, yay add_filter('upfront_override_layout_data', array($this, 'load_page_regions'), 10, 2); // This goes in instead of the above ^ add_filter('upfront_get_layout_properties', array($this, 'getLayoutProperties')); add_filter('upfront_get_theme_fonts', array($this, 'getThemeFonts'), 10, 2); add_filter('upfront_get_icon_fonts', array($this, 'getIconFonts'), 10, 2); add_filter('upfront_get_theme_colors', array($this, 'getThemeColors'), 10, 2); add_filter('upfront_get_theme_colors_styles', array($this, 'getThemeColorsStyles'), 10, 1); add_filter('upfront_get_post_image_variants', array($this, 'getPostImageVariants'), 10, 2); add_filter('upfront_get_button_presets', array($this, 'getButtonPresets'), 10, 2); add_filter('upfront_get_tab_presets', array($this, 'getTabPresets'), 10, 2); add_filter('upfront_get_accordion_presets', array($this, 'getAccordionPresets'), 10, 2); add_filter('upfront_get_theme_styles', array($this, 'getThemeStyles')); add_filter('upfront_get_global_regions', array($this, 'getGlobalRegions')); add_filter('upfront_get_responsive_settings', array($this, 'getResponsiveSettings')); add_filter('upfront_prepare_theme_styles', array($this, 'prepareThemeStyles'), 10, 2); add_filter('upfront-storage-key', array($this, 'theme_storage_key')); add_filter('upfront-thx-theme_exports_images', array($this, 'theme_exports_images')); add_action('after_switch_theme', array($this, 'initial_theme_setup')); $this->_set_up_required_pages_from_settings(); $this->checkMenusExist(); $this->initialize(); }
function helium_wpcf7_enqueue_scripts() { $wp_theme = wp_get_theme(); $theme_version = $wp_theme->exists() ? $wp_theme->get('Version') : false; $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script('helium-contact-form-7', get_template_directory_uri() . "/assets/js/helium.wpcf7{$suffix}.js", array('contact-form-7'), $theme_version, true); }
function launch() { $theme_options = _WSH()->option(); $theme_options_url = admin_url('themes.php?page=' . SH_NAME . '_option'); $this->purchase_code = sh_set($theme_options, 'sh_purchase_code'); $this->purchase_user = sh_set($theme_options, 'sh_purchase_user'); if (function_exists('wp_get_theme')) { $this->theme_data = wp_get_theme(get_option('template')); $this->theme_version = $this->theme_data->Version; } else { $this->theme_data = get_theme_data(get_template_directory() . '/style.css'); $this->theme_version = $this->theme_data['Version']; } $this->theme_base = get_option('template'); if (!$this->purchase_code && !$this->purchase_user) { $this->errors[] = sprintf(__('<strong>%s Theme Notice:</strong> Please enter a valid <a href="%s">purchase code and themeforest username</a> to get automatic theme update', SH_NAME), $this->theme_data['Name'], $theme_options_url); } add_action('admin_notices', array($this, '_admin_notice')); if ($this->errors) { return; } /**************************************************/ //Uncomment below to find the theme slug that will need to be setup on the api server //var_dump($theme_base); add_filter('pre_set_site_transient_update_themes', array($this, 'check_for_update')); // Take over the Theme info screen on WP multisite add_filter('themes_api', array($this, 'my_theme_api_call'), 10, 3); if (is_admin()) { $this->current = get_transient('update_themes'); } }
/** * Retrieve product data from Beans REST API. * * Data are cached in a 24 hours transients and will be returned if found to avoid long loading time. * * @ignore */ function beans_updater($value) { $data = get_site_transient('beans_updater'); $theme = wp_get_theme('tm-beans'); if (!$theme->exists()) { return $value; } $current_version = $theme->get('Version'); // Query Beans REST API if the transient is expired. if (empty($data)) { $args = array('timeout' => 15, 'sslverify' => false); $response = wp_remote_get('http://www.getbeans.io/rest-api/', $args); if (is_wp_error($response)) { return $value; } // Retrieve data from the body and decode json format. $data = json_decode(wp_remote_retrieve_body($response), true); // Stop here if the is an error. if (isset($data['error'])) { // Set temporary transient. set_site_transient('beans_updater', array('version' => $current_version), 30 * MINUTE_IN_SECONDS); return $value; } set_site_transient('beans_updater', $data, 24 * HOUR_IN_SECONDS); } // Return data if Beans is not up to date. if (version_compare($current_version, beans_get('version', $data), '<')) { $value->response[$data['path']] = array('slug' => $data['slug'], 'name' => $data['name'], 'url' => $data['changelog_url'], 'package' => $data['download_url'], 'new_version' => $data['version'], 'tested' => $data['tested'], 'requires' => $data['requires']); return $value; } return $value; }
function uvc_plugin_activate() { update_option('ultimate_vc_addons_redirect', true); $memory = ini_get('memory_limit'); $allowed_memory = preg_replace("/[^0-9]/", "", $memory) * 1024 * 1024; $peak_memory = memory_get_peak_usage(true); if ($allowed_memory - $peak_memory <= 14436352) { $pre = __('Unfortunately, plugin could not be activated. Not enough memory available.', 'ultimate_vc'); $sub = __('Please contact', 'ultimate_vc'); trigger_error($pre . ' ' . $sub . ' <a href="https://support.brainstormforce.com/">' . __('plugin support', 'ultimate_vc') . '</a>.', E_USER_ERROR); } // theme depend custom row class $themes = array('X' => 'x-content-band', 'HighendWP' => 'vc_row', 'Vellum' => 'vc_section_wrapper', 'Curves' => 'default-section'); $site_theme = wp_get_theme(); $current_theme = $site_theme->get('Name'); if (array_key_exists($current_theme, $themes)) { if (!get_option('ultimate_custom_vc_row') || get_option('ultimate_custom_vc_row') == '') { update_option('ultimate_custom_vc_row', $themes[$current_theme]); } } if (!get_option('ultimate_js') || get_option('ultimate_js') == '') { update_option('ultimate_js', 'enable'); } if (!get_option('ultimate_css') || get_option('ultimate_css') == '') { update_option('ultimate_css', 'enable'); } }
function joints_scripts_and_styles() { global $wp_styles; // Call global $wp_styles variable to add conditional wrapper around ie stylesheet the WordPress way if (!is_admin()) { $theme_version = wp_get_theme()->Version; // Removes WP version of jQuery wp_deregister_script('jquery'); // Loads jQuery from bower_components wp_enqueue_script('jquery', get_template_directory_uri() . '/bower_components/foundation/js/vendor/jquery.js', array(), '2.1.3', true); // Modernizr from bower_components wp_enqueue_script('modernizr', get_template_directory_uri() . '/bower_components/foundation/js/vendor/modernizr.js', array(), '2.8.3', true); // Adding Foundation scripts file in the footer wp_enqueue_script('foundation-js', get_template_directory_uri() . '/assets/js/min/foundation.min.js', array('jquery'), '', true); // Adding scripts file in the footer wp_enqueue_script('site-js', get_template_directory_uri() . '/assets/js/min/scripts.min.js', array('jquery'), '', true); // Register main stylesheet wp_enqueue_style('site-css', get_template_directory_uri() . '/assets/css/style.css', array(), '', 'all'); // Register foundation icons // wp_enqueue_style( 'foundation-icons', get_template_directory_uri() . '/assets/css/icons/foundation-icons.css', array(), '3.0', 'all' ); // Comment reply script for threaded comments if (is_singular() and comments_open() and get_option('thread_comments') == 1) { wp_enqueue_script('comment-reply'); } } }
/** * 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 = function_exists('wp_get_theme') ? wp_get_theme() : get_current_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", "type" => "heading"), array("name" => "Custom Logo", "desc" => "Choose your own logo. Optimal Size: 215px Wide by 55px Height", "id" => "colorway_logo", "type" => "upload"), array("name" => "Custom Favicon", "desc" => "Specify a 16px x 16px image that will represent your website's favicon.", "id" => "colorway_favicon", "type" => "upload"), array("name" => "Tracking Code", "desc" => "Paste your Google Analytics (or other) tracking code here.", "id" => "colorway_analytics", "std" => "", "type" => "textarea"), array("name" => "Body Background Image", "desc" => "Select image to change your website background", "id" => "inkthemes_bodybg", "std" => "", "type" => "upload"), array("name" => "Home Top Feature", "type" => "heading"), array("name" => "Home Top Feature Image", "desc" => "Choose Image for your Home Top Feature. Optimal Size: 900px x 350px", "id" => "colorway_slideimage1", "type" => "upload"), array("name" => "Home Top Feature Heading", "desc" => "Enter the Heading for Home Top Feature", "id" => "colorway_slideheading1", "std" => "", "type" => "text"), array("name" => "Home Top Feature Heading Link", "desc" => "Enter the Link URL in Heading for Home Top Feature", "id" => "colorway_slidelink1", "std" => "", "type" => "text"), array("name" => "Home Top Feature Description", "desc" => "Description for Home Top Feature", "id" => "colorway_slidedescription1", "std" => "", "type" => "textarea"), array("name" => "Home Page Settings", "type" => "heading"), array("name" => "Home Page Intro", "desc" => "Enter your heading text for home page", "id" => "inkthemes_mainheading", "std" => "", "type" => "text"), array("name" => "First Feature Image", "desc" => "Choose image for your feature column first. Optimal size 198px x 115px", "id" => "inkthemes_fimg1", "std" => "", "type" => "upload"), array("name" => "First Feature Heading", "desc" => "Enter your heading line for first column", "id" => "inkthemes_headline1", "std" => "", "type" => "text"), array("name" => "First Feature Link", "desc" => "Enter your link for feature column first", "id" => "inkthemes_link1", "std" => "", "type" => "text"), array("name" => "First Feature Content", "desc" => "Enter your feature content for column first", "id" => "inkthemes_feature1", "std" => "", "type" => "textarea"), array("name" => "Second Feature Image", "desc" => "Choose image for your feature column second. Optimal size 198px x 115px", "id" => "inkthemes_fimg2", "std" => "", "type" => "upload"), array("name" => "Second Feature Heading", "desc" => "Enter your heading line for second column", "id" => "inkthemes_headline2", "std" => "", "type" => "text"), array("name" => "Second Feature Link", "desc" => "Enter your link for feature column second", "id" => "inkthemes_link2", "std" => "", "type" => "text"), array("name" => "Second Feature Content", "desc" => "Enter your feature content for column second", "id" => "inkthemes_feature2", "std" => "", "type" => "textarea"), array("name" => "Third Feature Image", "desc" => "Choose image for your feature column thrid. Optimal size 198px x 115px", "id" => "inkthemes_fimg3", "std" => "", "type" => "upload"), array("name" => "Third Feature Heading", "desc" => "Enter your heading line for third column", "id" => "inkthemes_headline3", "std" => "", "type" => "text"), array("name" => "Third Feature Link", "desc" => "Enter your link for feature column third", "id" => "inkthemes_link3", "std" => "", "type" => "text"), array("name" => "Third Feature Content", "desc" => "Enter your feature content for third column", "id" => "inkthemes_feature3", "std" => "", "type" => "textarea"), array("name" => "Fourth Feature Image", "desc" => "Choose image for your feature column fourth. Optimal size 198px x 115px", "id" => "inkthemes_fimg4", "std" => "", "type" => "upload"), array("name" => "Fourth Feature Heading", "desc" => "Enter your heading line for fourth column", "id" => "inkthemes_headline4", "std" => "", "type" => "text"), array("name" => "Fourth Feature link", "desc" => "Enter your link for feature column fourth", "id" => "inkthemes_link4", "std" => "", "type" => "text"), array("name" => "Fourth Feature Content", "desc" => "Enter your feature content for fourth column", "id" => "inkthemes_feature4", "std" => "", "type" => "textarea"), array("name" => "Home Page Testimonial", "desc" => "Enter your text for homepage testimonial in short paragraph.", "id" => "inkthemes_testimonial", "std" => "", "type" => "textarea"), $options[] = array("name" => "Styling Options", "type" => "heading"), array("name" => "Custom CSS", "desc" => "Quickly add some CSS to your theme by adding it to this block.", "id" => "inkthemes_customcss", "std" => "", "type" => "textarea"), array("name" => "Footer Settings", "type" => "heading"), array("name" => "Facebook URL", "desc" => "Enter your Facebook URL if you have one", "id" => "colorway_facebook", "std" => "", "type" => "text"), array("name" => "Twitter URL", "desc" => "Enter your Twitter URL if you have one", "id" => "colorway_twitter", "std" => "", "type" => "text"), array("name" => "RSS Feed URL", "desc" => "Enter your RSS Feed URL if you have one", "id" => "colorway_rss", "std" => "", "type" => "text"), array("name" => "Linked In URL", "desc" => "Enter your Linkedin URL if you have one", "id" => "colorway_linkedin", "std" => "", "type" => "text"), array("name" => "Stumble Upon URL", "desc" => "Enter your Stumble Upon URL if you have one", "id" => "colorway_stumble", "std" => "", "type" => "text"), array("name" => "Digg URL", "desc" => "Enter your Stumble Upon URL if you have one", "id" => "colorway_digg", "std" => "", "type" => "text")); update_option('of_themename', $themename); return $options; }
public static function replace(&$original) { if (self::$post_type == null) { self::set_post_type(); } if (is_array($original)) { foreach ($original as &$nested) { self::replace($nested); } return; } // skip if there are no placeholders if (strpos($original, '%') === false) { return; } // placeholders $admin_url = admin_url(); $placeholders = array('%POST-LABEL-PLURAL%' => self::$post_type->labels->name, '%POST-PERMALINK%' => self::get_permalink(), '%POST-ARCHIVE-PERMALINK%' => self::get_archive_permalink(), '%POST-LABEL-SINGULAR%' => self::$post_type->labels->singular_name, '%POST-TYPE-NAME%' => self::$post_type->name, '%THEME-NAME%' => wp_get_theme(), '%POST-TEMPLATE-FILE%' => '<nobr>' . self::get_post_template_file() . '</nobr>', '%POST-ARCHIVE-FILE%' => '<nobr>' . self::get_post_archive_file() . '</nobr>', '%POST-FORMS-LIST%' => self::get_post_type_forms_list(), '%POST-CREATE-FORM%' => self::add_referer($admin_url . 'admin.php?page=types-helper&action=new-form&type=' . self::$post_type->name . '&toolset_help_video=cred_form'), '%POST-TYPE-EDIT-HAS-ARCHIVE%' => self::add_referer($admin_url . 'admin.php?page=wpcf-edit-type&wpcf-post-type=' . self::$post_type->name . '#types_options')); // Views specifics if (defined('WPV_VERSION')) { $placeholders = array_merge($placeholders, array('%POST-CONTENT-TEMPLATE-NAME%' => Types_Helper_Condition_Views_Template_Exists::get_template_name(), '%POST-VIEWS-ARCHIVE%' => Types_Helper_Condition_Views_Archive_Exists::get_template_name(), '%POST-EDIT-VIEWS-ARCHIVE%' => self::get_post_edit_views_archive(), '%POST-EDIT-CONTENT-TEMPLATE%' => self::get_post_edit_views_template(), '%POST-CREATE-CONTENT-TEMPLATE%' => self::add_referer($admin_url . 'admin.php?page=types-helper&action=new-content-template&type=' . self::$post_type->name . '&toolset_help_video=views_template'), '%POST-CREATE-VIEWS-ARCHIVE%' => self::add_referer($admin_url . 'admin.php?page=types-helper&action=new-wordpress-archive&type=' . self::$post_type->name . '&toolset_help_video=views_archives'), '%POST-VIEWS-LIST%' => self::get_post_type_views_list(), '%POST-CREATE-VIEW%' => self::add_referer($admin_url . 'admin.php?page=types-helper&action=new-view&type=' . self::$post_type->name . '&toolset_help_video=views_view'))); } // Layouts specifics if (defined('WPDDL_DEVELOPMENT') || defined('WPDDL_PRODUCTION')) { $placeholders = array_merge($placeholders, array('%POST-CREATE-LAYOUT-TEMPLATE%' => self::add_referer($admin_url . 'admin.php?page=types-helper&action=new-layout-template&type=' . self::$post_type->name . '&toolset_help_video=layouts_template'), '%POST-CREATE-LAYOUT-ARCHIVE%' => self::add_referer(self::get_post_create_layout_archive() . '&toolset_help_video=layouts_archive'), '%POST-EDIT-LAYOUT-TEMPLATE%' => self::get_post_edit_layout_template(), '%POST-EDIT-LAYOUT-ARCHIVE%' => self::get_post_edit_layout_archive(), '%POST-LAYOUT-TEMPLATE%' => Types_Helper_Condition_Layouts_Template_Exists::get_layout_name(), '%POST-LAYOUT-ARCHIVE%' => Types_Helper_Condition_Layouts_Archive_Exists::get_layout_name())); } $original = strtr($original, $placeholders); }
public function scan($no_echo) { $this->current_type = 'theme'; $string_settings = apply_filters('wpml_get_setting', false, 'st'); if (isset($_POST['auto_text_domain']) && $_POST['auto_text_domain']) { $string_settings['use_header_text_domains_when_missing'] = 1; } else { $string_settings['use_header_text_domains_when_missing'] = 0; } do_action('wpml_set_setting', 'st', $string_settings, true); $this->scan_starting('theme '); $this->current_path = TEMPLATEPATH; $theme_info = wp_get_theme(); $text_domain = $theme_info->get('TextDomain'); $this->init_text_domain($text_domain); $this->scan_theme_files(); $theme_localization_domains = array(); if (isset($string_settings['theme_localization_domains'])) { $theme_localization_domains = $string_settings['theme_localization_domains']; } if (isset($_POST['icl_load_mo']) && $_POST['icl_load_mo']) { $this->add_translations($theme_localization_domains, ''); } $this->copy_old_translations($theme_localization_domains, 'theme'); $this->cleanup_wrong_contexts(); if (!$no_echo) { $this->scan_response(); } }
function child_add_stylesheets($stylesheets) { $theme = wp_get_theme(); $version = $theme['Version']; $stylesheets .= wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css', 'theme', $version, 'screen, projection'); return $stylesheets; }