function td_import_demo_style_fonts($file_style) { $explode_nr_file = explode('_', $file_style); //read the settings file $file_settings = unserialize(base64_decode(file_get_contents(get_template_directory() . '/includes/stacks/' . $file_style . '.txt', true))); foreach (td_style_imported_settings::$td_array_import_settings_from_file as $import_setting_from_file) { /** * we import a setting from the file only if it's not empty * OR * if the setting is td_body_classes we import it even as empty if needed */ if (isset($file_settings[$import_setting_from_file])) { td_global::$td_options[$import_setting_from_file] = $file_settings[$import_setting_from_file]; } else { if ($import_setting_from_file == 'td_body_classes') { td_global::$td_options['td_body_classes'] = ''; } } } //import typography settings if (!empty($file_settings['td_fonts'])) { td_global::$td_options['td_fonts'] = $file_settings['td_fonts']; } //import css font files (google) buffer if (!empty($file_settings['td_fonts_css_files'])) { td_global::$td_options['td_fonts_css_files'] = $file_settings['td_fonts_css_files']; } //compile user css if any td_global::$td_options['tds_user_compile_css'] = td_css_generator(); //print_r($file_settings); //write the changes to the database update_option(TD_THEME_OPTIONS_NAME, td_global::$td_options); return true; }
static function update() { //load all the theme's settings td_global::$td_options = get_option(TD_THEME_OPTIONS_NAME); /* ---------------------------------------------------------------------------- save the data */ //print_r($_POST); foreach ($_POST as $post_data_source => $post_value) { switch ($post_data_source) { case 'td_category': self::update_category($post_value); break; case 'td_option': self::update_td_option($post_value); break; case 'wp_option': self::update_wp_option($post_value); break; case 'td_homepage': break; case 'td_page_option': break; case 'td_author': self::update_td_author($post_value); break; case 'wp_widget': self::update_wp_widget($post_value); break; case 'wp_theme_mod': self::update_wp_theme_mod($post_value); break; case 'wp_theme_menu_spot': self::update_wp_theme_menu_spot($post_value); break; case 'td_translate': self::update_td_translate($post_value); break; case 'td_ads': self::update_td_ads($post_value); break; //social networks //social networks case 'td_social_networks': self::update_td_social_networks($post_value); break; case 'td_fonts': self::update_td_fonts($post_value); break; case 'td_block_styles': self::update_td_block_styles($post_value); break; } } //compile user css if any td_global::$td_options['tds_user_compile_css'] = td_css_generator(); //save all the themes settings (td_options + td_category) update_option(TD_THEME_OPTIONS_NAME, td_global::$td_options); }
/** --------------------------------------------------------------------------- * front end user compiled css @see td_css_generator.php */ function td_include_user_compiled_css() { if (!is_admin()) { // add the global css compiler td_css_buffer::add_to_header(PHP_EOL . '/* Style generated by theme (global compiled style) */' . PHP_EOL); if (TD_DEPLOY_MODE == 'dev') { // get it live td_css_buffer::add_to_header(td_css_generator()); } else { // get it from the cache - do not compile at runtime td_css_buffer::add_to_header(td_util::get_option('tds_user_compile_css')); } // add the demo specific css compiler $demo_state = get_option(TD_THEME_NAME . '_demo_state'); // get the current loaded demo if (isset($demo_state['demo_id'])) { $demo_id = $demo_state['demo_id']; if (td_global::$demo_list[$demo_id]['td_css_generator_demo'] === true) { require_once td_global::$demo_list[$demo_id]['folder'] . 'td_css_generator_demo.php'; td_css_buffer::add_to_header(PHP_EOL . PHP_EOL . PHP_EOL . '/* Style generated by theme for demo: ' . $demo_id . ' */' . PHP_EOL); td_css_buffer::add_to_header(td_css_demo_gen()); } } } }
//td_demo_media::remove(); td_demo_content::remove(); td_demo_category::remove(); td_demo_menus::remove(); td_demo_widgets::remove(); $td_demo_installer = new td_demo_installer(); // remove panel settings and recompile the css as empty foreach (td_global::$td_options as $option_id => $option_value) { td_global::$td_options[$option_id] = ''; } //typography settings td_global::$td_options['td_fonts'] = ''; //css font files (google) buffer td_global::$td_options['td_fonts_css_files'] = ''; //compile user css if any td_global::$td_options['tds_user_compile_css'] = td_css_generator(); update_option(TD_THEME_OPTIONS_NAME, td_global::$td_options); td_demo_state::update_state($_GET['puiu_test'], 'full'); // load panel settings $td_demo_installer->import_panel_settings(td_global::$demo_list[$_GET['puiu_test']]['folder'] . 'td_panel_settings.txt'); // load the media import script //require_once(td_global::$demo_list[$td_demo_id]['folder'] . 'td_media_1.php'); require_once td_global::$demo_list[$_GET['puiu_test']]['folder'] . 'td_import.php'; } ?> <div class=" about-wrap td-admin-wrap theme-browser"> <h1><?php echo TD_THEME_NAME; ?> demos</h1>
public function import_panel_settings($file_path, $empty_ignored_settings = false) { //it's public only for testing // this settings will be "" out when any of the imports is runned $ignored_settings = array('tds_logo_upload', 'tds_logo_upload_r', 'tds_favicon_upload', 'tds_logo_menu_upload', 'tds_logo_menu_upload_r', 'tds_footer_logo_upload', 'tds_footer_retina_logo_upload', 'tds_site_background_image', 'category_options', 'td_ads', 'sidebars'); //read the settings file $file_settings = unserialize(base64_decode(file_get_contents($file_path, true))); //apply td_cake variables $file_settings['td_cake_status_time'] = td_util::get_option('td_cake_status_time'); $file_settings['td_cake_status'] = td_util::get_option('td_cake_status'); $file_settings['envato_key'] = td_util::get_option('envato_key'); if ($empty_ignored_settings === true) { // we empty the ignored settings td_global::$td_options = $file_settings; foreach ($ignored_settings as $setting) { td_global::$td_options[$setting] = ''; } } else { // we leave the ignored settings alone foreach ($file_settings as $setting_id => $setting_value) { if (!in_array($setting_id, $ignored_settings)) { td_global::$td_options[$setting_id] = $setting_value; } } } //compile user css if any td_global::$td_options['tds_user_compile_css'] = td_css_generator(); //write the changes to the database update_option(TD_THEME_OPTIONS_NAME, td_global::$td_options); }