# 4. save\_settings database (ok)

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MasIW_UM-xExA0akOfZ%2F-MasIuIoh3fUnbkp6dan%2Fimage.png?alt=media\&token=c99524a9-04af-49f1-bd72-0e282e203f09)

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MasIW_UM-xExA0akOfZ%2F-MasIa1NuD6jWy_PfJ25%2Fimage.png?alt=media\&token=3765fa49-8f9f-4065-8b8b-c673cf1d11f4)

wp-content/plugins/lionel-setup-content/admin/class-lionel\_content-settings.php

```
<?php
  class Lionel_Content_Settings
  {
    private $plugin_name;
    private $version;
    private $buffer;
    public function __construct ()
    {

    }
    public function load_page ()
    {
?>
<div class="ecp-grid ecp-col-940 ecp-top-menu" ecp-registered="1">
  <div class="ecp-header-wrapper">
    <div class="ecp-grid ecp-col-700">
      <div class="ecp-header-logo"></div>
      <ul class="ecp-header-menu">
        <li class="ecp-active-tab"><a class="ecp-tab-selector" href="#" data-link="ecp_settings"><span><?php _e('Settings', 'evergreen_content_poster'); ?></span></a></li>
        <li class=""><a class="ecp-tab-selector" href="<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin.php?page=evergreen_content_library" data-link="ecp_content_library"><span><?php _e('Content Library', 'evergreen_content_poster'); ?></span></a></li>
      </ul>
    </div>
    <div class="ecp-grid ecp-col-220 ecp-fit">
      <?php
        wp_nonce_field('evergreen-settings-save', 'evergreen-settings-save');
      ?>
      <button id="save_settings" class="button ecp-navy-button ecp-save-settings" disabled><?php _e('Save Changes', 'evergreen_content_poster'); ?></button>
    </div>
      <div class="ecp-grid ecp-col-940 ecp-top-menu" ecp-registered="1">
          <div class="ecp-grid ecp-col-940 ecp-fit ecp-loading-saving">Saving Settings</div>
          <label class="hidden saving-default">Saving Settings</label>
          <label class="hidden saving-success">Settings Saved!</label>
          <label class="hidden saving-error">There was an error saving your settings. Please try again later.</label>
          <label class="hidden saving-posting-time-success">Successfully added a new posting timeslot</label>
          <label class="hidden saving-posting-time-error">There is an error trying to add this posting timeslot, please try again</label>
          <label class="hidden delete-posting-time-success">Successfully deleted posting timeslot</label>
          <label class="hidden delete-posting-time-error">There is an error trying to delete this posting timeslot, please try again</label>
          <label class="hidden clear-posting-time-success">Successfully cleared posting timeslot</label>
          <label class="hidden clear-posting-time-error">There is an error trying to clear this posting timeslot, please try again</label>
      </div>
    <div class="ecp-clearfix"></div>
  </div>
  <div class="ecp-wrapper">
    <div class="ecp-container">
      <div class="ecp-section">
        <div class="ecp-grid ecp-col-700">
          <form id="ecp_settings_form" method="post" action="<?php echo esc_html (admin_url ('admin-post.php')); ?>">
            <div class="ecp-admin-tab ecp-grid ecp-col-940"
                 style="display: block;">
                <div class="ecp-section ecp-grid ecp-col-940 ecp-fit ecp-option-container ecp-general-settings-title-wrapper">
                    <h2><?php _e('General Settings', 'evergreen_content_poster'); ?></h2>
                </div>
                <div class="ecp-grid ecp-col-940 ecp-option-container ecp-field-setting">
                    <div class="ecp-grid ecp-col-300">
                        <p class="ecp-input-label ecp-label-min-days"><?php _e('Minimum number of days not to repeat the same post', 'evergreen_content_poster'); ?></p>
                        <p class="description"><?php _e('If zero, this won\'t be taken into account and post can be potentially be posted twice on the same day.', 'evergreen_content_poster'); ?></p>
                    </div>
                    <div class="ecp-grid ecp-col-300">
                        <input type="number" name="eg_numberofdays" min="1" max="120" required="true" value="2" class="ecp-admin-input field-setting" data-ref="saved_numberofdays" aria-invalid="false" />
                        <input type="hidden" name="saved_numberofdays" value="1" />
                    </div>
                </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<?php
    }
  }
```

wp-content/plugins/lionel-setup-content/admin/js/lionel\_content-admin.js

```
function toggleSaveSettingSh(on) {
  const saveBtn = document.querySelector('#save_settings');
  saveBtn.setAttribute('disabled', 'disabled');
  saveBtn.classList.remove('ecp-red-button');
  if (on === true) {
    // saveBtn.classList.add = 'ecp-green-button';
    saveBtn.removeAttribute('disabled');
    saveBtn.classList.add('ecp-red-button');
    // document.querySelector('#save_settings').classList.add = 'ecp-green-button';
  }
}
jQuery(document).ready(function( $ ) {
  $('.field-setting').on('change', function () {
    const field = $(this);
    const savedField = field.data('ref');
    field.removeClass('field-updated');
    if (field.val() != $('#' + savedField).val()) {
      field.addClass('field-updated');
    }
    toggleSaveSettingSh(false);
    if ($('.field-updated').length > 0) {
      toggleSaveSettingSh(true);
      field.removeClass('field-updated');
    }
  });
  $('#save_settings').on('click', function() {
    const data = {
      'action': 'save_settings',
      'fields': $('#ecp_settings_form').serialize(),
      'nonce': document.querySelector('#evergreen-settings-save').value
    };
    const saveLoader = document.querySelector('.ecp-loading-saving');
    saveLoader.classList.add('show')
    jQuery.post(
      ajaxSettings.ajaxurl,
      data,
      function (response) {
        if (response.success) {
          setTimeout(function(){
            saveLoader.classList.add('ecp-loading-success');
            saveLoader.innerText = document.querySelector('label.saving-success').innerText;
            toggleSaveSettingSh(false);
          }, 500);
          
          // update all field(s) saved defaults
          toggleSaveSettingSh();
          
        } else {
          saveLoader.innerText = document.querySelector('label.saving-error').innerText;
        }
        setTimeout(function(){
          saveLoader.classList.remove('ecp-loading-success');
          saveLoader.classList.remove('show');
          saveLoader.innerText = document.querySelector('label.saving-default').innerText;
        }, 2000);
      });
  });
});
```

wp-content/plugins/lionel-setup-content/includes/class-lionel\_content.php

```
<?php
  class Lionel_Content
  {
    protected $loader;
    protected $plugin_name;
    protected $version;
    private $plugin_admin;
    private $buffer_service;
    public function __construct ()
    {
      if ( defined( 'LIONEL_CONTENT_PLUGIN_VERSION' ) ) {
        $this->version = LIONEL_CONTENT_PLUGIN_VERSION;
      } else {
        $this->version = '1.0.0';
      }
      $this->plugin_name = 'lionel_content';
      $this->load_dependencies ();
      $this->define_admin_hooks();
    }
    private function load_dependencies ()
    {
      require_once plugin_dir_path (dirname (__FILE__))
        . 'includes/class-lionel_content-loader.php';
      $this->loader = new Lionel_Content_Loader();
      /**
       * Part 3
       */
      require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-lionel_content-admin.php';
    }
    public function get_loader() {
      return $this->loader;
    }
    public function get_plugin_name() {
      return $this->plugin_name;
    }
    public function get_version() {
      return $this->version;
    }
    public static $instance;
    public static function get_instance() {
      if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
        self::$instance = new self;
      }
      return self::$instance;
    }
    public function install() {
      $this->add_lionel_content_defaults();
    }
    public function add_lionel_content_defaults ()
    {
      global $wpdb;
      $options = get_option ('lionel_options');
      if ( !isset($options['lionel_installed']) || $options['lionel_installed'] != 1 || !is_array($options) )
      {
        $opt = array(
          'lionel_version' => LIONEL_CONTENT_PLUGIN_VERSION,
          'lionel_db_version' => LIONEL_CONTENT_DB_VERSION,
          'lionel_installed' => 1,
          'premium' => 0
        );
        if ( is_multisite() )
        {
          update_site_option( 'lionel_options', $opt );
        } else {
          $this->lionel_content_update_option( 'lionel_options', $opt );
        }
      }
      $this->lionel_content_db_install();
    }
    public function lionel_content_update_option( $option_name, $new_value ) {
      if ( get_option( $option_name ) !== false ) {
        // The option already exists, so we just update it.
        update_option( $option_name, $new_value );
      } else {
        // The option hasn't been added yet. We'll add it with $autoload set to 'no'.
        add_option( $option_name, $new_value, $deprecated=null, $autoload='no' );
      }
    }
    public function lionel_content_db_install ()
    {
      global $wpdb;
      $charset_collate = $wpdb->get_charset_collate ();
      $this->lionel_content_set_wpdb_tables ();
      require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
      $sql = "CREATE TABLE IF NOT EXISTS $wpdb->lionel_content_logs (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `post_id` int(11) NOT NULL,
        `action` enum('publish','update','repost','bulk_publish', 'share', 'add_queue') DEFAULT NULL,
        `request_sent` datetime NOT NULL,
        `profile_id` varchar(191) NOT NULL,
        `profile_name` varchar(191) NOT NULL DEFAULT '',
        `result` enum('success','test','pending','warning','error') NOT NULL DEFAULT 'success',
        `result_message` text,
        `status_text` text,
        `status_image` text,
        `status_link` text,
        `status_created_at` datetime DEFAULT NULL,
        `status_due_at` datetime DEFAULT NULL,
        `lionel_posting_schedule` text,
        PRIMARY KEY (`id`),
        KEY `post_id` (`post_id`),
        KEY `action` (`action`),
        KEY `result` (`result`),
        KEY `profile_id` (`profile_id`)
      ) {$charset_collate};";
      dbDelta ($sql);
      $sqlCate = "CREATE TABLE IF NOT EXISTS $wpdb->lionel_categories (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `name` varchar(191) NOT NULL DEFAULT '',
        `description` text,
        `random_availability` int(1) NOT NULL DEFAULT 1,
        `status` int(1) NOT NULL DEFAULT 1,
        `is_default` int(1) DEFAULT NULL,
        `created_at` datetime DEFAULT NULL,
        `updated_at` datetime DEFAULT NULL,
        PRIMARY KEY (`id`)
      ) {$charset_collate};";
      dbDelta ($sqlCate);
      // Check categories
      $categories = $wpdb->get_results("SELECT * FROM {$wpdb->lionel_categories}");
      if(empty((array)$categories)) {
        // add default Category
				$dateNow	=	date(	'Y-m-d H:i:s'	);
				 $insertSql = "INSERT INTO ({$wpdb->lionel_categories})(name, description, random_availability, status, is_default, created_at, updated_at) VALUES ('Your evergreen content', 'Use this category to promote your own content - share any blog posts or pages you publish.', 1, 1, 1, '$dateNow', null), ('Promotional', 'Use this category to promote your services/products. Make sure to include Calls To Actions (CTAs) like \"Book a call with us\" or \"start a trial account\".', 1, 1, 0, '$dateNow', null), ('Quotes, Questions, and Fun', 'Use this category to generate engagement on your socials. Share inspirational or fun quotes, from your niche or create open questions for your audience.', 1, 1, 0, '$dateNow', null)";
        dbDelta($insertSql);
      }
    }
    public function lionel_content_set_wpdb_tables()
    {
      global $wpdb;
      $wpdb->lionel_content_logs = $wpdb->prefix . 'lionel_content_logs';
      $wpdb->lionel_categories = $wpdb->prefix . 'lionel_categories';
    }
    public function run ()
    {
      $this->loader->run();
    }
    /**
     * Part 4
     */
    private function define_admin_hooks ()
    {
      $plugin_admin = new Lionel_Content_Admin($this->get_plugin_name (),
        $this->get_version ());
      $this->plugin_admin = $plugin_admin;
      $this->loader->add_action( 'admin_menu', $plugin_admin, 'lionel_content_admin_menu' );
      $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
      $this->loader->add_action('admin_enqueue_scripts', $plugin_admin,
        'enqueue_scripts');
      $this->loader->add_action( 'wp_ajax_nopriv_save_settings', $plugin_admin, 'save_settings' );
      $this->loader->add_action( 'wp_ajax_save_settings', $plugin_admin, 'save_settings' );
    }
  }
```

wp-content/plugins/lionel-setup-content/admin/class-lionel\_content-admin.php

```
<?php
  class Lionel_Content_Admin
  {
    private $plugin_name;
    private $version;
    private $plugin_public_name;
    private $service;
    private $client_id;
    private $settings;
    private $buffer_service;
    public function __construct ($plugin_name, $version)
    {
      $this->plugin_name = $plugin_name;
      $this->version = $version;
      $this->plugin_public_name = 'Lionel Content';
      $this->service = 'Buffer';
      $this->load_dependencies();
    }
    public function enqueue_styles ()
    {
      if (LIONEL_CONTENT_ENABLE_DEBUG == true) :
        wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/lionel_content-admin.css', array(), time(), 'all');
      else :
        wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/lionel_content-admin.css', array(), $this->version, 'all');
      endif;
    }
    public function enqueue_scripts ()
    {
      if (LIONEL_CONTENT_ENABLE_DEBUG == true) :
        wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/lionel_content-admin.js', array('jquery'), time(), false);
        // set variables for script
        wp_localize_script($this->plugin_name, 'ajaxSettings', array('ajaxurl' => admin_url('admin-ajax.php')));
      else :
        wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/lionel_content-admin.js', array('jquery'), $this->version, false);
        // set variables for script
        wp_localize_script($this->plugin_name, 'ajaxSettings', array('ajaxurl' => admin_url('admin-ajax.php')));
      endif;
    }
    public function load_dependencies ()
    {
			require_once	plugin_dir_path(	dirname(	__FILE__	)	)
										.	'includes/class-lionel_content_buffer.php';
	    $this->buffer_service = new Lionel_Content_Buffer();
			 require_once plugin_dir_path(dirname(__FILE__))
        . 'admin/class-lionel_content-settings.php';
      $this->settings = new Lionel_Content_Settings();
    }
    public function lionel_content_admin_menu ()
    {
      if (!is_user_logged_in()) {
        return;
      }
      add_menu_page(
        __('Evergreen Content', 'evergreen_content_poster'),
'Evergreen Content',
        'edit_posts',
        'lionel_content_settings',
        array($this, 'lionel_content_settings_page'),
        'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDEzIiBoZWlnaHQ9IjUyNCIgdmlld0JveD0iMCAwIDQxMyA1MjQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMzk2LjU2NiAyNDYuODQ1QzQwNy4zNTkgMjcyLjA4OSA0MTIuNzU2IDI5OC41MyA0MTIuNzU2IDMyNi4xNjlDNDEyLjc1NiAzNTMuODA3IDQwNy4zNTkgMzgwLjI0OSAzOTYuNTY2IDQwNS40OTNDMzg2LjE0MiA0MjkuODc1IDM3MS40MjggNDUxLjQ2NyAzNTIuNDIyIDQ3MC4yNjlDMzQ4LjM5IDQ3NC4yNTggMzQ0LjIzMSA0NzguMDU2IDMzOS45NDUgNDgxLjY2M0wzNDAuNzIxIDQ3MS40MjJMMzQwLjg2IDQ2OS41ODZDMzQyLjczMyA0NjcuODY4IDM0NC41NzkgNDY2LjEwOSAzNDYuMzk4IDQ2NC4zMDlDMzY0LjYxOSA0NDYuMjgxIDM3OC43MjYgNDI1LjU4MiAzODguNzE4IDQwMi4yMUMzOTkuMDYyIDM3OC4wMTUgNDA0LjIzNCAzNTIuNjY4IDQwNC4yMzQgMzI2LjE2OUM0MDQuMjM0IDI5OS42NzEgMzk5LjA2MiAyNzQuMzI0IDM4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5Mi4yNDIgNDA2Ljc5MyAxOTMuMjE1IDQwNS4zOTUgMTkzLjE5MyA0MDMuNzY3QzE5My4xMyAzOTkuMzQ1IDE5My41NTggMzk0LjkyNiAxOTQuNDM4IDM5MC41NjZDMjAwLjE2MyAzOTIuODk0IDIwNi43OTQgMzkyLjUzIDIxMi4zNTYgMzkwLjQzMkMyMjMuNzkzIDM4Ni4xMTkgMjMwLjg1MSAzNzMuMTA2IDIyNy4xNyAzNjEuMTYyTDIyNy4xNzYgMzYxLjE3N0MyMjQuMjM2IDM1Mi40NyAyMjUuMDM4IDM0My4zMTcgMjI4LjU5NiAzMzUuNzI5QzIyOS40OTQgMzMzLjgxNiAyMjcuOTA3IDMzMy40MzMgMjI3LjA0OSAzMzMuMjg4QzIyMC41NzYgMzMyLjE5MSAyMTMuMTU3IDMzMi44ODUgMjA1Ljc4OCAzMzUuNjY1QzE4OS4xOTEgMzQxLjkyNiAxNzkuOTk0IDM1NC4yODMgMTgxLjIwNyAzNjkuMzAzQzE4MS41NDkgMzczLjY4NyAxODIuNTA5IDM3Ny4zMzkgMTgzLjkyIDM4MC4zNDdaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNMzQ5LjIxIDcuOTYzMzhMMjk0LjUyNiAxMjguNTQzTDM0MS42NjcgMTI4LjU0M0wzOTQuMjUzIDcuOTYzMzhMMzQ5LjIxIDcuOTYzMzhaIiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjE1IiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPgo='
      );
    }
    public function lionel_content_settings_page()
    {
      $this->settings->load_page();
    }
    public function save_settings()
    {
      if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        wp_send_json_error();
      }
      $updated_fields = [];
			$fields_array	=	explode(	'&',	$_POST['fields']	);
			//	array (
			//		0 => 'eg_numberofdays=3',
			//    1 => 'saved_numberofdays=1',
			//  )
			 foreach ($fields_array as $value) {
        list($field_key, $field_val) = explode('=', $value); // eg_numberofdays=4
        if (stripos($field_key, 'saved_') === true) continue;
				 $updated_fields[$field_key] = urldecode($field_val);
				}
	    // Save  settings
	    $updated_fields['utm_tags'] = isset($updated_fields['utm_tags']) ? $updated_fields['utm_tags'] : 'N';
      if (!$this->buffer_service->save_settings($updated_fields)) wp_send_json_error();
	    wp_send_json_success(__('Buffer Settings have been saved successfully!', 'evergreen_content_poster'));
		 }
  }
```

wp-content/plugins/lionel-setup-content/includes/class-lionel\_content\_buffer.php

```
<?php
  class Lionel_Content_Buffer
  {
	  private $option_general_settings = LIONEL_CONTENT_KEY_PREFIX . '_general_settings';
	  public function save_settings($settings) {
		  if ( ! current_user_can( 'manage_options' ) ) {
			  return false;
		  }
		  if ( empty($settings) ) {
			  return false;
		  }
		  $success = update_option( $this->option_general_settings, $settings );
		  return $success;
	  }
	 }

```

Full code

{% file src="https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MasSmGnce4KG3F6bX1z%2F-MasSz17f3_0CSuZVNM0%2Flionel-setup-content.zip?alt=media&token=782f5ea9-bda8-4f86-8023-2dc6ddad5fbf" %}
