Esempio n. 1
0
 /**
  * Init settings page && menu item
  * vc_filter: vc_settings_tabs - hook to override settings tabs
  */
 public function initAdmin()
 {
     $this->setTabs();
     self::$color_settings = array(array('vc_color' => array('title' => __('Main accent color', 'js_composer'))), array('vc_color_hover' => array('title' => __('Hover color', 'js_composer'))), array('vc_color_call_to_action_bg' => array('title' => __('Call to action background color', 'js_composer'))), array('vc_color_google_maps_bg' => array('title' => __('Google maps background color', 'js_composer'))), array('vc_color_post_slider_caption_bg' => array('title' => __('Post slider caption background color', 'js_composer'))), array('vc_color_progress_bar_bg' => array('title' => __('Progress bar background color', 'js_composer'))), array('vc_color_separator_border' => array('title' => __('Separator border color', 'js_composer'))), array('vc_color_tab_bg' => array('title' => __('Tabs navigation background color', 'js_composer'))), array('vc_color_tab_bg_active' => array('title' => __('Active tab background color', 'js_composer'))));
     self::$defaults = array('vc_color' => '#f7f7f7', 'vc_color_hover' => '#F0F0F0', 'margin' => '35px', 'gutter' => '15', 'responsive_max' => '768', 'compiled_js_composer_less' => '');
     if ('restore_color' === vc_post_param('vc_action') && vc_user_access()->check('wp_verify_nonce', vc_post_param('_wpnonce'), vc_settings()->getOptionGroup() . '_color' . '-options')->validateDie()->wpAny('manage_options')->validateDie()->part('settings')->can('vc-color-tab')->validateDie()->get()) {
         $this->restoreColor();
     }
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('update_option_wpb_js_compiled_js_composer_less', array(&$this, 'buildCustomColorCss'));
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('update_option_wpb_js_custom_css', array(&$this, 'buildCustomCss'));
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('add_option_wpb_js_compiled_js_composer_less', array(&$this, 'buildCustomColorCss'));
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('add_option_wpb_js_custom_css', array(&$this, 'buildCustomCss'));
     /**
      * Tab: General Settings
      */
     $tab = 'general';
     $this->addSection($tab);
     $this->addField($tab, __('Disable responsive content elements', 'js_composer'), 'not_responsive_css', array(&$this, 'sanitize_not_responsive_css_callback'), array(&$this, 'not_responsive_css_field_callback'));
     $this->addField($tab, __('Google fonts subsets', 'js_composer'), 'google_fonts_subsets', array(&$this, 'sanitize_google_fonts_subsets_callback'), array(&$this, 'google_fonts_subsets_callback'));
     /**
      * Tab: Design Options
      */
     $tab = 'color';
     $this->addSection($tab);
     // Use custom checkbox
     $this->addField($tab, __('Use custom design options', 'js_composer'), 'use_custom', array(&$this, 'sanitize_use_custom_callback'), array(&$this, 'use_custom_callback'));
     foreach (self::$color_settings as $color_set) {
         foreach ($color_set as $key => $data) {
             $this->addField($tab, $data['title'], $key, array(&$this, 'sanitize_color_callback'), array(&$this, 'color_callback'), array('id' => $key));
         }
     }
     // Margin
     $this->addField($tab, __('Elements bottom margin', 'js_composer'), 'margin', array(&$this, 'sanitize_margin_callback'), array(&$this, 'margin_callback'));
     // Gutter
     $this->addField($tab, __('Grid gutter width', 'js_composer'), 'gutter', array(&$this, 'sanitize_gutter_callback'), array(&$this, 'gutter_callback'));
     // Responsive max width
     $this->addField($tab, __('Mobile screen width', 'js_composer'), 'responsive_max', array(&$this, 'sanitize_responsive_max_callback'), array(&$this, 'responsive_max_callback'));
     $this->addField($tab, false, 'compiled_js_composer_less', array(&$this, 'sanitize_compiled_js_composer_less_callback'), array(&$this, 'compiled_js_composer_less_callback'));
     /**
      * Tab: Custom CSS
      */
     $tab = 'custom_css';
     $this->addSection($tab);
     $this->addField($tab, __('Paste your CSS code', 'js_composer'), 'custom_css', array(&$this, 'sanitize_custom_css_callback'), array(&$this, 'custom_css_field_callback'));
     /**
      * Custom Tabs
      */
     foreach ($this->getTabs() as $tab => $title) {
         do_action('vc_settings_tab-' . preg_replace('/^vc\\-/', '', $tab), $this);
     }
     /**
      * Tab: Updater
      */
     $tab = 'updater';
     $this->addSection($tab);
 }
 /**
  * Create tab fields. in Visual composer settings page options-general.php?page=vc_settings
  *
  * @param Vc_Settings $settings
  */
 public function buildTab(Vc_Settings $settings)
 {
     $settings->addSection($this->settings_tab);
     add_filter('vc_setting-tab-form-' . $this->settings_tab, array(&$this, 'settingsFormParams'));
     $settings->addField($this->settings_tab, __('Export VC Templates', "templatera"), 'export', array(&$this, 'settingsFieldExportSanitize'), array(&$this, 'settingsFieldExport'));
     $settings->addField($this->settings_tab, __('Import VC Templates', "templatera"), 'import', array(&$this, 'settingsFieldImportSanitize'), array(&$this, 'settingsFieldImport'));
 }
 /**
  * Init settings page && menu item
  * vc_filter: vc_settings_tabs - hook to override settings tabs
  */
 public function initAdmin()
 {
     $this->setTabs();
     self::$color_settings = array(array('vc_color' => array('title' => __('Main accent color', 'js_composer'))), array('vc_color_hover' => array('title' => __('Hover color', 'js_composer'))), array('vc_color_call_to_action_bg' => array('title' => __('Call to action background color', 'js_composer'))), array('vc_color_google_maps_bg' => array('title' => __('Google maps background color', 'js_composer'))), array('vc_color_post_slider_caption_bg' => array('title' => __('Post slider caption background color', 'js_composer'))), array('vc_color_progress_bar_bg' => array('title' => __('Progress bar background color', 'js_composer'))), array('vc_color_separator_border' => array('title' => __('Separator border color', 'js_composer'))), array('vc_color_tab_bg' => array('title' => __('Tabs navigation background color', 'js_composer'))), array('vc_color_tab_bg_active' => array('title' => __('Active tab background color', 'js_composer'))));
     self::$defaults = array('vc_color' => '#f7f7f7', 'vc_color_hover' => '#F0F0F0', 'margin' => '35px', 'gutter' => '15', 'responsive_max' => '768', 'compiled_js_composer_less' => '');
     $vc_action = vc_action();
     if ($vc_action === 'restore_color') {
         $this->restoreColor();
     } elseif ($vc_action === 'remove_all_css_classes') {
         $this->removeAllCssClasses();
     }
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('update_option_wpb_js_compiled_js_composer_less', array(&$this, 'buildCustomColorCss'));
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('update_option_wpb_js_custom_css', array(&$this, 'buildCustomCss'));
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('add_option_wpb_js_compiled_js_composer_less', array(&$this, 'buildCustomColorCss'));
     /**
      * @since 4.5 used to call update file once option is changed
      */
     add_action('add_option_wpb_js_custom_css', array(&$this, 'buildCustomCss'));
     $this->deactivate = vc_license()->deactivation();
     // TODO: Refactor with separate class.
     /**
      * Tab: General Settings
      */
     $tab = 'general';
     $this->addSection($tab);
     $this->addField($tab, __("Content types", "js_composer"), 'content_types', array(&$this, 'sanitize_post_types_callback'), array(&$this, 'content_types_field_callback'));
     $this->addField($tab, __("User groups access rules", "js_composer"), 'groups_access_rules', array(&$this, 'sanitize_group_access_rules_callback'), array(&$this, 'groups_access_rules_callback'));
     $this->addField($tab, __("Disable responsive content elements", "js_composer"), 'not_responsive_css', array(&$this, 'sanitize_not_responsive_css_callback'), array(&$this, 'not_responsive_css_field_callback'));
     $this->addField($tab, __("Google fonts subsets", "js_composer"), 'google_fonts_subsets', array(&$this, 'sanitize_google_fonts_subsets_callback'), array(&$this, 'google_fonts_subsets_callback'));
     /**
      * Tab: Design Options
      */
     $tab = 'color';
     $this->addSection($tab);
     // Use custom checkbox
     $this->addField($tab, __('Use custom design options', 'js_composer'), 'use_custom', array(&$this, 'sanitize_use_custom_callback'), array(&$this, 'use_custom_callback'));
     foreach (self::$color_settings as $color_set) {
         foreach ($color_set as $key => $data) {
             $this->addField($tab, $data['title'], $key, array(&$this, 'sanitize_color_callback'), array(&$this, 'color_callback'), array('id' => $key));
         }
     }
     // Margin
     $this->addField($tab, __('Elements bottom margin', 'js_composer'), 'margin', array(&$this, 'sanitize_margin_callback'), array(&$this, 'margin_callback'));
     // Gutter
     $this->addField($tab, __('Grid gutter width', 'js_composer'), 'gutter', array(&$this, 'sanitize_gutter_callback'), array(&$this, 'gutter_callback'));
     // Responsive max width
     $this->addField($tab, __('Mobile screen width', 'js_composer'), 'responsive_max', array(&$this, 'sanitize_responsive_max_callback'), array(&$this, 'responsive_max_callback'));
     $this->addField($tab, false, 'compiled_js_composer_less', array(&$this, 'sanitize_compiled_js_composer_less_callback'), array(&$this, 'compiled_js_composer_less_callback'));
     /**
      * Tab: Element Class names
      */
     $tab = 'element_css';
     $this->addSection($tab);
     $this->addField($tab, __('Row CSS class name', 'js_composer'), 'row_css_class', array(&$this, 'sanitize_row_css_class_callback'), array(&$this, 'row_css_class_callback'));
     $this->addField($tab, __('Columns CSS class names', 'js_composer'), 'column_css_classes', array(&$this, 'sanitize_column_css_classes_callback'), array(&$this, 'column_css_classes_callback'));
     /**
      * Tab: Custom CSS
      */
     $tab = 'custom_css';
     $this->addSection($tab);
     $this->addField($tab, __("Paste your CSS code", "js_composer"), 'custom_css', array(&$this, 'sanitize_custom_css_callback'), array(&$this, 'custom_css_field_callback'));
     /**
      * Custom Tabs
      */
     foreach ($this->getTabs() as $tab => $title) {
         do_action('vc_settings_tab-' . preg_replace('/^vc\\-/', '', $tab), $this);
     }
     /**
      * Tab: Updater
      */
     $tab = 'updater';
     $this->addSection($tab);
     $this->addField($tab, __('Envato Username', 'js_composer'), 'envato_username', array(&$this, 'sanitize_envato_username'), array(&$this, 'envato_username_callback'));
     $this->addField($tab, __('Secret API Key', 'js_composer'), 'envato_api_key', array(&$this, 'sanitize_envato_api_key'), array(&$this, 'envato_api_key_callback'));
     $this->addField($tab, __('Visual Composer License Key', 'js_composer'), 'js_composer_purchase_code', array(&$this, 'sanitize_js_composer_purchase_code'), array(&$this, 'js_composer_purchase_code_callback'));
 }
Esempio n. 4
0
 /**
  * Init settings page && menu item
  */
 public function initAdmin()
 {
     $this->setTabs();
     $this->tabs = apply_filters('vc_settings_tabs', $this->tabs);
     if (!empty($_COOKIE['wpb_js_composer_settings_active_tab']) && isset($this->tabs[str_replace('#vc-settings-', '', $_COOKIE['wpb_js_composer_settings_active_tab'])])) {
         $this->active_tab = str_replace('#vc-settings-', '', $_COOKIE['wpb_js_composer_settings_active_tab']);
     } else {
         if (!empty($_GET['tab']) && isset($this->tabs[$_GET['tab']])) {
             $this->active_tab = $_GET['tab'];
         } elseif (!$this->showConfigurationTabs()) {
             $this->active_tab = 'updater';
         } else {
             $this->active_tab = 'general';
         }
     }
     self::$color_settings = array(array('vc_color' => array('title' => __('Main accent color', LANGUAGE_ZONE))), array('vc_color_hover' => array('title' => __('Hover color', LANGUAGE_ZONE))), array('vc_color_call_to_action_bg' => array('title' => __('Call to action background color', LANGUAGE_ZONE))), array('vc_color_google_maps_bg' => array('title' => __('Google maps background color', LANGUAGE_ZONE))), array('vc_color_post_slider_caption_bg' => array('title' => __('Post slider caption background color', LANGUAGE_ZONE))), array('vc_color_progress_bar_bg' => array('title' => __('Progress bar background color', LANGUAGE_ZONE))), array('vc_color_separator_border' => array('title' => __('Separator border color', LANGUAGE_ZONE))), array('vc_color_tab_bg' => array('title' => __('Tabs navigation background color', LANGUAGE_ZONE))), array('vc_color_tab_bg_active' => array('title' => __('Active tab background color', LANGUAGE_ZONE))));
     self::$defaults = array('vc_color' => '#f7f7f7', 'vc_color_hover' => '#F0F0F0', 'margin' => '35px', 'gutter' => '15', 'responsive_max' => '768');
     $vc_action = !empty($_POST['vc_action']) ? $_POST['vc_action'] : (!empty($_GET['vc_action']) ? $_GET['vc_action'] : '');
     if ($vc_action == 'restore_color') {
         $this->restoreColor();
     } elseif ($vc_action == 'remove_all_css_classes') {
         $this->removeAllCssClasses();
     }
     $this->deactivate = vc_license()->deactivation();
     // TODO: Refactor with separate class.
     /**
      * General Settings
      */
     $tab_prefix = '_general';
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'content_types', array($this, 'sanitize_post_types_callback'));
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'groups_access_rules', array($this, 'sanitize_group_access_rules_callback'));
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'not_responsive_css', array($this, 'sanitize_not_responsive_css_callback'));
     add_settings_section($this->option_group . $tab_prefix, null, array(&$this, 'setting_section_callback_function'), $this->page . $tab_prefix);
     add_settings_field(self::$field_prefix . 'content_types', __("Content types", LANGUAGE_ZONE), array(&$this, 'content_types_field_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix);
     add_settings_field(self::$field_prefix . 'groups_access_rules', __("User groups access rules", LANGUAGE_ZONE), array(&$this, 'groups_access_rules_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix);
     add_settings_field(self::$field_prefix . 'not_responsive_css', __("Disable responsive content elements", LANGUAGE_ZONE), array(&$this, 'not_responsive_css_field_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix);
     /**
      * Color Options
      */
     $tab_prefix = '_color';
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'use_custom', array($this, 'sanitize_use_custom_callback'));
     add_settings_field(self::$field_prefix . 'use_custom', __('Use custom design options', LANGUAGE_ZONE), array(&$this, 'use_custom_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix, array('id' => 'use_custom'));
     // add_action('update_option_'.self::$field_prefix.'use_custom', array(&$this, 'buildCustomColorCss'));
     // add_action('add_option_'.self::$field_prefix.'use_custom', array(&$this, 'buildCustomColorCss'));
     foreach (self::$color_settings as $color_set) {
         foreach ($color_set as $key => $data) {
             register_setting($this->option_group . $tab_prefix, self::$field_prefix . $key, array($this, 'sanitize_color_callback'));
             add_settings_field(self::$field_prefix . $key, $data['title'], array(&$this, 'color_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix, array('id' => $key));
             // add_action('update_option_'.self::$field_prefix.$key, array(&$this, 'buildCustomColorCss'));
             // add_action('add_option_'.self::$field_prefix.$key, array(&$this, 'buildCustomColorCss'));
         }
     }
     // Margin
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'margin', array($this, 'sanitize_margin_callback'));
     add_settings_field(self::$field_prefix . 'margin', __('Elements bottom margin', LANGUAGE_ZONE), array(&$this, 'margin_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix, array('id' => 'margin'));
     // add_action('update_option_'.self::$field_prefix.'margin', array(&$this, 'buildCustomColorCss'));
     // Gutter
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'gutter', array($this, 'sanitize_gutter_callback'));
     add_settings_field(self::$field_prefix . 'gutter', __('Grid gutter width', LANGUAGE_ZONE), array(&$this, 'gutter_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix, array('id' => 'gutter'));
     /// add_action('update_option_'.self::$field_prefix.'gutter', array(&$this, 'buildCustomColorCss'));
     // Responsive max width
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'responsive_max', array($this, 'sanitize_responsive_max_callback'));
     add_settings_field(self::$field_prefix . 'responsive_max', __('Mobile screen width', LANGUAGE_ZONE), array(&$this, 'responsive_max_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix, array('id' => 'responsive_max'));
     // add_action('update_option_'.self::$field_prefix.'responsive_max', array(&$this, 'buildCustomColorCss'));
     add_settings_section($this->option_group . $tab_prefix, null, array(&$this, 'setting_section_callback_function'), $this->page . $tab_prefix);
     /**
      * Element Class names
      */
     $tab_prefix = '_element_css';
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'row_css_class', array($this, 'sanitize_row_css_class_callback'));
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'column_css_classes', array($this, 'sanitize_column_css_classes_callback'));
     add_settings_section($this->option_group . $tab_prefix, null, array(&$this, 'setting_section_callback_function'), $this->page . $tab_prefix);
     add_settings_field(self::$field_prefix . 'row_css_class', "Row CSS class name", array(&$this, 'row_css_class_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix);
     add_settings_field(self::$field_prefix . 'column_css_classes', "Columns CSS class names", array(&$this, 'column_css_classes_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix);
     /**
      * Custom CSS
      */
     $tab_prefix = '_custom_css';
     register_setting($this->option_group . $tab_prefix, self::$field_prefix . 'custom_css', array($this, 'sanitize_custom_css_callback'));
     // add_action('update_option_'.self::$field_prefix.'custom_css', array(&$this, 'buildCustomCss'));
     add_settings_section($this->option_group . $tab_prefix, null, array(&$this, 'setting_section_callback_function'), $this->page . $tab_prefix);
     add_settings_field(self::$field_prefix . 'custom_css', __("Paste your CSS code", LANGUAGE_ZONE), array(&$this, 'custom_css_field_callback'), $this->page . $tab_prefix, $this->option_group . $tab_prefix);
     foreach ($this->tabs as $tab => $title) {
         do_action('vc_settings_tab-' . $tab, $this);
     }
     $tab = 'updater';
     $this->addSection($tab, null, array(&$this, 'setting_section_callback_function'));
     $this->addField($tab, __('Envato Username', LANGUAGE_ZONE), 'envato_username', array(&$this, 'sanitize_envato_username'), array(&$this, 'envato_username_callback'));
     $this->addField($tab, __('Secret API Key', LANGUAGE_ZONE), 'envato_api_key', array(&$this, 'sanitize_envato_api_key'), array(&$this, 'envato_api_key_callback'));
     $this->addField($tab, __('Visual Composer License Key', LANGUAGE_ZONE), 'js_composer_purchase_code', array(&$this, 'sanitize_js_composer_purchase_code'), array(&$this, 'js_composer_purchase_code_callback'));
 }
 /**
  * Get settings data for default templates
  *
  * @return array|mixed|void
  */
 protected function get()
 {
     require_once vc_path_dir('SETTINGS_DIR', 'class-vc-settings.php');
     return ($value = Vc_Settings::get($this->key)) ? $value : array();
 }