/**
  * @inheritdoc
  *
  * @param array $arguments
  */
 public function process_call($arguments)
 {
     $am = $this->get_am();
     $am->ajax_begin(array('nonce' => $am->get_action_js_name(Types_Ajax::CALLBACK_SETTINGS_ACTION)));
     $setting = sanitize_text_field(wpcf_getpost('setting'));
     $setting_value = wpcf_getpost('setting_value');
     if (!is_array($setting_value)) {
         parse_str($setting_value, $setting_value);
         $setting_value = array_pop($setting_value);
     }
     $sanitized_value = array();
     foreach ($setting_value as $key => $value) {
         $sanitized_key = sanitize_title($key);
         $sanitized_value[$sanitized_key] = sanitize_text_field($value);
     }
     // use toolset settings if available
     if (class_exists('Toolset_Settings') && method_exists('Toolset_Settings', 'get_instance')) {
         $toolset_settings = Toolset_Settings::get_instance();
         if (method_exists($toolset_settings, 'save')) {
             $toolset_settings[$setting] = $sanitized_value;
             $toolset_settings->save();
             $am->ajax_finish('success', true);
         }
     } else {
         update_option($setting, $sanitized_value);
         $am->ajax_finish('success', true);
     }
     // default toolset setting error will be used
     // todo throw specific error
     $am->ajax_finish(array('error'), false);
 }
Ejemplo n.º 2
0
 public function get_stored_value(Types_Setting_Interface $setting)
 {
     if ($this->stored_value === null) {
         if (class_exists('Toolset_Settings') && method_exists('Toolset_Settings', 'get_instance')) {
             $toolset_settings = Toolset_Settings::get_instance();
             $full_setting = $toolset_settings->get($setting->get_id());
         } else {
             $full_setting = get_option($setting->get_id());
         }
         $value = isset($full_setting[$this->get_id()]) ? $full_setting[$this->get_id()] : $this->default;
         $this->stored_value = $value;
     }
     return $this->stored_value;
 }
Ejemplo n.º 3
0
 public function register_inc()
 {
     $sections_loaded = self::$sections_loaded;
     if (!in_array('toolset_inc', $sections_loaded)) {
         $sections_loaded[] = 'toolset_inc';
         if (!class_exists('Toolset_Settings')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.class.php';
             $this->settings = Toolset_Settings::get_instance();
         }
         if (!class_exists('Toolset_Localization')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.localization.class.php';
             $this->localization = new Toolset_Localization();
         }
         if (!class_exists('Toolset_WPLogger')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wplogger.class.php';
         }
         if (!class_exists('Toolset_Object_Relationship')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.object.relationship.class.php';
             $this->object_relationship = Toolset_Object_Relationship::get_instance();
         }
         if (!class_exists('Toolset_Settings_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.screen.class.php';
             $this->settings_screen = new Toolset_Settings_Screen();
         }
         if (!class_exists('Toolset_Export_Import_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.export.import.screen.class.php';
             $this->export_import_screen = new Toolset_Export_Import_Screen();
         }
         if (!class_exists('Toolset_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.menu.class.php';
             $this->menu = new Toolset_Menu();
         }
         if (!class_exists('Toolset_Promotion')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.promotion.class.php';
             $this->promotion = new Toolset_Promotion();
         }
         if (!class_exists('Toolset_Admin_Bar_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.admin.bar.menu.class.php';
             global $toolset_admin_bar_menu;
             $toolset_admin_bar_menu = Toolset_Admin_Bar_Menu::get_instance();
         }
         if (!class_exists('Toolset_WPML_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wpml.compatibility.class.php';
             $this->wpml_compatibility = new Toolset_WPML_Compatibility();
         }
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.compatibility.php';
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.function.helpers.php';
         require_once TOOLSET_COMMON_PATH . '/deprecated.php';
         self::$sections_loaded = $sections_loaded;
     }
 }
 /**
  * Update the stored data once a fields group has been saved.
  *
  * @param $group_id	string	The ID of the group being saved.
  *
  * @since 2.2
  */
 function types_store_fields_on_group_save($group_id)
 {
     if (empty($this->pending_to_add) && empty($this->pending_to_remove)) {
         return;
     }
     $relevanssi_fields_to_remove = array();
     $relevanssi_fields_changed = false;
     $toolset_settings = Toolset_Settings::get_instance();
     $relevanssi_fields_to_index = isset($toolset_settings['relevanssi_fields_to_index']) ? $toolset_settings['relevanssi_fields_to_index'] : array();
     // Note that the 'refresh' argument is temporary and will not me needed much longer
     $args = array('domain' => 'posts', 'field_type' => array('textfield', 'textarea', 'wysiwyg'), 'group_id' => $group_id, 'refresh' => true);
     // https://onthegosystems.myjetbrains.com/youtrack/issue/types-742
     $group_fields = apply_filters('types_filter_query_field_definitions', array(), $args);
     foreach ($group_fields as $field) {
         if (in_array($field['slug'], $this->pending_to_add)) {
             $real_custom_field_name = wpcf_types_get_meta_prefix($field) . $field['slug'];
             if (!in_array($real_custom_field_name, $relevanssi_fields_to_index)) {
                 $relevanssi_fields_to_index[] = $real_custom_field_name;
                 $relevanssi_fields_changed = true;
             }
         }
         if (in_array($field['slug'], $this->pending_to_remove)) {
             $real_custom_field_name = wpcf_types_get_meta_prefix($field) . $field['slug'];
             if (in_array($real_custom_field_name, $relevanssi_fields_to_index)) {
                 $relevanssi_fields_to_remove[] = $real_custom_field_name;
                 $relevanssi_fields_changed = true;
             }
         }
     }
     if (count($relevanssi_fields_to_remove) > 0) {
         $relevanssi_fields_to_index = array_diff($relevanssi_fields_to_index, $relevanssi_fields_to_remove);
         $relevanssi_fields_to_index = is_array($relevanssi_fields_to_index) ? array_values($relevanssi_fields_to_index) : array();
     }
     if ($relevanssi_fields_changed) {
         $toolset_settings->relevanssi_fields_to_index = $relevanssi_fields_to_index;
         $toolset_settings->save();
     }
 }
 function toolset_update_toolset_admin_bar_options()
 {
     $toolset_options = Toolset_Settings::get_instance();
     if (!current_user_can('manage_options')) {
         $data = array('type' => 'capability', 'message' => __('You do not have permissions for that.', 'wpv-views'));
         wp_send_json_error($data);
     }
     if (!isset($_POST["wpnonce"]) || !wp_verify_nonce($_POST["wpnonce"], 'toolset_admin_bar_settings_nonce')) {
         $data = array('type' => 'nonce', 'message' => __('Your security credentials have expired. Please reload the page to get new ones.', 'wpv-views'));
         wp_send_json_error($data);
     }
     $frontend = isset($_POST['frontend']) ? sanitize_text_field($_POST['frontend']) : 'true';
     $backend = wpv_getpost('backend', null, array('disable', 'editor', 'always'));
     if (null != $backend) {
         $toolset_options['shortcodes_generator'] = $backend;
     }
     $toolset_options['show_admin_bar_shortcut'] = $frontend == 'true' ? 'on' : 'off';
     $toolset_options->save();
     wp_send_json_success();
 }
Ejemplo n.º 6
0
 public function register_inc()
 {
     if (!$this->is_section_loaded(self::TOOLSET_INCLUDES)) {
         $this->add_section_loaded(self::TOOLSET_INCLUDES);
         if (!class_exists('Toolset_Settings')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.class.php';
             $this->settings = Toolset_Settings::get_instance();
         }
         if (!class_exists('Toolset_Localization')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.localization.class.php';
             $this->localization = new Toolset_Localization();
         }
         if (!class_exists('Toolset_WPLogger')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wplogger.class.php';
         }
         if (!class_exists('Toolset_Object_Relationship')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.object.relationship.class.php';
             $this->object_relationship = Toolset_Object_Relationship::get_instance();
         }
         if (!class_exists('Toolset_Settings_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.screen.class.php';
             $this->settings_screen = new Toolset_Settings_Screen();
         }
         if (!class_exists('Toolset_Export_Import_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.export.import.screen.class.php';
             $this->export_import_screen = new Toolset_Export_Import_Screen();
         }
         if (!class_exists('Toolset_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.menu.class.php';
             $this->menu = new Toolset_Menu();
         }
         if (!class_exists('Toolset_Promotion')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.promotion.class.php';
             $this->promotion = new Toolset_Promotion();
         }
         if (!class_exists('Toolset_Admin_Bar_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.admin.bar.menu.class.php';
             global $toolset_admin_bar_menu;
             $toolset_admin_bar_menu = Toolset_Admin_Bar_Menu::get_instance();
         }
         if (!class_exists('Toolset_Internal_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.internal.compatibility.class.php';
             $this->internal_compatibility = new Toolset_Internal_Compatibility();
         }
         if (!class_exists('Toolset_WPML_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wpml.compatibility.class.php';
             $this->wpml_compatibility = new Toolset_WPML_Compatibility();
         }
         if (!class_exists('Toolset_Relevanssi_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.relevanssi.compatibility.class.php';
             $this->relevanssi_compatibility = new Toolset_Relevanssi_Compatibility();
         }
         if (!class_exists('Toolset_CssComponent')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.css.component.class.php';
             $toolset_bs_component = Toolset_CssComponent::getInstance();
         }
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.compatibility.php';
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.function.helpers.php';
         require_once TOOLSET_COMMON_PATH . '/deprecated.php';
         $this->apply_filters_on_sections_loaded('toolset_register_include_section');
     }
 }