/** * Constructor * * @author peshkov@UD */ public function __construct() { parent::__construct(); /** Handle screen option 'per page' */ add_filter('set-screen-option', array($this, 'set_per_page_option'), 10, 3); /** Init Administration Menu */ add_action('admin_menu', array($this, 'admin_menu'), 20); }
/** * */ public function __construct($args = array()) { parent::__construct($args); //echo "<pre>"; print_r( $args ); echo "</pre>"; die(); //** Set UD API URL. Can be defined custom one in wp-config.php */ $this->api_url = defined('UD_API_URL') ? trailingslashit(UD_API_URL) : 'https://www.usabilitydynamics.com/'; //** Don't ever change this, as it will mess with the data stored of which products are activated, etc. */ $this->token = 'udl_' . $this->slug; //** API */ $this->api = new API(array_merge($args, array('api_url' => $this->api_url, 'token' => $this->token))); //** Set available screens */ $screens = array(); if ($this->type == 'theme') { $screens = array_filter(array('licenses' => __('License', $this->domain), 'more_products' => false)); } elseif ($this->type == 'plugin') { $screens = array_filter(array('licenses' => __('Licenses', $this->domain), 'more_products' => __('More Products', $this->domain))); } //** UI */ $this->ui = new UI(array_merge($args, array('token' => $this->token, 'screens' => $screens))); $path = wp_normalize_path(dirname(dirname(__DIR__))); $this->screens_path = trailingslashit($path . '/static/templates'); if ($this->type == 'theme' && strpos($path, wp_normalize_path(WP_PLUGIN_DIR)) === false) { $root_path = wp_normalize_path(get_template_directory()); $this->assets_url = trailingslashit(get_template_directory_uri() . str_replace($root_path, '', $path) . '/static'); } else { $this->assets_url = trailingslashit(plugin_dir_url(dirname(dirname(__DIR__)) . '/readme.md') . 'static'); } //** Load the updaters. */ add_action('admin_init', array($this, 'load_updater_instances')); //** Ensure keys are actually active on specific screens */ add_action('current_screen', array($this, 'current_screen')); if ($this->type == 'plugin') { //** Check Activation Statuses */ add_action('plugins_loaded', array($this, 'check_activation_status'), 11); } elseif ($this->type == 'theme') { $this->check_activation_status(); } //** Add Licenses page */ add_action('admin_menu', array($this, 'register_licenses_screen'), 999); //** Admin Notices Filter */ add_filter('ud:errors:admin_notices', array($this, 'maybe_remove_notices')); add_filter('ud:messages:admin_notices', array($this, 'maybe_remove_notices')); add_filter('ud:warnings:admin_notices', array($this, 'maybe_remove_notices')); /** * May be add additional information about available add-ons * for legacy users ( who purchased any deprecated premium feature ) */ add_action('ud::bootstrap::upgrade_notice::additional_info', array($this, 'maybe_add_info_to_upgrade_notice'), 10, 2); }
/** * Constructor * Attention: MUST NOT BE CALLED DIRECTLY! USE get_instance() INSTEAD! * * @author peshkov@UD */ protected function __construct($args) { parent::__construct($args); //** Define our Admin Notices handler object */ $this->errors = new Errors($args); //** Determine if Composer autoloader is included and modules classes are up to date */ $this->composer_dependencies(); //** Determine if plugin/theme requires or recommends another plugin(s) */ $this->plugins_dependencies(); // Maybe run install or upgrade processes. $this->maybe_run_upgrade_process(); //** Set install/upgrade pages if needed */ $this->define_splash_pages(); //** Maybe need to show UD splash page. Used static functions intentionaly. */ if (!has_action('admin_init', array(Dashboard::get_instance(), 'maybe_ud_splash_page'))) { add_action('admin_init', array(Dashboard::get_instance(), 'maybe_ud_splash_page')); } if (!has_action('admin_menu', array(Dashboard::get_instance(), 'add_ud_splash_page'))) { add_action('admin_menu', array(Dashboard::get_instance(), 'add_ud_splash_page')); } }
/** * */ public function __construct($args = array()) { global $_ud_license_updater; parent::__construct($args); //** Maybe get queued theme update */ if ($this->type == 'theme') { $this->maybe_get_queued_theme_update(); } elseif ($this->type == 'plugin') { add_action('plugins_loaded', array($this, 'load_queued_updates'), 10); } $_ud_license_updater = !is_array($_ud_license_updater) ? array() : $_ud_license_updater; $_ud_license_updater[$this->slug] = $this; //** Load the admin. */ if (is_admin()) { $this->admin = new Admin($args); } /** * HACK. * Filter the whitelist of hosts to redirect to. * It adds Admin URL ( in case it's different with home or site urls ) * to allowed list. * * @param array $hosts An array of allowed hosts. * @param bool|string $host The parsed host; empty if not isset. */ add_filter('allowed_redirect_hosts', function ($hosts, $host) { if (!is_array($hosts)) { $hosts = array(); } $schema = parse_url(admin_url()); if (isset($schema['host'])) { array_push($hosts, $schema['host']); $hosts = array_unique($hosts); } return $hosts; }, 99, 2); }
/** * */ public function __construct($args) { parent::__construct($args); add_action('admin_notices', array($this, 'admin_notices')); add_action('admin_head', array($this, 'dismiss')); }
/** * */ public function __construct($args) { parent::__construct($args); $this->api_url = isset($args['api_url']) ? $args['api_url'] : false; $this->token = isset($args['token']) ? $args['token'] : false; }
/** * Constructor */ public function __construct($args) { parent::__construct($args); $this->token = isset($args['token']) ? $args['token'] : array(); $this->available_screens = isset($args['screens']) ? $args['screens'] : array(); }