public function enqueue_scripts() { global $gadsense_globals, $pagenow, $post_type; $screen = get_current_screen(); $plugin = Advanced_Ads_Admin::get_instance(); if ('post-new.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type || 'post.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type && isset($_GET['action']) && 'edit' == $_GET['action']) { $default_script = array('path' => GADSENSE_BASE_URL . 'admin/assets/js/new-ad.js', 'dep' => array('jquery'), 'version' => null); $scripts = array('gadsense-new-ad' => $default_script); // Allow modifications of script files to enqueue $scripts = apply_filters('advanced-ads-gadsense-ad-param-script', $scripts); foreach ($scripts as $handle => $value) { if (empty($handle)) { continue; } if (!empty($handle) && empty($value)) { // Allow inclusion of WordPress's built-in script like jQuery wp_enqueue_script($handle); } else { if (!isset($value['version'])) { $value['version'] = null; } wp_enqueue_script($handle, $value['path'], $value['dep'], $value['version']); } } $styles = array(); // Allow modifications of default style files to enqueue $styles = apply_filters('advanced-ads-gadsense-ad-param-style', $styles); foreach ($styles as $handle => $value) { if (!isset($value['path']) || !isset($value['dep']) || empty($handle)) { continue; } if (!isset($value['version'])) { $value['version'] = null; } wp_enqueue_style($handle, $value['path'], $value['dep'], $value['version']); } } }
return; } // load basic path to the plugin define('ADVADS_BASE_PATH', plugin_dir_path(__FILE__)); define('ADVADS_BASE_URL', plugin_dir_url(__FILE__)); define('ADVADS_BASE_DIR', dirname(plugin_basename(__FILE__))); // directory of the plugin without any paths // general and global slug, e.g. to store options in WP, textdomain define('ADVADS_SLUG', 'advanced-ads'); define('ADVADS_URL', 'https://wpadvancedads.com/'); define('ADVADS_VERSION', '1.6.2.1'); /*----------------------------------------------------------------------------* * Autoloading, modules and functions *----------------------------------------------------------------------------*/ // load public functions (might be used by modules, other plugins or theme) require_once ADVADS_BASE_PATH . 'includes/functions.php'; require_once ADVADS_BASE_PATH . 'includes/load_modules.php'; Advanced_Ads_ModuleLoader::getLoader(); // enable autoloading /*----------------------------------------------------------------------------* * Public-Facing and Core Functionality *----------------------------------------------------------------------------*/ Advanced_Ads::get_instance(); Advanced_Ads_ModuleLoader::loadModules(ADVADS_BASE_PATH . 'modules/'); // enable modules, requires base class /*----------------------------------------------------------------------------* * Dashboard and Administrative Functionality *----------------------------------------------------------------------------*/ if (is_admin()) { Advanced_Ads_Admin::get_instance(); }
/** * deactivate license of an add-on * * @since 1.6.11 */ public function deactivate_license() { // check nonce check_ajax_referer('advads_ajax_license_nonce', 'security'); if (!isset($_POST['addon']) || $_POST['addon'] === '') { die; } echo Advanced_Ads_Admin::get_instance()->deactivate_license($_POST['addon'], $_POST['pluginname'], $_POST['optionslug']); die; }
/** * check if license keys are already expired * * @since 1.6.6 * @update 1.6.9 moved from Advanced_Ads_Plugin * @return true if there are expired licenses */ public static function licenses_expired() { $add_ons = apply_filters('advanced-ads-add-ons', array()); if ($add_ons === array()) { return false; } $now = time(); foreach ($add_ons as $_add_on_key => $_add_on) { // don’t display error for invalid licenses if (Advanced_Ads_Admin::get_instance()->get_license_status($_add_on['options_slug']) === 'invalid') { continue; } $expiry_date = Advanced_Ads_Admin::get_instance()->get_license_expires($_add_on['options_slug']); if ($expiry_date && strtotime($expiry_date) < $now) { return true; } } return false; }
<?php $errortext = false; $expires = Advanced_Ads_Admin::get_instance()->get_license_expires($options_slug); $expired = false; if ($expires) { $expires_time = strtotime($expires); $days_left = ($expires_time - time()) / DAY_IN_SECONDS; if ($days_left <= 0) { $plugin_url = isset($plugin_url) ? $plugin_url : ADVADS_URL; $errortext = sprintf(__('Your license expired. Please visit <a href="%s" target="_blank">the plugin page</a> to renew it.', 'advanced-ads'), $plugin_url . '#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses'); $expired = true; } } ?> <input type="text" class="regular-text" placeholder="<?php _e('License key', 'advanced-ads'); ?> " name="<?php echo ADVADS_SLUG . '-licenses'; ?> [<?php echo $index; ?> ]" value="<?php echo esc_attr_e($license_key); ?> " <?php