protected function do_render()
 {
     echo "<div class='nelio-message'>";
     printf('<img class="animated flipInY" src="%s" alt="%s" />', nelioab_admin_asset_link('/images/error-icon.png'), __('Error Notice', 'nelioab'));
     echo "<h2>{$this->msg}</h2>";
     echo '</div>';
 }
 protected function do_render()
 {
     echo "<div class='nelio-message'>";
     printf('<img class="animated flipInY" src="%s" alt="%s" />', nelioab_admin_asset_link('/images/message-icon.png'), __('Information Notice', 'nelioab'));
     echo "<h2>{$this->msg}</h2>";
     echo "<p class='nelio-admin-explanation'>{$this->explanation}</p>";
     echo '</div>';
 }
 public function json4js()
 {
     $image_id = isset($this->value['image_id']) ? $this->value['image_id'] : 'inherit';
     $image_src = false;
     if (is_int($image_id)) {
         $image_src = wp_get_attachment_image_src($image_id, 'thumbnail');
     }
     if (!$image_src) {
         $image_id = 'inherit';
         $image_src = nelioab_admin_asset_link('/images/feat-image-placeholder.png');
     } else {
         $image_src = $image_src[0];
     }
     return array('id' => $this->id, 'name' => $this->name, 'fakePostId' => isset($this->value['id']) ? $this->value['id'] : -1, 'excerpt' => isset($this->value['excerpt']) ? $this->value['excerpt'] : '', 'imageId' => $image_id, 'imageSrc' => $image_src, 'wasDeleted' => $this->was_removed, 'isDirty' => $this->is_dirty);
 }
        private function print_form_for_editing_a_headline($title)
        {
            ?>
			<fieldset style="padding:1em;">
				<h4><?php 
            echo $title;
            ?>
</h4>
				<div>
					<div class="headline_image_holder">
						<img class="headline_image"
							src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
							style="background:url('<?php 
            echo nelioab_admin_asset_link('/images/feat-image-placeholder.png');
            ?>
') no-repeat center center;
								-webkit-background-size:cover;
								-moz-background-size:cover;
								-o-background-size:cover;
								background-size:cover;
								width:100px;height:100px;" />
						<div class="headline_image_hover"><?php 
            _e('Change', 'nelioab');
            ?>
</div>
					</div>
					<div style="width:60%;display:inline-block;vertical-align:top;">
						<span class="input-text-wrap">
							<div class="nelio-sect"><label style="margin:0px;">
								<input type="text" class="headline_title ptitle" value="" placeholder="<?php 
            echo esc_html(__('Title', 'nelioab'));
            ?>
" />
							</label></div>
							<textarea class="headline_excerpt" placeholder="<?php 
            echo __('Original Excerpt', 'nelioab');
            ?>
"></textarea>
						</span>
					</div>
				</div>
			</fieldset>
			<?php 
        }
 /**
  * PHPDOC
  *
  * @return void
  *
  * @since PHPDOC
  */
 public function add_heatmap_script()
 {
     wp_enqueue_script('nelio-heatmap', nelioab_admin_asset_link('/js/heatmap.min.js'), array(), NELIOAB_PLUGIN_VERSION);
 }
Beispiel #6
0
	<link rel="stylesheet" href="<?php 
echo nelioab_admin_asset_link('/css/nelioab-heatmap.min.css');
?>
">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9, chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta charset="utf-8">
</head>

<body>
	<script src="<?php 
echo nelioab_admin_asset_link('/js/jquery4hm.min.js');
?>
"></script>
	<script src="<?php 
echo nelioab_admin_asset_link('/js/heatmap-viewer.min.js');
?>
"></script>

	<div id="toolbar" data-resizer="basic">
		<ul id="devices">
			<?php 
$name = __('Smartphone (no Heatmap available)', 'nelioab');
?>
			<li><a id='mobile' data-viewport="360x640" data-icon="mobile" title="<?php 
echo $name;
?>
" class="portrait"><?php 
echo $name;
?>
</a></li>
        /**
         * Returns the heading of a certain box type.
         *
         * This heading contains the title of the box and a beautiful icon.
         *
         * @param string $type the type of the heading we want to create.
         *
         * @return string the heading of a certain box type.
         *
         * @since 4.1.3
         */
        protected function get_action_heading($type)
        {
            switch ($type) {
                case 'basic-info':
                    $icon = nelioab_admin_asset_link('/images/freetrial-mail.png');
                    $aux = __('Your Basic Information (%s)', 'nelioab');
                    $alt = __('You and Your E-Mail', 'nelioab');
                    $num = 100;
                    break;
                case 'tweet':
                    $icon = nelioab_admin_asset_link('/images/freetrial-twitter.png');
                    $aux = __('Tweet About Us (%s)', 'nelioab');
                    $alt = __('Twitter', 'nelioab');
                    $num = 200;
                    break;
                case 'site-info':
                    $icon = nelioab_admin_asset_link('/images/freetrial-site.png');
                    $aux = __('Information About Your Site (%s)', 'nelioab');
                    $alt = __('Tiny form about your site', 'nelioab');
                    $num = 100;
                    break;
                case 'connect':
                    $icon = nelioab_admin_asset_link('/images/freetrial-facebook.png');
                    $aux = __('Like Our Facebook Profile (%s)', 'nelioab');
                    $alt = __('Facebook', 'nelioab');
                    $num = 200;
                    break;
                case 'recommend':
                    $icon = nelioab_admin_asset_link('/images/freetrial-friends.png');
                    $aux = __('Recommend Us to Your Friends (%s)', 'nelioab');
                    $alt = __('Friends', 'nelioab');
                    $num = 100;
                    break;
                case 'goals':
                    $icon = nelioab_admin_asset_link('/images/freetrial-life-goals.png');
                    $aux = __('The Goals You Pursue (%s)', 'nelioab');
                    $alt = __('Goals', 'nelioab');
                    $num = 200;
                    break;
                case 'subscribe':
                    $icon = nelioab_admin_asset_link('/images/freetrial-subscribe.png');
                    $aux = __('Subscribe to Nelio A/B Testing (%s)', 'nelioab');
                    $alt = __('Subscribe', 'nelioab');
                    $num = 5000;
                    break;
            }
            $num = '+' . number_format_i18n($num);
            $title = sprintf($aux, $num);
            $completed_title = sprintf($aux, __('Done!', 'nelioab'));
            $completed_icon = nelioab_admin_asset_link('/images/action-completed.png');
            // Workaround for BASIC INFO (which might use Confirmation...)
            if ('basic-info' === $type) {
                if (NelioABAccountSettings::is_promo_completed('basic-info')) {
                    $icon = nelioab_admin_asset_link('/images/action-pending.png');
                } else {
                    $completed_icon = nelioab_admin_asset_link('/images/action-pending.png');
                }
                $type = 'basic-info-check';
                $completed_title = sprintf($aux, __('Awaiting Confirmation...', 'nelioab'));
            }
            // End of the workaround
            if (NelioABAccountSettings::is_promo_completed($type)) {
                $animation = '';
            } else {
                $animation = 'animated flipInY';
            }
            $html = <<<HTML
\t\t\t<span class="nelio-freetrial-heading regular">
\t\t\t\t<img width="32" height="32" src="{$icon}" alt="{$alt}"/>
\t\t\t\t<span>{$title}</span>
\t\t\t</span>
\t\t\t<span class="nelio-freetrial-heading completed">
\t\t\t\t<img class="{$animation}" width="32" height="32" src="{$completed_icon}" alt="{$alt}"/>
\t\t\t\t<span>{$completed_title}</span>
\t\t\t</span>
HTML;
            return $html;
        }
        public function render()
        {
            ?>
			<script type="text/javascript" src="<?php 
            echo nelioab_admin_asset_link('/js/tablesorter.min.js');
            ?>
"></script><?php 
            $is_data_pending_loader = 'display:none;';
            $is_data_pending_data = 'display:visible;';
            if ($this->is_data_pending) {
                $is_data_pending_loader = 'display:visible;';
                $is_data_pending_data = 'display:none;';
            }
            ?>
			<script type="text/javascript">
			function smoothTransitions() {
				jQuery("#ajax-loader-label2").hide().delay(10000).fadeIn('fast');
				jQuery("#poststuff").delay(100).fadeOut(150);
				jQuery("#errors-div").delay(100).fadeOut(150);
				jQuery("#error-message-div").delay(100).fadeOut(150);
				jQuery("#message-div").delay(100).fadeOut(150);
				jQuery("#ajax-loader").delay(260).fadeIn(150);
			}
			</script>
			<div class="wrap">
				<div class="icon32" id="<?php 
            echo $this->icon_id;
            ?>
"></div>
				<h2><?php 
            echo $this->title . ' ' . $this->title_action;
            ?>
</h2>
				<?php 
            if ($this->is_data_pending) {
                $this->print_global_warnings();
                $this->print_error_message('none');
                $this->print_message('none');
                $this->print_errors('none');
            } else {
                $this->print_error_message();
                $this->print_message();
                $this->print_errors();
            }
            ?>
				<br />
				<div id="ajax-loader" style="text-align:center;<?php 
            echo $is_data_pending_loader;
            ?>
">
					<br /><br />

					<div style="text-align:center;height:50px;">
						<div class="nelioab_spinner"></div>
					</div>
					<h2 style="color:#555;margin:0;padding:0;"><?php 
            _e('Loading...', 'nelioab');
            ?>
</h2>
					<p id="ajax-loader-label1" style="color:#777;margin:0;padding:0;"><?php 
            _e('Please, wait a moment.', 'nelioab');
            ?>
</p>
					<p id="ajax-loader-label2" style="color:#777;margin:0;padding:0;display:none;"><?php 
            _e('Keep waiting...', 'nelioab');
            ?>
</p>
					<p id="ajax-loader-label3" style="color:#777;margin:0;padding:0;display:none;"><?php 
            _e('Internet connection seems very slow.', 'nelioab');
            ?>
</p>
				</div>
				<div id="poststuff" class="metabox-hold" style="<?php 
            echo $is_data_pending_data;
            ?>
">
					<div id="ajax-data"><?php 
            if (!$this->is_data_pending) {
                $this->do_render();
                ?>
						<br />
						<div class="actions"><?php 
                $this->print_page_buttons();
                ?>
						</div><?php 
            }
            ?>
					</div>
				</div>
			</div><?php 
            if (!$this->is_data_pending) {
                ?>
				<div id="dialog-modal" title="Basic modal dialog" style="display:none;">
					<div id="dialog-content">
						<?php 
                $this->print_dialog_content();
                ?>
					</div>
				</div>
			<?php 
            }
            if ($this->is_data_pending) {
                ?>
			<script>

				function nelioabHideSpinnerAndShowContent() {
					var $ajaxLoader = jQuery("#ajax-loader");
					$ajaxLoader.fadeOut(200, function() {
						var $postStuff = jQuery("#poststuff");
						$postStuff.fadeIn(200);

						var aux;
						var $errMsgDiv = jQuery("#error-message-div");
						var $msgDiv = jQuery("#message-div");
						var $errorsDiv = jQuery("#errors-div");

						aux = jQuery.trim( jQuery("#error-message-box-delayed").html() );
						if ( aux.length > 0 ) {
							$errMsgDiv.addClass("to-be-shown");
							$errMsgDiv.html( aux );
						}
						aux = jQuery.trim( jQuery("#message-box-delayed").html() );
						if ( aux.length > 0 ) {
							$msgDiv.addClass("to-be-shown");
							$msgDiv.html( aux );
						}
						aux = jQuery.trim( jQuery("#errors-box-delayed").html() );
						if ( aux.length > 0 ) {
							$errorsDiv.addClass("to-be-shown");
							$errorsDiv.html( aux );
						}

						if ( $errMsgDiv.hasClass("to-be-shown") ) {
							$errMsgDiv.css('display','block');
							$errMsgDiv.hide();
							$errMsgDiv.fadeIn(200);
						}
						if ( $msgDiv.hasClass("to-be-shown") ) {
							$msgDiv.css('display','block');
							$msgDiv.hide();
							$msgDiv.fadeIn(200);
						}
						if ( $errorsDiv.hasClass("to-be-shown") ) {
							$errorsDiv.css('display','block');
							$errorsDiv.hide();
							$errorsDiv.fadeIn(200);
						}

						jQuery(document).trigger('nelioab-ajax-page-loaded');
					});
				}

				jQuery(document).ready(function() {

					var data = {
						"action" : "nelioab_get_html_content",<?php 
                foreach ($this->post_params as $param) {
                    echo "\n\t\t\t\t\t\t\"{$param['0']}\" : \"{$param['1']}\",";
                }
                ?>

						"filename"  : "<?php 
                echo $this->controller_file;
                ?>
",
						"classname" : "<?php 
                echo $this->controller_class;
                ?>
"
					};

					// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
					jQuery.ajax({
						type: 'POST',
						url:  ajaxurl,
						data: data,
						success: function(response){
							jQuery("#poststuff > #ajax-data").html(response);
							nelioabHideSpinnerAndShowContent();
						},
						error: function() {
							jQuery("#ajax-loader").html(
							"<?php 
                printf("<img src='%s' alt='%s' />", nelioab_asset_link('/admin/images/error-icon.png'), __('Funny image to graphically notify of an error.', 'nelioab'));
                ?>
" +
							"<h2 style='color:#555;margin:0;padding:0;'><?php 
                _e('Oops! There was an AJAX-related error.');
                ?>
</h2>" +
							"<div style='color:#999;text-align:left;max-width:600px;margin:auto;'>" +
								"<br /><br /><b>Details:</b><br />" +
								"<u>Class</u>: " + data.classname + "<br />" +
								"<u>File</u>: " + data.filename + "<br />" +
							"</div>");
						}
					});

					jQuery("#ajax-loader-label2").hide().delay(10000).fadeIn('fast');
					//jQuery("#ajax-loader-label3").hide().delay(15000).fadeIn('fast');
				});
			</script>
			<?php 
            }
        }
        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 
        }
        protected function do_render()
        {
            echo "<div class='nelio-message'>";
            printf('<img class="animated flipInY" src="%s" alt="%s" />', nelioab_admin_asset_link('/images/settings-icon.png'), __('Information Notice', 'nelioab'));
            $tac_text = '';
            if (NelioABAccountSettings::can_free_trial_be_started()) {
                echo '<h2>' . __('Welcome!', 'nelioab') . '</h2>';
                printf("<p class=\"nelio-admin-explanation\">%s</p>\n", __('Thank you very much for installing <strong>Nelio A/B Testing</strong> by <em>Nelio Software</em>. You\'re just one step away from optimizing your WordPress site.', 'nelioab'));
                printf("<p class=\"nelio-admin-explanation\"><strong>%s</strong></p>\n", __('Let\'s get started!', 'nelioab'));
                $account_url = admin_url('admin.php?page=nelioab-account&nabmode=my-account');
                $my_account_button = $this->make_button(__('Use Nelio Account', 'nelioab'), $account_url, false);
                $free_trial_button = $this->make_button(__('Start Free Trial', 'nelioab'), '#', true);
                $tac_text = sprintf(__('By starting the free trial you agree to be legally bound by these <a href="%s" target="_blank">terms</a>.', 'nelioab'), 'https://nelioabtesting.com/terms-and-conditions/');
            } else {
                if (!NelioABAccountSettings::is_email_valid() || !NelioABAccountSettings::is_reg_num_valid() || !NelioABAccountSettings::are_terms_and_conditions_accepted()) {
                    echo '<h2>' . __('Welcome!', 'nelioab') . '</h2>';
                    printf("<p class=\"nelio-admin-explanation\">%s</p>\n", __('Thank you very much for installing <strong>Nelio A/B Testing</strong> by <em>Nelio Software</em>. You\'re just one step away from optimizing your WordPress site.', 'nelioab'));
                    printf("<p class=\"nelio-admin-explanation\"><strong>%s</strong></p>\n", __('Let\'s get started!', 'nelioab'));
                    $account_url = admin_url('admin.php?page=nelioab-account&nabmode=my-account');
                    $my_account_button = $this->make_button(__('Use Nelio Account', 'nelioab'), $account_url, true);
                    $free_trial_button = '';
                } else {
                    echo '<h2>' . __('Setup', 'nelioab') . '</h2>';
                    printf("<p class=\"nelio-admin-explanation\">%s</p>\n", __('You\'re just one step away from optimizing WordPress with <strong style="white-space:nowrap;">Nelio A/B Testing</strong> by <em>Nelio Software</em>. Are you ready?', 'nelioab'));
                    printf("<p class=\"nelio-admin-explanation\"><strong>%s</strong></p>\n", __('Activate this site in your account.', 'nelioab'));
                    $account_url = admin_url('admin.php?page=nelioab-account&nabmode=my-account');
                    $my_account_button = $this->make_button(__('Open My Account', 'nelioab'), $account_url, true);
                    $free_trial_button = '';
                }
            }
            printf("<p id=\"nelio-cta-buttons\" class=\"nelio-admin-explanation\">%s %s</p>\n", $my_account_button, $free_trial_button);
            if (strlen($tac_text) > 0) {
                echo '<p style="padding-top:3em;font-size:95%;color:gray;">' . $tac_text . '</p>';
            }
            if (NelioABAccountSettings::can_free_trial_be_started()) {
                ?>
				<script type="text/javascript">
				(function($) {
					$('#nelio-cta-buttons .button-primary').click(function() {
						smoothTransitions();
						$.ajax({
							url: ajaxurl,
							data: {
								action: 'nelioab_start_free_trial'
							},
							type: 'post',
							success: function(res) {
								if ( "OK" === res ) {
									window.location = "<?php 
                echo admin_url('admin.php?page=nelioab-account&nabmode=free-trial');
                ?>
";
								} else {
									window.location.reload();
								}
							},
						});
					});
				})(jQuery);
				</script>
				<?php 
            }
            echo '</div>';
        }
        /**
         * PHPDOC
         *
         * @return void
         *
         * @since PHPDOC
         */
        public function render()
        {
            ?>
			<script type="text/javascript" src="<?php 
            echo nelioab_admin_asset_link('/js/tablesorter.min.js');
            ?>
"></script>
			<div class="wrap <?php 
            echo implode(' ', $this->classes);
            ?>
">
				<div class="icon32" id="<?php 
            echo $this->icon_id;
            ?>
"></div>
				<h2><?php 
            echo $this->title . ' ' . $this->title_action;
            ?>
</h2>
				<?php 
            $this->print_global_warnings();
            $this->print_error_message();
            $this->print_message();
            $this->print_errors();
            ?>
				<br />
				<?php 
            $this->do_render();
            ?>
				<br />
				<div class="actions"><?php 
            $this->print_page_buttons();
            ?>
				</div>
			</div>
			<div id="dialog-modal" title="Basic modal dialog" style="display:none;">
				<div id="dialog-content">
					<?php 
            $this->print_dialog_content();
            ?>
				</div>
			</div>
			<?php 
        }
        public function do_render()
        {
            echo '<div id="post-body" class="metabox-holder columns-2">';
            echo '<div id="post-body-content">';
            if (count($this->experiments) == 0) {
                echo "<div class='nelio-message'>";
                echo sprintf('<img class="animated flipInY" src="%s" alt="%s" />', nelioab_admin_asset_link('/images/dashboard.png'), __('Dashboard Icon', 'nelioab'));
                echo '<h2 style="max-width:750px;">';
                printf('%1$s<br><br><a class="button button-primary" href="%3$s">%2$s</a>', __('Here you\'ll find relevant information about your running experiments.', 'nelioab'), __('Create One Now!', 'nelioab', 'create-experiment'), 'admin.php?page=nelioab-add-experiment');
                echo '</h2>';
                echo '</div>';
            } else {
                echo '<h2>' . __('Running Experiments', 'nelioab') . '</h2>';
                $this->print_cards();
            }
            echo '</div>';
            ?>
			<div id="postbox-container-1" class="postbox-container" style="overflow:hidden;">
				<h2>&nbsp;</h2>
				<?php 
            require_once NELIOAB_UTILS_DIR . '/wp-helper.php';
            $cs = NelioABWpHelper::get_current_colorscheme();
            ?>

				<div class="numbers" style="height:40px;">
					<div class="left" style="float:left; width:55%;">
						<span style="font-weight:bold;"><?php 
            _e('AVAILABLE QUOTA', 'nelioab');
            ?>
</span><br>
						<span style="color:<?php 
            echo $cs['primary'];
            ?>
; font-size:10px;"><?php 
            echo number_format_i18n($this->quota['regular'], 0);
            ?>
</span><span style="font-size:10px;"> / <?php 
            echo number_format_i18n($this->quota['monthly'], 0);
            if ($this->quota['extra'] > 0) {
                echo ' <span style="color:#999;">';
                printf(__('(+%s extra)', 'nelioab'), number_format_i18n($this->quota['extra'], 0));
                echo '</span>';
            }
            ?>
</span>
					</div>
					<div class="right" style="font-size:32px; text-align:right; float:right; width:38%; padding-right:5%; margin-top:8px; opacity:0.7;">
						<span><?php 
            // Let's compute the size of the extra quota (if any)
            if ($this->quota['extra'] > 0) {
                $extra = $this->quota['extra'];
                $max_extra = $this->quota['monthly'] / 2;
                if ($extra > $max_extra) {
                    $extra = $max_extra;
                }
                $extra_perc = $extra / $max_extra * 20;
            } else {
                $extra_perc = 0;
            }
            $extra_perc = number_format($extra_perc, 0);
            // Now let's compute the size of the regular bar
            if ($this->quota['regular'] > 0) {
                $perc = $this->quota['regular'] / $this->quota['monthly'] * 100;
            } else {
                $perc = 0;
            }
            $num_of_decs = 1;
            if (100 == $perc) {
                $num_of_decs = 0;
            }
            echo number_format($perc, $num_of_decs);
            ?>
%</span>
					</div>
				</div>

				<div class="progress-bar-container" style="background:none;border:2px solid rgba(0,0,0,0.1); width:95%; margin:0px; height:20px;"><?php 
            $bar = '<div class="progress-bar" style="margin:0;padding:0;display:inline-block;height:20px;background-color:%s;width:%s%%;"></div>';
            $perc = number_format($perc, 0);
            if ($perc + $extra_perc > 100) {
                $perc = 100 - $extra_perc;
            }
            printf($bar, $cs['primary'], $perc);
            printf($bar, $cs['secondary'], $extra_perc);
            ?>
</div>
			<?php 
            $this->print_rss();
            echo '</div>';
            // #post-body
        }
        protected function do_render()
        {
            // If there are no experiments, tell the user to create one.
            if (count($this->experiments) == 0) {
                echo "<div class='nelio-message'>";
                echo sprintf('<img class="animated flipInY" src="%s" alt="%s" />', nelioab_admin_asset_link('/images/message-icon.png'), __('Information Notice', 'nelioab'));
                echo '<h2 style="max-width:750px;">';
                printf('%1$s<br><br><a class="button button-primary" href="%3$s">%2$s</a>', __('Find and manage all your experiments from this page.<br>Click the following button and create your first experiment!', 'nelioab'), __('Create Experiment', 'nelioab', 'create-experiment'), 'admin.php?page=nelioab-add-experiment');
                echo '</h2>';
                echo '</div>';
                return;
            }
            ?>
			<script type="text/javascript">
			(function($) {
				$('#dialog-modal').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(__('OK', 'nelioab'));
            ?>
",
							'class': 'button button-primary',
							click: function() {
								$(this).dialog('close');
								window.location.href = $(this).data( 'href' );
							}
						}
					]
				});
			})(jQuery);
			function nelioabValidateClick(msg_id, href) {
				var $dialog = jQuery('#dialog-modal');
				$dialog.data( 'href', href );
				switch (msg_id) {
					case 0:<?php 
            $title = __('Start Experiment', 'nelioab');
            $title = str_replace('"', '\\"', $title);
            $msg = __('You are about to start an experiment. Once the experiment has started, you cannot edit it. Are you sure you want to start the experiment?', 'nelioab');
            $msg = str_replace('"', '\\"', $msg);
            ?>
						jQuery('#dialog-content').html("<?php 
            echo $msg;
            ?>
");
						$dialog.dialog('option', 'title', "<?php 
            echo $title;
            ?>
");
						$dialog.parent().find('.button-primary .ui-button-text').text("<?php 
            _e('Start', 'nelioab');
            ?>
");
						$dialog.dialog('open');
						break;
					case 1:<?php 
            $title = __('Stop Experiment', 'nelioab');
            $title = str_replace('"', '\\"', $title);
            $msg = __('You are about to stop an experiment. Once the experiment is stopped, you cannot resume it. Are you sure you want to stop the experiment?', 'nelioab');
            $msg = str_replace('"', '\\"', $msg);
            ?>
						jQuery('#dialog-content').html("<?php 
            echo $msg;
            ?>
");
						$dialog.dialog('option', 'title', "<?php 
            echo $title;
            ?>
");
						$dialog.parent().find('.button-primary .ui-button-text').text("<?php 
            _e('Stop', 'nelioab');
            ?>
");
						$dialog.dialog('open');
						break;
				}
			}
			</script>
			<form id="nelioab_experiment_list_form" method="POST" >
				<input type="hidden" name="nelioab_experiment_list_form" value="true" />
				<input type="hidden" id="action" name="action" value="" />
				<input type="hidden" id="experiment_id" name="experiment_id" value="" />
			</form>
			<?php 
            $status_draft = NelioABExperiment::STATUS_DRAFT;
            $status_ready = NelioABExperiment::STATUS_READY;
            $status_scheduled = NelioABExperiment::STATUS_SCHEDULED;
            $status_running = NelioABExperiment::STATUS_RUNNING;
            $status_finished = NelioABExperiment::STATUS_FINISHED;
            $status_trash = NelioABExperiment::STATUS_TRASH;
            NelioABHtmlGenerator::print_filters(admin_url('admin.php?page=nelioab-experiments'), array(array('value' => 'none', 'label' => __('All'), 'count' => count($this->filter_experiments())), array('value' => $status_draft, 'label' => NelioABExperiment::get_label_for_status($status_draft), 'count' => count($this->filter_experiments($status_draft))), array('value' => $status_ready, 'label' => NelioABExperiment::get_label_for_status($status_ready), 'count' => count($this->filter_experiments($status_ready))), array('value' => $status_scheduled, 'label' => NelioABExperiment::get_label_for_status($status_scheduled), 'count' => count($this->filter_experiments($status_scheduled))), array('value' => $status_running, 'label' => NelioABExperiment::get_label_for_status($status_running), 'count' => count($this->filter_experiments($status_running))), array('value' => $status_finished, 'label' => NelioABExperiment::get_label_for_status($status_finished), 'count' => count($this->filter_experiments($status_finished))), array('value' => $status_trash, 'label' => NelioABExperiment::get_label_for_status($status_trash), 'count' => count($this->filter_experiments($status_trash)))), 'status', $this->current_status);
            $wp_list_table = new NelioABExperimentsTable($this->filter_experiments($this->current_status));
            $wp_list_table->prepare_items();
            echo '<div id="nelioab-experiment-list-table">';
            $wp_list_table->display();
            echo '</div>';
            // Code for duplicating experiments.
            $this->insert_duplicate_dialog();
            // Code for scheduling experiments.
            if (NelioABAccountSettings::is_plan_at_least(NelioABAccountSettings::ENTERPRISE_SUBSCRIPTION_PLAN)) {
                $this->insert_schedule_dialog();
            }
        }
 protected function get_required_scripts()
 {
     return array(nelioab_admin_asset_link('/js/tabbed-experiment-setup.min.js'), nelioab_admin_asset_link('/js/admin-table.min.js'), nelioab_admin_asset_link('/js/alt-table.min.js'));
 }
Beispiel #15
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 
    }
 public function load_custom_style_and_scripts()
 {
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (isset($_POST['nelioab_save_exp_post'])) {
         return;
     }
     if ($this->is_page(array('add-headline-exp', 'edit-headline-exp'))) {
         wp_enqueue_media();
     }
     // TODO: this should be moved to WooCommerce controller
     if ($this->is_page(array('add-product-summary-exp', 'edit-product-summary-exp'))) {
         wp_enqueue_media();
     }
     // We make sure jQuery is loaded:
     wp_enqueue_script('jquery');
     // Custom CSS for GRAPHICS and RESULTS (experiment progress)
     if ($this->is_page(array('exp-progress', 'nelioab-dashboard'))) {
         wp_register_style('nelioab_progress_css', nelioab_admin_asset_link('/css/progress.min.css'), array(), NELIOAB_PLUGIN_VERSION);
         wp_enqueue_style('nelioab_progress_css');
         wp_enqueue_script('jquery-masonry');
     }
     wp_register_style('nelioab_tab_type_css', nelioab_admin_asset_link('/css/nelioab-tab-type.min.css'), array(), NELIOAB_PLUGIN_VERSION);
     wp_enqueue_style('nelioab_tab_type_css');
     // Animated Font Awesome Icons
     wp_register_style('nelioab_animated_fontawesome_css', nelioab_admin_asset_link('/css/font-awesome-animation.min.css'), array(), NELIOAB_PLUGIN_VERSION);
     wp_enqueue_style('nelioab_animated_fontawesome_css');
     // Custom JS for GRAPHICS (conversion experiment progress)
     wp_enqueue_script('nelioab_highcharts', nelioab_admin_asset_link('/js/highcharts.min.js'), array(), NELIOAB_PLUGIN_VERSION);
     wp_enqueue_script('nelioab_exporting', nelioab_admin_asset_link('/js/exporting.min.js'), array(), NELIOAB_PLUGIN_VERSION);
     wp_enqueue_script('nelioab_graphic_functions', nelioab_admin_asset_link('/js/graphic-functions.min.js'), array(), NELIOAB_PLUGIN_VERSION);
     wp_register_style('font_awesome_css', nelioab_admin_asset_link('/css/font-awesome.min.css'), array(), NELIOAB_PLUGIN_VERSION);
     wp_enqueue_style('font_awesome_css');
     wp_enqueue_script('d3', nelioab_admin_asset_link('/js/d3.v3.min.js'), array(), NELIOAB_PLUGIN_VERSION);
     if ($this->is_page('nelioab-dashboard')) {
         wp_register_style('cal_heatmap_css', nelioab_admin_asset_link('/css/cal-heatmap.min.css'), array(), NELIOAB_PLUGIN_VERSION);
         wp_enqueue_style('cal_heatmap_css');
         wp_enqueue_script('cal_heatmap', nelioab_admin_asset_link('/js/cal-heatmap.min.js'), array(), NELIOAB_PLUGIN_VERSION);
     }
     // Post Searcher
     if ($this->is_page(array('nelioab-add-experiment', 'edit-exp', 'nelioab-css-edit'))) {
         wp_enqueue_style('nelioab_select2_css', nelioab_admin_asset_link('/lib/select2-3.5.0/select2.min.css'), array(), NELIOAB_PLUGIN_VERSION);
         wp_enqueue_script('nelioab_select2', nelioab_admin_asset_link('/lib/select2-3.5.0/select2.min.js'), array(), NELIOAB_PLUGIN_VERSION);
         wp_enqueue_style('nelioab_post_searcher_css', nelioab_admin_asset_link('/css/post-searcher.css'), array(), NELIOAB_PLUGIN_VERSION);
         wp_enqueue_script('nelioab_post_searcher', nelioab_admin_asset_link('/js/post-searcher.min.js'), array(), NELIOAB_PLUGIN_VERSION);
         wp_enqueue_script('nelioab_form_searcher', nelioab_admin_asset_link('/js/form-searcher.min.js'), array(), NELIOAB_PLUGIN_VERSION);
     }
     // Dialog for all nelio pages
     global $pagenow;
     if (isset($_GET['page']) && strpos('nelioab-', $_GET['page']) == 0) {
         wp_enqueue_script('jquery-ui-dialog');
         wp_enqueue_script('jquery-ui-sortable');
         wp_enqueue_style('wp-jquery-ui-dialog');
     } else {
         if ('plugins.php' == $pagenow) {
             wp_enqueue_script('jquery-ui-dialog');
             wp_enqueue_style('wp-jquery-ui-dialog');
         }
     }
 }
 /**
  * It registers and enqueues the CSS files that contain our plugin iconography.
  *
  * @return void
  *
  * @since 3.3.0
  */
 public function add_custom_styles()
 {
     require_once NELIOAB_UTILS_DIR . '/wp-helper.php';
     if (NelioABWpHelper::is_at_least_version(3.8)) {
         wp_register_style('nelioab_new_icons_css', nelioab_admin_asset_link('/css/nelioab-new-icons.min.css', false), array(), NELIOAB_PLUGIN_VERSION);
         wp_enqueue_style('nelioab_new_icons_css');
     }
 }