/** * 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 }
/** * 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; }
public static function print_def_conv_value_field() { $field_name = 'def_conv_value'; $value = sprintf('<input type="text" id="%1$s" name="nelioab_settings[%1$s]" value="%2$s" placeholder="%3$s" $4%s style="max-width:5em;" />', $field_name, NelioABSettings::get_def_conv_value(), NelioABSettings::DEFAULT_CONVERSION_VALUE, self::get_basic_details()); $field_name = 'conv_unit'; ob_start(); printf('<select id="%1$s" name="nelioab_settings[%1$s]" %2$s>', $field_name, self::get_basic_details()); ?> <?php $val = NelioABSettings::CONVERSION_UNIT_DOLLAR; ?> <option value='<?php echo $val; ?> '><?php echo $val; ?> </option> <?php $val = NelioABSettings::CONVERSION_UNIT_EURO; ?> <option value='<?php echo $val; ?> '<?php if (NelioABSettings::get_conv_unit() == $val) { echo ' selected="selected"'; } ?> ><?php echo $val; ?> </option> <?php $val = NelioABSettings::CONVERSION_UNIT_POUND; ?> <option value='<?php echo $val; ?> '<?php if (NelioABSettings::get_conv_unit() == $val) { echo ' selected="selected"'; } ?> ><?php echo $val; ?> </option> <?php $val = NelioABSettings::CONVERSION_UNIT_YEN; ?> <option value='<?php echo $val; ?> '<?php if (NelioABSettings::get_conv_unit() == $val) { echo ' selected="selected"'; } ?> ><?php echo $val; ?> </option> <?php $val = NelioABSettings::CONVERSION_UNIT_BITCOIN; ?> <option value='<?php echo $val; ?> '<?php if (NelioABSettings::get_conv_unit() == $val) { echo ' selected="selected"'; } ?> ><?php echo $val; ?> </option> </select> <?php $unit = ob_get_contents(); ob_end_clean(); printf(__('%1$s %2$s', 'nelioab', 'conversion-unit-and-value'), $unit, $value); ?> <div class="the-descr" style="display:none;"><span class="description"><?php _e('Define a default value (in money units) for your conversions. This value could be, for instance, the average benefit you obtain every time a visitor converts (that is, she buys a product or subscribes to a service). The conversion value can be overwritten when adding goals into an experiment.', 'nelioab'); ?> </span></div><?php }
/** * 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(); } }