private function set_values($values, $reschedule = true)
 {
     fw_set_db_extension_data($this->backup()->get_name(), 'settings', $values);
     if ($reschedule) {
         $this->backup()->cron()->reschedule();
     }
 }
 public function import($fp)
 {
     $json = '';
     while ($line = fgets($fp)) {
         $json .= $line;
     }
     fw_set_db_extension_data('backup', $this->name, json_decode($json, true));
 }
 /**
  * @param $options_before_save
  */
 public function _action_fw_ext_social_facebook_save_options($options_before_save)
 {
     $parent = $this->get_parent()->get_name();
     $response = wp_remote_get(add_query_arg(array('grant_type' => 'client_credentials', 'client_id' => fw_get_db_ext_settings_option($parent, 'facebook-app-id'), 'client_secret' => fw_get_db_ext_settings_option($parent, 'facebook-app-secret')), 'https://graph.facebook.com/oauth/access_token'));
     $body = wp_remote_retrieve_body($response);
     if (strpos($body, 'access_token=') !== false) {
         $token = substr($body, 13);
         fw_set_db_extension_data($this->get_name(), $this->access_token_name, $token);
     } else {
         fw_set_db_extension_data($this->get_name(), $this->access_token_name, false);
     }
 }
 public function export(FW_Backup_Interface_Feedback $feedback)
 {
     /**
      * @var wpdb $wpdb
      */
     global $wpdb;
     $db = new FW_Backup_Export_Database();
     $fs = new FW_Backup_Export_File_System();
     $zip_file = sprintf('%s/backup-demo-install-%s.zip', get_temp_dir(), date('Y_m_d-H_i_s'));
     $tmp_file = array();
     try {
         touch($zip_file);
         $zip = new ZipArchive();
         if ($zip->open($zip_file) !== true) {
             throw new FW_Backup_Exception(__('Could not create .zip file', 'fw'));
         }
         $upload_dir = wp_upload_dir();
         fw_set_db_extension_data($this->backup()->get_name(), 'wp_upload_dir', $upload_dir);
         $upload_dir = $upload_dir['basedir'];
         $stylesheet_dir = get_stylesheet_directory();
         $template_dir = get_template_directory();
         // Do not put auto-install directory which comes with theme into archive
         $exclude = array();
         if ($a = $this->backup()->get_auto_install_dir()) {
             $exclude[] = $a;
         }
         $fs->append_zip($zip, $template_dir, basename($template_dir) . '/', $feedback, $exclude);
         if ($stylesheet_dir != $template_dir) {
             $fs->append_zip($zip, $stylesheet_dir, basename($stylesheet_dir) . '/', $feedback, $exclude);
         }
         $fs->append_zip($zip, $upload_dir, basename($template_dir) . '/auto-install/uploads/', $feedback);
         $options_where = "WHERE option_name NOT LIKE 'fw_backup.%%' AND option_name NOT IN ('ftp_credentials', 'mailserver_url', 'mailserver_login', 'mailserver_pass', 'mailserver_port', 'admin_email')";
         $exclude_table = array($wpdb->users);
         $zip->addFile($tmp_file[] = $db->export_sql($feedback, $options_where, $exclude_table), basename($template_dir) . '/auto-install/database.txt');
         $feedback->set_task(__('Compressing files...', 'fw'));
         $zip->close();
     } catch (FW_Backup_Exception $exception) {
         unset($zip);
         unlink($zip_file);
     }
     array_map('unlink', $tmp_file);
     if (isset($exception)) {
         throw $exception;
     }
     return $zip_file;
 }
 private function set_option($service_id, $key, $value)
 {
     $option_name = $this->get_option_name($service_id, $key);
     $settings = fw_get_db_extension_data($this->get_name(), 'settings');
     $settings[$option_name] = $value;
     fw_set_db_extension_data($this->get_name(), 'settings', $settings);
 }
Пример #6
0
 /**
  * Set some extension's data in database
  *
  * @param string|null $multi_key The key of the data you want to set. null - all data
  * @param mixed $value
  */
 public final function set_db_data($multi_key = null, $value)
 {
     fw_set_db_extension_data($this->get_name(), $multi_key, $value);
 }
 /**
  * Update sitemap.xml file
  */
 public function update_sitemap()
 {
     if (empty($this->sitemap)) {
         return false;
     }
     do_action('fw_ext_seo_sitemap_pre_update');
     $response = $this->sitemap->update_sitemap();
     $options = array('last_sitemap_update' => time());
     fw_set_db_extension_data($this->get_name(), 'last_modif', $options);
     do_action('fw_ext_seo_sitemap_updated');
     return $response;
 }
 /**
  * Triggers when the extension settings are saved,
  * it generates css from the styling settings and stores it
  * @internal
  */
 public function _admin_action_generate_css()
 {
     $theme_options = fw_extract_only_options($this->get_options('appearance-settings'));
     $saved_data = fw_get_db_extension_data($this->get_name(), 'options');
     $css_for_style_options = FW_Styling_Css_Generator::get_css($theme_options, $saved_data);
     fw_set_db_extension_data($this->get_name(), 'css', $css_for_style_options);
 }
 private static function set_storage_items($items)
 {
     fw_set_db_extension_data('builder', 'fullscreen', $items);
 }
 public function import_settings($settings)
 {
     foreach ($settings as $key => $value) {
         fw_set_db_extension_data(fw()->extensions->get('backup')->get_name(), $key, $value);
     }
 }
Пример #11
0
 private static function set_templates($builder_type, $templates)
 {
     fw_set_db_extension_data('builder', 'templates/' . $builder_type, $templates);
 }
 /**
  * @internal
  *
  * @param $data
  *
  * @return mixed
  */
 public function _form_save($data)
 {
     fw_set_db_extension_data($this->get_name(), 'options', fw_get_options_values_from_input($this->get_seo_options()));
     do_action('fw_' . $this->get_name() . '_form_save');
     $data['redirect'] = fw_current_url();
     return $data;
 }
 /**
  * @param $builder_type
  * @param $templates
  */
 private function set_db_templates($builder_type, $templates)
 {
     fw_set_db_extension_data('builder', 'templates:' . $this->get_type() . '/' . $builder_type, $templates);
 }
 /**
  * @internal
  */
 public function _action_ajax_delete_template()
 {
     if (!current_user_can('edit_posts')) {
         wp_send_json_error();
     }
     $builder_type = (string) FW_Request::POST('builder_type');
     if (!$this->builder_type_is_valid($builder_type)) {
         wp_send_json_error();
     }
     $template_id = (string) FW_Request::POST('template_id');
     delete_option($this->get_wp_option_prefix($builder_type) . $template_id);
     $old_templates = fw_get_db_extension_data('builder', 'templates/' . $builder_type, array());
     unset($old_templates[$template_id]);
     fw_set_db_extension_data('builder', 'templates/' . $builder_type, $old_templates);
     unset($old_templates);
     wp_send_json_success();
 }