Пример #1
0
 /**
  * HTML OUTPUT.
  *
  * @since NHP_Options 1.0
  */
 function _options_page_html()
 {
     echo '<div class="wrap">';
     echo isset($this->args['intro_text']) ? $this->args['intro_text'] : '';
     do_action('nhp-opts-page-before-form');
     do_action('nhp-opts-page-before-form-' . $this->args['opt_name']);
     echo '<form method="post" action="options.php" enctype="multipart/form-data" id="nhp-opts-form-wrapper">';
     settings_fields($this->args['opt_name'] . '_group');
     echo '<input type="hidden" id="last_tab" name="' . $this->args['opt_name'] . '[last_tab]" value="' . $this->options['last_tab'] . '" />';
     echo '<div id="nhp-opts-header">';
     echo '<a href="http://mythemeshop.com" id="optionpanellogo" class="logo" target="_blank"><img src="' . $this->url . 'img/optionpanellogo.png" /></a>';
     echo '<span class="headtext">Welcome to your theme\'s mission control center.</span>';
     echo '<a href="http://mythemeshop.com/support" class="docsupport" target="_blank"><i class="fa fa-medkit"></i> Support</a>';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div>';
     if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && get_transient('nhp-opts-saved') == '1') {
         if (isset($this->options['imported']) && $this->options['imported'] == 1) {
             echo '<div id="nhp-opts-imported">' . __('<strong>Settings Imported!</strong>', 'mythemeshop') . '</div>';
         } else {
             echo '<div id="nhp-opts-save">' . __('<strong>Settings Saved!</strong>', 'mythemeshop') . '</div>';
         }
         delete_transient('nhp-opts-saved');
     }
     echo '<div id="nhp-opts-save-warn">' . __('<strong>Settings have changed, you should save them!</strong>', 'mythemeshop') . '</div>';
     echo '<div id="nhp-opts-field-errors">' . __('<strong><span></span> error(s) were found!</strong>', 'mythemeshop') . '</div>';
     echo '<div id="nhp-opts-field-warnings">' . __('<strong><span></span> warning(s) were found!</strong>', 'mythemeshop') . '</div>';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '<div id="nhp-opts-sidebar">';
     echo '<ul id="nhp-opts-group-menu">';
     /* foreach($this->sections as $k => $section){
                              // Accordion: tab 3-14 are homepage items
                              if ($k == 3) {
                                  echo '<li id="accordion_section_group_li" class="nhp-opts-group-tab-link-li"><a href="javascript:void(0);" id="accordion_section_group_li_a" class="nhp-opts-group-tab-link-a" data-rel="3" title="Homepage"><i class="fa fa-home"></i> <span class="section_title">Homepage</span></a></li>';
                                  echo '<div id="nhp-opts-homepage-accordion">';
                              }
                              if ($k == 10) {
                                  echo '<li id="accordion_section_group_li" class="nhp-opts-group-tab-link-li"><a href="javascript:void(0);" id="accordion_section_group_li_a_2" class="nhp-opts-group-tab-link-a" data-rel="3" title="Blog Settings"><i class="fa fa-file-text"></i> <span class="section_title">Blog Settings</span></a></li>';
                                  echo '<div id="nhp-opts-blog-accordion">';
                              }
     				$icon = (!isset($section['icon']))?'<i class="fa fa-cogs"></i> ':'<i class="fa '.$section['icon'].'"></i> ';
     				echo '<li id="'.$k.'_section_group_li" class="nhp-opts-group-tab-link-li">';
     					echo '<a href="javascript:void(0);" id="'.$k.'_section_group_li_a" class="nhp-opts-group-tab-link-a" data-rel="'.$k.'" title="'.$section['title'].'">'.$icon.'<span class="section_title">'.$section['title'].'</span></a>';
     				echo '</li>';
                              if ($k == 9 || $k == 13) {
                                  echo '</div>';
                              }
     			} */
     foreach ($this->sections as $k => $section) {
         $icon = !isset($section['icon']) ? '<i class="fa fa-cogs"></i> ' : '<i class="' . $section['icon'] . '"></i> ';
         echo '<li id="' . $k . '_section_group_li" class="nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="' . $k . '_section_group_li_a" class="nhp-opts-group-tab-link-a" data-rel="' . $k . '" title="' . $section['title'] . '">' . $icon . '<span class="section_title">' . $section['title'] . '</span></a>';
         echo '</li>';
     }
     do_action('nhp-opts-after-section-menu-items', $this);
     do_action('nhp-opts-after-section-menu-items-' . $this->args['opt_name'], $this);
     // Typography link
     if (true === $this->args['show_typography']) {
         echo '<li id="typography_default_section_group_li" class="nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="typography_default_section_group_li_a" class="nhp-opts-group-tab-link-a" data-rel="typography_default"><i class="fa fa-text-width"></i> ' . '<span class="section_title">' . __('Typography', 'mythemeshop') . '</span></a>';
         echo '</li>';
     }
     //if
     // Translation link
     if (true === $this->args['show_translate']) {
         echo '<li id="translation_default_section_group_li" class="nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="translation_default_section_group_li_a" class="nhp-opts-group-tab-link-a" data-rel="translation_default"><i class="fa fa-flag-o"></i> ' . '<span class="section_title">' . __('Translate', 'mythemeshop') . '</span></a>';
         echo '</li>';
     }
     //if
     // Import/export link
     if (true === $this->args['show_import_export']) {
         echo '<li id="import_export_default_section_group_li" class="nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="import_export_default_section_group_li_a" class="nhp-opts-group-tab-link-a" data-rel="import_export_default"><i class="fa fa-sign-in"></i> ' . '<span class="section_title">' . __('Import / Export', 'mythemeshop') . '</span></a>';
         echo '</li>';
     }
     //if
     foreach ($this->extra_tabs as $k => $tab) {
         $icon = !isset($tab['icon']) ? '<i class="fa fa-cogs" /> ' : '<i class="' . $tab['icon'] . '" /> ';
         echo '<li id="' . $k . '_section_group_li" class="nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="' . $k . '_section_group_li_a" class="nhp-opts-group-tab-link-a custom-tab" data-rel="' . $k . '">' . $icon . $tab['title'] . '</a>';
         echo '</li>';
     }
     if (true === $this->args['dev_mode']) {
         echo '<li id="dev_mode_default_section_group_li" class="nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="dev_mode_default_section_group_li_a" class="nhp-opts-group-tab-link-a custom-tab" data-rel="dev_mode_default"><img src="' . $this->url . 'img/glyphicons/glyphicons_195_circle_info.png" /> ' . __('Dev Mode Info', 'mythemeshop') . '</a>';
         echo '</li>';
     }
     //if
     echo '</ul>';
     echo '</div>';
     echo '<div id="nhp-opts-main">';
     foreach ($this->sections as $k => $section) {
         echo '<div id="' . $k . '_section_group' . '" class="nhp-opts-group-tab">';
         do_settings_sections($k . '_section_group');
         echo '</div>';
     }
     if (true === $this->args['show_import_export']) {
         echo '<div id="import_export_default_section_group' . '" class="nhp-opts-group-tab">';
         echo '<h3>' . __('Import / Export Options', 'mythemeshop') . '</h3>';
         // presets
         if (!empty($this->args['presets'])) {
             echo '<h4>' . __('Preset Options', 'mythemeshop') . '</h4>';
             echo '<div id="presets" class="nhp-opts-field-wrapper">';
             foreach ($this->args['presets'] as $preset) {
                 echo '<div class="preset">';
                 echo '<h5>' . $preset['title'] . '</h5>';
                 echo '<div class="preset-thumb-wrap">';
                 echo '<img src="' . $preset['thumbnail'] . '" />';
                 echo '</div>';
                 if (!empty($preset['demo'])) {
                     echo '<a href="' . $preset['demo'] . '" target="_blank" class="button button-secondary demo-button">' . __('Demo', 'mythemeshop') . '</a>';
                 }
                 echo '<a href="#" class="button button-primary activate-button">' . __('Import', 'mythemeshop') . '</a>';
                 echo '<input type="hidden" class="preset-data" value="' . esc_attr($preset['data']) . '" />';
                 echo '</div>';
             }
             echo '</div>';
             echo '<div id="import_divide"></div>';
         }
         echo '<h4>' . __('Import Options', 'mythemeshop') . '</h4>';
         echo '<p><a href="#" id="nhp-opts-import-code-button" class="button-secondary">Import Code</a></p>';
         echo '<div id="nhp-opts-import-code-wrapper">';
         echo '<div class="nhp-opts-section-desc">';
         echo '<p class="description" id="import-code-description">' . apply_filters('nhp-opts-import-file-description', __('Insert your backup code below and hit Import to restore your site options from a backup.', 'mythemeshop')) . '</p>';
         echo '</div>';
         echo '<div class="nhp-opts-field-wrapper">';
         echo '<textarea id="import-code-value" name="' . $this->args['opt_name'] . '[import_code]" class="large-text" rows="8"></textarea><br />';
         echo '<input type="submit" id="nhp-opts-import" name="' . $this->args['opt_name'] . '[import]" class="button-primary" value="' . __('Import', 'mythemeshop') . '">';
         echo '</div>';
         echo '</div>';
         echo '<div id="import_divide"></div>';
         echo '<h4>' . __('Export Options', 'mythemeshop') . '</h4>';
         echo '<p><a href="#" id="nhp-opts-export-code-copy" class="button-secondary">' . __('Show Export Code', 'mythemeshop') . '</a></p>';
         echo '<div class="nhp-opts-section-desc">';
         //echo '<p class="description">'.apply_filters('nhp-opts-backup-description', __('Here, you can export your current theme options.  Keep this safe, as you can use it for backup in case of an emergency. You can also use this to restore settings on this site, or on any other site using this theme.  You can also copy the link to your settings, and duplicate it to another site, which is useful if you have a network of blogs that all need the same settings.', 'mythemeshop')).'</p>';
         echo '</div>';
         $backup_options = $this->options;
         // google typography
         $typography = get_option(MTS_TYPOGRAPHY_COLLECTIONS_OPT);
         if (!empty($typography)) {
             $backup_options['google_typography_collections'] = $typography;
         }
         $mts_translations = get_option('mts_translations_' . MTS_THEME_NAME);
         if (!empty($this->options['translate']) && !empty($mts_translations)) {
             $backup_options['translations'] = $mts_translations;
         }
         $backup_options['nhp-opts-backup'] = '1';
         $encoded_options = '###' . serialize($backup_options) . '###';
         echo '<div class="nhp-opts-field-wrapper">';
         echo '<textarea class="large-text" id="nhp-opts-export-code" rows="8">';
         print_r($encoded_options);
         echo '</textarea>';
         echo '</div>';
         echo '<input type="text" class="large-text" id="nhp-opts-export-link-value" value="' . add_query_arg(array('feed' => 'nhpopts', 'secret' => md5(AUTH_KEY . SECURE_AUTH_KEY), 'option' => $this->args['opt_name']), site_url()) . '" />';
         echo '<div id="import_divide"></div>';
         // Child Theme
         if (true === $this->args['show_child_theme_opts'] && !is_child_theme()) {
             echo '<h4>' . __('Child Theme', 'mythemeshop') . '</h4>';
             echo '<div class="nhp-opts-section-desc">';
             echo '<p class="description">' . __('To create child theme for current theme, enter desired name and hit "Create Child Theme" button', 'mythemeshop') . '</p>';
             echo '</div>';
             echo '<div class="nhp-opts-field-wrapper">';
             //echo '<label for="nhp-opts-child-name">'.__( 'Child theme name', 'mythemeshop' ).'</label><br />';
             echo '<input type="text" id="nhp-opts-child-name" name="nhp-opts-child-name" value="" />';
             echo '<input type="submit" id="nhp-opts-child-button" name="nhp-opts-child-button" class="button-primary" value="' . __('Create Child Theme', 'mythemeshop') . '">';
             echo '</div>';
             echo '<div id="child-theme-list-wrap">';
             $this->mts_list_child_themes();
             echo '</div>';
         }
         echo '</div>';
     }
     if (true === $this->args['show_typography']) {
         echo '<div id="typography_default_section_group' . '" class="nhp-opts-group-tab">';
         //echo '<h3>'.__('Theme Typography', 'mythemeshop').'</h3>';
         $typography = new mtsGoogleTypography();
         $typography->options_ui();
         echo '</div>';
     }
     if (true === $this->args['show_translate']) {
         echo '<div id="translation_default_section_group' . '" class="nhp-opts-group-tab">';
         echo '<h3>' . __('Theme Translation Panel', 'mythemeshop') . '</h3>';
         echo '<div class="nhp-opts-section-desc">';
         echo '<p class="description">' . __('The theme translation panel provides an easy way to translate text appearing on your site, without the hassle of handling .po .mo files. Translations are saved instantly after typing in.', 'mythemeshop') . '</p>';
         echo '<p id="nhp-opts-reset-translations-action"><input type="submit" id="nhp-opts-reset-translations" name="' . $this->args['opt_name'] . '[reset_translations]" class="button-primary" value="' . __('Reset translations', 'mythemeshop') . '"></p>';
         echo '</div>';
         // here comes the translation panel
         $translate_enabled = false;
         if (!empty($this->options['translate'])) {
             $translate_enabled = true;
         }
         echo '<div class="nhp-opts-field-wrapper">';
         echo '<p><label for="nhp-opts-translate"><input type="checkbox" name="' . $this->args['opt_name'] . '[translate]" id="nhp-opts-translate" value="1" ' . checked($translate_enabled, true, false) . ' />' . __('Enable translation panel', 'mythemeshop') . '</label></p>';
         echo '</div>';
         echo '<div class="nhp-opts-field-wrapper" id="translate_search_wrapper">';
         echo '<p><input type="text" val="" id="translate_search" placeholder="' . __('Search Translations', 'mythemeshop') . '" />';
         echo '</div>';
         echo '<div class="nhp-opts-field-wrapper translate-strings">';
         // ajaxed content
         echo '</div>';
         echo '</div>';
     }
     foreach ($this->extra_tabs as $k => $tab) {
         echo '<div id="' . $k . '_section_group' . '" class="nhp-opts-group-tab">';
         echo '<h3>' . $tab['title'] . '</h3>';
         echo $tab['content'];
         echo '</div>';
     }
     if (true === $this->args['dev_mode']) {
         echo '<div id="dev_mode_default_section_group' . '" class="nhp-opts-group-tab">';
         echo '<h3>' . __('Dev Mode Info', 'mythemeshop') . '</h3>';
         echo '<div class="nhp-opts-section-desc">';
         echo '<textarea class="large-text" rows="24">' . print_r($this, true) . '</textarea>';
         echo '</div>';
         echo '</div>';
     }
     do_action('nhp-opts-after-section-items', $this);
     do_action('nhp-opts-after-section-items-' . $this->args['opt_name'], $this);
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div>';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '<div id="nhp-opts-footer">';
     if (isset($this->args['share_icons'])) {
         echo '<div id="nhp-opts-share">';
         foreach ($this->args['share_icons'] as $link) {
             echo '<a href="' . $link['link'] . '" title="' . $link['title'] . '" target="_blank"><i class="' . $link['img'] . '"></i></a>';
         }
         echo '</div>';
     }
     echo '<input type="submit" name="' . $this->args['opt_name'] . '[defaults]" value="' . __('Reset to Defaults', 'mythemeshop') . '" class="button-secondary" />';
     echo '<input type="submit" name="save" id="savechanges" value="' . __('Save Changes', 'mythemeshop') . '" class="button-primary" disabled="disabled" />';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div>';
     echo '</form>';
     // Floating buttons
     echo '<div id="nhp-opts-bottom"></div>';
     do_action('nhp-opts-page-after-form');
     do_action('nhp-opts-page-after-form-' . $this->args['opt_name']);
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div><!--wrap-->';
 }
Пример #2
0
        wp_enqueue_script('google-typography');
        //wp_enqueue_script('chosen2');
        wp_enqueue_script('select2');
        // Stylesheets
        wp_register_style('google-typography', get_template_directory_uri() . '/options/google-typography/stylesheets/google-typography.css', false, '1.1');
        //wp_register_style('chosen', get_template_directory_uri() .'/options/google-typography/stylesheets/chosen.css', false, '1.0.0');
        wp_register_style('select2', get_template_directory_uri() . '/options/css/select2.css');
        wp_register_style('google-font', 'http://fonts.googleapis.com/css?family=Lato:300,400');
        wp_enqueue_style('google-typography');
        //wp_enqueue_style('chosen');
        wp_enqueue_style('select2');
        wp_enqueue_style('google-font');
        wp_enqueue_style('wp-color-picker');
    }
}
mtsGoogleTypography::init();
/**
 * Function for registering default typography collections 
 *
 *
 * @uses get_option()
 * @uses update_option()
 *
 */
function mts_register_typography($collections)
{
    if (!get_option(MTS_TYPOGRAPHY_DEFAULT_OPT)) {
        $defaults = array();
        delete_option(MTS_TYPOGRAPHY_COLLECTIONS_OPT);
        foreach ($collections as $key => $collection) {
            array_push($defaults, array_merge(array('default' => true), $collection));