Пример #1
0
 /**
  * Returns whether the field can be edited by subscribers of the current plan.
  *
  * @param string $field_name the name of one setting.
  *
  * @return boolean whether the field can be edited by subscribers of the current plan.
  *
  * @since 3.2.0
  */
 public static function is_field_enabled_for_current_plan($field_name)
 {
     if (!NelioABAccountSettings::is_plan_at_least(NelioABAccountSettings::ENTERPRISE_SUBSCRIPTION_PLAN)) {
         // Nothing here
     }
     if (!NelioABAccountSettings::is_plan_at_least(NelioABAccountSettings::PROFESSIONAL_SUBSCRIPTION_PLAN)) {
         switch ($field_name) {
             case 'expl_ratio':
             case 'ori_perc':
             case 'min_confidence_for_significance':
             case 'algorithm':
             case 'perc_of_tested_users':
             case 'quota_limit_per_exp':
             case 'notifications':
             case 'headlines_quota_mode':
             case 'plugin_available_to':
                 return false;
         }
     }
     return true;
 }
Пример #2
0
        public static function print_quota_limit_per_experiment_field()
        {
            $limit = NelioABSettings::get_quota_limit_per_exp();
            $field_name = 'quota_limit_per_exp';
            printf('<select id="%1$s" name="nelioab_settings[%1$s]" %2$s>', $field_name, self::get_pro_details());
            ?>
				<option value='-1'><?php 
            _e('Unlimited', 'nelioab');
            ?>
</option>
			<?php 
            $options = array(500, 1000, 1500, 2500, 3000);
            if (NelioABAccountSettings::is_plan_at_least(NelioABAccountSettings::PROFESSIONAL_SUBSCRIPTION_PLAN)) {
                array_push($options, 4000, 5000, 7500, 10000);
            }
            foreach ($options as $v) {
                printf('<option value="%2$s" %3$s>%1$s</option>', sprintf(__('%s page views', 'nelioab'), number_format_i18n($v)), strval($v), $limit == $v ? 'selected="selected"' : '');
            }
            ?>
			</select>
			<br><div class="the-descr" style="display:none;"><span <?php 
            echo self::get_pro_details('description');
            ?>
><?php 
            _e('This setting will automatically stop the experiment as soon as the results of an experiment are updated and the number of page views is equal to (or a little bit greater than) the limit you set. Don\'t waste your quota anymore!', 'nelioab');
            ?>
</span></div>
			<?php 
        }
 function column_name($exp)
 {
     $url_fragment = admin_url('admin.php?page=nelioab-experiments&action=%1$s&id=%2$s&exp_type=%3$s');
     if (isset($_REQUEST['status'])) {
         $url_fragment .= '&status=' . $_REQUEST['status'];
     }
     $url = '<a href="' . $url_fragment . '">%4$s</a>';
     $url_dialog = '<a href="#" onclick="javascript:nelioabValidateClick(%5$s, \'' . $url_fragment . '\');return false;">%4$s</a>';
     $url_duplicate = '<a href="' . $url_fragment . '&_nonce=' . nelioab_onetime_nonce('duplicate-' . $exp->get_id()) . '">%4$s</a>';
     $progress_url = '<a href="?page=nelioab-experiments&action=progress&id=%1$s&exp_type=%2$s">%3$s</a>';
     if ($exp->get_type() == NelioABExperiment::HEATMAP_EXP) {
         include_once NELIOAB_UTILS_DIR . '/wp-helper.php';
         $progress_url = '<a href="' . str_replace('https://', 'http://', admin_url('admin.php?nelioab-page=heatmaps&id=%1$s&exp_type=%2$s')) . '">%3$s</a>';
     }
     $actions = array();
     switch ($exp->get_status()) {
         case NelioABExperiment::STATUS_DRAFT:
             $actions = array('edit' => sprintf($url, 'edit', $exp->get_id(), $exp->get_type(), __('Edit')), 'trash' => sprintf($url, 'trash', $exp->get_id(), $exp->get_type(), __('Trash')));
             break;
         case NelioABExperiment::STATUS_READY:
             $actions = array();
             $actions['edit'] = sprintf($url, 'edit', $exp->get_id(), $exp->get_type(), __('Edit'));
             $actions['start'] = sprintf($url_dialog, 'start', $exp->get_id(), $exp->get_type(), __('Start', 'nelioab'), 0);
             $actions['schedule'] = sprintf($url, 'schedule', $exp->get_id(), $exp->get_type(), __('Schedule'));
             $actions['duplicate'] = sprintf($url_duplicate, 'duplicate', $exp->get_id(), $exp->get_type(), __('Duplicate'), 'nelioab');
             $actions['trash'] = sprintf($url, 'trash', $exp->get_id(), $exp->get_type(), __('Trash'));
             break;
         case NelioABExperiment::STATUS_SCHEDULED:
             $actions = array('start' => sprintf($url_dialog, 'start', $exp->get_id(), $exp->get_type(), __('Start Now', 'nelioab'), 0), 'schedule' => sprintf($url, 'schedule', $exp->get_id(), $exp->get_type(), __('Reschedule')), 'cancel-schedule' => sprintf($url, 'cancel-schedule', $exp->get_id(), $exp->get_type(), __('Cancel Schedule', 'nelioab'), 1), 'duplicate' => sprintf($url_duplicate, 'duplicate', $exp->get_id(), $exp->get_type(), __('Duplicate', 'nelioab')));
             break;
         case NelioABExperiment::STATUS_RUNNING:
             $actions = array('theprogress' => sprintf($progress_url, $exp->get_id(), $exp->get_type(), __('View')), 'stop' => sprintf($url_dialog, 'stop', $exp->get_id(), $exp->get_type(), __('Stop', 'nelioab'), 1), 'duplicate' => sprintf($url_duplicate, 'duplicate', $exp->get_id(), $exp->get_type(), __('Duplicate', 'nelioab')));
             break;
         case NelioABExperiment::STATUS_FINISHED:
             $actions = array('theprogress' => sprintf($progress_url, $exp->get_id(), $exp->get_type(), __('View')), 'duplicate' => sprintf($url_duplicate, 'duplicate', $exp->get_id(), $exp->get_type(), __('Duplicate', 'nelioab')), 'delete' => sprintf($url, 'delete', $exp->get_id(), $exp->get_type(), __('Delete Permanently')));
             break;
         case NelioABExperiment::STATUS_TRASH:
         default:
             $actions = array('restore' => sprintf($url, 'restore', $exp->get_id(), $exp->get_type(), __('Restore')), 'delete' => sprintf($url, 'delete', $exp->get_id(), $exp->get_type(), __('Delete Permanently')));
             break;
     }
     $related_post = $exp->get_related_post_id();
     if (isset($actions['start']) && $related_post && $related_post > 0 && get_post_status($related_post) !== 'publish') {
         $label = sprintf('<span style="cursor:default;" title="%s">%s</span>', esc_html(__('The experiment cannot be started because the tested element has not been published yet', 'nelioab')), __('Start'));
         $actions['start'] = $label;
     }
     if (!NelioABAccountSettings::is_plan_at_least(NelioABAccountSettings::PROFESSIONAL_SUBSCRIPTION_PLAN)) {
         $expl = __('Feature only available in the Professional Plan', 'nelioab');
         // No actions available to Professional Plans only
     }
     if (!NelioABAccountSettings::is_plan_at_least(NelioABAccountSettings::ENTERPRISE_SUBSCRIPTION_PLAN)) {
         $expl = __('Feature only available in the Enterprise Plan', 'nelioab');
         if (isset($actions['schedule'])) {
             $actions['schedule'] = sprintf('<span title="%s">%s</span>', $expl, __('Schedule', 'nelioab'));
         }
     }
     //Build row actions
     return sprintf('<span class="row-title">%2$s</span>%3$s', $exp->get_id(), $exp->get_name(), $this->row_actions($actions));
 }