Example #1
0
/**
 * This function determines whether the current user is able to manage the plugin or not.
 *
 * @return boolean PHPDOC
 *
 * @since PHPDOC
 */
function nelioab_can_user_manage_plugin()
{
    // If the user is super admin, he can use the plugin
    if (is_super_admin()) {
        return true;
    }
    // If we're in a multisite, admin users should be able to use the plugin.
    // But, who's admin? The super admin or a site admin? That depends...
    if (NelioABSettings::regular_admins_can_manage_plugin()) {
        if (current_user_can('manage_options')) {
            return true;
        }
    }
    return false;
}
Example #2
0
 /**
  * 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() . '.'));
     }
 }
 public function apply_alternative()
 {
     if (isset($_POST['original']) && isset($_POST['alternative'])) {
         $ori_id = $_POST['original'];
         $alt_id = $_POST['alternative'];
         $categories = isset($_POST['copy_categories']) && $_POST['copy_categories'] == 'on';
         $tags = isset($_POST['copy_tags']) && $_POST['copy_tags'] == 'on';
         $meta = isset($_POST['copy_meta']) && $_POST['copy_meta'] == 'on';
         NelioABSettings::set_copy_metadata($meta);
         NelioABSettings::set_copy_categories($categories);
         NelioABSettings::set_copy_tags($tags);
         require_once NELIOAB_UTILS_DIR . '/wp-helper.php';
         NelioABWPHelper::overwrite($ori_id, $alt_id, $meta, $categories, $tags);
         echo 'OK';
         die;
     }
 }
 /**
  * PHPDOC
  *
  * @param object            $json_goal PHPDOC
  * @param NelioABExperiment $exp       PHPDOC
  *
  * @return NelioABAltExpGoal PHPDOC
  *
  * @since PHPDOC
  */
 public static function build_goal_using_json4js($json_goal, $exp)
 {
     $goal = new NelioABAltExpGoal($exp);
     // If the goal was new, but it was also deleted, do nothing...
     if (isset($json_goal->wasDeleted) && $json_goal->wasDeleted) {
         if ($json_goal->id < 0) {
             return false;
         } else {
             $goal->set_to_be_deleted(true);
         }
     }
     $goal->set_id($json_goal->id);
     $goal->set_name($json_goal->name);
     if (isset($json_goal->benefit) && !empty($json_goal->benefit)) {
         $goal->set_benefit($json_goal->benefit);
     } else {
         $goal->set_benefit(NelioABSettings::get_def_conv_value());
     }
     foreach ($json_goal->actions as $json_action) {
         $action = NelioABAction::build_action_using_json4js($json_action);
         if ($action) {
             $goal->add_action($action);
         }
     }
     return $goal;
 }
 /**
  * PHPDOC
  *
  * @param boolean $ajax PHPDOC
  *
  * @return array PHPDOC
  *
  * @since PHPDOC
  */
 public function add_list_of_applied_headlines($ajax = false)
 {
     $res = array('nelioab' => array());
     if ($ajax) {
         if (isset($ajax['nelioab'])) {
             $res = $ajax;
         } else {
             $res['result'] = $ajax;
         }
     }
     if (NelioABSettings::get_headlines_quota_mode() == NelioABSettings::HEADLINES_QUOTA_MODE_ON_FRONT_PAGE) {
         /** @var NelioABController $nelioab_controller */
         global $nelioab_controller;
         $current_post_id = $nelioab_controller->get_queried_post_id();
         $front_page_id = nelioab_get_page_on_front();
         if ($front_page_id == 0) {
             $front_page_id = NelioABController::FRONT_PAGE__YOUR_LATEST_POSTS;
         }
         if ($front_page_id != $current_post_id) {
             $this->applied_headlines = array();
         }
     }
     $headlines = array();
     foreach ($this->applied_headlines as $hl) {
         array_push($headlines, implode(':', $hl));
     }
     $headlines = implode(',', $headlines);
     $res['nelioab']['headlines'] = $headlines;
     return $res;
 }
Example #6
0
 /**
  * PHPDOC
  *
  * @param int $benefit
  *
  * @return void
  *
  * @since PHPDOC
  */
 public function set_benefit($benefit)
 {
     try {
         $benefit = intval($benefit);
         if ($benefit > 0) {
             $this->benefit = $benefit;
         } else {
             $this->benefit = NelioABSettings::get_def_conv_value();
         }
     } catch (Exception $e) {
         $this->benefit = NelioABSettings::get_def_conv_value();
     }
 }
Example #7
0
 /**
  * This function registers Nelio tracking scripts.
  *
  * Our tracking scripts are:
  *
  * * `nelioab_appengine_script`: a script pointing to Google Cloud Storage,
  * with all the information about running experiments.
  * * `nelioab_tracking_script`: our tracking script.
  *
  * It also initializes some params that will be used by our tracking
  * script. They'll be available by means of the object `NelioABParams`.
  *
  * @return void
  *
  * @see self::load_tracking_script
  *
  * @since 3.3.2
  */
 public function register_tracking_script()
 {
     wp_register_script('nelioab_appengine_script', '//storage.googleapis.com/' . NELIOAB_BACKEND_NAME . '/' . NelioABAccountSettings::get_site_id() . '.js', array(), NELIOAB_PLUGIN_VERSION);
     wp_register_script('nelioab_tracking_script', nelioab_asset_link('/js/tracking.min.js', false), array('jquery', 'nelioab_appengine_script'), NELIOAB_PLUGIN_VERSION);
     // Prepare some information for our tracking script (such as the page we're in)
     /** @var $aux NelioABAlternativeExperimentController */
     $aux = $this->controllers['alt-exp'];
     $current_id = $this->get_queried_post_id();
     if ($aux->is_post_in_a_post_alt_exp($current_id)) {
         $current_actual_id = intval($aux->get_post_alternative($current_id));
     } elseif ($aux->is_post_in_a_headline_alt_exp($current_id)) {
         $headline_data = $aux->get_headline_experiment_and_alternative($current_id);
         /** @var NelioABAlternative $alternative */
         $alternative = $headline_data['alt'];
         $val = $alternative->get_value();
         $current_actual_id = $val['id'];
     } else {
         $current_actual_id = $current_id;
     }
     $current_page_ids = array('currentId' => $current_id, 'currentActualId' => $current_actual_id);
     // OUTWARDS NAVIGATIONS USING TARGET="_BLANK"
     $misc['useOutwardsNavigationsBlank'] = NelioABSettings::use_outwards_navigations_blank();
     $this->tracking_script_params = array('ajaxurl' => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'version' => NELIOAB_PLUGIN_VERSION, 'customer' => NelioABAccountSettings::get_customer_id(), 'site' => NelioABAccountSettings::get_site_id(), 'backend' => array('domain' => NELIOAB_BACKEND_DOMAIN, 'version' => NELIOAB_BACKEND_VERSION), 'misc' => $misc, 'sync' => array('headlines' => array()), 'info' => $current_page_ids, 'ieUrl' => preg_replace('/^https?:/', '', NELIOAB_URL . '/ajax/iesupport.php'), 'wasPostRequest' => 'POST' === $_SERVER['REQUEST_METHOD']);
 }
        /**
         * This function prints the list of goals (a set of cards). It also
         * prepares the "card" template, which is used by the JavaScript code
         * for adding new cards.
         *
         * Each kind of possible goal (the form for adding it) is also printed
         * by this function.
         */
        protected function print_goals()
        {
            $handler = '<i class="handler dashicons-before dashicons-menu"><br></i>';
            ?>
			<div id="new-action-templates">
				<?php 
            require_once NELIOAB_UTILS_DIR . '/html-generator.php';
            ?>
				<div class="action page" style="display:none;">
					<?php 
            echo $handler;
            $options = NelioABHtmlGenerator::get_page_searcher('new-action-page-searcher', false, 'no-drafts', array(), false);
            $this->print_post_or_form_action('page', $options, !$this->is_global);
            ?>
					<a href="javascript:;" class="delete"><?php 
            _e('Delete');
            ?>
</a>
				</div>
				<div class="action post" style="display:none;">
					<?php 
            echo $handler;
            $options = NelioABHtmlGenerator::get_post_searcher('new-action-post-searcher', false, 'no-drafts', array(), false);
            $this->print_post_or_form_action('post', $options, !$this->is_global);
            ?>
					<a href="javascript:;" class="delete"><?php 
            _e('Delete');
            ?>
</a>
				</div>
				<div class="action wc-order-completed" style="display:none;">
					<?php 
            echo $handler;
            $options = NelioABHtmlGenerator::get_post_searcher_based_on_type('new-wc-order-completed-searcher', false, 'no-drafts', array(), false, array('product'));
            $text = __('An order containing the product %1$s is completed.', 'nelioab');
            printf($text, $options);
            ?>
					<a href="javascript:;" class="delete"><?php 
            _e('Delete');
            ?>
</a>
				</div>
				<div class="action external-page" style="display:none;">
					<?php 
            echo $handler;
            $name = sprintf('<input type="text" class="name" placeholder="%s" style="max-width:120px;">', __('Name', 'nelioab'));
            $url = sprintf('<input type="text" class="url" placeholder="%s" style="max-width:200px;">', __('URL', 'nelioab'));
            $options = '<select class="url_mode">';
            $options .= sprintf('<option value="exact">%s</option>', __('whose URL is', 'nelioab'));
            $options .= sprintf('<option value="starts-with">%s</option>', __('whose URL starts with', 'nelioab'));
            $options .= sprintf('<option value="contains">%s</option>', __('whose URL contains', 'nelioab'));
            $options .= sprintf('<option value="ends-with">%s</option>', __('whose URL ends with', 'nelioab'));
            $options .= '</select>';
            if (!$this->is_global) {
                $indirect = '<select class="direct">';
                if ($this->tests_a_page) {
                    $indirect .= ' <option value="1">' . __('from the tested page', 'nelioab') . '</option>';
                    $indirect .= ' <option value="0">' . __('from any page', 'nelioab') . '</option>';
                } else {
                    $indirect .= ' <option value="1">' . __('from the tested post', 'nelioab') . '</option>';
                    $indirect .= ' <option value="0">' . __('from any page', 'nelioab') . '</option>';
                }
                printf(__('A visitor accesses %4$s the page %1$s, %2$s %3$s', 'nelioab'), $name, $options, $url, $indirect);
            } else {
                printf(__('A visitor accesses the page %1$s, %2$s %3$s', 'nelioab'), $name, $options, $url);
                printf('<input type="hidden" class="direct" value="0" />');
            }
            ?>
					<a href="javascript:;" class="delete"><?php 
            _e('Delete');
            ?>
</a>
				</div>
				<div class="action form-submit cf7" style="display:none;"><?php 
            echo $handler;
            $options = NelioABHtmlGenerator::get_form_searcher('new-cf7-form-searcher', false, array(), false);
            $this->print_post_or_form_action('cf7-submit', $options, !$this->is_global);
            ?>
					<a href="javascript:;" class="delete"><?php 
            _e('Delete');
            ?>
</a>
				</div>
				<div class="action form-submit gf" style="display:none;"><?php 
            echo $handler;
            $options = NelioABHtmlGenerator::get_form_searcher('new-gf-form-searcher', false, array(), false);
            $this->print_post_or_form_action('gf-submit', $options, !$this->is_global);
            ?>
					<a href="javascript:;" class="delete"><?php 
            _e('Delete');
            ?>
</a>
				</div>
				<div class="action click-element" style="display:none;"><?php 
            echo $handler;
            $name = sprintf('<input type="text" class="value" placeholder="%s" style="max-width:200px;">', __('Matcher', 'nelioab'));
            require_once NELIOAB_MODELS_DIR . '/goals/actions/click-element-action.php';
            $options = '<select class="mode">';
            $options .= sprintf('<option value="%s">%s</option>', NelioABClickElementAction::ID_MODE, __('whose ID is', 'nelioab'));
            $options .= sprintf('<option value="%s">%s</option>', NelioABClickElementAction::CSS_MODE, __('that matches the CSS Selector rule', 'nelioab'));
            $options .= sprintf('<option value="%s">%s</option>', NelioABClickElementAction::TEXT_MODE, __('that contains the text', 'nelioab'));
            $options .= '</select>';
            printf(__('A visitor clicks on an element %1$s %2$s', 'nelioab'), $options, $name);
            ?>
					<a href="javascript:;" class="delete"><?php 
            _e('Delete');
            ?>
</a>
				</div>
			</div>

			<div style="display:none;">
				<span id="defaultNameForMainGoal" style="display:none;"><?php 
            _e('Default', 'nelioab');
            ?>
</span>
				<?php 
            $this->print_beautiful_box('goal-template', '<span class="form" style="font-weight:normal;">' . '  <input type="text" class="new-name">' . '  <a class="button rename">' . __('Save') . '</a>' . '</span>' . '<span class="name" style="display:none;">' . '  <span style="width:25%;max-width:120px;float:right">' . '    <input style="width:100%;" type="number" min="1" class="benefit" placeholder="' . sprintf(__('Benefit - %1$s%2$s', 'nelioab'), NelioABSettings::get_conv_unit(), NelioABSettings::get_def_conv_value()) . '" />' . '  </span>' . '  <span class="value">' . __('Unnamed Goal', 'nelioab') . '</span>' . '  <small class="isMain" style="display:none;font-weight:normal;">' . __('[Main Goal]', 'nelioab') . '</small><br>' . '  <div class="row-actions">' . '    <span class="rename"><a href="javascript:;">' . __('Rename') . '</a></span>' . '    <span class="sep">|</span>' . '    <span class="delete"><a href="javascript:;">' . __('Delete') . '</a></span>' . '  </div>' . '</span>', array($this, 'print_new_card_content'));
            ?>
			</div>
			<div id="goal-list"></div>
			<h2 style="text-align:center;margin-top:-10px;"><a class="add-new-h2" href="javascript:;" onClick="javascript:NelioABGoalCards.create();"><?php 
            _e('Add Additional Goal', 'nelioab');
            ?>
</a></h2>
			<?php 
        }
 public function save_settings()
 {
     $aux = $_POST['plugin_available_to'];
     $enabled_for_everybody = $_POST['plugin_available_to'] == NelioABSettings::PLUGIN_AVAILABLE_TO_ANY_ADMIN;
     NelioABSettings::set_site_option_regular_admins_can_manage_plugin($enabled_for_everybody);
 }
        protected function print_dialog_content()
        {
            $exp = $this->exp;
            ?>
			<p><?php 
            printf(__('You are about to overwrite the original %s with the content of an alternative. Please, remember <strong>this operation cannot be undone</strong>. Are you sure you want to overwrite it?', 'nelioab'), $this->post_type['name']);
            ?>
</p>
			<form id="apply_alternative" method="post" action="<?php 
            echo admin_url('admin.php?page=nelioab-experiments&action=progress&' . 'id=' . $exp->get_id() . '&' . 'type=' . $exp->get_type());
            ?>
">
				<input type="hidden" name="apply_alternative" value="true" />
				<input type="hidden" name="nelioab_exp_type" value="<?php 
            echo $exp->get_type();
            ?>
" />
				<input type="hidden" id="original" name="original" value="<?php 
            echo $exp->get_originals_id();
            ?>
" />
				<input type="hidden" id="alternative" name="alternative" value="" />
				<p><input type="checkbox" id="copy_content" name="copy_content" checked="checked" disabled="disabled" /><?php 
            _e('Override title and content', 'nelioab');
            ?>
</p>
				<p><input type="checkbox" id="copy_meta" name="copy_meta" <?php 
            if (NelioABSettings::is_copying_metadata_enabled()) {
                echo 'checked="checked" ';
            }
            ?>
/><?php 
            _e('Override all metadata', 'nelioab');
            ?>
</p>
				<?php 
            if (!'page' == $this->post_type['name']) {
                ?>
					<p><input type="checkbox" id="copy_categories" name="copy_categories" <?php 
                if (NelioABSettings::is_copying_categories_enabled()) {
                    echo 'checked="checked" ';
                }
                ?>
/><?php 
                _e('Override categories', 'nelioab');
                ?>
</p>
					<p><input type="checkbox" id="copy_tags" name="copy_tags" <?php 
                if (NelioABSettings::is_copying_tags_enabled()) {
                    echo 'checked="checked" ';
                }
                ?>
/><?php 
                _e('Override tags', 'nelioab');
                ?>
</p><?php 
            }
            ?>
			</form>
			<?php 
        }
Example #11
0
/**
 * This is an AJAX callback function, triggered by the action
 * <code>dismiss_upgrade_notice</code>. This action occurs when an admin user
 * dismisses an upgrade notice.
 */
function dismiss_upgrade_notice_callback()
{
    NelioABSettings::hide_upgrade_message();
    echo '0';
    die;
}
        protected function print_experiment_status($exp, $res, $the_winner, $the_winner_confidence, $originals_conversion_rate, $best_alt, $best_alt_conversion_rate, $best_alt_improvement_factor)
        {
            if ($res) {
                $message = NelioABGTest::generate_status_message($res->get_summary_status());
            } else {
                $message = NelioABGTest::generate_status_message(false);
            }
            $src = nelioab_admin_asset_link('/images/progress-no.png');
            if ($best_alt > 0) {
                $best_alt = '(' . __('Alternative', 'nelioab') . ' ' . $best_alt . ')';
            } else {
                $best_alt = '';
            }
            $arrow = '';
            $stats_color = 'auto';
            $gain = '';
            if (self::NO_WINNER == $the_winner) {
                $main_message = __('Testing...', 'nelioab');
                if (NelioABExperiment::STATUS_RUNNING == $exp->get_status()) {
                    $status_message = __('No alternative is better than the rest', 'nelioab');
                } else {
                    $status_message = __('No alternative was better than the rest', 'nelioab');
                }
            } else {
                $main_message = __('¡Winner!', 'nelioab');
                if ($the_winner == 0) {
                    if ($the_winner_confidence >= NelioABSettings::get_min_confidence_for_significance()) {
                        $status_message = sprintf(__('Original wins with a %1$s%% confidence', 'nelioab'), $the_winner_confidence);
                    } else {
                        $status_message = sprintf(__('Original wins with just a %1$s%% confidence', 'nelioab'), $the_winner_confidence);
                    }
                } else {
                    if ($the_winner_confidence >= NelioABSettings::get_min_confidence_for_significance()) {
                        $status_message = sprintf(__('Alternative %1$s wins with a %2$s%% confidence', 'nelioab'), $the_winner, $the_winner_confidence);
                    } else {
                        $status_message = sprintf(__('Alternative %1$s wins with just a %2$s%% confidence', 'nelioab'), $the_winner, $the_winner_confidence);
                    }
                }
                if ($the_winner_confidence >= NelioABSettings::get_min_confidence_for_significance()) {
                    $src = nelioab_admin_asset_link('/images/progress-yes.png');
                } else {
                    $src = nelioab_admin_asset_link('/images/progress-yes-no.png');
                }
            }
            $print_improvement = false;
            if (is_numeric($best_alt_improvement_factor)) {
                // gain
                $alt_results = $this->results->get_alternative_results();
                $ori_conversions = $alt_results[0]->get_num_of_conversions();
                $aux = $ori_conversions * $this->goal->get_benefit() * $best_alt_improvement_factor / 100;
                $print_improvement = true;
                // format improvement factor
                if ($best_alt_improvement_factor < 0) {
                    $arrow = 'fa-arrow-down';
                    $stats_color = 'red';
                    $best_alt_improvement_factor = $best_alt_improvement_factor * -1;
                } else {
                    if ($best_alt_improvement_factor > 0) {
                        $arrow = 'fa-arrow-up';
                        $stats_color = 'green';
                    } else {
                        $print_improvement = false;
                        $arrow = 'fa-arrow-none';
                        $stats_color = 'black';
                    }
                }
                if ($aux > 0) {
                    $gain = sprintf(__('%1$s%2$s', 'nelioab', 'money'), NelioABSettings::get_conv_unit(), number_format_i18n($aux, 2));
                } else {
                    $gain = sprintf(__('%1$s%2$s', 'nelioab', 'money'), NelioABSettings::get_conv_unit(), number_format_i18n($aux * -1, 2));
                }
            }
            ?>

			<div id="info-status">
				<span class="main-message"><?php 
            echo $main_message;
            ?>
</span>
				<img src="<?php 
            echo $src;
            ?>
" title="<?php 
            echo $message;
            ?>
" alt="<?php 
            echo $message;
            ?>
" class="masterTooltip animated flipInY"/>
				<span class="additional-message"><?php 
            echo $status_message;
            ?>
</span>
			</div>
			<div id="ori-status">
				<span class="ori-name"><?php 
            _e('Original', 'nelioab');
            ?>
</span>
				<div id="ori-cr">
					<span class="ori-cr-title"><?php 
            _e('Conversion Rate', 'nelioab');
            ?>
</span>
					<span class="ori-cr-value"><?php 
            printf('%s %%', $originals_conversion_rate);
            ?>
</span>
				</div>
			</div>
			<div id="alt-status">
				<span class="alt-name"><?php 
            _e('Best Alternative', 'nelioab');
            ?>
 <?php 
            echo $best_alt;
            ?>
</span>
				<div id="alt-cr">
					<span class="alt-cr-title"><?php 
            _e('Conversion Rate', 'nelioab');
            ?>
</span>
					<span class="alt-cr"><?php 
            printf('%s %%', $best_alt_conversion_rate);
            ?>
</span>
				</div>
				<div id="alt-stats" style="color:<?php 
            echo $stats_color;
            ?>
;">
					<span class="alt-if"><i class="fa <?php 
            echo $arrow;
            ?>
" style="vertical-align: top;"></i><?php 
            if ($print_improvement) {
                printf('%s%%', $best_alt_improvement_factor);
            }
            ?>
</span>
					<span class="alt-ii"><i class="fa <?php 
            echo $arrow;
            ?>
" style="vertical-align: top;"></i><?php 
            if ($print_improvement) {
                echo $gain;
            }
            ?>
</span>
				</div>
			</div>
		<?php 
        }
Example #13
0
 /**
  * This function is an AJAX callback that looks for posts.
  *
  * It returns a list of up to 20 posts (or pages). It is used by the
  * select2 widget (an item selector that looks more beautiful than regular
  * the "select>option" combo.
  *
  * Accepted POST params are:
  *
  * * term: {string} the (part of the) string used to look for items.
  * * type: {array}  array containing the types of element are we looking.
  * * default_id: {int} (optional) if set, the item with that ID will be
  * returned. If that item is not found, then we'll perform a regular search
  * (as if the param had not been set).
  *
  * @return array a list of matching posts.
  *
  * @since PHPDOC
  */
 public static function search_posts()
 {
     $term = false;
     if (isset($_POST['term']) & !empty($_POST['term'])) {
         $term = $_POST['term'];
     }
     $types = array();
     if (isset($_POST['type'])) {
         $types = $_POST['type'];
     }
     if (!is_array($types)) {
         $types = array($types);
     }
     $status = 'publish';
     if (isset($_POST['drafts']) && 'show-drafts' == $_POST['drafts']) {
         $status = array('publish', 'draft');
     }
     $default_id = false;
     if (isset($_POST['default_id'])) {
         $default_id = $_POST['default_id'];
     }
     if ($default_id == -1) {
         $default_id = false;
     }
     $default_thumbnail = sprintf('<img src="data:image/gif;%s" class="%s" alt="%s" />', 'base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 'attachment-thumbnail wp-post-image nelioab-no-thumbnail', __('No featured image available', 'nelioab'));
     $args = array('post_title_like' => $term, 'posts_per_page' => 20, 'meta_key' => '_is_nelioab_alternative', 'meta_compare' => 'NOT EXISTS', 'post_status' => $status);
     if (count($types) > 0) {
         $aux = array();
         foreach ($types as $type) {
             if (strpos($type, 'nelioab-') === false) {
                 array_push($aux, $type);
             }
         }
         foreach ($types as $type) {
             if ('nelioab-all-post-types' == $type) {
                 array_push($aux, 'page');
                 array_push($aux, 'post');
                 foreach (NelioABWpHelper::get_custom_post_types() as $cpt) {
                     array_push($aux, $cpt->name);
                 }
             }
         }
         if (count($aux) > 0) {
             $args['post_type'] = $aux;
         }
     }
     if ($types && count($types) == 1 && 'page' === $types[0] && !$term) {
         $args['order'] = 'asc';
         $args['orderby'] = 'title';
     }
     $latest_post_item = false;
     if (in_array('nelioab-latest-posts', $types) || false !== $default_id) {
         $lp_title = __('Your latest posts', 'nelioab');
         if (!$term || strpos(strtolower($lp_title), strtolower($term)) !== false) {
             $latest_post_item = array('id' => NelioABController::FRONT_PAGE__YOUR_LATEST_POSTS, 'type' => '<i>latest-posts</i>', 'title' => self::fix_title($lp_title), 'status' => '<i>dynamic</i>', 'date' => '', 'author' => 'WordPress', 'thumbnail' => $default_thumbnail);
         }
     }
     $theme_based_landing_page = false;
     if (in_array('nelioab-theme-landing-page', $types) && NelioABSettings::does_theme_use_a_custom_landing_page() || NelioABController::FRONT_PAGE__THEME_BASED_LANDING == $default_id) {
         $lp_title = __('Landing Page (Theme-based)', 'nelioab');
         if (!$term || strpos(strtolower($lp_title), strtolower($term)) !== false) {
             $theme_based_landing_page = array('id' => NelioABController::FRONT_PAGE__THEME_BASED_LANDING, 'type' => '<i>landing-page</i>', 'title' => self::fix_title($lp_title), 'status' => '<i>dynamic</i>', 'date' => '', 'author' => 'WordPress', 'thumbnail' => $default_thumbnail);
         }
     }
     // If there's a default_id set, it means that the user is interested
     // in one post only; I'm going to return that post to him
     if ($default_id !== false) {
         $id = $default_id;
         $post = false;
         if ($id == NelioABController::FRONT_PAGE__YOUR_LATEST_POSTS) {
             header('Content-Type: application/json');
             echo json_encode(array($latest_post_item));
             die;
         }
         if ($id == NelioABController::FRONT_PAGE__THEME_BASED_LANDING) {
             header('Content-Type: application/json');
             echo json_encode(array($theme_based_landing_page));
             die;
         }
         if ($id > 0) {
             $post = get_post($id);
         }
         if ($post) {
             $thumbnail = get_the_post_thumbnail($post->ID, 'thumbnail');
             if ($thumbnail === '') {
                 $thumbnail = $default_thumbnail;
             }
             $item = array('id' => $post->ID, 'title' => self::fix_title($post->post_title), 'thumbnail' => $thumbnail, 'excerpt' => $post->post_excerpt);
             header('Content-Type: application/json');
             echo json_encode(array($item));
             die;
         }
     }
     $result = array();
     add_filter('posts_where', array('NelioABWpHelper', 'add_title_filter_to_wpquery'), 10, 2);
     $my_query = new WP_Query($args);
     remove_filter('posts_where', array('NelioABWpHelper', 'add_title_filter_to_wpquery'), 10, 2);
     if ($my_query->have_posts()) {
         global $post;
         while ($my_query->have_posts()) {
             $my_query->the_post();
             $thumbnail = get_the_post_thumbnail($post->ID, 'thumbnail');
             if ($thumbnail === '') {
                 $thumbnail = $default_thumbnail;
             }
             $item = array('id' => $post->ID, 'type' => $post->post_type, 'title' => self::fix_title($post->post_title), 'status' => $post->post_status, 'date' => $post->post_date, 'excerpt' => $post->post_excerpt, 'author' => get_the_author(), 'thumbnail' => $thumbnail);
             array_push($result, $item);
         }
     }
     if ($latest_post_item) {
         array_unshift($result, $latest_post_item);
     }
     if ($theme_based_landing_page) {
         array_unshift($result, $theme_based_landing_page);
     }
     header('Content-Type: application/json');
     echo json_encode($result);
     die;
 }
 private function filter_experiments($status = false)
 {
     if (!$status) {
         $result = array();
         $filter_finished = NelioABSettings::show_finished_experiments();
         foreach ($this->experiments as $exp) {
             if ($exp->get_status() == NelioABExperiment::STATUS_FINISHED) {
                 if (NelioABSettings::FINISHED_EXPERIMENTS_HIDE_ALL == $filter_finished) {
                     continue;
                 }
                 if (NelioABSettings::FINISHED_EXPERIMENTS_SHOW_RECENT == $filter_finished && $exp->get_days_since_finalization() > 7) {
                     continue;
                 }
             }
             if ($exp->get_status() != NelioABExperiment::STATUS_TRASH) {
                 array_push($result, $exp);
             }
         }
         return $result;
     } else {
         $result = array();
         foreach ($this->experiments as $exp) {
             if ($exp->get_status() == $status) {
                 array_push($result, $exp);
             }
         }
         return $result;
     }
 }
 /**
  * Sets the result status of this experiment to the given status and confidence.
  *
  * @param int $status     the new status of the experiment.
  * @param int $confidence the confidence (from 0 to 100) we have in the status of the current results.
  *
  * @return void
  *
  * @since 3.0.0
  */
 public function set_result_status($status, $confidence)
 {
     $this->result_status = NelioABGTest::get_result_status_from_str($status);
     if (NelioABGTest::WINNER == $this->result_status) {
         if (NelioABSettings::get_min_confidence_for_significance() <= $confidence) {
             $this->result_status = NelioABGTest::WINNER_WITH_CONFIDENCE;
         }
     }
 }
Example #16
0
 /**
  * Returns PHPDOC
  *
  * @param int $status PHPDOC
  *
  * @return string PHPDOC
  *
  * @since PHPDOC
  */
 public static function generate_status_message($status)
 {
     $message = '';
     switch ($status) {
         case NelioABGTest::WINNER_WITH_CONFIDENCE:
             $message = sprintf(__('There is a clear winner, with a confidence greater than %s%%', 'nelioab'), NelioABSettings::get_min_confidence_for_significance());
             break;
         case NelioABGTest::WINNER:
             $message = sprintf(__('There is a possible winner, but keep in mind the confidence does not reach %s%%', 'nelioab'), NelioABSettings::get_min_confidence_for_significance());
             break;
         case NelioABGTest::NO_CLEAR_WINNER:
             $message = __('There is not enough data to determine any winner', 'nelioab');
             break;
         case NelioABGTest::NOT_ENOUGH_VISITS:
             $message = __('There are not enough visits', 'nelioab');
             break;
         case NelioABGTest::UNKNOWN:
         default:
             $message = __('There are not enough visits', 'nelioab');
     }
     return $message;
 }
        protected function print_the_real_alternatives()
        {
            // REAL ALTERNATIVES
            // -----------------------------------------
            $exp = $this->exp;
            if ($this->results == null) {
                $alt_results = null;
                $ori_conversions = 0;
            } else {
                $alt_results = $this->results->get_alternative_results();
                $ori_conversions = $alt_results[0]->get_num_of_conversions();
                // in this function, the original alternative is NOT used
                $alt_results = array_slice($alt_results, 1);
            }
            $conversions_label = __('Conversions', 'nelioab');
            $pageviews_label = __('Pageviews', 'nelioab');
            $conversion_views_label = __('Conversions / Views', 'nelioab');
            $conversion_rate_label = __('Conversion Rate', 'nelioab');
            $alternative_label = __('Alternative', 'nelioab');
            $colorscheme = NelioABWpHelper::get_current_colorscheme();
            $color = $colorscheme['primary'];
            $base_color = $color;
            $i = 0;
            foreach ($exp->get_alternatives() as $alt) {
                $i++;
                $name = $this->trunk($alt->get_name());
                $icon = $this->get_experiment_icon($exp);
                $id = $alt->get_id();
                $graphic_id = 'graphic-' . $id;
                if ($alt_results != null) {
                    $alt_result = $alt_results[$i - 1];
                    $pageviews = $alt_result->get_num_of_visitors();
                    $conversions = $alt_result->get_num_of_conversions();
                    $conversion_rate = $alt_result->get_conversion_rate();
                    $improvement_factor = $alt_result->get_improvement_factor();
                } else {
                    $pageviews = 0;
                    $conversions = 0;
                    $conversion_rate = 0.0;
                    $improvement_factor = 0.0;
                }
                $alt_conversion_views = $conversions . ' / ' . $pageviews;
                $aux = $ori_conversions * $this->goal->get_benefit() * $improvement_factor / 100;
                $print_improvement = true;
                // format improvement factor
                if ($improvement_factor < 0) {
                    $arrow = 'fa-arrow-down';
                    $stats_color = 'red';
                    $improvement_factor = $improvement_factor * -1;
                } else {
                    if ($improvement_factor > 0) {
                        $arrow = 'fa-arrow-up';
                        $stats_color = 'green';
                    } else {
                        // $improvement_factor = 0.0
                        $arrow = 'fa-none';
                        $stats_color = 'black';
                        $print_improvement = false;
                    }
                }
                if ($aux > 0) {
                    $gain = sprintf(__('%1$s%2$s', 'nelioab', 'money'), NelioABSettings::get_conv_unit(), number_format_i18n($aux, 2));
                } else {
                    $gain = sprintf(__('%1$s%2$s', 'nelioab', 'money'), NelioABSettings::get_conv_unit(), number_format_i18n($aux * -1, 2));
                }
                $alt_conversion_rate = number_format_i18n(floatval($conversion_rate), 2) . ' %';
                $alt_improvement_factor = number_format_i18n(floatval($improvement_factor), 2) . ' %';
                $alternative_number = $i;
                $winner = false;
                $winner_color = '';
                if ($this->is_winner($alt->get_id())) {
                    $icon = $this->get_winner_icon($exp);
                    $color = $colorscheme['winner'];
                    $winner_color = 'style="background-color:' . $colorscheme['primary'] . ';color:' . $colorscheme['foreground'] . ';"';
                    $winner = true;
                } else {
                    $color = $base_color;
                }
                $action_links = $this->get_action_links($exp, $alt->get_id(), $winner);
                $buttons = implode(' ', $action_links);
                if (!$print_improvement) {
                    $gain = '';
                    $alt_improvement_factor = '';
                }
                $result = <<<HTML
\t\t\t\t<div class="nelio-alternative alternative-{$i} postbox nelio-card">
\t\t\t\t\t<div class="alt-info-header" {$winner_color}>
\t\t\t\t\t\t{$icon}
\t\t\t\t\t\t<span class="alt-title">{$name}</span>
\t\t\t\t\t</div>
\t\t\t\t\t<div class="alt-info-body">
\t\t\t\t\t\t<div class="alt-screen no-hover" id="{$id}" style="color:{$color};">
\t\t\t\t\t\t\t\t<div class="alt-name">
\t\t\t\t\t\t\t\t\t{$alternative_label}
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t<div class="alt-number">
\t\t\t\t\t\t\t\t\t{$alternative_number}
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t</div>
\t\t\t\t\t\t<div class="alt-stats">
\t\t\t\t\t\t\t<div class="alt-stats-graphic" id="{$graphic_id}"></div>
\t\t\t\t\t\t\t<div class="alt-status">
\t\t\t\t\t\t\t\t<div class="alt-cv">
\t\t\t\t\t\t\t\t\t<span class="alt-cv-title">{$conversion_views_label}</span>
\t\t\t\t\t\t\t\t\t<span class="alt-cv">{$alt_conversion_views}</span>
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t<div class="alt-cr">
\t\t\t\t\t\t\t\t\t<span class="alt-cr-title">{$conversion_rate_label}</span>
\t\t\t\t\t\t\t\t\t<span class="alt-cr">{$alt_conversion_rate}</span>
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t<div class="alt-stats" style="color:{$stats_color};">
\t\t\t\t\t\t\t\t\t<span class="alt-if"><i class="fa {$arrow}" style="vertical-align: top;"></i>{$alt_improvement_factor}</span>
\t\t\t\t\t\t\t\t\t<span class="alt-ii"><i class="fa {$arrow}" style="vertical-align: top;"></i>{$gain}</span>
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t\t<div class="alt-info-footer">
\t\t\t\t\t\t<div class="alt-info-footer-content">
\t\t\t\t\t\t\t{$buttons}
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<script>
\t\t\t\tjQuery(document).ready(function() {
\t\t\t\t\tdrawAlternativeGraphic('{$graphic_id}',
\t\t\t\t\t\t{$conversions},
\t\t\t\t\t\t'{$conversions_label}',
\t\t\t\t\t\t'{$color}',
\t\t\t\t\t\t{$pageviews},
\t\t\t\t\t\t'{$pageviews_label}');
\t\t\t\t});
\t\t\t\t</script>
HTML;
                echo $result;
            }
        }
        protected function print_the_real_alternatives()
        {
            // REAL ALTERNATIVES
            // -----------------------------------------
            $exp = $this->exp;
            $the_themes = wp_get_themes();
            if ($this->results == null) {
                $alt_results = null;
                $ori_conversions = 0;
            } else {
                $alt_results = $this->results->get_alternative_results();
                $ori_conversions = $alt_results[0]->get_num_of_conversions();
                // in this function, the original alternative is NOT used
                $alt_results = array_slice($alt_results, 1);
            }
            $conversions_label = __('Conversions', 'nelioab');
            $pageviews_label = __('Pageviews', 'nelioab');
            $conversion_views_label = __('Conversions / Views', 'nelioab');
            $conversion_rate_label = __('Conversion Rate', 'nelioab');
            $alternative_label = __('Alternative', 'nelioab');
            $colorscheme = NelioABWpHelper::get_current_colorscheme();
            $color = $colorscheme['primary'];
            $base_color = $color;
            $i = 0;
            foreach ($exp->get_alternatives() as $alt) {
                $i++;
                $action_links = array();
                $name = $this->trunk($alt->get_name());
                $icon = $this->get_experiment_icon($exp);
                $id = $alt->get_id();
                $graphic_id = 'graphic-' . $id;
                if ($alt_results != null) {
                    $alt_result = $alt_results[$i - 1];
                    $pageviews = $alt_result->get_num_of_visitors();
                    $conversions = $alt_result->get_num_of_conversions();
                    $conversion_rate = $alt_result->get_conversion_rate();
                    $improvement_factor = $alt_result->get_improvement_factor();
                } else {
                    $pageviews = 0;
                    $conversions = 0;
                    $conversion_rate = 0.0;
                    $improvement_factor = 0.0;
                }
                $alt_conversion_views = $conversions . ' / ' . $pageviews;
                $aux = $ori_conversions * $this->goal->get_benefit() * $improvement_factor / 100;
                $print_improvement = true;
                // format improvement factor
                if ($improvement_factor < 0) {
                    $arrow = 'fa-arrow-down';
                    $stats_color = 'red';
                    $improvement_factor = $improvement_factor * -1;
                } else {
                    if ($improvement_factor > 0) {
                        $arrow = 'fa-arrow-up';
                        $stats_color = 'green';
                    } else {
                        // $improvement_factor = 0.0
                        $arrow = 'fa-none';
                        $stats_color = 'black';
                        $print_improvement = false;
                    }
                }
                if ($aux > 0) {
                    $gain = sprintf(__('%1$s%2$s', 'nelioab', 'money'), NelioABSettings::get_conv_unit(), number_format_i18n($aux, 2));
                } else {
                    $gain = sprintf(__('%1$s%2$s', 'nelioab', 'money'), NelioABSettings::get_conv_unit(), number_format_i18n($aux * -1, 2));
                }
                $alt_conversion_rate = number_format_i18n(floatval($conversion_rate), 2) . ' %';
                $alt_improvement_factor = number_format_i18n(floatval($improvement_factor), 2) . ' %';
                $alternative_number = $i;
                $winner_color = '';
                if ($this->is_winner($alt->get_id())) {
                    $icon = $this->get_winner_icon($exp);
                    $color = $colorscheme['winner'];
                    $winner_color = 'style="background-color:' . $colorscheme['primary'] . ';color:' . $colorscheme['foreground'] . ';"';
                } else {
                    $color = $base_color;
                }
                $theme = null;
                $theme_image = '#';
                foreach ($the_themes as $t) {
                    if ($t['Stylesheet'] == $alt->get_value()) {
                        $theme = $t;
                        $theme_image = $t->get_screenshot();
                        break;
                    }
                }
                if ($theme != NULL && $exp->get_status() == NelioABExperiment::STATUS_FINISHED) {
                    $img = '<span id="loading-' . $alt->get_value() . '" class="dashicons dashicons-update fa-spin animated nelio-apply"></span>';
                    $aux = sprintf(' <a class="apply-link button" href="javascript:nelioab_confirm_overwriting(\'%1$s\', \'%2$s\', \'%3$s\');">%4$s %5$s</a>', $alt->get_value(), $theme['Stylesheet'], $theme['Template'], $img, __('Apply', 'nelioab'));
                    array_push($action_links, $aux);
                }
                $buttons = implode(' ', $action_links);
                if (!$print_improvement) {
                    $gain = '';
                    $alt_improvement_factor = '';
                }
                $result = <<<HTML
\t\t\t\t<div class="nelio-alternative alternative-{$i} postbox nelio-card">
\t\t\t\t\t<div class="alt-info-header" {$winner_color}>
\t\t\t\t\t\t{$icon}
\t\t\t\t\t\t<span class="alt-title">{$name}</span>
\t\t\t\t\t</div>
\t\t\t\t\t<div class="alt-info-body">
\t\t\t\t\t\t<div class="alt-screen hover-img-fade" id="{$id}" style="color:{$color};">
\t\t\t\t\t\t\t<img class="alt-theme-img" src="{$theme_image}" width="320" height="240">
\t\t\t\t\t\t\t\t<div class="alt-name">
\t\t\t\t\t\t\t\t\t{$alternative_label}
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t<div class="alt-number">
\t\t\t\t\t\t\t\t\t{$alternative_number}
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t</div>
\t\t\t\t\t\t<div class="alt-stats">
\t\t\t\t\t\t\t<div class="alt-stats-graphic" id="{$graphic_id}"></div>
\t\t\t\t\t\t\t<div class="alt-status">
\t\t\t\t\t\t\t\t<div class="alt-cv">
\t\t\t\t\t\t\t\t\t<span class="alt-cv-title">{$conversion_views_label}</span>
\t\t\t\t\t\t\t\t\t<span class="alt-cv">{$alt_conversion_views}</span>
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t<div class="alt-cr">
\t\t\t\t\t\t\t\t\t<span class="alt-cr-title">{$conversion_rate_label}</span>
\t\t\t\t\t\t\t\t\t<span class="alt-cr">{$alt_conversion_rate}</span>
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t<div class="alt-stats" style="color:{$stats_color};">
\t\t\t\t\t\t\t\t\t<span class="alt-if"><i class="fa {$arrow}" style="vertical-align: top;"></i>{$alt_improvement_factor}</span>
\t\t\t\t\t\t\t\t\t<span class="alt-ii"><i class="fa {$arrow}" style="vertical-align: top;"></i>{$gain}</span>
\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t\t<div class="alt-info-footer">
\t\t\t\t\t\t<div class="alt-info-footer-content">
\t\t\t\t\t\t\t{$buttons}
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<script>
\t\t\t\tjQuery(document).ready(function() {
\t\t\t\t\tdrawAlternativeGraphic('{$graphic_id}',
\t\t\t\t\t\t{$conversions},
\t\t\t\t\t\t'{$conversions_label}',
\t\t\t\t\t\t'{$color}',
\t\t\t\t\t\t{$pageviews},
\t\t\t\t\t\t'{$pageviews_label}');
\t\t\t\t});
\t\t\t\t</script>
HTML;
                echo $result;
            }
        }
        public static function print_theme_landing_page_field()
        {
            $field_name = 'theme_landing_page';
            printf('<select id="%1$s" name="nelioab_settings[%1$s]" %2$s>', $field_name, self::get_basic_details());
            ?>
				<option value='0'><?php 
            _e('Regular Front Page («Latest Posts» or «Static Page»)', 'nelioab');
            ?>
</option>
				<option value='1'<?php 
            if (NelioABSettings::does_theme_use_a_custom_landing_page()) {
                echo ' selected="selected"';
            }
            ?>
><?php 
            _e('Theme-based Front Page', 'nelioab');
            ?>
</option>
			</select>
			<div class="the-descr" style="display:none;"><span class="description"><?php 
            printf(__('As stated in the <a href="%s">WordPress Codex</a>, by default WordPress shows your most recent posts in reverse chronological order on the front page (also known as "landing page") of your site. If you want a static front page or splash page as the front page instead, you may select it using the "Front page display" setting Dashboard » Settings » Reading.<br>Some themes, however, define "dynamic front pages", which can not be A/B tested by Nelio. If you want to track Heatmaps for such a front page, simply select "Theme-based Front Page". ', 'nelioab'), 'http://codex.wordpress.org/Creating_a_Static_Front_Page');
            ?>
</span></div><?php 
        }
 /**
  * PHPDOC
  *
  * @param int $max PHPDOC
  * @param int $min PHPDOC
  *
  * @return string PHPDOC
  *
  * @since PHPDOC
  */
 private static function select_confidence($max, $min = -1)
 {
     if ($min === -1) {
         $min = $max;
         ++$max;
     }
     $confidence = NelioABSettings::get_min_confidence_for_significance();
     if ($min <= $confidence && $confidence < $max) {
         return ' selected="selected" ';
     } else {
         return ' ';
     }
 }
 /**
  * This function creates all the relevant pages for our plugin.
  * These pages appear in the Dashboard.
  *
  * @since 0.1
  */
 public function create_nelioab_admin_pages()
 {
     $nelioab_menu = 'nelioab-dashboard';
     // Main menu
     // ----------------------------------------------------------------------
     add_menu_page(__('Nelio A/B Testing', 'nelioab'), __('Nelio A/B Testing', 'nelioab'), 'manage_options', $nelioab_menu, null, null, NelioABSettings::get_menu_location() . '.000023510');
     // Dashboard page
     // ----------------------------------------------------------------------
     require_once NELIOAB_ADMIN_DIR . '/dashboard-page-controller.php';
     add_submenu_page($nelioab_menu, __('Dashboard', 'nelioab'), __('Dashboard', 'nelioab'), 'manage_options', 'nelioab-dashboard', array('NelioABDashboardPageController', 'build'));
     // Experiments pages (depending on the action, we show one or another)
     // ----------------------------------------------------------------------
     $the_action = NULL;
     if (isset($_GET['action'])) {
         $the_action = $_GET['action'];
     }
     switch ($the_action) {
         case 'edit':
             require_once NELIOAB_ADMIN_DIR . '/select-exp-edition-page-controller.php';
             $page_to_build = array('NelioABSelectExpEditionPageController', 'build');
             break;
         case 'progress':
             require_once NELIOAB_ADMIN_DIR . '/select-exp-progress-page-controller.php';
             $page_to_build = array('NelioABSelectExpProgressPageController', 'build');
             break;
         default:
             require_once NELIOAB_ADMIN_DIR . '/experiments-page-controller.php';
             $page_to_build = array('NelioABExperimentsPageController', 'build');
             break;
     }
     add_submenu_page($nelioab_menu, __('Experiments', 'nelioab'), __('Experiments', 'nelioab'), 'manage_options', 'nelioab-experiments', $page_to_build);
     // Creating Experiment; (depending on the type, we show one form or another)
     // ----------------------------------------------------------------------
     require_once NELIOAB_ADMIN_DIR . '/select-exp-creation-page-controller.php';
     add_action('admin_head', array($this, 'add_css_for_creation_page'));
     add_action('admin_head', array($this, 'add_css_for_themes'));
     $page_to_build = array('NelioABSelectExpCreationPageController', 'build');
     add_submenu_page($nelioab_menu, __('Add Experiment', 'nelioab'), __('Add Experiment', 'nelioab'), 'manage_options', 'nelioab-add-experiment', $page_to_build);
     // Either Free Trial or My Account page
     // ----------------------------------------------------------------------
     if (NelioABAccountSettings::is_using_free_trial()) {
         $label = __('Free Trial', 'nelioab');
     } else {
         $label = __('My Account', 'nelioab');
     }
     require_once NELIOAB_ADMIN_DIR . '/account-page-controller.php';
     add_submenu_page($nelioab_menu, $label, $label, 'manage_options', 'nelioab-account', array('NelioABAccountPageController', 'build'));
     // Settings page
     // ----------------------------------------------------------------------
     require_once NELIOAB_ADMIN_DIR . '/settings-page-controller.php';
     add_submenu_page($nelioab_menu, __('Settings', 'nelioab'), __('Settings', 'nelioab'), 'manage_options', 'nelioab-settings', array('NelioABSettingsPageController', 'build'));
     // Help
     // ----------------------------------------------------------------------
     add_submenu_page($nelioab_menu, __('Help', 'nelioab'), __('Help', 'nelioab'), 'manage_options', 'nelioab-help');
     global $submenu;
     for ($i = 0; $i < count($submenu['nelioab-dashboard']); ++$i) {
         if ('nelioab-help' == $submenu['nelioab-dashboard'][$i][2]) {
             $submenu['nelioab-dashboard'][$i][2] = 'http://support.nelioabtesting.com/support/home';
             break;
         }
     }
     // OTHER PAGES (not included in the menu)
     // CSS Editing
     // ----------------------------------------------------------------------
     require_once NELIOAB_ADMIN_DIR . '/views/content/css-edit.php';
     add_submenu_page(NULL, __('CSS Edit', 'nelioab'), __('CSS Edit', 'nelioab'), 'manage_options', 'nelioab-css-edit', array('NelioABCssEditPage', 'build'));
 }
        public function print_plugin_available_to_field()
        {
            $field_name = 'plugin_available_to';
            printf('<select id="%1$s" name="%1$s">', $field_name);
            ?>
				<?php 
            $val = NelioABSettings::PLUGIN_AVAILABLE_TO_ANY_ADMIN;
            ?>
				<option value='<?php 
            echo $val;
            ?>
'><?php 
            _e('Super Admins and Site Admins', 'nelioab');
            ?>
</option>
				<?php 
            $val = NelioABSettings::PLUGIN_AVAILABLE_TO_SUPER_ADMIN;
            ?>
				<option value='<?php 
            echo $val;
            ?>
'<?php 
            if (!NelioABSettings::get_site_option_regular_admins_can_manage_plugin()) {
                echo ' selected="selected"';
            }
            ?>
><?php 
            _e('Super Admins Only', 'nelioab');
            ?>
</option>
			</select>
			<?php 
        }