$err = NelioABErrCodes::NO_HEATMAPS_AVAILABLE_FOR_NON_RUNNING_EXPERIMENT; throw new Exception(NelioABErrCodes::to_string($err), $err); } } } catch (Exception $e) { echo sprintf('<img src="%s" alt="%s" style="margin-top:50px;"/>', nelioab_asset_link('/admin/images/white-error-icon.png'), __('Funny image to graphically notify of an error.', 'nelioab')); ?> <p id="ajax-loader-label1" style="margin-top:10px;color:white;font-size:20px;"><?php echo $e->getMessage(); ?> </p><?php die; } // Prepare the content $page_on_front = nelioab_get_page_on_front(); if (!$page_on_front && !$post_id) { // if the home page is the list of posts and the experiment is for the home page $url = get_option('home'); } else { // otherwise (1 - the heatmaps is NOT for the home page or 2 - the home page is a specific page, the heatmaps should display that page $url = get_permalink($post_id); } $aux = get_post_type($post_id); if (!$url) { if ('page' == $aux) { $url = esc_url(add_query_arg(array('page_id' => $post_id), get_option('home'))); } else { $url = esc_url(add_query_arg(array('p' => $post_id), get_option('home'))); } }
protected function do_build() { $title = __('Edit Heatmap Experiment', 'nelioab'); // Check settings require_once NELIOAB_ADMIN_DIR . '/error-controller.php'; $error = NelioABErrorController::build_error_page_on_invalid_settings(); if ($error) { return; } // We recover the experiment (if any) // ---------------------------------------------- global $nelioab_admin_controller; $experiment = NULL; $other_names = array(); if (!empty($nelioab_admin_controller->data)) { $experiment = $nelioab_admin_controller->data; } else { $experiment = new NelioABHeatmapExperiment(-time()); $experiment->clear(); } // Get id of Original page or post // ---------------------------------------------- if (isset($_GET['post-id']) && $_GET['experiment-type'] == NelioABExperiment::HEATMAP_EXP) { $experiment->set_post_id($_GET['post-id']); } if (isset($_GET['page-id']) && $_GET['experiment-type'] == NelioABExperiment::HEATMAP_EXP) { $experiment->set_post_id($_GET['page-id']); } // ...and we also recover other experiment names (if any) if (isset($_POST['other_names'])) { $other_names = json_decode(urldecode($_POST['other_names'])); } else { foreach (NelioABExperimentsManager::get_experiments() as $aux) { if ($aux->get_id() != $experiment->get_id()) { array_push($other_names, $aux->get_name()); } } } // If everything is OK, we keep going! // --------------------------------------------------- // Creating the view $view = $this->create_view(); foreach ($other_names as $name) { $view->add_another_experiment_name($name); } // Experiment information $view->set_basic_info($experiment->get_id(), $experiment->get_name(), $experiment->get_description(), $experiment->get_finalization_mode(), $experiment->get_finalization_value()); $view->set_post_id($experiment->get_post_id()); // Checking whether there are pages or posts available // --------------------------------------------------- // ...pages... $list_of_pages = get_pages(); $options_for_posts = array('posts_per_page' => 1); $list_of_posts = get_posts($options_for_posts); require_once NELIOAB_UTILS_DIR . '/data-manager.php'; NelioABArrays::sort_posts($list_of_posts); if (count($list_of_pages) + count($list_of_posts) == 0) { require_once NELIOAB_ADMIN_DIR . '/views/errors/error-page.php'; $view = new NelioABErrorPage(__('There are no pages nor posts available.', 'nelioab'), __('Please, create some pages or posts and then try again.', 'nelioab')); return $view; } $is_there_a_static_front_page = nelioab_get_page_on_front(); $view->show_latest_posts_option(!$is_there_a_static_front_page); return $view; }
/** * PHPDOC * * @param string $title PHPDOC * @param string|boolean $sep PHPDOC * * @return string PHPDOC * * @since PHPDOC */ public function fix_title_for_landing_page($title, $sep = false) { global $post; if (is_object($post) && $this->is_post_alternative($post->ID)) { $front_page_id = nelioab_get_page_on_front(); $ori_id = $this->get_original_related_to($post->ID); if ($ori_id == $front_page_id) { $title = get_bloginfo('name') . " {$sep} "; } } return $title; }