function jim_styles() { wp_enqueue_style('custom_style', get_template_directory_uri() . '/css/global.css'); $mods = get_theme_mods(); // var_dump($mods); $p_color = get_theme_mod('color_setting'); $styles = ' body { color:' . $p_color . ';} body p { color: ' . $p_color . ';} body h1 { color:' . $mods['h1_color'] . ' } body h2 { color:' . $mods['h2_color'] . ' } body h3 { color:' . $mods['h3_color'] . ' } body h4 { color:' . $mods['h4_color'] . ' } body h5 { color:' . $mods['h5_color'] . ' } '; wp_add_inline_style('custom_style', $styles); }
function wpo_init_constants() { $theme_mods = get_theme_mods(); if (!defined('TEMPLATEURI')) { define('TEMPLATEURI', trailingslashit(get_stylesheet_directory_uri())); } if (!defined('HOMEURL')) { define('HOMEURL', trailingslashit(get_home_url())); } if (!defined('THEMECOLOR')) { if (!empty($theme_mods['wpo_theme_color'])) { $meta_color = $theme_mods['wpo_theme_color']; } else { $meta_color = '#000000'; } define('THEMECOLOR', $meta_color); } if (!defined('HEADERCOLOR')) { if (!empty($theme_mods['wpo_header_color'])) { $meta_color = $theme_mods['wpo_header_color']; } else { $meta_color = '#000000'; } define('HEADERCOLOR', $meta_color); } }
function customcss() { $thim_options = get_theme_mods(); $custom_css = ''; if (isset($thim_options['thim_user_bg_pattern']) && $thim_options['thim_user_bg_pattern'] == '1') { $custom_css .= ' body{background-image: url("' . $thim_options['thim_bg_pattern'] . '"); }'; } if (isset($thim_options['thim_bg_pattern_upload']) && $thim_options['thim_bg_pattern_upload'] != '') { $bg_body = wp_get_attachment_image_src($thim_options['thim_bg_pattern_upload'], 'full'); $custom_css .= ' body{background-image: url("' . $bg_body[0] . '"); } body{ background-repeat: ' . $thim_options['thim_bg_repeat'] . '; background-position: ' . $thim_options['thim_bg_position'] . '; background-attachment: ' . $thim_options['thim_bg_attachment'] . '; background-size: ' . $thim_options['thim_bg_size'] . '; } '; } /* Footer */ // Background if (isset($thim_options['thim_footer_background_img']) && $thim_options['thim_footer_background_img']) { $bg_footer = wp_get_attachment_image_src($thim_options['thim_footer_background_img'], 'full'); $custom_css .= 'footer#colophon {background-image: url("' . $bg_footer[0] . '"); }'; } $custom_css .= $thim_options['thim_custom_css']; return $custom_css; }
/** * Update theme modifications for the current theme. * Note: Candidate core function. * http://core.trac.wordpress.org/ticket/20091 * * @since 3.4.0 * * @param array $mods Theme modifications. */ public function set_theme_mods($mods) { $current = get_theme_mods(); $mods = wp_parse_args($mods, $current); $theme = get_stylesheet(); update_option("theme_mods_{$theme}", $mods); }
/** * Custom implementation for get_context method. */ public function get_context() { global $content_width; if (class_exists('Easy_Digital_Downloads')) { global $edd_options; } $context = Timber::get_context(); $sidebar_primary = Timber::get_widgets('sidebar_primary'); $sidebar_footer = Timber::get_widgets('sidebar_footer'); $context['theme_mods'] = get_theme_mods(); $context['site_options'] = wp_load_alloptions(); $context['teaser_mode'] = apply_filters('maera/teaser/mode', 'excerpt'); $context['thumbnail']['width'] = apply_filters('maera/image/width', 600); $context['thumbnail']['height'] = apply_filters('maera/image/height', 371); $context['menu']['primary'] = has_nav_menu('primary_navigation') ? new TimberMenu('primary_navigation') : null; $context['sidebar']['primary'] = apply_filters('maera/sidebar/primary', $sidebar_primary); $context['sidebar']['footer'] = apply_filters('maera/sidebar/footer', $sidebar_footer); $context['pagination'] = Timber::get_pagination(); $context['comment_form'] = TimberHelper::get_comment_form(); $context['comments_args'] = array('style' => 'ul', 'reply_text' => __('Reply', 'maera'), 'short_ping' => true, 'avatar_size' => 60); $context['site_logo'] = get_option('site_logo', false); $context['content_width'] = $content_width; $context['sidebar_template'] = maera_templates_sidebar(); if (class_exists('Easy_Digital_Downloads')) { $data['edd_options'] = $edd_options; $data['download_categories'] = Timber::get_terms('download_category'); $data['download_tags'] = Timber::get_terms('download_tag'); $data['default_image'] = new TimberImage(get_template_directory_uri() . '/assets/images/default.png'); } return apply_filters('maera/timber/context', $context); }
public function export_customizer_options() { $mods = get_theme_mods(); unset($mods['nav_menu_locations']); $output = base64_encode(serialize($mods)); $this->save_as_txt_file("customizer_options.txt", $output); }
function add_to_context($context) { $context['foo'] = 'bar'; $context['stuff'] = 'I am a value set in your functions.php file'; $context['notes'] = 'These values are available everytime you call Timber::get_context();'; $context['menu'] = new TimberMenu(); //$context['custom_wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) ); $context['custom_wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu')); $context['site'] = $this; $context['theme_url'] = get_stylesheet_directory_uri(); $context['is_logged_in'] = is_user_logged_in(); $context['theme_mod'] = get_theme_mods(); $context['options'] = wp_load_alloptions(); $context['site_url'] = site_url(); if (is_home() || is_front_page()) { $context['is_home'] = true; } /* * Footer */ $context['footer_tag_line'] = get_option('footer_text'); $context['footer_address'] = get_option('address'); $context['footer_site_url'] = site_url(); $context['footer_inquiry_mail'] = get_option('inquiry_mail'); $context['footer_telephone'] = get_option('telephone'); $context['s_facebook'] = get_option('facebook'); $context['s_twitter'] = get_option('twitter'); $context['s_linkedin'] = get_option('linkedin'); $context['footer_copyright'] = get_option('copyright'); return $context; }
/** * Get theme mod value. * * @param string $value * @return string */ public function get_theme_mod_value($value) { $key = substr(current_filter(), 10); $set_theme_mods = get_theme_mods(); if (isset($set_theme_mods[$key])) { return $value; } $values = $this->get_storefront_default_setting_values(); return isset($values[$key]) ? $values[$key] : $value; }
/** * Styles the header image and text displayed on the blog. * * @see octopus_custom_header_setup(). */ function octopus_header_style() { $header_text_color = get_header_textcolor(); // If no custom options are set, let's bail. if (!get_theme_mods()) { return; } // If we get this far, we have custom styles. Let's do this. ?> <style type="text/css" id="octopus-custom-style"> <?php /* * If no custom options for text are set, let's bail. * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: HEADER_TEXTCOLOR. */ if (!HEADER_TEXTCOLOR === $header_text_color) { // Has the text been hidden? if (!display_header_text()) { ?> .site-title, .site-description { position: absolute; clip: rect(1px, 1px, 1px, 1px); } <?php // If the user has set a custom color for the text use that. } else { ?> .site-title a, .site-description { color: #<?php echo esc_attr($header_text_color); ?> ; } <?php } ?> <?php } ?> <?php octopus_generate_css('#page.container', 'max-width', 'container_max_width', '', '', true); //Header octopus_generate_css('.container-fluid .octopus-wrapper', 'max-width', 'wrapped_element_max_width', '', 'px', true); // Header banner octopus_generate_css('.octopus-header-banner', 'height', 'header_banner_height', '', 'px', true); ?> </style> <?php }
function thememove_customizer_options_exporter() { $blogname = strtolower(str_replace(' ', '-', get_option('blogname'))); $file_name = $blogname . '-thememove-' . date('Ydm') . '.txt'; $options = get_theme_mods(); unset($options['nav_menu_locations']); ob_clean(); header("Content-type: application/text", true, 200); header("Content-Disposition: attachment; filename=\"{$file_name}\""); header("Pragma: no-cache"); header("Expires: 0"); echo base64_encode(serialize($options)); die; }
protected function import_skin_from_file($file) { $content = $this->get_file_contents($file); $options = @unserialize(base64_decode($content)); foreach ((array) $options as $key => $val) { set_theme_mod($key, $val); } $mods = get_theme_mods(); foreach ($mods as $mod_key => $mod_valud) { if ('nav_menu_locations' != $mod_key && !isset($options[$mod_key])) { remove_theme_mod($mod_key); } } }
/** * Get options from the database and process them with the load filter hook. * * @author Jonah Dahlquist * @since 1.4.0 * @return array */ function of_get_options($key = null, $data = null) { do_action('of_get_options_before', array('key' => $key, 'data' => $data)); if ($key != null) { // Get one specific value $data = get_theme_mod($key, $data); } else { // Get all values $data = get_theme_mods(); } $data = apply_filters('of_options_after_load', $data); do_action('of_option_setup_before', array('key' => $key, 'data' => $data)); return $data; }
/** * Hooks into the customize_save action to save modifications in theme_options/mods */ public function customize_save(\WP_Customize_Manager $manager) { foreach ($manager->settings() as $key => $setting) { if ($setting->type == 'theme_mod') { // We have to call this early to make sure it is saved $setting->save(); } } $mods = get_theme_mods(); if ($mods) { ksort($mods); static::writeConfigs("theme_options/mods", array('mods' => $mods)); } }
function thim_customizer_export_theme_settings() { $blogname = strtolower(str_replace(' ', '-', get_option('blogname'))); $file_name = $blogname . '-thimtheme-' . date('Ydm') . '.json'; $options = get_theme_mods(); unset($options['nav_menu_locations']); foreach ($options as $key => $value) { $value = maybe_unserialize($value); $need_options[$key] = $value; } $json_file = json_encode($need_options); ob_clean(); header('Content-Type: text/json; charset=' . get_option('blog_charset')); header('Content-Disposition: attachment; filename="' . $file_name . '"'); echo ent2ncr($json_file); exit; }
function x_version_migration() { $prior = get_option('x_version', '1.0.0'); if (version_compare($prior, X_VERSION, '<')) { // // If $prior is less than 2.2.0. // if (version_compare($prior, '2.2.0', '<')) { $mods = get_theme_mods(); foreach ($mods as $key => $value) { update_option($key, $value); } } // // If $prior is less than 3.1.0. // if (version_compare($prior, '3.1.0', '<')) { $stack = get_option('x_stack'); $design = $stack == 'integrity' ? '_' . get_option('x_integrity_design') : ''; $stack_safe = $stack == 'icon' ? 'integrity' : $stack; $updated = array('x_layout_site' => get_option('x_' . $stack . '_layout_site'), 'x_layout_site_max_width' => get_option('x_' . $stack . '_sizing_site_max_width'), 'x_layout_site_width' => get_option('x_' . $stack . '_sizing_site_width'), 'x_layout_content' => get_option('x_' . $stack . '_layout_content'), 'x_layout_content_width' => get_option('x_' . $stack_safe . '_sizing_content_width'), 'x_layout_sidebar_width' => get_option('x_icon_sidebar_width'), 'x_design_bg_color' => get_option('x_' . $stack . $design . '_bg_color'), 'x_design_bg_image_pattern' => get_option('x_' . $stack . $design . '_bg_image_pattern'), 'x_design_bg_image_full' => get_option('x_' . $stack . $design . '_bg_image_full'), 'x_design_bg_image_full_fade' => get_option('x_' . $stack . $design . '_bg_image_full_fade')); foreach ($updated as $key => $value) { update_option($key, $value); } } // // If $prior is less than 4.0.0. // if (version_compare($prior, '4.0.0', '<')) { $updated = array('x_pre_v4' => true); foreach ($updated as $key => $value) { update_option($key, $value); } } // // Update stored version number. // update_option('x_version', X_VERSION); // // Turn on the version migration notice. // update_option('x_version_migration_notice', true); } }
function brawny_customizer_setup() { if (count(get_theme_mods()) <= 1) { global $options; $brawny = get_option('brawny'); foreach ($options['panels']['theme_options']['sections'] as $section) { foreach ($section['fields'] as $name => $settings) { //echo 'Name: ' . $name . '<br>' . 'Value: ' . $brawny[$name] . '<br>'; if (!get_theme_mod($name) && isset($brawny[$name])) { if (is_array($brawny[$name])) { set_theme_mod($name, $brawny[$name]['url']); } else { set_theme_mod($name, $brawny[$name]); } } } } foreach ($options['panels']['home']['sections'] as $section) { foreach ($section['fields'] as $name => $settings) { if (!get_theme_mod($name) && isset($brawny[$name])) { if (is_array($brawny[$name])) { set_theme_mod($name, $brawny[$name]['url']); } else { set_theme_mod($name, $brawny[$name]); } } if (isset($brawny['slides'])) { $slide_count = 1; foreach ($brawny['slides'] as $slide) { if (!get_theme_mod('image_upload-' . $slide_count) && isset($slide['image'])) { set_theme_mod('image_upload-' . $slide_count, $slide['image']); } if (!get_theme_mod('flexcaption-' . $slide_count) && isset($slide['description'])) { set_theme_mod('flexcaption-' . $slide_count, $slide['description']); } $slide_count++; } } } } } }
/** * Convert a new theme mod value from an old one. * * @since 1.3.0. * * @param mixed $value The current value. * @return mixed The modified value. */ function ttfmake_customizer_convert_theme_mods_filter($value) { $new_mod_name = str_replace('theme_mod_', '', current_filter()); $conversions = ttfmake_customizer_get_key_conversions(); $mods = get_theme_mods(); /** * When previewing a page, the logic for this filter needs to change. Because the isset check in the conditional * below will always fail if the new mod key is not set (i.e., the value isn't in the db yet), the default value, * instead of the preview value will always show. Instead, when previewing, the value needs to be gotten from * the `get_theme_mod()` call without this filter applied. This will give the new preview value. If it is not found, * then the normal routine will be used. */ if (ttfmake_is_preview()) { remove_filter(current_filter(), 'ttfmake_customizer_convert_theme_mods_filter', 11); $previewed_value = get_theme_mod($new_mod_name, 'default-value'); add_filter(current_filter(), 'ttfmake_customizer_convert_theme_mods_filter', 11); if ('default-value' !== $previewed_value) { return $previewed_value; } } /** * We only want to convert the value if the new mod is not in the mods array. This means that the value is not set * and an attempt to get the value from an old key is warranted. */ if (!isset($mods[$new_mod_name])) { // Verify that this key should be converted if (isset($conversions[$new_mod_name])) { $old_mod_name = $conversions[$new_mod_name]; $old_mod_value = get_theme_mod($old_mod_name, 'default-value'); // The old value is indeed set if ('default-value' !== $old_mod_value) { $value = $old_mod_value; // Now that we have the right old value, convert it if needed $value = ttfmake_customizer_convert_theme_mods_values($old_mod_name, $new_mod_name, $value); } } } return $value; }
public function getStyleOptions($customizeMode = false) { //getting all theme mods $result = $themeMods = get_theme_mods(); if ($customizeMode) { $updatedOptions = isset($_POST['customized']) ? json_decode(wp_unslash($_POST['customized']), true) : null; if ($updatedOptions) { foreach ($updatedOptions as $optionName => $value) { $result[$optionName] = get_theme_mod($optionName); } } } $theme_cusomizer = adventure_tours_di('theme_customizer'); $font_options = $theme_cusomizer->getFontFamilySettings(); if ($font_options) { foreach ($font_options as $option_name) { if (!isset($result[$option_name])) { $result[$option_name] = $theme_cusomizer->getFontSettingDefaults($option_name); } } } return $result; }
/** * Get one or more theme mods. * * ## OPTIONS * * [<mod>...] * : One or more mods to get. * * [--all] * : List all theme mods * * [--format=<format>] * : Render output in a particular format. * --- * default: table * options: * - table * - json * - csv * - yaml * --- * * ## EXAMPLES * * # Get all theme mods * $ wp theme mod get --all * +------------------+---------+ * | key | value | * +------------------+---------+ * | background_color | dd3333 | * | link_color | #dd9933 | * | main_text_color | #8224e3 | * +------------------+---------+ * * # Get single theme mod in JSON format * $ wp theme mod get background_color --format=json * [{"key":"background_color","value":"dd3333"}] * * # Get multiple theme mods * $ wp theme mod get background_color header_textcolor * +------------------+--------+ * | key | value | * +------------------+--------+ * | background_color | dd3333 | * | header_textcolor | | * +------------------+--------+ */ public function get($args = array(), $assoc_args = array()) { if (!\WP_CLI\Utils\get_flag_value($assoc_args, 'all') && empty($args)) { WP_CLI::error("You must specify at least one mod or use --all."); } if (\WP_CLI\Utils\get_flag_value($assoc_args, 'all')) { $args = array(); } $list = array(); $mods = get_theme_mods(); if (!is_array($mods)) { // if no mods are set (perhaps new theme), make sure foreach still works $mods = array(); } foreach ($mods as $k => $v) { // if mods were given, skip the others if (!empty($args) && !in_array($k, $args)) { continue; } if (is_array($v)) { $list[] = array('key' => $k, 'value' => '=>'); foreach ($v as $_k => $_v) { $list[] = array('key' => " {$_k}", 'value' => $_v); } } else { $list[] = array('key' => $k, 'value' => $v); } } // For unset mods, show blank value foreach ($args as $mod) { if (!isset($mods[$mod])) { $list[] = array('key' => $mod, 'value' => ''); } } $formatter = new \WP_CLI\Formatter($assoc_args, array('key', 'value'), 'thememods'); $formatter->display_items($list); }
/** * Get the value of a field. */ function kirki_get_option($option = '') { // Make sure the class is instanciated Kirki::get_instance(); // Get the array of all the fields. $fields = Kirki::fields()->get_all(); // Get the config. $config = Kirki::config()->get_all(); /** * If no setting has been defined then return all. */ if ('' == $option) { if ('option' == $config['options_type']) { $values = array(); foreach ($fields as $field) { $values[] = get_option($field['settings'], $field['default']); } } else { $values = get_theme_mods(); } return $values; } // If a value has been defined then we proceed. // Early exit if this option does not exist if (!isset($fields[$option])) { return; } $option_name = $fields[$option]['settings']; $default = $fields[$option]['default']; if ('option' == $config['options_type']) { $value = get_option($option_name, $default); } else { $value = get_theme_mod($option_name, $default); } return $value; }
function x_customizer_export_option_page() { if (!isset($_POST['export'])) { ?> <div class="wrap"> <div id="icon-tools" class="icon32"><br></div> <h2>Customizer Export</h2> <form method="post"> <?php wp_nonce_field('x-customizer-export'); ?> <p>When you click the button below WordPress will create a JSON file for you to save to your computer.</p> <p>This format, which we call X Customizer Settings or XCS, will contain your Customizer settings for X.</p> <p>Once you've saved the download file, you can use the X Customizer Import function to import the previusly exported settings.</p> <p class="submit"><input type="submit" name="export" class="button button-primary" value="Download XCS File"></p> </form> </div> <?php } elseif (check_admin_referer('x-customizer-export')) { $blogname = strtolower(str_replace(' ', '', get_option('blogname'))); $date = date('m-d-Y'); $json_name = $blogname . '-x-customizer-' . $date; $options = get_theme_mods(); unset($options['nav_menu_locations']); foreach ($options as $key => $value) { $value = maybe_unserialize($value); $need_options[$key] = $value; } $json_file = json_encode($need_options); ob_clean(); echo $json_file; header('Content-Type: text/json; charset=' . get_option('blog_charset')); header('Content-Disposition: attachment; filename="' . $json_name . '.json"'); exit; } }
/** * Remove theme modification name from current theme list. * * If removing the name also removes all elements, then the entire option will * be removed. * * @since 2.1.0 * * @param string $name Theme modification name. * @return null */ function remove_theme_mod($name) { $mods = get_theme_mods(); if (!isset($mods[$name])) { return; } unset($mods[$name]); if (empty($mods)) { return remove_theme_mods(); } $theme = get_option('stylesheet'); update_option("theme_mods_{$theme}", $mods); }
/** * ->get_options(); This is used to get options from the database * * @since ReduxFramework 3.0.0 */ function get_options() { $defaults = false; $results = array(); if (!empty($this->defaults)) { $defaults = $this->defaults; } if ($this->args['database'] === "transient") { $result = get_transient($this->args['opt_name'] . '-transient'); } else { if ($this->args['database'] === "theme_mods") { $result = get_theme_mod($this->args['opt_name'] . '-mods'); } else { if ($this->args['database'] === 'theme_mods_expanded') { $result = get_theme_mods(); } else { $result = get_option($this->args['opt_name']); } } } if (empty($result) && !empty($defaults)) { $results = $defaults; $this->set_options($results); } else { $this->options = $result; } // Set a global variable by the global_variable argument. $this->set_global_variable(); }
<?php /** * @package uniq */ ?> <article id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <?php $uniq = get_theme_mods(); if (!isset($uniq['featured_image']) && has_post_thumbnail()) { ?> <div class="post-thumb"> <?php the_post_thumbnail(); ?> </div> <?php } else { $featured_image = get_theme_mod('featured_image'); if ($featured_image && has_post_thumbnail()) { ?> <div class="post-thumb"> <?php
/** * ->get_options(); This is used to get options from the database * * @since ReduxFramework 3.0.0 */ public function get_options() { $defaults = false; if (!empty($this->defaults)) { $defaults = $this->defaults; } if ($this->args['database'] === "transient") { $result = get_transient($this->args['opt_name'] . '-transient'); } else { if ($this->args['database'] === "theme_mods") { $result = get_theme_mod($this->args['opt_name'] . '-mods'); } else { if ($this->args['database'] === 'theme_mods_expanded') { $result = get_theme_mods(); } else { if ($this->args['database'] === 'network') { $result = get_site_option($this->args['opt_name'], array()); $result = json_decode(stripslashes(json_encode($result)), true); } else { $result = get_option($this->args['opt_name'], array()); } } } } if (empty($result) && !empty($defaults)) { $results = $defaults; $this->set_options($results); } else { $this->options = $result; } /** * action 'redux/options/{opt_name}/options' * * @param mixed $value option values */ $this->options = apply_filters("redux/options/{$this->args['opt_name']}/options", $this->options); // Get transient values $this->get_transients(); // Set a global variable by the global_variable argument. $this->set_global_variable(); }
/** * ->get_options(); This is used to get options from the database * * @since ReduxFramework 3.0.0 */ function get_options() { $defaults = false; if (!empty($this->defaults)) { $defaults = $this->defaults; } if ($this->args['database'] === "transient") { $result = get_transient($this->args['opt_name'] . '-transient'); } else { if ($this->args['database'] === "theme_mods") { $result = get_theme_mod($this->args['opt_name'] . '-mods'); } else { if ($this->args['database'] === 'theme_mods_expanded') { $result = get_theme_mods(); } else { $result = get_option($this->args['opt_name']); } } } if (empty($result) && !empty($defaults)) { $results = $defaults; $this->set_options($results); } // Set a global variable by the global_variable agument. if ($this->args['global_variable']) { $options = $this->args['global_variable']; global ${$options}; ${$options} = $result; } //print_r($result); return $result; }
<?php /** * @package stronghold */ ?> <article id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <?php $stronghold = get_theme_mods(); if (!isset($stronghold['featured_image']) && has_post_thumbnail()) { ?> <div class="post-thumb"> <?php the_post_thumbnail(); ?> </div> <?php } else { $featured_image = get_theme_mod('featured_image'); if ($featured_image && has_post_thumbnail()) { ?> <div class="post-thumb"> <?php
/** * Export customizer settings. * * @since 0.1 * @since 0.3 Added $wp_customize param and exporting of options. * @access private * @param object $wp_customize An instance of WP_Customize_Manager. * @return void */ private static function _export($wp_customize) { if (!wp_verify_nonce($_REQUEST['cei-export'], 'cei-exporting')) { return; } $theme = get_stylesheet(); $template = get_template(); $charset = get_option('blog_charset'); $mods = get_theme_mods(); $data = array('template' => $template, 'mods' => $mods ? $mods : array(), 'options' => array()); // Get options from the Customizer API. $settings = $wp_customize->settings(); foreach ($settings as $key => $setting) { if ('option' == $setting->type) { // Don't save widget data. if (stristr($key, 'widget_')) { continue; } // Don't save sidebar data. if (stristr($key, 'sidebars_')) { continue; } // Don't save core options. if (in_array($key, self::$core_options)) { continue; } $data['options'][$key] = $setting->value(); } } // Plugin developers can specify additional option keys to export. $option_keys = apply_filters('cei_export_option_keys', array()); foreach ($option_keys as $option_key) { $option_value = get_option($option_key); if ($option_value) { $data['options'][$option_key] = $option_value; } } // Set the download headers. header('Content-disposition: attachment; filename=' . $theme . '-export.dat'); header('Content-Type: application/octet-stream; charset=' . $charset); // Serialize the export data. echo serialize($data); // Start the download. die; }
?> <hr class="grid_24" /> <?php } ?> <?php $footer_menu = wp_nav_menu(array('theme_location' => 'footer_nav', 'depth' => 1, 'container_class' => 'grid_16 push_8', 'fallback_cb' => false)); ?> <?php $copyright_class = $footer_menu ? 'grid_8 pull_16' : 'grid_24'; ?> <?php $mods = get_theme_mods(); $theme_mods = isset($mods[TEMPLATE_DOMAIN . '_options']) ? $mods[TEMPLATE_DOMAIN . '_options'] : false; if ($theme_mods) { ?> <div id="copyright_notice" class="<?php echo $copyright_class; ?> "> <p><?php echo $theme_mods['copyright_notice']; ?> </p> </div> <?php } ?>
/** * Settings page output * * @since 1.6.0 */ public static function create_admin_page() { ?> <div class="wrap"> <h2><?php _e('Import, Export or Reset Theme Settings', 'wpex'); ?> </h2> <p><?php _e('This will export/import/delete ALL theme_mods that means if other plugins are adding settings in the Customizer it will export/import/delete those as well.', 'wpex'); ?> </p> <?php // Default options $options = array('import' => '', 'reset' => ''); ?> <form method="post" action="options.php"> <?php // Output nonce, action, and option_page fields for a settings page $options = get_option('wpex_customizer_options', $options); settings_fields('wpex_customizer_options'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Export Settings', 'wpex'); ?> </th> <td> <?php // Get an array of all the theme mods if ($theme_mods = get_theme_mods()) { $mods = array(); foreach ($theme_mods as $theme_mod => $value) { $mods[$theme_mod] = maybe_unserialize($value); } $json = json_encode($mods); $disabled = ''; } else { $json = __('No Settings Found', 'wpex'); $disabled = 'disabled'; } echo '<textarea rows="10" cols="50" readonly id="wpex-customizer-export" style="width:100%;">' . $json . '</textarea>'; ?> <p class="submit"> <a href="#" class="button-primary wpex-highlight-options <?php echo $disabled; ?> "><?php _e('Highlight Options', 'wpex'); ?> </a> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Import Settings', 'wpex'); ?> </th> <td> <textarea name="wpex_customizer_options[import]" rows="10" cols="50" style="width:100%;"><?php echo stripslashes($options['import']); ?> </textarea> <input id="wpex-reset-hidden" name="wpex_customizer_options[reset]" type="hidden" value=""></input> <p class="submit"> <input type="submit" class="button-primary wpex-submit-form" value="<?php _e('Import Options', 'wpex'); ?> " /> <a href="#" class="button-secondary wpex-delete-options"><?php _e('Reset Options', 'wpex'); ?> </a> <a href="#" class="button-secondary wpex-cancel-delete-options" style="display:none;"><?php _e('Cancel Reset', 'wpex'); ?> </a> </p> <div class="wpex-delete-options-warning error inline" style="display:none;"> <p style="margin:.5em 0;"><?php _e('Always make sure you have a backup of your settings before resetting, just incase! Your menu locations and widget areas will not reset and will remain intact. All customizer and addon settings will reset.', 'wpex'); ?> </p> </div> </td> </tr> </table> </form> <script> (function($) { "use strict"; $( '.wpex-highlight-options' ).click( function() { $( '#wpex-customizer-export' ).focus().select(); return false; } ); $( '.wpex-delete-options' ).click( function() { $(this).hide(); $( '.wpex-delete-options-warning, .wpex-cancel-delete-options' ).show(); $( '.wpex-submit-form' ).val( "<?php _e('Confirm Reset', 'wpex'); ?> " ); $( '#wpex-reset-hidden' ).val( '-1' ); return false; } ); $( '.wpex-cancel-delete-options' ).click( function() { $(this).hide(); $( '.wpex-delete-options-warning' ).hide(); $( '.wpex-delete-options' ).show(); $( '.wpex-submit-form' ).val( "<?php _e('Import Options', 'wpex'); ?> " ); $( '#wpex-reset-hidden' ).val( '' ); return false; } ); } ) ( jQuery ); </script> </div> <?php }