Initial Commit

This commit is contained in:
David Stone
2024-11-30 18:24:12 -07:00
commit e8f7955c1c
5432 changed files with 1397750 additions and 0 deletions

View File

@ -0,0 +1,113 @@
<?php
/**
* Class used for querying forms.
*
* @package WP_Ultimo
* @subpackage Database\Checkout_Forms
* @since 2.0.0
*/
namespace WP_Ultimo\Database\Checkout_Forms;
use WP_Ultimo\Database\Engine\Query;
// Exit if accessed directly
defined('ABSPATH') || exit;
/**
* Class used for querying forms.
*
* @since 2.0.0
*/
class Checkout_Form_Query extends Query {
/** Table Properties ******************************************************/
/**
* Name of the database table to query.
*
* @since 2.0.0
* @access public
* @var string
*/
protected $table_name = 'forms';
/**
* String used to alias the database table in MySQL statement.
*
* @since 2.0.0
* @access public
* @var string
*/
protected $table_alias = 'f';
/**
* Name of class used to setup the database schema
*
* @since 2.0.0
* @access public
* @var string
*/
protected $table_schema = '\\WP_Ultimo\\Database\\Checkout_Forms\\Checkout_Forms_Schema';
/** Item ******************************************************************/
/**
* Name for a single item
*
* @since 2.0.0
* @access public
* @var string
*/
protected $item_name = 'form';
/**
* Plural version for a group of items.
*
* @since 2.0.0
* @access public
* @var string
*/
protected $item_name_plural = 'forms';
/**
* Callback function for turning IDs into objects
*
* @since 2.0.0
* @access public
* @var mixed
*/
protected $item_shape = '\\WP_Ultimo\\Models\\Checkout_Form';
/**
* Group to cache queries and queried items in.
*
* @since 2.0.0
* @access public
* @var string
*/
protected $cache_group = 'forms';
/**
* If we should use a global cache group.
*
* @since 2.1.2
* @var bool
*/
protected $global_cache = true;
/**
* Sets up the customer query, based on the query vars passed.
*
* @since 2.0.0
* @access public
*
* @param string|array $query Array of query arguments.
*/
public function __construct($query = array()) {
parent::__construct($query);
} // end __construct;
} // end class Checkout_Form_Query;

View File

@ -0,0 +1,82 @@
<?php
/**
* Class used for querying forms' meta data.
*
* @package WP_Ultimo
* @subpackage Database\Checkout_Forms
* @since 2.0.0
*/
namespace WP_Ultimo\Database\Checkout_Forms;
use WP_Ultimo\Database\Engine\Table;
// Exit if accessed directly
defined('ABSPATH') || exit;
/**
* Setup the "wu_formmeta" database table
*
* @since 2.0.0
*/
final class Checkout_Forms_Meta_Table extends Table {
/**
* Table name
*
* @since 2.0.0
* @var string
*/
protected $name = 'formmeta';
/**
* Is this table global?
*
* @since 2.0.0
* @var boolean
*/
protected $global = true;
/**
* Table current version
*
* @since 2.0.0
* @var string
*/
protected $version = '2.0.0';
/**
* Posts constructor.
*
* @access public
* @since 2.0.0
* @return void
*/
public function __construct() {
parent::__construct();
} // end __construct;
/**
* Setup the database schema
*
* @access protected
* @since 2.0.0
* @return void
*/
protected function set_schema() {
$max_index_length = 191;
$this->schema = "meta_id bigint(20) unsigned NOT NULL auto_increment,
wu_form_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) DEFAULT NULL,
meta_value longtext DEFAULT NULL,
PRIMARY KEY (meta_id),
KEY wu_form_id (wu_form_id),
KEY meta_key (meta_key({$max_index_length}))";
} // end set_schema;
} // end class Checkout_Forms_Meta_Table;

View File

@ -0,0 +1,114 @@
<?php
/**
* Checkout_Form schema class
*
* @package WP_Ultimo
* @subpackage Database\Checkout_Forms
* @since 2.0.0
*/
namespace WP_Ultimo\Database\Checkout_Forms;
use WP_Ultimo\Database\Engine\Schema;
// Exit if accessed directly
defined('ABSPATH') || exit;
/**
* Checkout_Forms Schema Class.
*
* @since 2.0.0
*/
class Checkout_Forms_Schema extends Schema {
/**
* Array of database column objects
*
* @since 2.0.0
* @access public
* @var array
*/
public $columns = array(
array(
'name' => 'id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'extra' => 'auto_increment',
'primary' => true,
'sortable' => true,
),
array(
'name' => 'name',
'type' => 'varchar',
'searchable' => true,
'sortable' => true,
'transition' => true,
),
array(
'name' => 'slug',
'type' => 'tinytext',
'default' => '',
'searchable' => true,
'sortable' => true,
'transition' => true,
),
array(
'name' => 'active',
'type' => 'tinyint',
'length' => '4',
'unsigned' => true,
'default' => 1,
'transition' => true,
'sortable' => true,
),
array(
'name' => 'settings',
'type' => 'longtext',
'default' => '',
'transition' => true,
'allow_null' => false,
),
array(
'name' => 'custom_css',
'type' => 'longtext',
'default' => '',
'allow_null' => true,
),
array(
'name' => 'allowed_countries',
'type' => 'text',
'default' => '',
'allow_null' => true,
),
array(
'name' => 'date_created',
'type' => 'datetime',
'default' => null,
'created' => true,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
array(
'name' => 'date_modified',
'type' => 'datetime',
'default' => null,
'modified' => true,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
);
} // end class Checkout_Forms_Schema;

View File

@ -0,0 +1,121 @@
<?php
/**
* Class used for querying events.
*
* @package WP_Ultimo
* @subpackage Database\Event
* @since 2.0.0
*/
namespace WP_Ultimo\Database\Checkout_Forms;
use WP_Ultimo\Database\Engine\Table;
// Exit if accessed directly
defined('ABSPATH') || exit;
/**
* Setup the "wu_events" database table
*
* @since 2.0.0
*/
final class Checkout_Forms_Table extends Table {
/**
* Table name
*
* @since 2.0.0
* @var string
*/
protected $name = 'forms';
/**
* Is this table global?
*
* @since 2.0.0
* @var boolean
*/
protected $global = true;
/**
* Table current version
*
* @since 2.0.0
* @var string
*/
protected $version = '2.0.1-revision.20230601';
/**
* List of table upgrades.
*
* @var array
*/
protected $upgrades = array(
'2.0.1-revision.20230601' => 20_230_601,
);
/**
* Event constructor.
*
* @access public
* @since 2.0.0
* @return void
*/
public function __construct() {
parent::__construct();
} // end __construct;
/**
* Setup the database schema
*
* @access protected
* @since 2.0.0
* @return void
*/
protected function set_schema() {
$this->schema = "id bigint(20) NOT NULL auto_increment,
name tinytext NOT NULL DEFAULT '',
slug varchar(255),
active tinyint(4) default 1,
settings longtext DEFAULT NULL,
custom_css longtext DEFAULT NULL,
allowed_countries text DEFAULT NULL,
date_created datetime DEFAULT NULL,
date_modified datetime DEFAULT NULL,
PRIMARY KEY (id)";
} // end set_schema;
/**
* Fixes the datetime columns to accept null.
*
* @since 2.1.2
*/
protected function __20230601(): bool {
$null_columns = array(
'date_created',
'date_modified',
);
foreach ($null_columns as $column) {
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
if (!$this->is_success($result)) {
return false;
} // end if;
} // end foreach;
return true;
} // end __20230601;
} // end class Checkout_Forms_Table;