Desc: Database Object to contain Preset Objects to be * saved to the database.

* * @package APLPresetDbObj * @since 0.1.0 * */ class APLPresetDbObj { /** * @var string * @since 0.1.0 */ var $_preset_db_name; /** * @var array(APLPresetObj()) * @since 0.1.0 */ var $_preset_db; /** * @var string * @since 0.1.0 */ var $_delete; /** *

Desc: Loads Preset Database Option data. If no data * exists with the same name, then a new database * options is created and saved to the developer's * WordPress database.

* @param string $db_name * * @since 0.1.0 * @uses $this->option_load_db() * @uses $this->set_to_defaults() * @uses $this->options_save_db(); * * @tutorial *
    *
  1. Store Preset_Database-Name to * $this->Preset_Database-Name.
  2. *
  3. Load 'Preset DbOptions' values, if any then * skip Steps 3-4.
  4. *
  5. Set (this) values to default values.
  6. *
  7. Save 'Preset DbOptions.
  8. *
*/ function __construct($db_name) { //Step 1 $this->_preset_db_name = 'APL_preset_db-' . $db_name; //Step 2 $this->option_load_db(); //If data doesn't exist in options, then make one if (empty($this->_preset_db) && empty($this->_delete)) { //Step 3 $this->set_to_defaults(); //Step 4 $this->options_save_db(); //$this->option_load_db(); } } /** *

Desc: Loads and stores database values to * (this) class values.

* @param none * * @since 0.1.0 * * @tutorial *
    *
  1. Get 'Preset DbOptions with the value stored in * the class varible _preset_db_name.
  2. *
  3. Store database varible to class values (_preset_db & _delete).
  4. *
*/ function option_load_db() { //Step 1 $DBOptions = get_option($this->_preset_db_name); //Step 2 $this->_preset_db = $DBOptions->_preset_db; $this->_delete = $DBOptions->_delete; } /** *

Desc: Saves (this) class object to the developer's * WordPress database.

* @param none * * @since 0.1.0 * * @tutorial *
    *
  1. Save (this) class object to database.
  2. *
*/ function options_save_db() { //Step 1 update_option($this->_preset_db_name, $this); } // function options_save_db($newOptions) // { // // //$this->_option_db_name = 'APL_option_db_'.$db_name; // //$this->update_options_db(); // if (isset($newOptions)) // { // $this->_preset_db = $newOptions->_preset_db; // update_option($newOptions->_preset_db_name, $newOptions); // } // // } /** *

Desc: Deletes the 'Preset Database Options' that is * stored in the devoloper's WordPress database.

* @param none * * @since 0.1.0 * * @tutorial *
    *
  1. Delete Options with the same Preset Db Options name.
  2. *
*/ function options_remove_db() { //Step 1 delete_option($this->_preset_db_name); } /** *

Desc:

* @param none * @return string - returns a JSON string of the Standard Class * * @since 0.1.0 * * @tutorial *
    *
  1. Set delete to 'true'.
  2. *
  3. Create a temp Preset (stdclass). Hardcoded as a JSON string.
  4. *
  5. JSON Decode and store in (this) class _preset_db value.
  6. *
  7. *
  8. *
  9. *
  10. *
  11. *
  12. *
*/ function set_to_defaults() { $this->_preset_db = new stdClass(); //$this->_preset_db = array(); //Step 1 $this->_delete = 'true'; //Step 2 $tmpPreset = (string) '{"pageContentDivided_5":{ "_before":"

", "_content":"[post_title]<\/a> by [post_author] - [post_date][post_content]", "_after":"<\/p>", "_catsSelected":"", "_tagsSelected":"", "_catsInclude":"false", "_tagsInclude":"false", "_catsRequired":"false", "_tagsRequired":"false", "_listOrder":"DESC", "_listOrderBy":"post_date", "_listAmount":"5", "_postType":"post", "_postParent":"None", "_postExcludeCurrent":"true" }, "postExcerptDivided_5":{ "_before":"

", "_content":"[post_title]<\/a> by [post_author] - [post_date][post_excerpt]", "_after":"<\/p>", "_catsSelected":"", "_tagsSelected":"", "_catsInclude":"false", "_tagsInclude":"false", "_catsRequired":"false", "_tagsRequired":"false", "_listOrder":"DESC", "_listOrderBy":"post_date", "_listAmount":"5", "_postType":"post", "_postParent":"None", "_postExcludeCurrent":"true" }, "simpleAttachmentList_10":{ "_before":"