Esempio n. 1
0
 function on_init()
 {
     $this->metaboxes = xtreme_build_metaboxes(apply_filters('xtreme_metaboxes_default', array()), $this);
     $this->version = get_option(XF_VERSION_FIELD);
     $this->options = get_option(XF_OPTIONS, array());
     $this->layouts = get_option(XF_LAYOUTS, array());
     //templates done at different page but checked for consistency
     $templates = get_option(XF_TEMPLATES, array());
     if (empty($templates)) {
         $templates = array();
     }
     $files = xtreme_load_templates();
     if (count($templates) !== count($files)) {
         foreach ($files as $file => $data) {
             if (!array_key_exists($file, $templates)) {
                 $templates[$file] = 'xf_layout-default';
             }
         }
         update_option(XF_TEMPLATES, $templates);
     }
     $this->apply_options($this->options);
     add_action('wp_ajax_xtreme_check_user_credentials', array(&$this, 'on_check_user_credentials'));
     if (current_theme_supports('post-thumbnails')) {
         add_filter('manage_posts_columns', array(&$this, 'on_thumbnail_column'));
         add_filter('manage_pages_columns', array(&$this, 'on_thumbnail_column'));
         add_action('manage_posts_custom_column', array(&$this, 'on_thumbnail_column_value'), 10, 2);
         add_action('manage_pages_custom_column', array(&$this, 'on_thumbnail_column_value'), 10, 2);
     }
     if (is_admin()) {
         wp_enqueue_style('xtreme-hooks', XF_ADMIN_URL . '/css/xtreme-hooked.css');
     }
     global $wp_version;
     // advanced gallery legacy support
     if (current_theme_supports('xtreme-advanced-wpgallery-legacy') && version_compare($wp_version, '3.5', '>=')) {
         add_action('wp_enqueue_media', array($this, 'wp_enqueue_media_advanced_gallery_legacy'));
         add_action('print_media_templates', array($this, 'print_media_templates_advanced_gallery_legacy'));
     }
     //advanced tinymce support
     if (current_theme_supports('xtreme-advanced-tinymce')) {
         add_editor_style('css/screen/editor-style.css');
         add_filter('mce_css', array(&$this, 'on_mce_css'), 999);
         add_filter('mce_buttons', array(&$this, 'on_mce_buttons'), 999);
     }
     //advanced color style support
     if (current_theme_supports('xtreme-color-styles')) {
         add_filter('after_theme_css', array(&$this, 'after_theme_css'));
     }
     //css compression
     add_action('admin_notices', array(&$this, 'on_admin_notice'));
 }
 function __construct(&$owner)
 {
     parent::__construct($owner, get_class($this), __('Default Layout Settings', XF_TEXTDOMAIN));
     $measures = $this->owner->get_measures();
     $this->options[] = new xtreme_option_description($this, false, 'desc_row', '<em>' . __('You can overrule these settings for each template file under Xtreme Layouts.', XF_TEXTDOMAIN) . '</em>');
     $this->options[] = new xtreme_option_select_pair($this, false, 'columnlayout', __('Layout:', XF_TEXTDOMAIN), 1, array(__('1 column', XF_TEXTDOMAIN), __('2 columns - right sidebar', XF_TEXTDOMAIN), __('2 columns - left sidebar', XF_TEXTDOMAIN), __('3 columns - left and right sidebars', XF_TEXTDOMAIN), __('3 columns - 2 right sidebars', XF_TEXTDOMAIN), __('3 columns - 2 left sidebars', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_description($this, false, 'col2tip', '<em>' . __('In this case width of Sidebar 1 and width of Sidebar 2 must have the same units!', XF_TEXTDOMAIN) . '</em>');
     //altes Layout
     $this->options[] = new xtreme_option_numeric($this, false, 'col1width', __('Sidebar 1 Width:', XF_TEXTDOMAIN), 25, '%', $measures, array('px' => array(80, 500), 'em' => array(5, 50), '%' => array(5, 50)), false, false);
     $this->options[] = new xtreme_option_numeric($this, false, 'col2width', __('Sidebar 2 Width:', XF_TEXTDOMAIN), 25, '%', $measures, array('px' => array(80, 500), 'em' => array(5, 50), '%' => array(5, 50)), false, false);
     //neues Layout
     $this->options[] = new xtreme_option_numeric($this, false, 'layout_2_col1width', __('Content Width:', XF_TEXTDOMAIN), 75, '%', $measures, array('px' => array(100, 1600), '%' => array(5, 100)), false, false);
     $this->options[] = new xtreme_option_numeric($this, false, 'layout_2_col2width', __('Sidebar 2 Width:', XF_TEXTDOMAIN), 25, '%', $measures, array('px' => array(80, 500), '%' => array(5, 50)), false, false);
     //altes Layout
     $this->options[] = new xtreme_option_locate_files($this, false, 'col1content', __('File Sidebar 1:', XF_TEXTDOMAIN), 'sidebar-one', '/includes/sidebars/', 'php', false);
     $this->options[] = new xtreme_option_locate_files($this, false, 'col2content', __('File Sidebar 2:', XF_TEXTDOMAIN), 'sidebar-two', '/includes/sidebars/', 'php', false);
     //neues Layout
     $this->options[] = new xtreme_option_locate_files($this, false, 'layout_2_col3content', __('File Sidebar 1:', XF_TEXTDOMAIN), 'sidebar-one', '/includes/sidebars/', 'php', false);
     $this->options[] = new xtreme_option_locate_files($this, false, 'layout_2_col2content', __('File Sidebar 2:', XF_TEXTDOMAIN), 'sidebar-two', '/includes/sidebars/', 'php', false);
     //altes Layout
     $this->options[] = new xtreme_option_select_pair($this, false, 'col1txtalign', __('Sidebar 1 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'col2txtalign', __('Sidebar 2 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'col3txtalign', __('Content Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     //neues Layout
     $this->options[] = new xtreme_option_select_pair($this, false, 'layout_2_col3txtalign', __('Sidebar 1 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'layout_2_col2txtalign', __('Sidebar 2 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'layout_2_col1txtalign', __('Content Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_bool($this, false, 'use_header', __('Use Header:', XF_TEXTDOMAIN), true);
     $this->options[] = new xtreme_option_bool($this, false, 'use_teaser', __('Use Teaser:', XF_TEXTDOMAIN), false);
     $this->options[] = new xtreme_option_bool($this, false, 'use_footer', __('Use Footer:', XF_TEXTDOMAIN), false);
     $this->options[] = new xtreme_option_bool($this, false, 'use_siteinfo', __('Use Siteinfo:', XF_TEXTDOMAIN), true);
     $this->options[] = new xtreme_option_hidden($this, false, 'nicename', '', 'Default');
     $sanitized = sanitize_title('Default');
     $name = 'xf_layout-' . str_replace(' ', '-', strtolower($sanitized));
     $this->options[] = new xtreme_option_hidden($this, false, 'layoutname', '', $name);
     $this->options[] = new xtreme_option_hidden($this, false, 'description', '', 1);
     $classes = xtreme_classes_array();
     $this->options[] = new xtreme_option_hidden($this, false, 'mainclass', '', $classes[1]);
     $files = xtreme_load_templates();
     foreach ($files as $file => $value) {
         $this->options[] = new xtreme_option_hidden($this, false, substr($value['metavalue'], 0, -4), $value['Name'], true);
     }
     $this->options[] = new xtreme_option_select($this, false, 'sidebar_tag', __('Sidebar Tag:', XF_TEXTDOMAIN), 'ul', array('ul', 'div'));
     $this->options[] = new xtreme_option_select($this, false, 'sidebar_headline_tag', __('Tag before Title in Sidebars Widget Areas:', XF_TEXTDOMAIN), 'h5', array('h3', 'h4', 'h5', 'h6'));
     $this->options[] = new xtreme_option_select($this, false, 'html5_tag', __('HTML5 Tag of Sidebars:', XF_TEXTDOMAIN), 'aside', xtreme_html5_tags());
 }
 function __construct(&$owner)
 {
     parent::__construct($owner, get_class($this), __('New Layout Settings', XF_TEXTDOMAIN));
     $this->options[] = new xtreme_option_textfield($this, false, 'nicename', __('Name of the Layout:', XF_TEXTDOMAIN), 'new Layout', 'new Layout');
     $this->options[] = new xtreme_option_select_pair($this, false, 'columnlayout', __('Layout:', XF_TEXTDOMAIN), 1, array(__('1 column', XF_TEXTDOMAIN), __('2 columns - right sidebar', XF_TEXTDOMAIN), __('2 columns - left sidebar', XF_TEXTDOMAIN), __('3 columns - left and right sidebars', XF_TEXTDOMAIN), __('3 columns - 2 right sidebars', XF_TEXTDOMAIN), __('3 columns - 2 left sidebars', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_description($this, false, 'col2tip', '<em>' . __('In this case width of Sidebar 1 and width of Sidebar 2 must have the same units!', XF_TEXTDOMAIN) . '</em>');
     //wir brauchen den layoutwert
     $this->options[] = new xtreme_option_hidden($this, false, 'is_layout_2', '', (int) xtreme_is_layout_2());
     //altes Layout
     $measures = $this->owner->get_measures();
     $this->options[] = new xtreme_option_numeric($this, false, 'col1width', __('Sidebar 1 Width:', XF_TEXTDOMAIN), 25, '%', $measures, array('px' => array(80, 500), 'em' => array(5, 50), '%' => array(5, 50)), false, false);
     $this->options[] = new xtreme_option_numeric($this, false, 'col2width', __('Sidebar 2 Width:', XF_TEXTDOMAIN), 25, '%', $measures, array('px' => array(80, 500), 'em' => array(5, 50), '%' => array(5, 50)), false, false);
     $this->options[] = new xtreme_option_locate_files($this, false, 'col1content', __('File Sidebar 1:', XF_TEXTDOMAIN), 'sidebar-one', '/includes/sidebars/', 'php', false);
     $this->options[] = new xtreme_option_locate_files($this, false, 'col2content', __('File Sidebar 2:', XF_TEXTDOMAIN), 'sidebar-two', '/includes/sidebars/', 'php', false);
     $this->options[] = new xtreme_option_select_pair($this, false, 'col1txtalign', __('Sidebar 1 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'col2txtalign', __('Sidebar 2 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'col3txtalign', __('Content Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     //neues Layout
     $this->options[] = new xtreme_option_numeric($this, false, 'layout_2_col1width', __('Content Width:', XF_TEXTDOMAIN), 75, '%', $measures, array('px' => array(100, 1600), '%' => array(5, 100)), false, false);
     $this->options[] = new xtreme_option_numeric($this, false, 'layout_2_col2width', __('Sidebar 2 Width:', XF_TEXTDOMAIN), 25, '%', $measures, array('px' => array(80, 500), '%' => array(5, 50)), false, false);
     $this->options[] = new xtreme_option_locate_files($this, false, 'layout_2_col3content', __('File Sidebar 1:', XF_TEXTDOMAIN), 'sidebar-one', '/includes/sidebars/', 'php', false);
     $this->options[] = new xtreme_option_locate_files($this, false, 'layout_2_col2content', __('File Sidebar 2:', XF_TEXTDOMAIN), 'sidebar-two', '/includes/sidebars/', 'php', false);
     $this->options[] = new xtreme_option_select_pair($this, false, 'layout_2_col3txtalign', __('Sidebar 1 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'layout_2_col2txtalign', __('Sidebar 2 Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_select_pair($this, false, 'layout_2_col1txtalign', __('Content Textalignment:', XF_TEXTDOMAIN), 0, array(__('left', XF_TEXTDOMAIN), __('center', XF_TEXTDOMAIN), __('right', XF_TEXTDOMAIN)));
     $this->options[] = new xtreme_option_bool($this, false, 'use_header', __('Use Header:', XF_TEXTDOMAIN), true);
     $this->options[] = new xtreme_option_bool($this, false, 'use_teaser', __('Use Teaser:', XF_TEXTDOMAIN), false);
     $this->options[] = new xtreme_option_bool($this, false, 'use_footer', __('Use Footer:', XF_TEXTDOMAIN), false);
     $this->options[] = new xtreme_option_bool($this, false, 'use_siteinfo', __('Use Siteinfo:', XF_TEXTDOMAIN), true);
     $sanitized = sanitize_title('Default');
     $name = 'xf_layout-' . str_replace(' ', '-', strtolower($sanitized));
     $this->options[] = new xtreme_option_hidden($this, false, 'layoutname', '', $name);
     $this->options[] = new xtreme_option_hidden($this, false, 'description', '', __('2 columns - right sidebar', XF_TEXTDOMAIN));
     $classes = xtreme_classes_array();
     $this->options[] = new xtreme_option_hidden($this, false, 'mainclass', '', $classes[1]);
     $this->options[] = new xtreme_option_description($this, false, 'desc_row_1', '<strong>' . __('Apply these Template Files to the New Layout:', XF_TEXTDOMAIN) . '</strong>');
     $files = xtreme_load_templates();
     foreach ($files as $file => $value) {
         $this->options[] = new xtreme_option_bool($this, false, substr($value['metavalue'], 0, -4), $value['Name'], false);
     }
     $this->options[] = new xtreme_option_hidden($this, false, 'mode', '', 'add');
 }
Esempio n. 4
0
 function save_layout_options($saved_options)
 {
     $layouts = get_option(XF_LAYOUTS);
     $templates = get_option(XF_TEMPLATES);
     $files = xtreme_load_templates();
     $desc = xtreme_description_array();
     $this->classes = xtreme_classes_array();
     $sanitized = sanitize_title($saved_options['xc_templayout']['nicename']['value']);
     $name = strtolower($sanitized);
     if ($saved_options['xc_templayout']['mode']['value'] === 'add') {
         $key = 'xf_layout-' . $name;
     }
     if ($saved_options['xc_templayout']['mode']['value'] === 'edit') {
         $key = $saved_options['xc_templayout']['layoutname']['value'];
     }
     $title = strip_tags($saved_options['xc_templayout']['nicename']['value']);
     $title = apply_filters('wptexturize', $title);
     $title = apply_filters('convert_chars', $title);
     $title = apply_filters('trim', $title);
     $layouts[$key] = $saved_options['xc_templayout'];
     $layouts[$key]['layoutname']['value'] = $key;
     $layouts[$key]['nicename']['value'] = $title;
     $layouts[$key]['description']['value'] = $desc[$saved_options['xc_templayout']['columnlayout']['value']];
     $layouts[$key]['mainclass']['value'] = $this->classes[$saved_options['xc_templayout']['columnlayout']['value']];
     $i = 0;
     $templ = false;
     foreach ($files as $file => $data) {
         $field = substr($data['metavalue'], 0, -4);
         if (1 == $_POST['xc_templayout-' . $field . '-value']) {
             $i++;
             $templ[$file] = $key;
         } elseif (0 == $_POST['xc_templayout-' . $field . '-value']) {
             if ($templates[$file] === $key) {
                 $templ[$file] = 'xf_layout-default';
             }
         }
     }
     if ($templ) {
         $templates = array_merge($templates, $templ);
     } else {
         wp_redirect(admin_url('admin.php?page=xtreme_layouts&mode=add_layout&layout=' . esc_attr($key) . '&error=1'));
         exit;
     }
     foreach ($templates as $tpl => $f) {
         if (!array_key_exists($tpl, $files)) {
             unset($templates[$tpl]);
         }
     }
     $clear = array_unique(array_values($templates));
     $unique_templates = array_count_values($templates);
     $count_layouts = count($layouts);
     if ($count_layouts > count($unique_templates)) {
         foreach ($layouts as $layout => $data) {
             if (!in_array($layout, $clear)) {
                 if ($layout === 'xf_layout-default') {
                     wp_redirect(admin_url('admin.php?page=xtreme_layouts&mode=edit_layout&layout=' . esc_attr($key) . '&error=2'));
                     exit;
                 } else {
                     unset($layouts[$layout]);
                 }
             }
         }
     }
     if (!isset($layouts[$key])) {
         wp_redirect(admin_url('admin.php?page=xtreme_layouts&mode=edit_layout&layout=' . esc_attr($key) . '&error=3'));
         exit;
     }
     if ($layouts[$key]['mode']['value'] === 'add' || $layouts[$key]['mode']['value'] === 'edit') {
         if ($i === 0) {
             $redirect = admin_url('admin.php?page=xtreme_layouts&mode=add_layout&error=1');
             wp_redirect($redirect);
             exit;
         }
     }
     update_option(XF_LAYOUTS, $layouts);
     update_option(XF_TEMPLATES, $templates);
 }