/** * Assign sliders to dynamic areas */ public function slider_to_area() { $action = $this->get_action_data('assign_to_area'); check_ajax_referer($action['nonce']['action'], $action['nonce']['name']); if (!current_user_can('edit_fa_items')) { wp_die(-1); } if (!isset($_POST['areas'])) { wp_die(-1); } $settings = fa_get_options('hooks'); foreach ($_POST['areas'] as $area => $sliders) { // if area isn't found in stored areas, skip it if (!array_key_exists($area, $settings)) { continue; } $result = array(); // empty the area if nothing is set if (empty($sliders)) { $settigs[$area]['sliders'] = $result; } $sliders = explode(',', $sliders); foreach ($sliders as $slider) { $slider_id = absint(str_replace('fa_slider-', '', $slider)); $result[] = $slider_id; } $settings[$area]['sliders'] = $result; } fa_update_options('hooks', $settings); die; }
/** * Plugin activation hook callback function */ public function on_activation() { // give full access to administrators on plugin activation parent::set_capabilities(); $this->allow_admins(); // get the current option $option = fa_get_options('plugin_details'); // set the current plugin details $plugin_details = array('version' => FA_VERSION, 'wp_version' => get_bloginfo('version'), 'activated_on' => current_time('mysql')); /** * Action on plugin activation that allows maintenance related actions. * * @param $option - current option stored in plugin settings * @param $plugin_details - the new option that is going to be saved */ do_action('fa_pro_activation', $option, $plugin_details); // update the option fa_update_options('plugin_details', $plugin_details); // pre 3.0 plugin options verification $old_options = get_option('fa_plugin_details', array()); $updated = fa_get_options('updated'); if ($old_options && !version_compare($updated['to'], '3.0', '>=')) { $this->on_init(); include_once fa_get_path('includes/libs/class-fa-update.php'); new FA_Update(); // flag plugin as updated to prevent update from running again if previous plugin version reactivated fa_update_options('updated', array('from' => $old_options['version'], 'to' => FA_VERSION)); } }
/** * Set sliders that should auto display on hooks */ private function store_auto_displays() { if ($this->auto_display) { $option = fa_get_options('hooks'); foreach ($this->auto_display as $hook => $sliders) { if (array_key_exists($hook, $option)) { $option[$hook]['sliders'] = $sliders; } } fa_update_options('hooks', $option); } }
/** * Callback function on settings page load */ public function on_page_settings_load() { if (isset($_POST['fa_nonce']) && check_admin_referer('fapro_save_settings', 'fa_nonce')) { if (!current_user_can('manage_options')) { wp_die(__('Sorry, you are not allowed to do this.', 'fapro'), __('Access denied', 'fapro')); } // update general settings $result = fa_update_options('settings', $_POST); if (is_wp_error($result)) { $this->errors = $result; } if (is_wp_error($result)) { $this->errors = $result; } $this->save_caps(); if (!$this->errors && !is_wp_error($this->errors)) { $url = add_query_arg(array('message' => 801), html_entity_decode(menu_page_url('fapro_settings', false))); wp_redirect($url); die; } } fa_load_template_style('settings'); fa_load_admin_script('tabs', array('jquery', 'jquery-ui-tabs')); }