function test_thematic_convert_legacy_opt()
 {
     $this->add_legacy_pre_v1_options();
     $converted_ops = thematic_convert_legacy_opt();
     $expected_ops = array('index_insert' => 4, 'author_info' => 1, 'footer_txt' => 'Powered by [wp-link]. Built on the [theme-link].', 'del_legacy_opt' => 0, 'legacy_xhtml' => 1, 'layout' => thematic_default_theme_layout());
     $this->assertEquals($expected_ops, $converted_ops);
 }
Beispiel #2
0
 function thematic_opt_init()
 {
     // Retrieve current options from database
     $current_options = thematic_get_wp_opt('thematic_theme_opt');
     $legacy_options = thematic_convert_legacy_opt();
     // If no current settings exist
     if (false === $current_options) {
         // Check for legacy options
         if (false !== $legacy_options) {
             // Theme upgrade: Convert legacy to current format and add to database
             add_option('thematic_theme_opt', $legacy_options);
         } else {
             // Fresh theme installation: Add default settings to database
             add_option('thematic_theme_opt', thematic_default_opt());
         }
     }
     register_setting('thematic_opt_group', 'thematic_theme_opt', 'thematic_validate_opt');
     add_settings_section('thematic_opt_section_main', '', 'thematic_do_opt_section_main', 'thematic_theme_opt');
     add_settings_field('thematic_insert_opt', __('Index Insert Position', 'thematic'), 'thematic_do_insert_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     add_settings_field('thematic_auth_opt', __('Info on Author Page', 'thematic'), 'thematic_do_auth_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     add_settings_field('thematic_footer_opt', __('Text in Footer', 'thematic'), 'thematic_do_footer_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     // Show checkbox option for removing old options from database
     if (isset($legacy_options) && false !== $legacy_options) {
         add_settings_field('thematic_legacy_opt', __('Remove Legacy Options', 'thematic'), 'thematic_do_legacy_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     }
 }
Beispiel #3
0
 function thematic_opt_init()
 {
     // Retrieve current options from database
     $current_options = thematic_get_wp_opt('thematic_theme_opt');
     $legacy_options = thematic_convert_legacy_opt();
     // Check for pre-1.0 options
     if (false !== $legacy_options) {
         // Theme upgrade: Convert legacy to current format and add to database
         add_option('thematic_theme_opt', $legacy_options);
     }
     // If we are missing a 2.0 option, this is an upgrade from previous version
     if (!isset($current_options['layout']) && isset($current_options['footer_txt'])) {
         $current_options = wp_parse_args($current_options, thematic_default_opt());
         // enable xhtml mode by default on theme upgrades
         $current_options['legacy_xhtml'] = 1;
         update_option('thematic_theme_opt', $current_options);
     }
     register_setting('thematic_opt_group', 'thematic_theme_opt', 'thematic_validate_opt');
     add_settings_section('thematic_opt_section_main', '', 'thematic_do_opt_section_main', 'thematic_theme_opt');
     add_settings_field('thematic_insert_opt', __('Index Insert Position', 'thematic'), 'thematic_do_insert_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     add_settings_field('thematic_auth_opt', __('Info on Author Page', 'thematic'), 'thematic_do_auth_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     add_settings_field('thematic_footer_opt', __('Text in Footer', 'thematic'), 'thematic_do_footer_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     /**
      * Filter to enable child themes to hide the legacy mode checkbox
      * 
      * @param bool true
      */
     if (apply_filters('thematic_show_legacymode_checkbox', false)) {
         // show check box option for restoring legacy xtml1.0 doctype and compatible markup
         add_settings_field('thematic_legacy_xhtml_opt', __('Restore Legacy XHTML1.0 Doctype', 'thematic'), 'thematic_do_legacy_xhtml_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     }
     // Show checkbox option for removing old options from database
     if (isset($legacy_options) && false !== $legacy_options) {
         add_settings_field('thematic_legacy_opt', __('Remove Legacy Options', 'thematic'), 'thematic_do_legacy_opt', 'thematic_theme_opt', 'thematic_opt_section_main');
     }
 }