Initial Commit
This commit is contained in:
67
inc/traits/trait-singleton.php
Normal file
67
inc/traits/trait-singleton.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* A trait to be included in entities to enable REST API endpoints.
|
||||
*
|
||||
* @package WP_Ultimo
|
||||
* @subpackage Apis
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
namespace WP_Ultimo\Traits;
|
||||
|
||||
/**
|
||||
* Singleton trait.
|
||||
*/
|
||||
trait Singleton {
|
||||
|
||||
/**
|
||||
* Makes sure we are only using one instance of the class
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public static $instance;
|
||||
|
||||
/**
|
||||
* Returns the instance of WP_Ultimo
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function get_instance() {
|
||||
|
||||
if (!static::$instance instanceof static) {
|
||||
|
||||
static::$instance = new static();
|
||||
|
||||
static::$instance->init();
|
||||
|
||||
} // end if;
|
||||
|
||||
return static::$instance;
|
||||
|
||||
} // end get_instance;
|
||||
|
||||
/**
|
||||
* Runs only once, at the first instantiation of the Singleton.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
$this->has_parents() && method_exists(get_parent_class($this), 'init') && parent::init();
|
||||
|
||||
} // end init;
|
||||
|
||||
/**
|
||||
* Check if the current class has parents.
|
||||
*
|
||||
* @since 2.0.11
|
||||
* @return boolean
|
||||
*/
|
||||
public function has_parents() {
|
||||
|
||||
return (bool) class_parents($this);
|
||||
|
||||
} // end has_parents;
|
||||
|
||||
} // end trait Singleton;
|
79
inc/traits/trait-wp-ultimo-coupon-deprecated.php
Normal file
79
inc/traits/trait-wp-ultimo-coupon-deprecated.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* A trait to be included in entities to WU_Coupon Class depecrated methods.
|
||||
*
|
||||
* @package WP_Ultimo
|
||||
* @subpackage Deprecated
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
namespace WP_Ultimo\Traits;
|
||||
|
||||
/**
|
||||
* WP_Ultimo_Coupon_Deprecated trait.
|
||||
*/
|
||||
trait WP_Ultimo_Coupon_Deprecated {
|
||||
|
||||
/**
|
||||
* Generic set for old add-ons.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $key Meta key to save.
|
||||
* @param mixed $value The value to save as meta.
|
||||
*/
|
||||
public function __set($key, $value) {
|
||||
|
||||
/**
|
||||
* Let developers know that this is not going to be supported in the future.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
_doing_it_wrong($key, __('Discount Code keys should not be set directly.', 'wp-ultimo'), '2.0.0');
|
||||
|
||||
$this->meta["wpu_{$key}"] = $value;
|
||||
|
||||
} // end __set;
|
||||
|
||||
/**
|
||||
* Magic getter to provide backwards compatibility for plans.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @throws \Exception Throws an exception when trying to get a key that is not available or back-compat.
|
||||
* @param string $key Property to get.
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key) {
|
||||
|
||||
$value = null;
|
||||
|
||||
switch ($key) {
|
||||
default:
|
||||
$value = $this->get_meta('wpu_' . $key, false, true);
|
||||
|
||||
} // end switch;
|
||||
|
||||
if ($value === null) {
|
||||
|
||||
// translators: the placeholder is the key.
|
||||
$message = sprintf(__('Discount Codes do not have a %s parameter', 'wp-ultimo'), $key);
|
||||
|
||||
// throw new \Exception($message);
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
/**
|
||||
* Let developers know that this is not going to be supported in the future.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
_doing_it_wrong($key, __('Discount Code keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
|
||||
|
||||
return $value;
|
||||
|
||||
} // end __get;
|
||||
|
||||
} // end trait WP_Ultimo_Coupon_Deprecated;
|
138
inc/traits/trait-wp-ultimo-deprecated.php
Normal file
138
inc/traits/trait-wp-ultimo-deprecated.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* A trait to be included in entities to WP_Ultimo Class depecrated methods.
|
||||
*
|
||||
* @package WP_Ultimo
|
||||
* @subpackage Apis
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
namespace WP_Ultimo\Traits;
|
||||
|
||||
/**
|
||||
* WP_Ultimo_Deprecated trait.
|
||||
*/
|
||||
trait WP_Ultimo_Deprecated {
|
||||
|
||||
/**
|
||||
* Deprecated: WP_Ultimo->slugfy().
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @param string $term Returns a string based on the term and this plugin slug.
|
||||
* @return void
|
||||
*/
|
||||
public function slugfy($term) {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'wu_slugify($term)');
|
||||
|
||||
wu_slugify($term);
|
||||
|
||||
} // end slugfy;
|
||||
|
||||
/**
|
||||
* Deprecated: WP_Ultimo->add_page_to_branding()
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_page_to_branding() {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0');
|
||||
|
||||
} // end add_page_to_branding;
|
||||
|
||||
/**
|
||||
* Renders a view file from the view folder.
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @param string $view View file to render. Do not include the .php extension.
|
||||
* @param boolean $vars Key => Value pairs to be made available as local variables inside the view scope.
|
||||
* @return void
|
||||
*/
|
||||
public function render($view, $vars = false) {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_template()');
|
||||
|
||||
wu_get_template($view, $vars);
|
||||
|
||||
} // end render;
|
||||
|
||||
/**
|
||||
* Returns the full path to the plugin folder
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @since 0.0.1
|
||||
* @param string $dir Path relative to the plugin root you want to access.
|
||||
* @return string
|
||||
*/
|
||||
public function path($dir) {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'wu_path()');
|
||||
|
||||
return wu_path($dir);
|
||||
|
||||
} // end path;
|
||||
|
||||
/**
|
||||
* Deprecated: Add messages to be displayed as notices
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @param string $message Message to be displayed.
|
||||
* @param string $type Success, error, warning or info.
|
||||
* @param boolean $network Where to display, network admin or normal admin.
|
||||
* @return void
|
||||
*/
|
||||
public function add_message($message, $type = 'success', $network = false) {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo()->notices->add()');
|
||||
|
||||
$panel = $network ? 'network-admin' : 'admin';
|
||||
|
||||
$ultimo = WP_Ultimo();
|
||||
|
||||
if (isset($ultimo->notices) && $ultimo->notices) {
|
||||
|
||||
$ultimo->notices->add($message, $type, $panel);
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end add_message;
|
||||
|
||||
/**
|
||||
* Deprecated: This function is here to make sure that the plugin is network active
|
||||
* and that this is a multisite install.
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return boolean
|
||||
*/
|
||||
public function check_before_run() {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo()->is_loaded()');
|
||||
|
||||
return WP_Ultimo()->is_loaded();
|
||||
|
||||
} // end check_before_run;
|
||||
|
||||
/**
|
||||
* Deprecated: enqueue_select2.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_select2() {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0');
|
||||
|
||||
wp_enqueue_style('wu-select2css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all');
|
||||
|
||||
wp_enqueue_script('wu-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array('jquery'), '1.0', true);
|
||||
|
||||
} // end enqueue_select2;
|
||||
|
||||
} // end trait WP_Ultimo_Deprecated;
|
400
inc/traits/trait-wp-ultimo-plan-deprecated.php
Normal file
400
inc/traits/trait-wp-ultimo-plan-deprecated.php
Normal file
@ -0,0 +1,400 @@
|
||||
<?php
|
||||
/**
|
||||
* A trait to be included in entities to WP_Plans Class deprecated methods.
|
||||
*
|
||||
* @package WP_Ultimo
|
||||
* @subpackage Deprecated
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
namespace WP_Ultimo\Traits;
|
||||
|
||||
/**
|
||||
* WP_Ultimo_Plan_Deprecated trait.
|
||||
*/
|
||||
trait WP_Ultimo_Plan_Deprecated {
|
||||
|
||||
/**
|
||||
* Top deal equivalent.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var bool
|
||||
*/
|
||||
protected $featured_plan;
|
||||
|
||||
/**
|
||||
* Magic getter to provide backwards compatibility for plans.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @throws \Exception Throws an exception when trying to get a key that is not available or back-compat.
|
||||
* @param string $key Property to get.
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key) {
|
||||
|
||||
$value = null;
|
||||
|
||||
switch ($key) {
|
||||
case 'title':
|
||||
$value = $this->get_name();
|
||||
break;
|
||||
case 'id':
|
||||
case 'ID':
|
||||
$value = $this->get_id();
|
||||
break;
|
||||
case 'free':
|
||||
$value = $this->get_pricing_type() === 'free';
|
||||
break;
|
||||
case 'price_1':
|
||||
case 'price_3':
|
||||
case 'price_12':
|
||||
$value = 20;
|
||||
break;
|
||||
case 'top_deal':
|
||||
$value = $this->is_featured_plan();
|
||||
break;
|
||||
case 'feature_list':
|
||||
$value = $this->get_feature_list();
|
||||
break;
|
||||
case 'quotas':
|
||||
$value = array(
|
||||
// 'sites' => 300,
|
||||
'upload' => 1024 * 1024 * 1024,
|
||||
'visits' => 300,
|
||||
);
|
||||
break;
|
||||
case 'post':
|
||||
$value = (object) array(
|
||||
'ID' => $this->get_id(),
|
||||
'post_title' => $this->get_name(),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$value = $this->get_meta('wpu_' . $key, false, true);
|
||||
break;
|
||||
} // end switch;
|
||||
|
||||
/**
|
||||
* Let developers know that this is not going to be supported in the future.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
_doing_it_wrong($key, __('Product keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
|
||||
|
||||
return $value;
|
||||
|
||||
} // end __get;
|
||||
|
||||
/**
|
||||
* Get the featured status for this product.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return array
|
||||
*/
|
||||
public function is_featured_plan() {
|
||||
|
||||
if ($this->featured_plan === null) {
|
||||
|
||||
$this->featured_plan = $this->get_meta('featured_plan', false);
|
||||
|
||||
} // end if;
|
||||
|
||||
return (bool) $this->featured_plan;
|
||||
|
||||
} // end is_featured_plan;
|
||||
|
||||
/**
|
||||
* Set the featured status for this product.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @param array $featured_plan Feature list for pricing tables.
|
||||
* @return void
|
||||
*/
|
||||
public function set_featured_plan($featured_plan) {
|
||||
|
||||
$this->meta['featured_plan'] = $featured_plan;
|
||||
|
||||
} // end set_featured_plan;
|
||||
|
||||
/**
|
||||
* Deprecated: Checks if a given plan is a contact us plan.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @deprecated 2.0.0
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_contact_us() {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'get_pricing_type');
|
||||
|
||||
return $this->get_pricing_type() === 'contact_us';
|
||||
|
||||
} // end is_contact_us;
|
||||
|
||||
/**
|
||||
* Get the pricing table lines to be displayed on the pricing tables
|
||||
*
|
||||
* @since 1.4.0
|
||||
* @return array
|
||||
*/
|
||||
public function get_pricing_table_lines() {
|
||||
|
||||
$pricing_table_lines = array();
|
||||
|
||||
/*
|
||||
* Setup Fee
|
||||
* @since 1.7.0
|
||||
*/
|
||||
if ($this->should_display_quota_on_pricing_tables('setup_fee', true)) {
|
||||
|
||||
if ($this->get_pricing_type() === 'contact_us') {
|
||||
|
||||
$pricing_table_lines['wu_product_contact_us'] = __('Contact Us to know more', 'wp-ultimo');
|
||||
|
||||
} else {
|
||||
|
||||
$pricing_table_lines['wu_product_setup_fee'] = $this->has_setup_fee()
|
||||
? sprintf(__('Setup Fee: %s', 'wp-ultimo'), "<strong class='pricing-table-setupfee' data-value='" . $this->get_setup_fee() . "'>" . wu_format_currency($this->get_setup_fee()) . '</strong>')
|
||||
: __('No Setup Fee', 'wp-ultimo');
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end if;
|
||||
|
||||
/**
|
||||
*
|
||||
* Post Type Lines
|
||||
* Gets the post type lines to be displayed on the pricing table options
|
||||
*/
|
||||
$post_types = get_post_types(array('public' => true), 'objects');
|
||||
$post_types = apply_filters('wu_get_post_types', $post_types);
|
||||
|
||||
foreach ($post_types as $pt_slug => $post_type) {
|
||||
/*
|
||||
* @since 1.1.3 Let users choose which post types to display on the pt
|
||||
*/
|
||||
if ($this->should_display_quota_on_pricing_tables($pt_slug)) {
|
||||
/**
|
||||
* Get if disabled
|
||||
*/
|
||||
if ($this->is_post_type_disabled($pt_slug)) {
|
||||
|
||||
// Translators: used as "No Posts" where a post type is disabled
|
||||
$pricing_table_lines['wu_product_limit_post_type_' . $pt_slug] = sprintf(__('No %s', 'wp-ultimo'), $post_type->labels->name);
|
||||
|
||||
continue;
|
||||
|
||||
} // end if;
|
||||
|
||||
/**
|
||||
* Get the values
|
||||
*
|
||||
* @var integer|string
|
||||
*/
|
||||
$is_unlimited = (int) $this->get_limitations()->post_types->{$pt_slug}->number === 0 || !$this->get_limitations()->post_types->is_enabled();
|
||||
$value = $is_unlimited ? __('Unlimited', 'wp-ultimo') : $this->get_limitations()->post_types->{$pt_slug}->number;
|
||||
|
||||
// Add Line
|
||||
$label = $value == 1 ? $post_type->labels->singular_name : $post_type->labels->name;
|
||||
|
||||
$pricing_table_lines['wu_product_limit_post_type_' . $pt_slug] = sprintf('%s %s', $value, $label);
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
|
||||
/**
|
||||
*
|
||||
* Site, Disk Space and Trial
|
||||
* Gets the Disk Space and Sites to be displayed on the pricing table options
|
||||
*/
|
||||
if (wu_get_setting('enable_multiple_sites') && $this->should_display_quota_on_pricing_tables('sites')) {
|
||||
|
||||
$is_unlimited = (int) $this->get_limitations()->sites->get_limit() === 0 || !$this->get_limitations()->sites->is_enabled();
|
||||
$value = $is_unlimited ? __('Unlimited', 'wp-ultimo') : $this->get_limitations()->sites->get_limit();
|
||||
|
||||
// Add Line
|
||||
$pricing_table_lines['wu_product_limit_sites'] = sprintf('<strong>%s %s</strong>', $value, _n('Site', 'Sites', $this->get_limitations()->sites->get_limit(), 'wp-ultimo'));
|
||||
|
||||
} // end if;
|
||||
|
||||
/**
|
||||
* Display DiskSpace
|
||||
*/
|
||||
if ($this->should_display_quota_on_pricing_tables('upload')) {
|
||||
|
||||
$is_unlimited = (int) $this->get_limitations()->disk_space->get_limit() === 0 || !$this->get_limitations()->disk_space->is_enabled();
|
||||
$disk_space = $is_unlimited ? __('Unlimited', 'wp-ultimo') : size_format(absint($this->get_limitations()->disk_space->get_limit()) * 1024 * 1024);
|
||||
|
||||
// Add Line
|
||||
$pricing_table_lines['wu_product_limit_disk_space'] = !empty($disk_space) ? sprintf(__('%s <strong>Disk Space</strong>', 'wp-ultimo'), $disk_space) : false;
|
||||
|
||||
} // end if;
|
||||
|
||||
/**
|
||||
* Visits
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
if ($this->should_display_quota_on_pricing_tables('visits')) {
|
||||
|
||||
$is_unlimited = (int) $this->get_limitations()->visits->get_limit() === 0 || !$this->get_limitations()->visits->is_enabled();
|
||||
$value = $is_unlimited ? __('Unlimited', 'wp-ultimo') : number_format($this->get_limitations()->visits->get_limit());
|
||||
|
||||
// Add Line
|
||||
$pricing_table_lines['wu_product_limit_visits'] = sprintf('%s %s', $value, _n('Visit per month', 'Visits per month', $this->get_limitations()->visits->get_limit(), 'wp-ultimo'));
|
||||
|
||||
} // end if;
|
||||
|
||||
/**
|
||||
* Display Trial, if some
|
||||
*/
|
||||
$trial_days = wu_get_setting('trial');
|
||||
$trial_days_plan = $this->get_trial_duration();
|
||||
|
||||
if ($trial_days > 0 || $trial_days_plan) {
|
||||
|
||||
$trial_days = $trial_days_plan ? $trial_days_plan : $trial_days;
|
||||
|
||||
$pricing_table_lines['wu_product_trial'] = !$this->is_free() ? sprintf(__('%s day <strong>Free Trial</strong>', 'wp-ultimo'), $trial_days) : '-';
|
||||
|
||||
} // end if;
|
||||
|
||||
/**
|
||||
*
|
||||
* Site, Disk Space and Trial
|
||||
* Gets the Disk Space and Sites to be displayed on the pricing table options
|
||||
*/
|
||||
|
||||
/** Loop custom lines */
|
||||
$custom_features = explode('<br />', nl2br($this->get_feature_list()));
|
||||
|
||||
foreach ($custom_features as $key => $custom_feature) {
|
||||
|
||||
if (trim($custom_feature) == '') {
|
||||
|
||||
continue;
|
||||
|
||||
} // end if;
|
||||
|
||||
$pricing_table_lines['wu_product_feature_' . $key] = sprintf('%s', trim($custom_feature));
|
||||
|
||||
} // end foreach;
|
||||
|
||||
/**
|
||||
* Return Lines, filterable
|
||||
*/
|
||||
return apply_filters("wu_get_pricing_table_lines_$this->id", $pricing_table_lines, $this);
|
||||
|
||||
} // end get_pricing_table_lines;
|
||||
|
||||
/**
|
||||
* Deprecated: A quota to get.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
* @param string $quota_name The quota name.
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_quota($quota_name) {
|
||||
|
||||
if ($quota_name === 'visits') {
|
||||
|
||||
$limit = (float) $this->get_limitations()->visits->get_limit();
|
||||
|
||||
} elseif ($quota_name === 'disk_space') {
|
||||
|
||||
$limit = (float) $this->get_limitations()->disk_space->get_limit();
|
||||
|
||||
} elseif ($quota_name === 'sites') {
|
||||
|
||||
$limit = (float) $this->get_limitations()->sites->get_limit();
|
||||
|
||||
} else {
|
||||
|
||||
$limit = (float) $this->get_limitations()->post_types->{$quota_name}->number;
|
||||
|
||||
} // end if;
|
||||
|
||||
return $limit;
|
||||
|
||||
} // end get_quota;
|
||||
|
||||
/**
|
||||
* Returns wether or not we should display a given quota type in the Quotas and Limits widgets
|
||||
*
|
||||
* @since 1.5.4
|
||||
* @param string $quota_type Post type to check.
|
||||
* @param string $default Default value.
|
||||
* @return bool
|
||||
*/
|
||||
public function should_display_quota_on_pricing_tables($quota_type, $default = false) {
|
||||
/*
|
||||
* @since 1.3.3 Only Show elements allowed on the plan settings
|
||||
*/
|
||||
$elements = array();
|
||||
|
||||
if (!$elements) {
|
||||
|
||||
return true;
|
||||
|
||||
} // end if;
|
||||
|
||||
if (!isset( $elements[$quota_type] ) && $default) {
|
||||
|
||||
return true;
|
||||
|
||||
} // end if;
|
||||
|
||||
return isset( $elements[$quota_type] ) && $elements[$quota_type];
|
||||
|
||||
} // end should_display_quota_on_pricing_tables;
|
||||
|
||||
/**
|
||||
* Checks if this plan allows unlimited extra users
|
||||
*
|
||||
* @since 1.7.0
|
||||
* @return boolean
|
||||
*/
|
||||
public function should_allow_unlimited_extra_users() {
|
||||
|
||||
return apply_filters('wu_plan_should_allow_unlimited_extra_users', (bool) $this->unlimited_extra_users, $this);
|
||||
|
||||
} // end should_allow_unlimited_extra_users;
|
||||
|
||||
/**
|
||||
* Returns wether or not we should display a given quota type in the Quotas and Limits widgets
|
||||
*
|
||||
* @since 1.5.4
|
||||
* @param string $post_type The post type.
|
||||
* @return bool
|
||||
*/
|
||||
public function is_post_type_disabled($post_type) {
|
||||
|
||||
return !$this->get_limitations()->post_types->{$post_type}->enabled;
|
||||
|
||||
} // end is_post_type_disabled;
|
||||
|
||||
/**
|
||||
* Returns the post_type quotas
|
||||
*
|
||||
* @since 1.7.0
|
||||
* @return array
|
||||
*/
|
||||
public function get_post_type_quotas(): ?array {
|
||||
|
||||
$quotas = $this->quotas;
|
||||
|
||||
return array_filter($quotas, fn($quota_name) => !in_array($quota_name, array(
|
||||
'sites',
|
||||
'attachment',
|
||||
'upload',
|
||||
'users',
|
||||
'visits',
|
||||
), true), ARRAY_FILTER_USE_KEY);
|
||||
|
||||
} // end get_post_type_quotas;
|
||||
|
||||
} // end trait WP_Ultimo_Plan_Deprecated;
|
104
inc/traits/trait-wp-ultimo-settings-deprecated.php
Normal file
104
inc/traits/trait-wp-ultimo-settings-deprecated.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* A trait to be included in entities to WP_Settings Class depecrated methods.
|
||||
*
|
||||
* @package WP_Ultimo
|
||||
* @subpackage Deprecated
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
namespace WP_Ultimo\Traits;
|
||||
|
||||
/**
|
||||
* WP_Ultimo_Settings_Deprecated trait.
|
||||
*/
|
||||
trait WP_Ultimo_Settings_Deprecated {
|
||||
|
||||
/**
|
||||
* Adds the legacy scripts.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_legacy_scripts() {
|
||||
/*
|
||||
* Mailchimp: Backwards compatibility.
|
||||
*/
|
||||
if (wp_script_is('wu-mailchimp', 'registered')) {
|
||||
|
||||
wp_enqueue_script('wu-mailchimp');
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end handle_legacy_scripts;
|
||||
|
||||
/**
|
||||
* Handle legacy hooks to support old versions of our add-ons.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_legacy_filters() {
|
||||
|
||||
$legacy_settings = array();
|
||||
|
||||
/*
|
||||
* Fetch Extra Sections
|
||||
*/
|
||||
$sections = apply_filters_deprecated('wu_settings_sections', array(array()), '2.0.0', 'wu_register_settings_section()');
|
||||
|
||||
foreach ($sections as $section_key => $section) {
|
||||
|
||||
if ($section_key === 'activation') {
|
||||
|
||||
continue; // No activation stuff;
|
||||
|
||||
} // end if;
|
||||
|
||||
$legacy_settings = array_merge($legacy_settings, $section['fields']);
|
||||
|
||||
} // end foreach;
|
||||
|
||||
$filters = array(
|
||||
'wu_settings_section_general',
|
||||
'wu_settings_section_network',
|
||||
'wu_settings_section_domain_mapping',
|
||||
'wu_settings_section_payment_gateways',
|
||||
'wu_settings_section_emails',
|
||||
'wu_settings_section_styling',
|
||||
'wu_settings_section_tools',
|
||||
'wu_settings_section_advanced',
|
||||
);
|
||||
|
||||
foreach ($filters as $filter) {
|
||||
|
||||
$message = __('Adding setting sections directly via filters is no longer supported.');
|
||||
|
||||
$legacy_settings = apply_filters_deprecated($filter, array($legacy_settings), '2.0.0', 'wu_register_settings_field()', $message);
|
||||
|
||||
} // end foreach;
|
||||
|
||||
if ($legacy_settings) {
|
||||
|
||||
$this->add_section('other', array(
|
||||
'title' => __('Other', 'wp-ultimo'),
|
||||
'desc' => __('Other', 'wp-ultimo'),
|
||||
));
|
||||
|
||||
foreach ($legacy_settings as $setting_key => $setting) {
|
||||
|
||||
if (strpos((string) $setting_key, 'license_key_') !== false) {
|
||||
|
||||
continue; // Remove old license key fields
|
||||
|
||||
} // end if;
|
||||
|
||||
$this->add_field('other', $setting_key, $setting);
|
||||
|
||||
} // end foreach;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end handle_legacy_filters;
|
||||
|
||||
} // end trait WP_Ultimo_Settings_Deprecated;
|
65
inc/traits/trait-wp-ultimo-site-deprecated.php
Normal file
65
inc/traits/trait-wp-ultimo-site-deprecated.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* A trait to be included in entities to WU_Site Class deprecated methods.
|
||||
*
|
||||
* @package WP_Ultimo
|
||||
* @subpackage Deprecated
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
namespace WP_Ultimo\Traits;
|
||||
|
||||
/**
|
||||
* WP_Ultimo_Site_Deprecated trait.
|
||||
*/
|
||||
trait WP_Ultimo_Site_Deprecated {
|
||||
|
||||
/**
|
||||
* Magic getter to provide backwards compatibility for plans.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @throws \Exception Throws an exception when trying to get a key that is not available or back-compat.
|
||||
* @param string $key Property to get.
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key) {
|
||||
|
||||
$value = null;
|
||||
|
||||
switch ($key) {
|
||||
|
||||
case 'site_owner_id':
|
||||
$customer = $this->get_customer();
|
||||
$value = $customer ? $customer->get_user_id() : false;
|
||||
break;
|
||||
|
||||
} // end switch;
|
||||
|
||||
/**
|
||||
* Let developers know that this is not going to be supported in the future.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
_doing_it_wrong($key, __('Product keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
|
||||
|
||||
return $value;
|
||||
|
||||
} // end __get;
|
||||
|
||||
/**
|
||||
* Deprecated: get_subscription.
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @return \WP_Ultimo\Models\Membership
|
||||
*/
|
||||
public function get_subscription() {
|
||||
|
||||
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site::get_membership()');
|
||||
|
||||
return $this->get_membership();
|
||||
|
||||
} // end get_subscription;
|
||||
|
||||
} // end trait WP_Ultimo_Site_Deprecated;
|
49
inc/traits/trait-wp-ultimo-subscription-deprecated.php
Normal file
49
inc/traits/trait-wp-ultimo-subscription-deprecated.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* A trait to be included in entities to WU_Subscription Class deprecated methods.
|
||||
*
|
||||
* @package WP_Ultimo
|
||||
* @subpackage Deprecated
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
namespace WP_Ultimo\Traits;
|
||||
|
||||
/**
|
||||
* WP_Ultimo_Subscription_Deprecated trait.
|
||||
*/
|
||||
trait WP_Ultimo_Subscription_Deprecated {
|
||||
|
||||
/**
|
||||
* Magic getter to provide backwards compatibility for subs.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @throws \Exception Throws an exception when trying to get a key that is not available or back-compat.
|
||||
* @param string $key Property to get.
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key) {
|
||||
|
||||
$value = null;
|
||||
|
||||
switch ($key) {
|
||||
|
||||
case 'plan_id':
|
||||
$value = $this->get_plan_id();
|
||||
break;
|
||||
|
||||
} // end switch;
|
||||
|
||||
/**
|
||||
* Let developers know that this is not going to be supported in the future.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
_doing_it_wrong($key, __('Membership keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
|
||||
|
||||
return $value;
|
||||
|
||||
} // end __get;
|
||||
|
||||
} // end trait WP_Ultimo_Subscription_Deprecated;
|
Reference in New Issue
Block a user