Use new code style
This commit is contained in:
@ -78,7 +78,5 @@ class Broadcast_Query extends Post_Query {
|
||||
$query['type__in'] = array('broadcast_email', 'broadcast_notice');
|
||||
|
||||
return parent::query($query);
|
||||
|
||||
} // end query;
|
||||
|
||||
} // end class Broadcast_Query;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Checkout_Form_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Checkout_Form_Query;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Checkout_Forms_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'formmeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Checkout_Forms_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Checkout_Forms_Meta_Table extends Table {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -110,5 +110,4 @@ class Checkout_Forms_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Checkout_Forms_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Checkout_Forms_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'forms';
|
||||
|
||||
/**
|
||||
@ -64,8 +64,7 @@ final class Checkout_Forms_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -86,8 +85,7 @@ final class Checkout_Forms_Table extends Table {
|
||||
date_created datetime DEFAULT NULL,
|
||||
date_modified datetime DEFAULT NULL,
|
||||
PRIMARY KEY (id)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -101,21 +99,15 @@ final class Checkout_Forms_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Checkout_Forms_Table;
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,5 @@ class Customer_Query extends Query {
|
||||
// $query['type'] = 'customer';
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Customer_Query;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Customers_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'customermeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Customers_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Customers_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_customer_id (wu_customer_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Customers_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -129,5 +129,4 @@ class Customers_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Customers_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Customers_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'customers';
|
||||
|
||||
/**
|
||||
@ -66,8 +66,7 @@ final class Customers_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -91,8 +90,7 @@ final class Customers_Table extends Table {
|
||||
signup_form varchar(40) DEFAULT 'by-admin',
|
||||
PRIMARY KEY (id),
|
||||
KEY user_id (user_id)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the signup_form column.
|
||||
@ -109,17 +107,14 @@ final class Customers_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `signup_form` varchar(40) default 'by-admin' AFTER `ips`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210508;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the signup_form column.
|
||||
@ -133,27 +128,22 @@ final class Customers_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
|
||||
|
||||
$result_set = $this->get_db()->query($query_set);
|
||||
|
||||
if ($this->is_success($result_set) === false) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `signup_form` varchar(40) default 'by-admin' AFTER `ips`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210607;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
@ -169,21 +159,15 @@ final class Customers_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Customers_Table;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Discount_Code_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Discount_Code_Query;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Discount_Codes_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'discount_codemeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Discount_Codes_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Discount_Codes_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_discount_code_id (wu_discount_code_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Discount_Codes_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -172,5 +172,4 @@ class Discount_Codes_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Discount_Codes_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Discount_Codes_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'discount_codes';
|
||||
|
||||
/**
|
||||
@ -64,8 +64,7 @@ final class Discount_Codes_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -93,8 +92,7 @@ final class Discount_Codes_Table extends Table {
|
||||
date_created datetime NULL,
|
||||
date_modified datetime NULL,
|
||||
PRIMARY KEY (id)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -108,21 +106,15 @@ final class Discount_Codes_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Discount_Codes_Table;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Domain_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Domain_Query;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Domains;
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Database\Engine\Enum;
|
||||
use WP_Ultimo\Database\Engine\Enum;
|
||||
|
||||
/**
|
||||
* Domain Stage.
|
||||
@ -47,8 +47,7 @@ class Domain_Stage extends Enum {
|
||||
static::DONE => 'wu-bg-green-200 wu-text-green-700',
|
||||
static::DONE_WITHOUT_SSL => 'wu-bg-gray-800 wu-text-white',
|
||||
);
|
||||
|
||||
} // end classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
@ -65,7 +64,5 @@ class Domain_Stage extends Enum {
|
||||
static::DONE => __('Ready', 'wp-ultimo'),
|
||||
static::DONE_WITHOUT_SSL => __('Ready (without SSL)', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end labels;
|
||||
|
||||
} // end class Domain_Stage;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Domains_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'extra' => 'auto_increment',
|
||||
'primary' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -117,5 +117,4 @@ class Domains_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Domains_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Domains_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'domain_mappings';
|
||||
|
||||
/**
|
||||
@ -64,8 +64,7 @@ final class Domains_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -88,8 +87,7 @@ final class Domains_Table extends Table {
|
||||
PRIMARY KEY (id),
|
||||
KEY blog_id (blog_id,domain,active),
|
||||
KEY domain (domain)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -103,21 +101,15 @@ final class Domains_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Domains_Table;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,5 @@ class Email_Query extends Post_Query {
|
||||
$query['type__in'] = array('system_email');
|
||||
|
||||
return parent::query($query);
|
||||
|
||||
} // end query;
|
||||
|
||||
} // end class Email_Query;
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
|
||||
class Base extends \BerlinDB\Database\Base {
|
||||
|
||||
protected $prefix = 'wu';
|
||||
|
||||
} // end class Base;
|
||||
}
|
||||
|
@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
|
||||
class Column extends \BerlinDB\Database\Column {
|
||||
|
||||
protected $prefix = 'wu';
|
||||
|
||||
} // end class Column;
|
||||
}
|
||||
|
@ -17,4 +17,4 @@ defined('ABSPATH') || exit;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Compare extends \BerlinDB\Database\Compare {} // end class Compare;
|
||||
class Compare extends \BerlinDB\Database\Compare {}
|
||||
|
@ -17,4 +17,4 @@ defined('ABSPATH') || exit;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Date extends \BerlinDB\Database\Date {} // end class Date;
|
||||
class Date extends \BerlinDB\Database\Date {}
|
||||
|
@ -17,265 +17,242 @@ defined('ABSPATH') || exit;
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
abstract class Enum
|
||||
{
|
||||
/**
|
||||
* The default value.
|
||||
*/
|
||||
const __default = false;
|
||||
abstract class Enum {
|
||||
|
||||
/**
|
||||
* The default value.
|
||||
*/
|
||||
const __default = false;
|
||||
// phpcs:ignore
|
||||
/**
|
||||
* The options available.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
static $options = array();
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $value = '';
|
||||
/**
|
||||
* Constructor method. Takes the value you want to set.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $value The value to be set.
|
||||
*/
|
||||
public function __construct($value = '')
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
// end __construct;
|
||||
// Needs to be Implemented
|
||||
/**
|
||||
* Returns an array with values => CSS Classes.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function classes();
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function labels();
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
protected function icon_classes() {
|
||||
* The options available.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
static $options = array();
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $value = '';
|
||||
/**
|
||||
* Constructor method. Takes the value you want to set.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $value The value to be set.
|
||||
*/
|
||||
public function __construct($value = '') {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
return array();
|
||||
// Needs to be Implemented
|
||||
/**
|
||||
* Returns an array with values => CSS Classes.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function classes();
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function labels();
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
protected function icon_classes() {
|
||||
|
||||
}
|
||||
// end icon_classes;
|
||||
/**
|
||||
* Returns the options available as constants.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return array
|
||||
*/
|
||||
public static function get_options() {
|
||||
return array();
|
||||
}
|
||||
|
||||
$hook = static::get_hook_name();
|
||||
/**
|
||||
* Returns the options available as constants.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return array
|
||||
*/
|
||||
public static function get_options() {
|
||||
|
||||
if (!isset(static::$options[$hook])) {
|
||||
$hook = static::get_hook_name();
|
||||
|
||||
$reflector = new \ReflectionClass(static::class);
|
||||
if ( ! isset(static::$options[ $hook ])) {
|
||||
$reflector = new \ReflectionClass(static::class);
|
||||
|
||||
static::$options[$hook] = apply_filters("wu_available_{$hook}_options", $reflector->getConstants());
|
||||
static::$options[ $hook ] = apply_filters("wu_available_{$hook}_options", $reflector->getConstants());
|
||||
}
|
||||
|
||||
} // end if;
|
||||
return static::$options[ $hook ];
|
||||
}
|
||||
|
||||
return static::$options[$hook];
|
||||
public static function get_allowed_list($string = false) {
|
||||
|
||||
}
|
||||
// end get_options;
|
||||
public static function get_allowed_list($string = false) {
|
||||
$options = array_unique(self::get_options());
|
||||
|
||||
$options = array_unique(self::get_options());
|
||||
return $string ? implode(',', $options) : $options;
|
||||
}
|
||||
|
||||
return $string ? implode(',', $options) : $options;
|
||||
/**
|
||||
* Returns the value loaded here.
|
||||
*
|
||||
* This runs through is_valid and returns the
|
||||
* default value if a invalid value is passed on.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_value() {
|
||||
|
||||
}
|
||||
// end get_allowed_list;
|
||||
/**
|
||||
* Returns the value loaded here.
|
||||
*
|
||||
* This runs through is_valid and returns the
|
||||
* default value if a invalid value is passed on.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_value() {
|
||||
if ($this->is_valid($this->value)) {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
if ($this->is_valid($this->value)) {
|
||||
return static::__default;
|
||||
}
|
||||
|
||||
return $this->value;
|
||||
/**
|
||||
* Check for the the validity of the value passed.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $value The string.
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_valid($value) {
|
||||
|
||||
} // end if;
|
||||
$options = static::get_options();
|
||||
|
||||
return static::__default;
|
||||
return in_array($value, $options, true);
|
||||
}
|
||||
|
||||
}
|
||||
// end get_value;
|
||||
/**
|
||||
* Check for the the validity of the value passed.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $value The string.
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_valid($value) {
|
||||
/**
|
||||
* Returns the label of a given value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
$options = static::get_options();
|
||||
$hook = static::get_hook_name();
|
||||
|
||||
return in_array($value, $options, true);
|
||||
$labels = apply_filters("wu_available_{$hook}_labels", $this->labels());
|
||||
|
||||
}
|
||||
// end is_valid;
|
||||
/**
|
||||
* Returns the label of a given value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
return $this->exists_or_default($labels, $this->get_value());
|
||||
}
|
||||
|
||||
$hook = static::get_hook_name();
|
||||
/**
|
||||
* Returns the classes of a given value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_classes() {
|
||||
|
||||
$labels = apply_filters("wu_available_{$hook}_labels", $this->labels());
|
||||
$hook = static::get_hook_name();
|
||||
|
||||
return $this->exists_or_default($labels, $this->get_value());
|
||||
$classes = apply_filters("wu_available_{$hook}_classes", $this->classes());
|
||||
|
||||
}
|
||||
// end get_label;
|
||||
/**
|
||||
* Returns the classes of a given value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_classes() {
|
||||
return $this->exists_or_default($classes, $this->get_value());
|
||||
}
|
||||
|
||||
$hook = static::get_hook_name();
|
||||
/**
|
||||
* Returns the classes of a given value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_icon_classes() {
|
||||
|
||||
$classes = apply_filters("wu_available_{$hook}_classes", $this->classes());
|
||||
$hook = static::get_hook_name();
|
||||
|
||||
return $this->exists_or_default($classes, $this->get_value());
|
||||
$classes = apply_filters("wu_available_{$hook}_icon_classes", $this->icon_classes());
|
||||
|
||||
}
|
||||
// end get_classes;
|
||||
/**
|
||||
* Returns the classes of a given value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_icon_classes() {
|
||||
return $this->exists_or_default($classes, $this->get_value());
|
||||
}
|
||||
|
||||
$hook = static::get_hook_name();
|
||||
/**
|
||||
* Returns an array of options.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public static function to_array() {
|
||||
|
||||
$classes = apply_filters("wu_available_{$hook}_icon_classes", $this->icon_classes());
|
||||
static $instance;
|
||||
|
||||
return $this->exists_or_default($classes, $this->get_value());
|
||||
if ($instance === null) {
|
||||
$instance = new static();
|
||||
}
|
||||
|
||||
}
|
||||
// end get_icon_classes;
|
||||
/**
|
||||
* Returns an array of options.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public static function to_array() {
|
||||
$hook = $instance::get_hook_name();
|
||||
|
||||
static $instance;
|
||||
$labels = apply_filters("wu_{$hook}_to_array", $instance->labels());
|
||||
|
||||
if ($instance === null) {
|
||||
return $labels;
|
||||
}
|
||||
|
||||
$instance = new static;
|
||||
/**
|
||||
* Get the hook name for this class, so we can add filters.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public static function get_hook_name() {
|
||||
|
||||
} // end if;
|
||||
$class_name = (new \ReflectionClass(static::class))->getShortName();
|
||||
|
||||
$hook = $instance::get_hook_name();
|
||||
return strtolower($class_name);
|
||||
}
|
||||
|
||||
$labels = apply_filters("wu_{$hook}_to_array", $instance->labels());
|
||||
/**
|
||||
* Checks if a key exists on an array, otherwise returns a default value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param array $array The array to check.
|
||||
* @param string $key The key to check.
|
||||
* @param string $default The default value.
|
||||
* @return string
|
||||
*/
|
||||
public function exists_or_default($array, $key, $default = '') {
|
||||
|
||||
return $labels;
|
||||
if (empty($default)) {
|
||||
$default = isset($array[ static::__default ]) ? $array[ static::__default ] : '';
|
||||
}
|
||||
|
||||
}
|
||||
// end to_array;
|
||||
/**
|
||||
* Get the hook name for this class, so we can add filters.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public static function get_hook_name() {
|
||||
return isset($array[ $key ]) ? $array[ $key ] : $default;
|
||||
}
|
||||
|
||||
$class_name = (new \ReflectionClass(static::class))->getShortName();
|
||||
/**
|
||||
* Converts this to string.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string {
|
||||
|
||||
return strtolower($class_name);
|
||||
return $this->get_value();
|
||||
}
|
||||
|
||||
}
|
||||
// end get_hook_name;
|
||||
/**
|
||||
* Checks if a key exists on an array, otherwise returns a default value.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param array $array The array to check.
|
||||
* @param string $key The key to check.
|
||||
* @param string $default The default value.
|
||||
* @return string
|
||||
*/
|
||||
public function exists_or_default($array, $key, $default = '') {
|
||||
/**
|
||||
* Magic method to allow for constants to be called.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $name The name of the constants.
|
||||
* @param array $arguments The list of arguments. Not really needed here.
|
||||
* @return string
|
||||
*/
|
||||
public static function __callStatic($name, $arguments) {
|
||||
|
||||
if (empty($default)) {
|
||||
$class_name = static::class;
|
||||
|
||||
$default = isset($array[static::__default]) ? $array[static::__default] : '';
|
||||
|
||||
} // end if;
|
||||
|
||||
return isset($array[$key]) ? $array[$key] : $default;
|
||||
|
||||
}
|
||||
// end exists_or_default;
|
||||
/**
|
||||
* Converts this to string.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string {
|
||||
|
||||
return $this->get_value();
|
||||
|
||||
}
|
||||
// end __toString;
|
||||
/**
|
||||
* Magic method to allow for constants to be called.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $name The name of the constants.
|
||||
* @param array $arguments The list of arguments. Not really needed here.
|
||||
* @return string
|
||||
*/
|
||||
public static function __callStatic($name, $arguments) {
|
||||
|
||||
$class_name = static::class;
|
||||
|
||||
return constant("$class_name::$name");
|
||||
|
||||
}
|
||||
// end __callStatic;
|
||||
} // end class Enum;
|
||||
return constant("$class_name::$name");
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,4 @@ defined('ABSPATH') || exit;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Meta extends \BerlinDB\Database\Meta {} // end class Meta;
|
||||
class Meta extends \BerlinDB\Database\Meta {}
|
||||
|
@ -19,7 +19,7 @@ defined('ABSPATH') || exit;
|
||||
*/
|
||||
class Query extends \BerlinDB\Database\Query {
|
||||
|
||||
/**
|
||||
/**
|
||||
* The prefix for the custom table.
|
||||
*
|
||||
* @since 2.0.0
|
||||
@ -73,17 +73,14 @@ class Query extends \BerlinDB\Database\Query {
|
||||
|
||||
$cache_group = $this->apply_prefix($this->cache_group, '-');
|
||||
|
||||
if ($this->global_cache && !in_array($cache_group, self::$added_globals, true)) {
|
||||
|
||||
if ($this->global_cache && ! in_array($cache_group, self::$added_globals, true)) {
|
||||
wp_cache_add_global_groups(array($cache_group));
|
||||
|
||||
self::$added_globals[] = $cache_group;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plural name.
|
||||
@ -94,7 +91,5 @@ class Query extends \BerlinDB\Database\Query {
|
||||
public function get_plural_name() {
|
||||
|
||||
return $this->item_name_plural;
|
||||
|
||||
} // end get_plural_name;
|
||||
|
||||
} // end class Query;
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
|
||||
class Row extends \BerlinDB\Database\Row {
|
||||
|
||||
protected $prefix = 'wu';
|
||||
|
||||
} // end class Row;
|
||||
}
|
||||
|
@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
|
||||
class Schema extends \BerlinDB\Database\Schema {
|
||||
|
||||
protected $prefix = 'wu';
|
||||
|
||||
} // end class Schema;
|
||||
}
|
||||
|
@ -47,21 +47,16 @@ abstract class Table extends \BerlinDB\Database\Table {
|
||||
*/
|
||||
public function is_upgradeable() {
|
||||
|
||||
if (!is_main_network()) {
|
||||
|
||||
if ( ! is_main_network()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
if (!is_main_site()) {
|
||||
|
||||
if ( ! is_main_site()) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end is_upgradeable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a caching layer to the parent exists method.
|
||||
@ -72,13 +67,9 @@ abstract class Table extends \BerlinDB\Database\Table {
|
||||
public function exists() {
|
||||
|
||||
if ($this->_exists === null) {
|
||||
|
||||
$this->_exists = parent::exists();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $this->_exists;
|
||||
|
||||
} // end exists;
|
||||
|
||||
} // end class Table;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Event_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Event_Query;
|
||||
}
|
||||
}
|
||||
|
@ -104,5 +104,4 @@ class Events_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Events_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Events_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'events';
|
||||
|
||||
/**
|
||||
@ -64,8 +64,7 @@ final class Events_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -89,8 +88,7 @@ final class Events_Table extends Table {
|
||||
KEY severity (severity),
|
||||
KEY author_id (author_id),
|
||||
KEY initiator (initiator)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -103,21 +101,15 @@ final class Events_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Events_Table;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Membership_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Membership_Query;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Memberships;
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Database\Engine\Enum;
|
||||
use WP_Ultimo\Database\Engine\Enum;
|
||||
|
||||
/**
|
||||
* Membership Status.
|
||||
@ -49,8 +49,7 @@ class Membership_Status extends Enum {
|
||||
static::EXPIRED => 'wu-bg-yellow-200 wu-text-yellow-700',
|
||||
static::CANCELLED => 'wu-bg-red-200 wu-text-red-700',
|
||||
);
|
||||
|
||||
} // end classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
@ -68,7 +67,5 @@ class Membership_Status extends Enum {
|
||||
static::EXPIRED => __('Expired', 'wp-ultimo'),
|
||||
static::CANCELLED => __('Cancelled', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end labels;
|
||||
|
||||
} // end class Membership_Status;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Memberships_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'membershipmeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Memberships_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Memberships_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_membership_id (wu_membership_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Memberships_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class Memberships_Schema extends Schema {
|
||||
'length' => '20',
|
||||
'unsigned' => true,
|
||||
'default' => null,
|
||||
'allow_null' => true
|
||||
'allow_null' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -76,7 +76,7 @@ class Memberships_Schema extends Schema {
|
||||
'length' => '20',
|
||||
'unsigned' => true,
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
// addons
|
||||
@ -91,7 +91,7 @@ class Memberships_Schema extends Schema {
|
||||
'type' => 'varchar',
|
||||
'length' => '20',
|
||||
'default' => 'USD',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -128,7 +128,7 @@ class Memberships_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -224,7 +224,7 @@ class Memberships_Schema extends Schema {
|
||||
'type' => 'smallint',
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
// times_billed
|
||||
@ -234,7 +234,7 @@ class Memberships_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
// billing_cycles
|
||||
@ -243,7 +243,7 @@ class Memberships_Schema extends Schema {
|
||||
'type' => 'smallint',
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
// status
|
||||
@ -263,7 +263,7 @@ class Memberships_Schema extends Schema {
|
||||
'default' => '',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
// gateway_subscription_id
|
||||
@ -273,7 +273,7 @@ class Memberships_Schema extends Schema {
|
||||
'default' => '',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
// gateway
|
||||
@ -298,7 +298,7 @@ class Memberships_Schema extends Schema {
|
||||
'length' => '32',
|
||||
'default' => '',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
// upgraded_from
|
||||
@ -307,7 +307,7 @@ class Memberships_Schema extends Schema {
|
||||
'type' => 'bigint',
|
||||
'length' => '20',
|
||||
'unsigned' => true,
|
||||
'default' => ''
|
||||
'default' => '',
|
||||
),
|
||||
|
||||
// date_modified
|
||||
@ -317,7 +317,7 @@ class Memberships_Schema extends Schema {
|
||||
'default' => null,
|
||||
'modified' => true,
|
||||
'date_query' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
// disabled
|
||||
@ -326,9 +326,8 @@ class Memberships_Schema extends Schema {
|
||||
'type' => 'smallint',
|
||||
'unsigned' => true,
|
||||
'default' => '',
|
||||
'pattern' => '%d'
|
||||
'pattern' => '%d',
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Memberships_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Memberships_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'memberships';
|
||||
|
||||
/**
|
||||
@ -64,8 +64,7 @@ final class Memberships_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema.
|
||||
@ -112,8 +111,7 @@ final class Memberships_Table extends Table {
|
||||
KEY plan_id (plan_id),
|
||||
KEY status (status),
|
||||
KEY disabled (disabled)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -133,21 +131,15 @@ final class Memberships_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Memberships_Table;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Payment_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Payment_Query;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Payments;
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Database\Engine\Enum;
|
||||
use WP_Ultimo\Database\Engine\Enum;
|
||||
|
||||
/**
|
||||
* Payment Status.
|
||||
@ -51,8 +51,7 @@ class Payment_Status extends Enum {
|
||||
static::FAILED => 'wu-bg-red-200 wu-text-red-700',
|
||||
static::CANCELLED => 'wu-bg-orange-200 wu-text-orange-700',
|
||||
);
|
||||
|
||||
} // end classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => CSS Classes.
|
||||
@ -71,8 +70,7 @@ class Payment_Status extends Enum {
|
||||
static::FAILED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-red-700',
|
||||
static::CANCELLED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-orange-700',
|
||||
);
|
||||
|
||||
} // end icon_classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
@ -91,7 +89,5 @@ class Payment_Status extends Enum {
|
||||
static::FAILED => __('Failed', 'wp-ultimo'),
|
||||
static::CANCELLED => __('Cancelled', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end labels;
|
||||
|
||||
} // end class Payment_Status;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Payments_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'paymentmeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Payments_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Payments_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_payment_id (wu_payment_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Payments_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class Payments_Schema extends Schema {
|
||||
'type' => 'varchar',
|
||||
'length' => '20',
|
||||
'default' => 'USD',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -188,5 +188,4 @@ class Payments_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Payments_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Payments_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'payments';
|
||||
|
||||
/**
|
||||
@ -66,8 +66,7 @@ final class Payments_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema.
|
||||
@ -102,8 +101,7 @@ final class Payments_Table extends Table {
|
||||
KEY parent_id (parent_id),
|
||||
KEY product_id (product_id),
|
||||
KEY status (status)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the refund_total column.
|
||||
@ -120,17 +118,14 @@ final class Payments_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `refund_total` decimal(13,4) default 0 AFTER `subtotal`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210417;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the refund_total column.
|
||||
@ -144,27 +139,22 @@ final class Payments_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
|
||||
|
||||
$result_set = $this->get_db()->query($query_set);
|
||||
|
||||
if ($this->is_success($result_set) === false) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `refund_total` decimal(13,4) default 0 AFTER `subtotal`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210607;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -178,21 +168,15 @@ final class Payments_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Payments_Table;
|
||||
}
|
||||
}
|
||||
|
@ -98,14 +98,10 @@ class Post_Query extends Query {
|
||||
*/
|
||||
public function query($query = array()) {
|
||||
|
||||
if (!isset($query['type__in'])) {
|
||||
|
||||
if ( ! isset($query['type__in'])) {
|
||||
$query['type'] = $this->item_name;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return parent::query($query);
|
||||
|
||||
} // end query;
|
||||
|
||||
} // end class Post_Query;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Posts_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'postmeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Posts_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Posts_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_post_id (wu_post_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Posts_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Posts_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'extra' => 'auto_increment',
|
||||
'primary' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -51,35 +51,35 @@ class Posts_Schema extends Schema {
|
||||
'name' => 'type',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'slug',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'title',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'content',
|
||||
'type' => 'longtext',
|
||||
'default' => '',
|
||||
'searchable' => true
|
||||
'searchable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'excerpt',
|
||||
'type' => 'longtext',
|
||||
'default' => '',
|
||||
'searchable' => true
|
||||
'searchable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -121,5 +121,4 @@ class Posts_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Posts_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Posts_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'posts';
|
||||
|
||||
/**
|
||||
@ -64,8 +64,7 @@ final class Posts_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -88,8 +87,7 @@ final class Posts_Table extends Table {
|
||||
list_order tinyint default 10,
|
||||
status varchar(100) NOT NULL default 'draft',
|
||||
PRIMARY KEY (id)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -103,21 +101,15 @@ final class Posts_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Posts_Table;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Product_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Product_Query;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Products;
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Database\Engine\Enum;
|
||||
use WP_Ultimo\Database\Engine\Enum;
|
||||
|
||||
/**
|
||||
* Product Types.
|
||||
@ -43,8 +43,7 @@ class Product_Type extends Enum {
|
||||
static::PACKAGE => 'wu-bg-gray-200 wu-text-blue-700',
|
||||
static::SERVICE => 'wu-bg-yellow-200 wu-text-yellow-700',
|
||||
);
|
||||
|
||||
} // end classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
@ -59,7 +58,5 @@ class Product_Type extends Enum {
|
||||
static::PACKAGE => __('Package', 'wp-ultimo'),
|
||||
static::SERVICE => __('Service', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end labels;
|
||||
|
||||
} // end class Product_Type;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Products_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'productmeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Products_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Products_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_product_id (wu_product_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Products_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'extra' => 'auto_increment',
|
||||
'primary' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -70,14 +70,14 @@ class Products_Schema extends Schema {
|
||||
'name' => 'name',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'description',
|
||||
'type' => 'longtext',
|
||||
'default' => '',
|
||||
'searchable' => true
|
||||
'searchable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -93,7 +93,7 @@ class Products_Schema extends Schema {
|
||||
'type' => 'varchar',
|
||||
'length' => '10',
|
||||
'default' => 'USD',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -101,7 +101,7 @@ class Products_Schema extends Schema {
|
||||
'type' => 'varchar',
|
||||
'length' => '10',
|
||||
'default' => 'paid',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -136,7 +136,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -151,7 +151,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -166,7 +166,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -213,9 +213,8 @@ class Products_Schema extends Schema {
|
||||
'name' => 'type',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Products_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Products_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'products';
|
||||
|
||||
/**
|
||||
@ -66,8 +66,7 @@ final class Products_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -101,8 +100,7 @@ final class Products_Table extends Table {
|
||||
date_created datetime NULL,
|
||||
date_modified datetime NULL,
|
||||
PRIMARY KEY (id)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the product_group column.
|
||||
@ -119,17 +117,14 @@ final class Products_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `product_group` varchar(20) default '' AFTER `description`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210419;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the product_group column.
|
||||
@ -143,27 +138,22 @@ final class Products_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
|
||||
|
||||
$result_set = $this->get_db()->query($query_set);
|
||||
|
||||
if ($this->is_success($result_set) === false) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `product_group` varchar(20) default '' AFTER `description`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210607;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -177,21 +167,15 @@ final class Products_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Products_Table;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,5 @@ class Site_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Site_Query;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Sites;
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Database\Engine\Enum;
|
||||
use WP_Ultimo\Database\Engine\Enum;
|
||||
|
||||
/**
|
||||
* Site Types.
|
||||
@ -49,8 +49,7 @@ class Site_Type extends Enum {
|
||||
static::EXTERNAL => 'wu-bg-blue-200 wu-text-blue-700',
|
||||
static::MAIN => 'wu-bg-pink-200 wu-text-pink-700',
|
||||
);
|
||||
|
||||
} // end classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
@ -67,7 +66,5 @@ class Site_Type extends Enum {
|
||||
static::PENDING => __('Pending', 'wp-ultimo'),
|
||||
static::MAIN => __('Main Site', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end labels;
|
||||
|
||||
} // end class Site_Type;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Sites_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table prefix, including the site prefix.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table prefix, including the site prefix.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = '';
|
||||
|
||||
/**
|
||||
@ -63,8 +63,7 @@ final class Sites_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Sites_Meta_Table extends Table {
|
||||
protected function set_schema() {
|
||||
|
||||
$this->schema = false;
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Sites_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -62,14 +62,14 @@ class Sites_Schema extends Schema {
|
||||
'name' => 'domain',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'path',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -147,5 +147,4 @@ class Sites_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Sites_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Sites_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table prefix, including the site prefix.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table prefix, including the site prefix.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = '';
|
||||
|
||||
/**
|
||||
@ -63,8 +63,7 @@ final class Sites_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,14 +75,12 @@ final class Sites_Table extends Table {
|
||||
protected function set_schema() {
|
||||
|
||||
$this->schema = false;
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing as this table already exists.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function install() {} // end install;
|
||||
|
||||
} // end class Sites_Table;
|
||||
public function install() {}
|
||||
}
|
||||
|
@ -107,7 +107,5 @@ class Webhook_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Webhook_Query;
|
||||
}
|
||||
}
|
||||
|
@ -132,5 +132,4 @@ class Webhooks_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Webhooks_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Webhooks_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'webhooks';
|
||||
|
||||
/**
|
||||
@ -64,8 +64,7 @@ final class Webhooks_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -94,8 +93,7 @@ final class Webhooks_Table extends Table {
|
||||
KEY event (event)";
|
||||
|
||||
// phpcs:enable
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -109,21 +107,15 @@ final class Webhooks_Table extends Table {
|
||||
);
|
||||
|
||||
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)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Webhooks_Table;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user