, Github: https://github.com/alexkovalevv * @since 2.0.7 */ class License extends PageBase { /** * {@inheritdoc} * * @author Alexander Kovalev * @since 2.1.2 * @var string */ public $type = "page"; /** * {@inheritdoc} * * @author Alexander Kovalev * @since 2.1.2 * @var string */ public $page_menu_dashicon = 'dashicons-admin-network'; /** * {@inheritdoc} * * @author Alexander Kovalev * @since 2.1.2 * @var bool */ public $show_right_sidebar_in_options = false; /** * {@inheritdoc} * * @author Alexander Kovalev * @since 2.1.2 * @var int */ public $page_menu_position = 0; /** * {@inheritdoc} * * @author Alexander Kovalev * @since 2.1.2 * @var bool */ public $available_for_multisite = true; /** * @author Alexander Kovalev * @since 2.1.2 * @var string */ public $plugin_name; /** * @var string Name of the paid plan. */ public $plan_name; // PREMIUM SECTION // ------------------------------------------------------------------ /** * @since 2.0.7 * @var bool */ protected $is_premium; /** * @since 2.0.7 * @var \WBCR\Factory_480\Premium\Provider */ protected $premium; /** * @since 2.0.7 * @var bool */ protected $is_premium_active; /** * @since 2.0.7 * @var bool */ protected $premium_has_subscription; /** * @since 2.0.7 * @var \WBCR\Factory_480\Premium\Interfaces\License */ protected $premium_license; // END PREMIUM SECTION // ------------------------------------------------------------------ /** * {@inheritdoc} * @param \Wbcr_Factory480_Plugin $plugin */ public function __construct(\Wbcr_Factory480_Plugin $plugin) { $this->plugin = $plugin; parent::__construct($plugin); if( !$this->id ) { $this->id = $this->plugin->getPrefix() . 'license'; } $this->plugin_name = $this->plugin->getPluginName(); $this->premium = $plugin->premium; $this->is_premium = $this->premium->is_activate(); $this->is_premium_active = $this->premium->is_active(); $this->premium_has_subscription = $this->premium->has_paid_subscription(); $this->premium_license = $this->premium->get_license(); add_action("wp_ajax_wbcr-clearfy-activate-license-for-{$this->plugin_name}", [$this, 'ajax_handler']); } /** * [MAGIC] Magic method that configures assets for a page. */ public function assets($scripts, $styles) { parent::assets($scripts, $styles); $this->styles->add(FACTORY_TEMPLATES_134_URL . '/assets/css/license-manager.css'); $this->scripts->add(FACTORY_TEMPLATES_134_URL . '/assets/js/clearfy-license-manager.js'); } /** * Регистрируем ajax обработчик для текущей страницы * * @since 2.0.7 */ public function ajax_handler() { wbcr_factory_templates_134_check_license($this->plugin); } /** * {@inheritdoc} */ public function showPageContent() { ?>
plugin_name}") ?>"> show_license_form(); ?>
is_premium ) { return ''; } return $this->premium_license->get_hidden_key(); } /** * @return string */ protected function get_plan() { if( !$this->is_premium ) { return 'free'; } return $this->premium->get_plan(); } /** * @return mixed */ protected function get_expiration_days() { if( !$this->is_premium ) { return ''; } return $this->premium_license->get_expiration_time('days'); } /** * @return string */ protected function get_billing_cycle_readable() { if( !$this->is_premium ) { return ''; } $billing_cycle = $this->premium->get_billing_cycle(); $billing = 'lifetime'; if( 1 == $billing_cycle ) { $billing = 'month'; } else if( 12 == $billing_cycle ) { $billing = 'year'; } return $billing; } /** * Тип лицензии, цветовое оформление для формы лицензирования * free - бесплатная * gift - пожизненная лицензия, лицензия на особых условиях * trial - красный цвет, применяется для триалов, если лиценизия истекла или заблокирована * paid - обычная оплаченная лицензия, в данный момент активна. * * @return string */ protected function get_license_type() { if( !$this->is_premium ) { return 'free'; } $license = $this->premium_license; if( $license->is_lifetime() ) { return 'gift'; } else if( $license->get_expiration_time('days') < 1 ) { return 'trial'; } return 'paid'; } protected function render_learnmore_section() { if( $this->is_premium ): ?>

Lean more about the premium version and get the license key to activate it now!', 'wbcr_factory_templates_134'), $this->plugin->get_support()->get_pricing_url(true, 'license_page')); ?>

this page and login using the e-mail address associated with your purchase.', 'wbcr_factory_templates_134'), $this->plugin->get_support()->get_contacts_url(true, 'license_page')) ?>

plan_name) ?>

get_plan_description() ?>

get_error_message(), 'wbcr_factory_templates_134') ?>

get_license_type() == 'free' ): ?>

plugin->getPluginTitle()) ?>

is_premium ): ?>

get_plan()); ?> is_premium && $this->premium_has_subscription ): ?> (get_billing_cycle_readable())); ?>)

is_premium ): ?>
get_hidden_license_key()) ?>
is_premium ): ?>

is_premium && $this->premium_has_subscription ): ?>

cancel subscription', 'wbcr_factory_templates_134') ?>

get_license_type() == 'trial' ): ?>

is_premium ) : ?> is_premium ): ?>
get_plan() ?> premium_license->get_count_active_sites()); ?> premium_license->get_sites_quota()); ?> plugin->getPluginVersion() ?> version get_license_type() == 'trial' ): ?> premium_license->is_lifetime() ) { echo 'infiniate'; } else { echo $this->get_expiration_days(); } ?>
is_premium): ?>

render_learnmore_section(); ?>