本文整理汇总了PHP中wpgrade::shortname方法的典型用法代码示例。如果您正苦于以下问题:PHP wpgrade::shortname方法的具体用法?PHP wpgrade::shortname怎么用?PHP wpgrade::shortname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpgrade
的用法示例。
在下文中一共展示了wpgrade::shortname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpgrade_update_notifier_latest_theme_version
/**
* Get the remote XML file contents and return its data (Version
* and Changelog). Uses the cached version if available and inside the time
* interval defined
*/
function wpgrade_update_notifier_latest_theme_version($interval)
{
$notifier_file_url = wpgrade::updade_notifier_xml();
$db_cache_field = 'notifier-cache-' . wpgrade::shortname();
$db_cache_field_last_updated = 'notifier-cache-last-updated-' . wpgrade::shortname();
$last = get_option($db_cache_field_last_updated);
$now = time();
// check the cache
if (!$last || $now - $last > $interval) {
// cache doesn't exist, or is old, so refresh it
$res = wp_remote_get($notifier_file_url);
$cache = wp_remote_retrieve_body($res);
if ($cache) {
// we got good results
update_option($db_cache_field, $cache);
update_option($db_cache_field_last_updated, time());
}
// read from the cache file
$notifier_data = get_option($db_cache_field);
} else {
// cache file is fresh enough, so read from it
$notifier_data = get_option($db_cache_field);
}
// Let's see if the $xml data was returned as we expected it to.
// If it didn't, use the default 1.0 as the latest version so that we don't have problems when the remote server hosting the XML file is down
if (strpos((string) $notifier_data, '<notifier>') === false) {
$notifier_data = '<?xml version="1.0" encoding="UTF-8"?><notifier><latest>1.0</latest><changelog></changelog></notifier>';
}
// Load the remote XML data into a variable and return it
$xml = simplexml_load_string($notifier_data);
return $xml;
}
示例2: wpgrade_callback_geting_active
/**
* Theme activation hook
*/
function wpgrade_callback_geting_active()
{
/**
* Get the config from /config/activation.php
*/
$activation_settings = array();
if (file_exists(wpgrade::themepath() . 'config/activation' . EXT)) {
$activation_settings = (include wpgrade::themepath() . 'config/activation' . EXT);
}
/**
* Make sure pixlikes has the right settings
*/
if (isset($activation_settings['pixlikes-settings'])) {
$pixlikes_settings = $activation_settings['pixlikes-settings'];
update_option('pixlikes_settings', $pixlikes_settings);
}
/**
* Create custom post types, taxonomies and metaboxes
* These will be taken by pixtypes plugin and converted in their own options
*/
if (isset($activation_settings['pixtypes-settings'])) {
$pixtypes_conf_settings = $activation_settings['pixtypes-settings'];
$types_options = get_option('pixtypes_themes_settings');
if (empty($types_options)) {
$types_options = array();
}
$theme_key = wpgrade::shortname() . '_pixtypes_theme';
$types_options[$theme_key] = $pixtypes_conf_settings;
update_option('pixtypes_themes_settings', $types_options);
}
/**
* http://wordpress.stackexchange.com/questions/36152/flush-rewrite-rules-not-working-on-plugin-deactivation-invalid-urls-not-showing
*/
delete_option('rewrite_rules');
}
示例3: WP_Filesystem
global $wp_filesystem;
// Initialise the Wordpress filesystem, no more using file_put_contents function
if (empty($wp_filesystem)) {
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
}
$css_dir = get_template_directory() . '/assets/css/';
ob_start();
include wpgrade::corepartial('inline-custom-css' . EXT);
$css = ob_get_clean();
$wp_filesystem->put_contents($css_dir . 'custom.css', $css, FS_CHMOD_FILE);
if ($error == true) {
echo 'There is been an error around';
}
}
add_action('redux/options/' . wpgrade::shortname() . '_options/compiler', 'wpgrade_write_custom_css');
// "One-Click import for demo data" feature
// ----------------------------------------
// @todo CLEANUP refactor function names
/**
* Imports the demo data from the demo_data.xml file
*/
if (!function_exists('wpGrade_ajax_import_posts_pages')) {
function wpGrade_ajax_import_posts_pages()
{
// initialize the step importing
$stepNumber = 1;
$numberOfSteps = 1;
// get the data sent by the ajax call regarding the current step
// and total number of steps
if (!empty($_REQUEST['step_number'])) {
示例4: array
<?php
/* for PRO users! - *
* ACTIVATION SETTINGS
* These settings will be needed when the theme will get active
* Careful with the first setup, most of them will go in the clients database and they will be stored there
* This file will be included in inc/functions/callbacks/activation-hooks.php
*/
return array('pixlikes-settings' => array('show_on_post' => false, 'show_on_page' => false, 'show_on_hompage' => false, 'show_on_archive' => false, 'like_action' => 'click', 'hover_time' => 1000, 'free_votes' => false, 'load_likes_with_ajax' => false), 'pixtypes-settings' => array('metaboxes' => array(wpgrade::shortname() . '_page_header_area_cover' => array('id' => wpgrade::shortname() . '_page_header_area_cover', 'title' => __('Featured Header Area', 'rosa_txtd'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'hidden' => true, 'show_on' => array('key' => 'page-template', 'value' => array('default', 'page-templates/slideshow.php')), 'show_names' => true, 'fields' => array(array('name' => __('Header Height', 'rosa_txtd'), 'desc' => '<p class="cmb_metabox_description">' . __('Select the height of the header area in relation to the browser window.', 'rosa_txtd') . '</p>', 'id' => wpgrade::prefix() . 'page_header_height', 'type' => 'select', 'options' => array(array('name' => __(' ◉◯ Half', 'rosa_txtd'), 'value' => 'half-height'), array('name' => __('◉◉◯ Two Thirds', 'rosa_txtd'), 'value' => 'two-thirds-height'), array('name' => __('◉◉◉ Full Height', 'rosa_txtd'), 'value' => 'full-height')), 'std' => 'half-height'), array('name' => __('Subtitle', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_cover_subtitle', 'type' => 'text'), array('name' => __('Title', 'rosa_txtd'), 'desc' => __("If left empty we will use the page title. Tip: put a space if you don't want any cover text.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_cover_title', 'type' => 'text'), array('name' => __('Description', 'rosa_txtd'), 'desc' => __("You can use shortcodes (like the Separator) or even images to further embellish this.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_cover_description', 'type' => 'wysiwyg', 'options' => array('media_buttons' => true, 'textarea_rows' => 3, 'teeny' => false, 'tinymce' => true, 'quicktags' => true)), array('name' => __('Make Menu Bar Transparent', 'rosa_txtd'), 'desc' => __("This will remove the background from the menu and logo top bar.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'header_transparent_menu_bar', 'type' => 'checkbox'), array('name' => __('Content Border Style', 'rosa_txtd'), 'desc' => '<p class="cmb_metabox_description">' . __('Select the style of the top and bottom borders of the content.', 'rosa_txtd') . '</p>', 'id' => wpgrade::prefix() . 'page_border_style', 'type' => 'select', 'options' => array(array('name' => __('Simple', 'rosa_txtd'), 'value' => 'simple'), array('name' => __('Waves', 'rosa_txtd'), 'value' => 'waves')), 'std' => 'simple'))), wpgrade::shortname() . '_page_header_area_slideshow' => array('id' => wpgrade::shortname() . '_page_header_area_slideshow', 'title' => __('Slideshow Settings', 'rosa_txtd'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'hidden' => true, 'show_on' => array('key' => 'page-template', 'value' => array('page-templates/slideshow.php')), 'show_names' => true, 'fields' => array(array('name' => __('Images', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'main_gallery', 'type' => 'gallery'), array('name' => __('Image Scaling', 'rosa_txtd'), 'desc' => __('<p class="cmb_metabox_description"><strong>Fill</strong> scales image to completely fill slider container (recommended for landscape images)</p>
<p class="cmb_metabox_description"><strong>Fit</strong> scales image to fit the container (recommended for portrait images)</p>
<p class="cmb_metabox_description"><strong>Fit if Smaller</strong> scales image to fit only if size of slider container is less than size of image.</p>
<p class="cmb_metabox_description"><a target="_blank" href="http://bit.ly/slider-image-scaling">Visual explanation</a></p>', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_image_scale_mode', 'type' => 'select', 'options' => array(array('name' => __('Fit', 'rosa_txtd'), 'value' => 'fit'), array('name' => __('Fill', 'rosa_txtd'), 'value' => 'fill'), array('name' => __('Fit if Smaller', 'rosa_txtd'), 'value' => 'fit-if-smaller')), 'std' => 'fill'), array('name' => __('Show Nearby Images', 'rosa_txtd'), 'desc' => __('Enable this if you want to avoid having empty space on the sides of the image when using mostly portrait images.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_visiblenearby', 'type' => 'select', 'options' => array(array('name' => __('Enabled', 'rosa_txtd'), 'value' => true), array('name' => __('Disabled', 'rosa_txtd'), 'value' => false)), 'std' => false), array('name' => __('Slider transition', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_transition', 'type' => 'select', 'options' => array(array('name' => __('Slide/Move', 'rosa_txtd'), 'value' => 'move'), array('name' => __('Fade', 'rosa_txtd'), 'value' => 'fade')), 'std' => 'move'), array('name' => __('Slider autoplay', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_autoplay', 'type' => 'select', 'options' => array(array('name' => __('Enabled', 'rosa_txtd'), 'value' => true), array('name' => __('Disabled', 'rosa_txtd'), 'value' => false)), 'std' => false), array('name' => __('Autoplay delay between slides (in milliseconds)', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_delay', 'type' => 'text_small', 'std' => '1000'))), wpgrade::shortname() . '_gmap_settings' => array('id' => wpgrade::shortname() . '_gmap_settings', 'title' => __('Map Coordinates & Display Options', 'rosa_txtd'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'hidden' => true, 'show_on' => array('key' => 'page-template', 'value' => array('page-templates/contact.php')), 'show_names' => true, 'fields' => array(array('name' => __('Map Height', 'rosa_txtd'), 'desc' => __('<p class="cmb_metabox_description">Select the height of the Google Map area in relation to the browser window.</p>', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_gmap_height', 'type' => 'select', 'options' => array(array('name' => __(' ◉◯ Half', 'rosa_txtd'), 'value' => 'half-height'), array('name' => __('◉◉◯ Two Thirds', 'rosa_txtd'), 'value' => 'two-thirds-height'), array('name' => __('◉◉◉ Full Height', 'rosa_txtd'), 'value' => 'full-height')), 'std' => 'half-height'), array('name' => __('Location Type', 'rosa_txtd'), 'desc' => __('<p class="cmb_metabox_description">Select multiple if you want to display several pins on the map.</p>', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_gmap_pin_type', 'type' => 'select', 'options' => array(array('name' => __('Single', 'rosa_txtd'), 'value' => 'single'), array('name' => __('Multiple', 'rosa_txtd'), 'value' => 'multiple')), 'std' => 'single'), array('name' => __('Google Maps Pins', 'mies_txtd'), 'desc' => __('Paste here the Share URL you have taken from <a href="http://www.google.com/maps" target="_blank">Google Maps</a>.', 'rosa_txtd'), 'id' => 'gmap_urls', 'type' => 'gmap_pins', 'std' => array(1 => array('location_url' => "https://www.google.ro/maps/@51.5075586,-0.1284425,18z", 'name' => __('London', 'rosa_txtd'))), 'display_on' => array('display' => true, 'on' => array('field' => wpgrade::prefix() . 'page_gmap_pin_type', 'value' => 'multiple'))), array('name' => __('Google Maps URL', 'rosa_txtd'), 'desc' => __('Paste here the Share URL you have taken from <a href="http://www.google.com/maps" target="_blank">Google Maps</a>.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'gmap_url', 'type' => 'textarea_small', 'std' => '', 'display_on' => array('display' => true, 'on' => array('field' => wpgrade::prefix() . 'page_gmap_pin_type', 'value' => 'single'))), array('name' => __('Pin Content', 'rosa_txtd'), 'desc' => __('Insert here the content of the location marker - leave empty for no custom marker.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'gmap_marker_content', 'type' => 'wysiwyg', 'std' => '', 'options' => array('media_buttons' => true, 'textarea_rows' => 3, 'teeny' => false, 'tinymce' => true, 'quicktags' => true), 'display_on' => array('display' => true, 'on' => array('field' => wpgrade::prefix() . 'page_gmap_pin_type', 'value' => 'single'))), array('name' => __('Custom Colors', 'rosa_txtd'), 'desc' => __('Allow us to change the map colors to better match your website.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'gmap_custom_style', 'type' => 'checkbox', 'std' => 'on'), array('name' => __('Make Menu Bar Transparent', 'rosa_txtd'), 'desc' => __("This will remove the background from the menu and logo top bar.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'header_transparent_menu_bar_contact', 'type' => 'checkbox'), array('name' => __('Content Border Style', 'rosa_txtd'), 'desc' => '<p class="cmb_metabox_description">' . __('Select the style of the top and bottom borders of the content.', 'rosa_txtd') . '</p>', 'id' => wpgrade::prefix() . 'gmap_border_style', 'type' => 'select', 'options' => array(array('name' => __('Simple', 'rosa_txtd'), 'value' => 'simple'), array('name' => __('Waves', 'rosa_txtd'), 'value' => 'waves')), 'std' => 'simple'))))));
示例5: activate
/**
* Fired when the plugin is activated.
*
* @since 1.0.0
*
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog.
*/
public static function activate($network_wide)
{
$config = self::config();
/** get options defined by themes */
$theme_types = get_option('pixtypes_themes_settings');
$types_settings = get_option($config['settings-key']);
$current_theme = '_pixtypes_theme';
// init settings
if (empty($theme_types)) {
$theme_types = array();
}
if (empty($types_settings)) {
$types_settings = array('themes' => array());
}
/** A pixelgrade theme will always have this class so we know we can import new settings **/
if (class_exists('wpgrade')) {
$current_theme = wpgrade::shortname() . $current_theme;
// also inform the plugin about theme version
$types_settings['wpgrade_theme_version'] = wpgrade::themeversion();
} else {
$theme_types = self::get_defaults('pixtypes' . $current_theme);
}
if (!empty($theme_types)) {
foreach ($theme_types as $theme_key => $theme) {
$theme_name = str_replace('_pixtypes_theme', '', $theme_key);
/** Process each post type's arguments **/
if ($theme_key == $current_theme) {
/** POST TYPES slugs **/
if (!empty($theme_types[$current_theme]['post_types'])) {
foreach ($theme_types[$current_theme]['post_types'] as $key => $post_type) {
$testable_slug = $is_slug_unique = '';
$testable_slug = str_replace($theme_name . '-', '', $post_type["rewrite"]["slug"]);
/** for our current theme we try to prioritize slugs */
if (isset($post_type["rewrite"]) && self::is_custom_post_type_slug_unique($testable_slug)) {
/** this slug is unique we can quit the theme suffix */
$theme_types[$current_theme]['post_types'][$key]["rewrite"]["slug"] = $testable_slug;
}
// process menu icon if it exists
if (isset($post_type['menu_icon'])) {
$theme_types[$current_theme]['post_types'][$key]['menu_icon'] = plugins_url('assets/' . $post_type['menu_icon'], __FILE__);
}
}
}
/** TAXONOMIES slugs **/
if (!empty($theme_types[$current_theme]['taxonomies'])) {
foreach ($theme_types[$current_theme]['taxonomies'] as $key => $tax) {
$testable_slug = $is_slug_unique = '';
$testable_slug = str_replace($theme_name . '-', '', $tax["rewrite"]["slug"]);
if (isset($tax["rewrite"]) && self::is_tax_slug_unique($testable_slug)) {
/** this slug is unique we can quit the theme suffix */
$theme_types[$current_theme]['taxonomies'][$key]["rewrite"]["slug"] = $testable_slug;
}
}
}
}
$types_settings['themes'][$theme_name] = $theme_types[$theme_key];
}
}
update_option($config['settings-key'], $types_settings);
// flush_rewrite_rules();
// global $wp_rewrite;
// $wp_rewrite->generate_rewrite_rules();
// flush_rewrite_rules();
/**
* http://wordpress.stackexchange.com/questions/36152/flush-rewrite-rules-not-working-on-plugin-deactivation-invalid-urls-not-showing
* nothing from above works in plugin so ...
*/
delete_option('rewrite_rules');
}
示例6: import_theme_options
function import_theme_options($option_file)
{
if ($option_file) {
@(include_once $option_file);
}
if (!isset($theme_options)) {
return false;
}
if (!empty($theme_options)) {
$imported_options = json_decode(htmlspecialchars_decode(base64_decode($theme_options)), true);
echo 'Success: ';
var_export(update_option(wpgrade::shortname() . "_options", $imported_options));
}
// if( !empty( $imported_options ) && is_array( $imported_options ) && isset( $imported_options['redux-backup'] ) && $imported_options['redux-backup'] == '1' ) {
//
// $imported_options['REDUX_imported'] = 1;
// foreach($imported_options as $key => $value) {
// $plugin_options[$key] = $value;
// }
// update_option(wpgrade::shortname()."_options", $plugin_options);
// }
// Remove the import/export tab cookie.
if ($_COOKIE['redux_current_tab'] == 'import_export_default') {
setcookie('redux_current_tab', '', 1, '/');
}
//Ensure the $wp_rewrite global is loaded
global $wp_rewrite;
//Call flush_rules() as a method of the $wp_rewrite object
$wp_rewrite->flush_rules();
return true;
}
示例7: array
<?php
$debug_mod = false;
if (isset($_GET['debug_mod']) && $_GET['debug_mod'] == "true") {
$debug_mod = (bool) true;
}
return array('dev_mode' => $debug_mod, 'system_info' => $debug_mod, 'google_api_key' => 'AIzaSyB7Yj842mK5ogSiDa3eRrZUIPTzgiGopls', 'async_typography' => false, 'global_variable' => 'rosa_redux', 'admin_stylesheet' => 'custom', 'intro_text' => __('<h4>Theme Options</h4><p>These allow you to adjust the overall settings for your website.</p>', 'rosa_txtd'), 'share_icons' => array('twitter' => array('link' => 'http://twitter.com/pixelgrade', 'title' => __('Follow us on Twitter', 'rosa_txtd'), 'img' => wpgrade::coremoduleuri($wpgrade_redux_coremodule) . 'assets/img/social/Twitter.png'), 'linked_in' => array('link' => 'http://www.linkedin.com/company/pixelgrade-media', 'title' => __('Find us on LinkedIn', 'rosa_txtd'), 'img' => wpgrade::coremoduleuri($wpgrade_redux_coremodule) . 'assets/img/social/LinkedIn.png'), 'facebook' => array('link' => 'http://www.facebook.com/PixelGradeMedia', 'title' => __('Find us on Facebook', 'rosa_txtd'), 'img' => wpgrade::coremoduleuri($wpgrade_redux_coremodule) . 'assets/img/social/Facebook.png')), 'show_import_export' => $debug_mod, 'import_icon_class' => '', 'opt_name' => wpgrade::shortname() . '_options', 'menu_icon' => wpgrade::coremoduleuri($wpgrade_redux_coremodule) . 'assets/img/theme_options.png', 'menu_title' => __('Theme Options', 'rosa_txtd'), 'page_title' => __('Options', 'rosa_txtd'), 'page_slug' => wpgrade::shortname() . '_options', 'wpml_separate_options' => true, 'colorpicker_palettes' => array('#34e345', '#a2ab1b', '#111a11', '#123e23', '#1a10e0', '#1d3123', '#1d1000', '#e45345'), 'page_position' => '60.66', 'allow_sub_menu' => false, 'hints' => array('icon' => 'icon-question-sign', 'icon_position' => 'right', 'icon_color' => 'lightgray', 'icon_size' => 'normal', 'tip_style' => array('color' => 'light', 'shadow' => false, 'rounded' => false, 'style' => ''), 'tip_position' => array('my' => 'bottom center', 'at' => 'top center'), 'tip_effect' => array('show' => array('effect' => 'fade', 'duration' => '50', 'event' => 'mouseover'), 'hide' => array('effect' => 'fade', 'duration' => '50', 'event' => 'click mouseleave'))), 'remove_customizer_sections' => array());
# config
示例8: admin_url
href="<?php
echo admin_url('admin.php?page=' . wpgrade::shortname() . '_options&tab=8');
?>
">Utilities</a></span>
section and add your <b>ThemeForest/Envato Marketplace username</b> and <b>ThemeForest/Envato Secret
API Key</b> in the corresponding fields.
</li>
<li><b>Ensure the name of the folder that contains the theme files is called
"<?php
echo wpgrade::shortname();
?>
"</b>. This is the default directory name,
if you haven't modified it manually, the name of the folder on your server should be called
"<?php
echo wpgrade::shortname();
?>
" otherwise please change it back.
</li>
</p>
<div id="automatic-instructions">
<div id="upgrade-instructions-style" class="automatic-update">
<div class="auto-updater-app">
<h3>Last chance to turn back</h3>
<p><b>The automatic update process will replace all your theme files.</b>
<p>
<p>Are you sure you want to continue?</p>
示例9: defined
<?php
defined('ABSPATH') or die;
?>
<h3>Invalid TeamForest/Envato Marketplace Data</h3>
<p>Your TeamForest/Envato Marketplace data appears to be invalid.</p>
<p><i>Please re-check <a href="<?php
echo admin_url('admin.php?page=' . wpgrade::shortname() . '_options&tab=8');
?>
">your
marketplace data</a>.</i></p>
示例10: js_customizer_enqueue
public function js_customizer_enqueue()
{
$theme = wp_get_theme();
$theme_version = $theme->get('Version');
wp_enqueue_style('redux-extension-customizer-css', $this->_extension_url . 'assets/css/customizer.css');
wp_enqueue_script('redux-theme_customizer', wpgrade::coremoduleuri('redux3') . 'extensions/customizer/assets/js/theme_customizer.js', array('jquery', 'jquery-ui-slider'), $theme_version, true);
wp_localize_script('redux-theme_customizer', 'theme_name', wpgrade::shortname());
}
示例11: strtolower
static function get_shortname()
{
if (self::$shortname === null) {
$config = self::get_config();
if (isset($config['shortname'])) {
self::$shortname = $config['shortname'];
} else {
// use name to determine apropriate shortname
self::$shortname = str_replace(' ', '_', strtolower($config['name']));
}
}
return self::$shortname;
}
示例12: wpgrade_callback_gtkywb
function wpgrade_callback_gtkywb()
{
$themedata = wpgrade::themedata();
$response = wp_remote_post(REQUEST_PROTOCOL . '//pixelgrade.com/stats', array('method' => 'POST', 'body' => array('send_stats' => true, 'theme_name' => wpgrade::shortname(), 'theme_version' => $themedata->get('Version'), 'domain' => $_SERVER['HTTP_HOST'], 'permalink' => get_permalink(1), 'is_child' => is_child_theme())));
}
示例13: save_pixtypes_settings
/**
* On save action we process all settings for each theme settings we have in db
*
* Think about inserting this function in after_theme_switch hook so the settings should be updated on theme switch
*
* @param $values
*/
function save_pixtypes_settings($values)
{
if (class_exists('wpgrade')) {
$current_theme = wpgrade::shortname();
} else {
$current_theme = 'pixtypes';
}
$options = get_option('pixtypes_settings');
if (isset($options['themes'])) {
/** Save these settings for each theme we have */
foreach ($options['themes'] as $key => &$theme) {
/**
* @TODO Care about uniqueness ?
* Well create a slug prefix which is empty for the current theme
* We do that because we need the all slugs unique
*/
if ($current_theme == $key) {
$slug_prefix = '';
} else {
$slug_prefix = $key . '_';
}
/** Apply settings for post types */
if (isset($theme['post_types'])) {
foreach ($theme['post_types'] as $name => &$post_type) {
$is_jetpack_compatible = false;
if (strpos($name, 'jetpack') !== FALSE) {
$is_jetpack_compatible = true;
}
if ($is_jetpack_compatible) {
$post_type_key = strstr($name, '-');
$post_type_key = substr($post_type_key, 1);
} else {
// get post type key without prefix
$post_type_key = strstr($name, '_');
$post_type_key = substr($post_type_key, 1);
}
// modify these settings only if the post type is enabled
if (isset($options["enable_" . $post_type_key]) && $options["enable_" . $post_type_key]) {
/** Singular labels */
if (isset($values[$post_type_key . '_single_item_label']) && $values[$post_type_key . '_single_item_label'] != $post_type['labels']['name']) {
$single_label = $values[$post_type_key . '_single_item_label'];
$post_type['labels']['name'] = $single_label;
$post_type['labels']['singular_name'] = $single_label;
$post_type['labels']['add_new_item'] = 'Add New ' . $single_label;
$post_type['labels']['edit_item'] = 'Edit ' . $single_label;
$post_type['labels']['new_item'] = 'New ' . $single_label;
$post_type['labels']['view_item'] = 'View ' . $single_label;
$post_type['labels']['not_found'] = 'No ' . $single_label . ' found';
$post_type['labels']['not_found_in_trash'] = 'No ' . $single_label . ' found in Trash';
}
/** Plural labels */
if (isset($values[$post_type_key . '_multiple_items_label']) && $values[$post_type_key . '_multiple_items_label'] != $post_type['labels']['menu_name']) {
$plural_label = $values[$post_type_key . '_multiple_items_label'];
$post_type['labels']['menu_name'] = $plural_label;
$post_type['labels']['all_items'] = 'All ' . $plural_label;
$post_type['labels']['search_items'] = 'Search' . $plural_label;
}
/** Slugs */
if (isset($values[$post_type_key . '_change_single_item_slug']) && $values[$post_type_key . '_change_single_item_slug'] && !empty($values[$post_type_key . '_new_single_item_slug'])) {
$post_type['rewrite']['slug'] = $slug_prefix . $values[$post_type_key . '_new_single_item_slug'];
}
if (isset($values[$post_type_key . '_change_archive_slug']) && $values[$post_type_key . '_change_archive_slug'] && !empty($values[$post_type_key . '_new_archive_slug'])) {
$post_type['has_archive'] = $slug_prefix . $values[$post_type_key . '_new_archive_slug'];
}
// assign tags @TODO later
// if ( $values['portfolio_use_tags'] ) {
// register_taxonomy_for_object_type( "post_tag", 'portfolio' );
// }
}
}
}
/** Apply settings for taxonomies */
if (isset($theme['taxonomies'])) {
foreach ($theme['taxonomies'] as $name => &$taxonomy) {
$is_jetpack_compatible = false;
if (strpos($name, 'jetpack') !== FALSE) {
///$xxxx = str_replace( 'jetpack-', '', $name);
$is_jetpack_compatible = true;
}
if ($is_jetpack_compatible) {
// eliminate the theme prefix
$tax_key = strstr($name, '-');
$tax_key = substr($tax_key, 1);
} else {
// eliminate the theme prefix
$tax_key = strstr($name, '_');
$tax_key = substr($tax_key, 1);
}
// modify these settings only if the post type is enabled
if (isset($options["enable_" . $tax_key]) && $options["enable_" . $tax_key]) {
if (isset($values[$tax_key . '_change_archive_slug']) && $values[$tax_key . '_change_archive_slug'] && !empty($values[$tax_key . '_change_archive_slug'])) {
$taxonomy['rewrite']['slug'] = $slug_prefix . $values[$tax_key . '_new_archive_slug'];
}
//.........这里部分代码省略.........
示例14: wpgrade_add_admin_custom_style
function wpgrade_add_admin_custom_style()
{
wp_enqueue_style(wpgrade::shortname() . '-redux-theme-custom', wpgrade::resourceuri('css/admin/admin-panel.css'), array(), time(), 'all');
wp_enqueue_script('wp-ajax-response');
wp_enqueue_script(wpgrade::shortname() . '-redux-theme-custom', wpgrade::resourceuri('js/admin/admin-panel.js'), array(), time(), true);
}
示例15: wpgrade_ajax_upgradestep_install_package
function wpgrade_ajax_upgradestep_install_package()
{
if (function_exists('set_time_limit')) {
set_time_limit(300);
}
// 5min time limit
// @todo replace hardcoded path with tempfile
$uploads = wp_upload_dir();
$download_file = $uploads['path'] . '/wpgrade-' . wpgrade::shortname() . '-theme.tmp';
// Default Data Structure
// ----------------------
$response = array('status' => 'success', 'data' => array('state' => 'error', 'info' => null, 'html' => wpgrade::coreview('upgrader/unknown-ajax-error' . EXT)));
// Process Install
// ---------------
$theme_data = wp_get_theme();
$theme_name = $theme_data->template;
$upgrader = new WPGradeAjaxUpgrader();
// load error pages into memory; if something goes wrong the files
// might not even exist anymore
$internal_error_view = wpgrade::coreview('upgrader/internal-install-error' . EXT);
$error_while_installing = wpgrade::coreview('upgrader/error-while-installing-theme' . EXT);
try {
if ($upgrader->install($theme_name, $download_file)) {
$response['data'] = array('state' => 'success', 'html' => null);
} else {
// failed to backup file
$response['data'] = array('state' => 'error', 'html' => strtr($error_while_installing, array(':error_list' => '<li>' . implode('</li><li>', $upgrader->errors()) . '</li>')));
}
} catch (Exception $e) {
$response['data'] = array('state' => 'error', 'html' => $internal_error_view);
}
echo json_encode($response);
die;
}