/** * It creates a new instance of this class. * * @param string $title The title of the page. * Default: empty string. * * @return NelioABAdminPage a new instance of this class. * * @since PHPDOC */ public function __construct($title = '') { $this->title = $title; $this->title_action = ''; $this->icon_id = 'icon-options-general'; $this->classes = array(); $this->message = false; try { $config = NelioABAccountSettings::check_user_settings(); } catch (Exception $e) { $config = false; } if ($config && NelioABSettings::is_upgrade_message_visible()) { $this->message = sprintf(__('<b><a href="%s">Upgrade to our Professional Plan</a></b> and get the most out of Nelio A/B Testing. Track <b>more visitors</b>, use the service on <b>more sites</b>, and benefit from our <b>consulting services</b>. <small><a class="dismiss-upgrade-notice" href="#" onClick="javascript:dismissUpgradeNotice();">Dismiss</a></small>', 'nelioab'), 'mailto:support@neliosoftware.com?' . 'subject=Nelio%20A%2FB%20Testing%20-%20Upgrade%20my%20Subscription&' . 'body=' . esc_html('I\'d like to upgrade my subscription plan. I\'m subscribed to Nelio A/B Testing with the following e-mail address: ' . NelioABAccountSettings::get_email() . '.')); } }
/** * PHPDOC * * @param string $url PHPDOC * @param array $params PHPDOC * @param boolean $skip_status_check PHPDOC * Default: false. * * @return WP_Error|array The response or WP_Error on failure. * * @throws Exception with the appropriate error code. * * @since PHPDOC */ public static function remote_post_raw($url, $params, $skip_status_check = false) { if (!$skip_status_check) { require_once NELIOAB_MODELS_DIR . '/visitor.php'; try { NelioABAccountSettings::check_user_settings(); } catch (Exception $e) { throw $e; } } if (!isset($params['timeout'])) { $params['timeout'] = 30; } $params['sslverify'] = false; $result = wp_remote_post($url, $params); NelioABBackend::throw_exceptions_if_any($result); return $result; }
public function init() { // If the user has been disabled... get out of here try { $aux = NelioABAccountSettings::check_user_settings(); } catch (Exception $e) { // We do nothing here (if the user is deactivated, proper "ERROR" pages will be shown). // However, it is important we add the check here: if the user was deactivated, but it // no longer is, then it's important his settings are checked from the admin area. } // Some relevant global warnings // ----------------------------- // If the current user is NOT admin, do not show the plugin if (!nelioab_can_user_manage_plugin()) { return; } require_once NELIOAB_ADMIN_DIR . '/about.php'; NelioABAboutPage::get_instance(); $this->process_special_pages(); // Iconography add_action('admin_head', array($this, 'add_custom_styles')); // Some hooks add_action('wp_count_posts', array($this, 'exclude_alternatives_from_post_count'), 10, 2); add_action('pre_get_posts', array($this, 'exclude_alternative_posts_and_pages')); add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2); // (Super)Settings for multisite add_action('network_admin_menu', array($this, 'create_nelioab_site_settings_page')); // Regular settings add_action('admin_menu', array($this, 'create_nelioab_admin_pages')); require_once NELIOAB_ADMIN_DIR . '/views/settings-page.php'; add_action('admin_init', array('NelioABSettingsPage', 'register_settings')); add_action('admin_menu', array($this, 'configure_edit_nelioab_alternative')); // AJAX functions add_action('wp_ajax_nelioab_get_html_content', array($this, 'generate_html_content')); add_action('wp_ajax_nelioab_rated', array($this, 'mark_as_rated')); require_once NELIOAB_UTILS_DIR . '/wp-helper.php'; add_action('wp_ajax_nelioab_post_searcher', array('NelioABWpHelper', 'search_posts')); add_action('wp_ajax_nelioab_form_searcher', array('NelioABWpHelper', 'search_forms')); add_action('admin_enqueue_scripts', array(&$this, 'load_custom_style_and_scripts')); // Footer Message add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1); }
public static function build_error_page_on_invalid_settings() { // Check settings try { $aux = NelioABAccountSettings::check_user_settings(); } catch (Exception $e) { switch ($e->getCode()) { case NelioABErrCodes::DEACTIVATED_USER: case NelioABErrCodes::INVALID_MAIL: case NelioABErrCodes::INVALID_PRODUCT_REG_NUM: case NelioABErrCodes::NON_ACCEPTED_TAC: case NelioABErrCodes::BACKEND_NO_SITE_CONFIGURED: require_once NELIOAB_ADMIN_DIR . '/error-controller.php'; $view = NelioABErrorController::get_view($e); $view->render(); return true; default: return false; } } return false; }
/** * Returns the subscription plan of this user. * * @return int the subscription plan of this user. * * @since 2.1.0 */ public static function get_subscription_plan() { try { NelioABAccountSettings::check_user_settings(); } catch (Exception $e) { // Nothing to catch here } return self::get_nelioab_option('subscription_plan', NelioABAccountSettings::BASIC_SUBSCRIPTION_PLAN); }
/** * Remind users that they have to clean their cache after an update * * @return void * * @since PHPDOC */ function nelioab_add_cache_notice() { global $pagenow; if ('plugins.php' == $pagenow || 'update.php' == $pagenow) { return; } try { NelioABAccountSettings::check_user_settings(); } catch (Exception $e) { return; } $message = sprintf(__('You\'ve recently upgraded to <strong>Nelio A/B Testing %s</strong>. <strong>If you\'re running a cache system</strong> (such as <em>W3 Total Cache</em> or <em>WP Super Cache</em>) <strong>or if your server is behind a CDN</strong>, please <strong>clean all your caches</strong>. Otherwise, you may serve old versions of our tracking scripts and, therefore, the plugin may not work properly.', 'nelioab'), NELIOAB_PLUGIN_VERSION); ?> <div class="updated"> <p> <?php echo $message; ?> <a id="dismiss-nelioab-cache-notice" style="font-size:80%;" href="#"><?php _e('Dismiss'); ?> </a> </p> <script style="display:none;" type="text/javascript"> (function($) { $('a#dismiss-nelioab-cache-notice').on('click', function() { $.post( ajaxurl, {action:'nelioab_dismiss_cache_notice'} ); $(this).parent().parent().fadeOut(); }); })(jQuery); </script> </div> <?php }
/** * It initializes the controller. * * If Nelio's subscription has been deactivated, the plugin will do * nothing at all. * * @return void */ public function init() { // If the user has been disabled... get out of here try { NelioABAccountSettings::check_user_settings(); } catch (Exception $e) { // It is important we add the check here: if the user was deactivated, but it no // longer is, then it's important his settings are rechecked so that we can // re-enable it. if ($e->getCode() == NelioABErrCodes::DEACTIVATED_USER) { return; } } // Load the Visitor class so that all assigned alternatives are require_once NELIOAB_MODELS_DIR . '/visitor.php'; NelioABVisitor::load(); // Trick for proper THEME ALT EXP testing require_once NELIOAB_UTILS_DIR . '/wp-helper.php'; // Theme alt exp related if (NelioABWpHelper::is_at_least_version(3.4)) { $aux = $this->controllers['alt-exp']; add_filter('stylesheet', array(&$aux, 'modify_stylesheet')); add_filter('template', array(&$aux, 'modify_template')); add_filter('sidebars_widgets', array(&$aux, 'show_the_appropriate_widgets')); add_filter('option_stylesheet', array(&$aux, 'modify_option_stylesheet')); add_filter('option_current_theme', array(&$aux, 'modify_option_current_theme')); require_once NELIOAB_UTILS_DIR . '/theme-compatibility-layer.php'; NelioABThemeCompatibilityLayer::make_compat(); } add_action('init', array(&$this, 'do_init')); add_action('init', array(&$this, 'init_admin_stuff')); }