protected function print_ori_field()
        {
            require_once NELIOAB_UTILS_DIR . '/html-generator.php';
            NelioABHtmlGenerator::print_post_searcher('exp_original', $this->original_id, 'show-drafts');
            ?>

			<a class="button" style="text-align:center;"
				href="javascript:NelioABEditExperiment.previewOriginal()"><?php 
            _e('Preview', 'nelioab');
            ?>
</a>
			<span class="description" style="display:block;"><?php 
            _e('You will create alternative headlines (title, featured image, and excerpt) for this post.', 'nelioab');
            ?>
</span><?php 
        }
        protected function print_ori_field()
        {
            require_once NELIOAB_UTILS_DIR . '/html-generator.php';
            NelioABHtmlGenerator::print_post_searcher_based_on_type('exp_original', $this->original_id, 'show-drafts', array(), true, array('product'));
            ?>

			<a class="button" style="text-align:center;"
				href="javascript:NelioABEditExperiment.previewOriginal()"><?php 
            _e('Preview', 'nelioab');
            ?>
</a>
			<span class="description" style="display:block;"><?php 
            _e('You will create alternative summaries (name, featured image, and description) for this product.', 'nelioab');
            ?>
</span><?php 
        }
예제 #3
0
        /**
         * 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 print_post_field()
 {
     require_once NELIOAB_UTILS_DIR . '/html-generator.php';
     NelioABHtmlGenerator::print_full_searcher('exp_post_id', $this->post_id, 'show-drafts');
 }
        protected function print_additional_info_for_new_alt_form()
        {
            ?>
			<label class="copying-content" style="padding-top:0.5em;">
				<span class="title"><?php 
            _e('Source', 'nelioab');
            ?>
 </span>
				<span class="input-text-wrap">
					<?php 
            require_once NELIOAB_UTILS_DIR . '/html-generator.php';
            if ($this->alt_type == NelioABExperiment::PAGE_ALT_EXP) {
                NelioABHtmlGenerator::print_page_searcher('based_on', false, 'show-drafts');
            } else {
                NelioABHtmlGenerator::print_post_searcher('based_on', false, 'show-drafts');
            }
            ?>
					<span class="description" style="display:block;"><?php 
            _e('The selected page\'s content will be duplicated and used by this alternative.', 'nelioab');
            ?>
</span>
				</span>
			</label><?php 
        }
예제 #6
0
    protected function do_render()
    {
        ?>

		<div id="post-body" class="metabox-holder columns-2">
		<form id="css_edit_value" method="POST" action="#">
			<input type="hidden" name="css_save_alt" id="css_save_alt" value="true"></input>
			<div id="post-body-content">

				<div id="titlediv">

					<div id="titlewrap">
						<label class="screen-reader-text" id="title-prompt-text" for="title">Enter title here</label>
						<input type="text" name="post_title" size="30" value="<?php 
        echo $this->css_alt->get_name();
        ?>
" id="title" autocomplete="off"></input>
					</div>

					<div class="inside">
						<div id="postdivrich" class="postarea edit-form-section">
							<div id="wp-content-wrap" class="wp-core-ui wp-editor-wrap tmce-active">
								<div class="wp-editor-tabs">
									<br>
									<!-- <a id="content-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);">Plain</a> -->
									<!-- <a id="content-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">Visual</a> -->
								</div>
							</div>
								<input type="hidden" id="content" name="content"></input>
								<pre id="editor"><?php 
        echo $this->css_alt->get_value();
        ?>
</pre>
								<script type="text/javascript" src="<?php 
        echo nelioab_admin_asset_link('/lib/ace-editor/ace.js');
        ?>
"></script>
								<script type="text/javascript">
									var nelioabCssEditor = ace.edit('editor');
									nelioabCssEditor.setTheme('ace/theme/tomorrow');
									nelioabCssEditor.session.setMode('ace/mode/css');
									nelioabCssEditor.setAutoScrollEditorIntoView(true);
									nelioabCssEditor.setOption('minLines', 20);
									nelioabCssEditor.setOption('maxLines', 100);
									nelioabCssEditor.setFontSize(15);
								</script>
						</div>
					</div>

				</div>
			</div><!-- /post-body-content -->

			<div id="postbox-container-1" class="postbox-container">

				<div id="save_nelioab_alternative_box" class="meta-box-sortables ui-sortable">
					<div id="submitdiv" class="postbox"><?php 
        require_once NELIOAB_UTILS_DIR . '/wp-helper.php';
        $colorscheme = NelioABWpHelper::get_current_colorscheme();
        ?>
						<script>
							var nelioab_style_metabox = document.createElement("style");
							nelioab_style_metabox.setAttribute("type", "text/css");
							nelioab_style_metabox.innerHTML = "#save_nelioab_alternative_box h3.hndle { " +
								"color:<?php 
        echo $colorscheme['foreground'];
        ?>
; " +
								"background: <?php 
        echo $colorscheme['focus'];
        ?>
;" +
								"border: 1px solid <?php 
        echo $colorscheme['focus'];
        ?>
;" +
							"}" +
							"#favorite-actions, #message, .add-new-h2, .tablenav, #edit-slug-box { display:none; }" +
							"#save_nelioab_alternative_box .handlediv," +
							"#save_nelioab_alternative_box .handlediv:hover { visibility:visible; color:white; }";
							document.getElementsByTagName('head')[0].appendChild(nelioab_style_metabox);
						</script>

						<h3 style="cursor:auto;" class="hndle"><span><?php 
        _e('Update');
        ?>
</span></h3>
						<div class="inside">
							<div class="submitbox" id="submitpost">

								<div style="margin:1em;">
									<p><?php 
        _e('Select a page or post for preview', 'nelioab');
        ?>
</p>
									<?php 
        require_once NELIOAB_UTILS_DIR . '/html-generator.php';
        NelioABHtmlGenerator::print_full_searcher('post-options', false, 'show-drafts');
        ?>
								</div>

								<div class="misc-pub-section" style="min-height:4em;">
									<div style="float:right;margin-top:1em;">
										<input name="original_publish" type="hidden" id="original_publish" value="Update">
										<input name="save" type="submit"
											class="button button-primary" id="publish"
											tabindex="5"
											value="<?php 
        _e('Update');
        ?>
" />
										<script type="text/javascript">
										jQuery( "#css_edit_value" ).on( 'submit', function() {
											jQuery("#content").attr('value', nelioabCssEditor.getValue());
										});
										</script>
									</div>
									<div style="float:right;margin-top:1em;margin-right:1em;">
										<div id="preview-action">
											<a id="preview-button" class="preview button" target="wp-preview" id="post-preview" tabindex="4"><?php 
        _e('Preview');
        ?>
</a>
											<input type="hidden" name="wp-preview" id="wp-preview" value="" />
										</div>
									</div>
								</div>
								<?php 
        $url = admin_url('admin.php');
        $url = add_query_arg(array('nelioab-page' => 'save-css', 'preview' => 'true', 'nelioab_preview_css' => $_REQUEST['css_id']), $url);
        ?>
								<script>
									jQuery("#preview-button").click(function(e) {
										var aux = jQuery("#post-options").attr('value');
										if ( aux == -1 || aux == "" || aux == undefined ) return;
										if ( aux == <?php 
        echo NelioABController::FRONT_PAGE__YOUR_LATEST_POSTS;
        ?>
 ) aux = "";
										else aux = "&p=" + aux;
										jQuery("#css_edit_value").attr('action', "<?php 
        echo $url;
        ?>
" + aux);
										jQuery("#css_edit_value").attr('target', '_blank');
										jQuery("#css_edit_value").submit();
										jQuery("#css_edit_value").attr('action', '#');
										jQuery("#css_edit_value").attr('target', '');
									});
								</script>

								<div style="margin:10px;">
									<b><?php 
        _e('Go back to...', 'nelioab');
        ?>
</b>
									<?php 
        $url = admin_url('admin.php?page=nelioab-experiments');
        $exp_id = $this->experiment->get_id();
        $exp_status = $this->experiment->get_status();
        ?>
									<ul style="margin-left:1.5em;">
										<?php 
        require_once NELIOAB_MODELS_DIR . '/experiment.php';
        switch ($exp_status) {
            case NelioABExperiment::STATUS_DRAFT:
            case NelioABExperiment::STATUS_READY:
                ?>
<li><a href="<?php 
                echo $url . '&action=edit&ctab=tab-alts&id=' . $exp_id . '&exp_type=' . $this->experiment->get_type();
                ?>
"><?php 
                _e('Editing this experiment', 'nelioab');
                ?>
</a></li><?php 
                break;
            case NelioABExperiment::STATUS_RUNNING:
            case NelioABExperiment::STATUS_FINISHED:
                ?>
<li><a href="<?php 
                echo $url . '&action=progress&id=' . $exp_id . '&exp_type=' . $this->experiment->get_type();
                ?>
"><?php 
                _e('The results of the related experiment', 'nelioab');
                ?>
</a></li><?php 
                break;
            case NelioABExperiment::STATUS_TRASH:
            case NelioABExperiment::STATUS_PAUSED:
            default:
                // Nothing here
        }
        ?>
									   <li><a href="<?php 
        echo $url;
        ?>
"><?php 
        _e('My list of experiments', 'nelioab');
        ?>
</a></li>
									   <li><a href="<?php 
        echo admin_url('admin.php?page=nelioab-dashboard');
        ?>
"><?php 
        _e('The Dashboard', 'nelioab');
        ?>
</a></li>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- END OF SIDEBAR -->

			</div>
		</form>
		</div>
		<?php 
    }
        private function insert_schedule_dialog()
        {
            ?>
			<div id="nelioab-scheduling-dialog" title="<?php 
            _e('Experiment Scheduling', 'nelioab');
            ?>
">
				<p><?php 
            _e('Schedule experiment start for:', 'nelioab');
            ?>
</p>
				<?php 
            require_once NELIOAB_UTILS_DIR . '/html-generator.php';
            NelioABHtmlGenerator::print_scheduling_picker();
            ?>
				<p class="error" style="color:red;display:none;"><?php 
            _e('Please, specify a full date (month, day, and year) in the future.', 'nelioab');
            ?>
</p>
			</div>
			<script>
				jQuery(function($) {<?php 
            $ts = time() + 86400;
            ?>
					var TOMORROW_DAY   = '<?php 
            echo date('d', $ts);
            ?>
';
					var TOMORROW_MONTH = '<?php 
            echo date('m', $ts);
            ?>
';
					var TOMORROW_YEAR  = '<?php 
            echo date('Y', $ts);
            ?>
';
					var $info = $('#nelioab-scheduling-dialog');
					$info.dialog({
						'dialogClass'   : 'wp-dialog',
						'modal'         : true,
						'autoOpen'      : false,
						'closeOnEscape' : true,
						buttons: [
							{
								text: "<?php 
            echo esc_html(__('Cancel', 'nelioab'));
            ?>
",
								click: function() {
									$(this).dialog('close');
								}
							},
							{
								text: "<?php 
            echo esc_html(__('Schedule', 'nelioab'));
            ?>
",
								'class': 'button button-primary',
								click: function() {
									try {
										var day   = $('#nelioab-scheduling-dialog input.jj').attr('value');
										var month = $('#nelioab-scheduling-dialog select.mm').attr('value');
										var year  = $('#nelioab-scheduling-dialog input.aa').attr('value');

										if ( day == undefined ) day = '00';
										if ( year == undefined ) year = '0000';
										while ( day.length < 2 ) day = '0' + day;
										while ( year.length < 4 ) year = '0' + year;
										if ( year < TOMORROW_YEAR )
											throw new Exception();
										if ( year == TOMORROW_YEAR && month < TOMORROW_MONTH )
											throw new Exception();
										else if ( year == TOMORROW_YEAR && month == TOMORROW_MONTH && day < TOMORROW_DAY )
											throw new Exception();

										var res = year + '-' + month + '-' + day;
										$( '#nelioab-scheduling-dialog .error').hide();
										$(this).dialog('close');
										window.location = $(this).data('url') + '&schedule_date=' + res;
									}
									catch ( e ) {
										$( '#nelioab-scheduling-dialog .error').show();
									}
								}
							}
						],
					});
					$('.row-actions .schedule > a').click(function(event) {
						event.preventDefault();
						$('#nelioab-scheduling-dialog input.jj').attr('value', TOMORROW_DAY);
						$('#nelioab-scheduling-dialog select.mm').attr('value', TOMORROW_MONTH);
						$('#nelioab-scheduling-dialog input.aa').attr('value', TOMORROW_YEAR);
						$info.data('url', $(this).attr('href'));
						$info.dialog( 'open' );
					});
				});
			</script><?php 
        }