function wp_statistics_generate_pages_postbox($ISOCountryCode, $search_engines) { global $WP_Statistics; if (!$WP_Statistics->get_option('pages')) { return; } list($total, $uris) = wp_statistics_get_top_pages(); if ($total > 0) { ?> <div class="postbox"> <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?> "><br /></div> <h3 class="hndle"> <span><?php _e('Top 10 Pages', 'wp_statistics'); ?> <a href="?page=wps_pages_menu"><?php echo wp_statistics_icons('dashicons-visibility', 'visibility'); _e('More', 'wp_statistics'); ?> </a></span> </h3> <div class="inside"> <?php wp_statistics_generate_pages_postbox_content($total, $uris); ?> </div> </div> <?php } }
function wp_statistics_generate_recent_postbox_content($ISOCountryCode, $count = 10) { global $wpdb, $WP_Statistics; $result = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}statistics_visitor` ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT 0, {$count}"); echo "<div class='log-latest'>"; $dash_icon = wp_statistics_icons('dashicons-visibility', 'visibility'); foreach ($result as $items) { if (substr($items->ip, 0, 6) == '#hash#') { $ip_string = __('#hash#', 'wp_statistics'); $map_string = ""; } else { $ip_string = "<a href='?page=wp-statistics/wp-statistics.php&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>"; $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __('Map', 'wp_statistics') . "'>" . wp_statistics_icons('dashicons-location-alt', 'map') . "</a>"; } echo "<div class='log-item'>"; echo "<div class='log-referred'>{$ip_string}</div>"; echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . "</div>"; echo "<div class='clear'></div>"; echo "<div class='log-url'>"; echo $map_string; if ($WP_Statistics->get_option('geoip')) { echo "<img src='" . plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; } if (array_search(strtolower($items->agent), array("chrome", "firefox", "msie", "opera", "safari")) !== FALSE) { $agent = "<img src='" . plugins_url('wp-statistics/assets/images/') . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; } else { $agent = wp_statistics_icons('dashicons-editor-help', 'unknown'); } echo "<a href='?page=wp-statistics/wp-statistics.php&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>"; echo "<a href='" . htmlentities($items->referred, ENT_QUOTES) . "' title='" . htmlentities($items->referred, ENT_QUOTES) . "'>" . wp_statistics_icons('dashicons-admin-links', 'link') . " " . htmlentities($items->referred, ENT_QUOTES) . "</a></div>"; echo "</div>"; } echo "</div>"; }
function wp_statistics_generate_hits_postbox($ISOCountryCode, $search_engines) { global $wpdb, $WP_Statistics; if ($WP_Statistics->get_option('visits') || $WP_Statistics->get_option('visitors')) { ?> <div class="postbox"> <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?> "><br /></div> <h3 class="hndle"><span><?php _e('Hit Statistics', 'wp_statistics'); ?> <a href="?page=wps_hits_menu"> <?php echo wp_statistics_icons('dashicons-visibility', 'visibility'); _e('More', 'wp_statistics'); ?> </a></span></h3> <div class="inside"> <?php wp_statistics_generate_hits_postbox_content(); ?> </div> </div> <?php } }
function wp_statistics_generate_words_postbox_content($ISOCountryCode, $count = 10) { global $wpdb, $WP_Statistics; // Retrieve MySQL data for the search words. $search_query = wp_statistics_searchword_query('all'); // Determine if we're using the old or new method of storing search engine info and build the appropriate table name. $tablename = $wpdb->prefix . 'statistics_'; if ($WP_Statistics->get_option('search_converted')) { $tabletwo = $tablename . 'visitor'; $tablename .= 'search'; $result = $wpdb->get_results("SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}"); } else { $tablename .= 'visitor'; $result = $wpdb->get_results("SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}"); } if (sizeof($result) > 0) { echo "<div class='log-latest'>"; foreach ($result as $items) { if (!$WP_Statistics->Search_Engine_QueryString($items->referred)) { continue; } if (substr($items->ip, 0, 6) == '#hash#') { $ip_string = __('#hash#', 'wp_statistics'); } else { $ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>"; } if ($WP_Statistics->get_option('search_converted')) { $this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine($items->engine); $words = $items->words; } else { $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred); $words = $WP_Statistics->Search_Engine_QueryString($items->referred); } echo "<div class='log-item'>"; echo "<div class='log-referred'>" . $words . "</div>"; echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . " - {$ip_string}</div>"; echo "<div class='clear'></div>"; echo "<div class='log-url'>"; echo "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __('Map', 'wp_statistics') . "'>" . wp_statistics_icons('dashicons-location-alt', 'map') . "</a>"; if ($WP_Statistics->get_option('geoip')) { echo "<img src='" . plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; } $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred); echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" . plugins_url('wp-statistics/assets/images/' . $this_search_engine['image']) . "' class='log-tools' title='" . $this_search_engine['translated'] . "'/></a>"; if (array_search(strtolower($items->agent), array("chrome", "firefox", "msie", "opera", "safari")) !== FALSE) { $agent = "<img src='" . plugins_url('wp-statistics/assets/images/') . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; } else { $agent = wp_statistics_icons('dashicons-editor-help', 'unknown'); } echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>"; echo "<a href='" . htmlentities($items->referred, ENT_QUOTES) . "' title='" . htmlentities($items->referred, ENT_QUOTES) . "'>" . wp_statistics_icons('dashicons-admin-links', 'link') . " " . htmlentities($items->referred, ENT_QUOTES) . "</a></div>"; echo "</div>"; } echo "</div>"; } }
function wp_statistics_generate_referring_postbox_content($count = 10) { global $wpdb, $WP_Statistics; $get_urls = array(); if ($WP_Statistics->get_option('search_converted')) { $result = $wpdb->get_results("SELECT DISTINCT host FROM {$wpdb->prefix}statistics_search"); foreach ($result as $item) { $get_urls[$item->host] = $wpdb->get_var("SELECT count(*) FROM {$wpdb->prefix}statistics_search WHERE host = '{$item->host}'"); } } else { $result = $wpdb->get_results("SELECT referred FROM {$wpdb->prefix}statistics_visitor WHERE referred <> ''"); $urls = array(); foreach ($result as $item) { $url = parse_url($item->referred); if (empty($url['host']) || stristr(get_bloginfo('url'), $url['host'])) { continue; } $urls[] = $url['host']; } $get_urls = array_count_values($urls); } arsort($get_urls); $get_urls = array_slice($get_urls, 0, $count); ?> <table width="100%" class="widefat table-stats" id="last-referrer"> <tr> <td width="10%"><?php _e('References', 'wp_statistics'); ?> </td> <td width="90%"><?php _e('Address', 'wp_statistics'); ?> </td> </tr> <?php foreach ($get_urls as $items => $value) { echo "<tr>"; echo "<td><a href='?page=wps_referrers_menu&referr=" . htmlentities($items, ENT_QUOTES) . "'>" . number_format_i18n($value) . "</a></td>"; echo "<td><a href='http://" . htmlentities($items, ENT_QUOTES) . "' target='_blank'>" . htmlentities($items, ENT_QUOTES) . " " . wp_statistics_icons('dashicons-admin-links', 'link') . "</a></td>"; echo "</tr>"; } ?> </table> <?php }
function wp_statistics_generate_referring_postbox_content($count = 10) { global $wpdb, $WP_Statistics; $get_urls = array(); $urls = array(); $start = 0; do { $result = $wpdb->get_results("SELECT referred FROM {$wpdb->prefix}statistics_visitor WHERE referred <> '' LIMIT {$start}, 10000"); $start += count($result); foreach ($result as $item) { $url = parse_url($item->referred); if (empty($url['host']) || stristr(get_bloginfo('url'), $url['host'])) { continue; } $urls[] = $url['host']; } } while (10000 == count($result)); $get_urls = array_count_values($urls); arsort($get_urls); $get_urls = array_slice($get_urls, 0, $count); ?> <table width="100%" class="widefat table-stats" id="last-referrer"> <tr> <td width="10%"><?php _e('References', 'wp_statistics'); ?> </td> <td width="90%"><?php _e('Address', 'wp_statistics'); ?> </td> </tr> <?php foreach ($get_urls as $items => $value) { echo "<tr>"; echo "<td><a href='?page=" . WP_STATISTICS_REFERRERS_PAGE . "&referr=" . htmlentities($items, ENT_QUOTES) . "'>" . number_format_i18n($value) . "</a></td>"; echo "<td><a href='http://" . htmlentities($items, ENT_QUOTES) . "' target='_blank'>" . htmlentities($items, ENT_QUOTES) . " " . wp_statistics_icons('dashicons-admin-links', 'link') . "</a></td>"; echo "</tr>"; } ?> </table> <?php }
function wp_statistics_generate_referring_postbox_content($result, $count = 10) { ?> <table width="100%" class="widefat table-stats" id="last-referrer"> <tr> <td width="10%"><?php _e('References', 'wp_statistics'); ?> </td> <td width="90%"><?php _e('Address', 'wp_statistics'); ?> </td> </tr> <?php $urls = array(); foreach ($result as $items) { $url = parse_url($items->referred); if (empty($url['host']) || stristr(get_bloginfo('url'), $url['host'])) { continue; } $urls[] = $url['host']; } $get_urls = array_count_values($urls); arsort($get_urls); $get_urls = array_slice($get_urls, 0, $count); foreach ($get_urls as $items => $value) { echo "<tr>"; echo "<td><a href='?page=wps_referrers_menu&referr=" . htmlentities($items, ENT_QUOTES) . "'>" . number_format_i18n($value) . "</a></td>"; echo "<td><a href='http://" . htmlentities($items, ENT_QUOTES) . "' target='_blank'>" . htmlentities($items, ENT_QUOTES) . " " . wp_statistics_icons('dashicons-admin-links', 'link') . "</a></td>"; echo "</tr>"; } ?> </table> <?php }
function wp_statistics_generate_browsers_postbox($ISOCountryCode, $search_engines) { ?> <div class="postbox"> <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?> "><br /></div> <h3 class="hndle"><span><?php _e('Browsers', 'wp_statistics'); ?> <a href="?page=wps_browsers_menu"><?php echo wp_statistics_icons('dashicons-visibility', 'visibility'); _e('More', 'wp_statistics'); ?> </a></span></h3> <div class="inside"> <?php wp_statistics_generate_browsers_postbox_content(); ?> </div> </div> <?php }
echo "<div class='log-ip'>" . $WP_Statistics->Local_Date(get_option('date_format'), strtotime($items->last_counter)) . " - {$ip_string}</div>"; echo "<div class='clear'></div>"; echo "<div class='log-url'>"; echo $map_string; if ($WP_Statistics->get_option('geoip')) { echo "<img src='" . plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; } $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred); echo "<a href='?page=wp-statistics/wp-statistics.php&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" . plugins_url('wp-statistics/assets/images/' . $this_search_engine['image']) . "' class='log-tools' title='" . __($this_search_engine['name'], 'wp_statistics') . "'/></a>"; if (array_search(strtolower($items->agent), array("chrome", "firefox", "msie", "opera", "safari")) !== FALSE) { $agent = "<img src='" . plugins_url('wp-statistics/assets/images/') . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; } else { $agent = wp_statistics_icons('dashicons-editor-help', 'unknown'); } echo "<a href='?page=wp-statistics/wp-statistics.php&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>"; echo "<a href='" . htmlentities($items->referred, ENT_QUOTES) . "' title='" . htmlentities($items->referred, ENT_QUOTES) . "'>" . wp_statistics_icons('dashicons-admin-links', 'link') . " " . htmlentities($items->referred, ENT_QUOTES) . "</a></div>"; echo "</div>"; } } echo "</div>"; ?> </div> </div> <div class="pagination-log"> <?php if ($total > 0) { echo $Pagination->display(); ?> <p id="result-log"><?php echo ' ' . __('Page', 'wp_statistics') . ' ' . $Pagination->getCurrentPage() . ' ' . __('From', 'wp_statistics') . ' ' . $Pagination->getTotalPages();
function wp_statistics_dashboard_inline_javascript() { $screen = get_current_screen(); if( 'dashboard' != $screen->id ) { return; } wp_statistics_load_widget_css_and_scripts(); $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp_statistics' ) . '"></div>'; $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '</button>'; $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button>'; $admin_url = get_admin_url() . "/admin.php?page="; $page_urls = array(); $page_urls['wp-statistics-browsers-widget_more_button'] = $admin_url . WP_STATISTICS_BROWSERS_PAGE; $page_urls['wp-statistics-countries-widget_more_button'] = $admin_url . WP_STATISTICS_COUNTRIES_PAGE; $page_urls['wp-statistics-exclusions-widget_more_button'] = $admin_url . WP_STATISTICS_EXCLUSIONS_PAGE; $page_urls['wp-statistics-hits-widget_more_button'] = $admin_url . WP_STATISTICS_HITS_PAGE; $page_urls['wp-statistics-online-widget_more_button'] = $admin_url . WP_STATISTICS_ONLINE_PAGE; $page_urls['wp-statistics-pages-widget_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE; $page_urls['wp-statistics-referring-widget_more_button'] = $admin_url . WP_STATISTICS_REFERRERS_PAGE; $page_urls['wp-statistics-search-widget_more_button'] = $admin_url . WP_STATISTICS_SEARCHES_PAGE; $page_urls['wp-statistics-words-widget_more_button'] = $admin_url . WP_STATISTICS_WORDS_PAGE; $page_urls['wp-statistics-top-visitors-widget_more_button'] = $admin_url . WP_STATISTICS_TOP_VISITORS_PAGE; $page_urls['wp-statistics-visitors-widget_more_button'] = $admin_url . WP_STATISTICS_VISITORS_PAGE; $page_urls['wp-statistics-quickstats-widget_more_button'] = $admin_url . WP_STATISTICS_OVERVIEW_PAGE; ?> <script type="text/javascript"> var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>; var wp_statistics_loading_image = '<?php echo $loading_img; ?>' function wp_statistics_wait_for_postboxes() { if( ! jQuery('#show-settings-link').is( ':visible') ) { setTimeout( wp_statistics_wait_for_postboxes, 500 ); } jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget ); jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more ); jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget ); } jQuery(document).ready(function(){ // Add the "more" and "refresh" buttons. jQuery('.postbox').each( function () { var temp = jQuery( this ); var temp_id = temp.attr( 'id' ); if( temp_id.substr( 0, 14 ) != 'wp-statistics-' ) { return; } var temp_html = temp.html(); if( temp_id == 'wp-statistics-summary-widget' ) { new_text = '<?php echo $new_button;?>'; new_text = new_text.replace( '{{refreshid}}', temp_id + '_refresh_button' ); temp_html = temp_html.replace( '</button>', new_text ); } else { new_text = '<?php echo $new_buttons;?>'; new_text = new_text.replace( '{{refreshid}}', temp_id + '_refresh_button' ); new_text = new_text.replace( '{{moreid}}', temp_id + '_more_button' ); temp_html = temp_html.replace( '</button>', new_text ); } temp.html( temp_html ); }); // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code. // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once. setTimeout( wp_statistics_wait_for_postboxes, 100 ); }); </script> <?php }
$ip_string = __('#hash#', 'wp_statistics'); $map_string = ""; } else { $ip_string = "<a href='?page=wp-statistics/wp-statistics.php&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>"; $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __('Map', 'wp_statistics') . "'>" . wp_statistics_icons('dashicons-location-alt', 'map') . "</a>"; } echo "<div class='log-item'>"; echo "<div class='log-url'>"; echo $map_string; if ($WP_Statistics->get_option('geoip')) { echo "<img src='" . plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; } if (array_search(strtolower($items->agent), array("chrome", "firefox", "msie", "opera", "safari")) !== FALSE) { $agent = "<img src='" . plugins_url('wp-statistics/assets/images/') . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; } else { $agent = wp_statistics_icons('dashicons-editor-help', 'unknown'); } echo "<a href='?page=wp-statistics/wp-statistics.php&type=last-all-visitor&agent={$items->agent}'>{$agent}</a> {$items->ip}"; echo "<br>"; echo __('Online for ', 'wp_statistics'); $timediff = $items->timestamp - $items->created; if ($timediff > 3600) { echo date("H:i:s", $items->timestamp - $items->created); } else { if ($timediff > 60) { echo "00:" . date("i:s", $items->timestamp - $items->created); } else { echo "00:00:" . date("s", $items->timestamp - $items->created); } } echo " (HH:MM:SS)";
$pagesPerSection = 10; $options = array(25, "All"); $stylePageOff = "pageOff"; $stylePageOn = "pageOn"; $styleErrors = "paginationErrors"; $styleSelect = "paginationSelect"; $Pagination = new WP_Statistics_Pagination($total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect); $start = $Pagination->getEntryStart(); $end = $Pagination->getEntryEnd(); if ($WP_Statistics->get_option('search_converted')) { $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}statistics_search` INNER JOIN `{$wpdb->prefix}statistics_visitor` on {$wpdb->prefix}statistics_search.`visitor` = {$wpdb->prefix}statistics_visitor.`ID` WHERE `host` = %s ORDER BY `{$wpdb->prefix}statistics_search`.`ID` DESC LIMIT %d, %d", $referr, $start, $end)); } if ($referr) { foreach ($result as $item) { echo "<div class='log-item'>"; echo "<div class='log-referred'><a href='?page=wp-statistics/wp-statistics.php&type=last-all-visitor&ip={$item->ip}'>" . wp_statistics_icons('dashicons-visibility', 'visibility') . "{$item->ip}</a></div>"; echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($item->last_counter)) . " - <a href='http://www.geoiptool.com/en/?IP={$item->ip}' target='_blank'>{$item->ip}</a></div>"; echo "<div class='clear'></div>"; echo "<a class='show-map' title='" . __('Map', 'wp_statistics') . "'><div class='dashicons dashicons-location-alt'></div></a>"; if (array_search(strtolower($item->agent), array("chrome", "firefox", "msie", "opera", "safari")) !== FALSE) { $agent = "<img src='" . plugins_url('wp-statistics/assets/images/') . $item->agent . ".png' class='log-tools' title='{$item->agent}'/>"; } else { $agent = "<div class='dashicons dashicons-editor-help'></div>"; } echo "<div class='log-agent'><a href='?page=wp-statistics/wp-statistics.php&type=last-all-visitor&agent={$item->agent}'>{$agent}</a>"; echo "<a href='" . htmlentities($item->referred, ENT_QUOTES) . "'><div class='dashicons dashicons-admin-links'></div> " . htmlentities(substr($item->referred, 0, 100), ENT_QUOTES) . "[...]</a></div>"; echo "</div>"; } } else { arsort($get_urls); $get_urls = array_slice($get_urls, $start, $end);
$pagesPerSection = 10; $options = array(25, "All"); $stylePageOff = "pageOff"; $stylePageOn = "pageOn"; $styleErrors = "paginationErrors"; $styleSelect = "paginationSelect"; $Pagination = new WP_Statistics_Pagination($total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect); $start = $Pagination->getEntryStart(); $end = $Pagination->getEntryEnd(); if ($WP_Statistics->get_option('search_converted')) { $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}statistics_search` INNER JOIN `{$wpdb->prefix}statistics_visitor` on {$wpdb->prefix}statistics_search.`visitor` = {$wpdb->prefix}statistics_visitor.`ID` WHERE `host` = %s AND {$wpdb->prefix}statistics_visitor.`last_counter` BETWEEN %s AND %s ORDER BY `{$wpdb->prefix}statistics_search`.`ID` DESC LIMIT %d, %d", $referr, $rangestartdate, $rangeenddate, $start, $end)); } if ($referr) { foreach ($result as $item) { echo "<div class='log-item'>"; echo "<div class='log-referred'><a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&ip={$item->ip}'>" . wp_statistics_icons('dashicons-visibility', 'visibility') . "{$item->ip}</a></div>"; echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($item->last_counter)) . " - <a href='http://www.geoiptool.com/en/?IP={$item->ip}' target='_blank'>{$item->ip}</a></div>"; echo "<div class='clear'></div>"; echo "<a class='show-map' title='" . __('Map', 'wp_statistics') . "'><div class='dashicons dashicons-location-alt'></div></a>"; if (array_search(strtolower($item->agent), array("chrome", "firefox", "msie", "opera", "safari")) !== FALSE) { $agent = "<img src='" . plugins_url('wp-statistics/assets/images/') . $item->agent . ".png' class='log-tools' title='{$item->agent}'/>"; } else { $agent = "<div class='dashicons dashicons-editor-help'></div>"; } echo "<div class='log-agent'><a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$item->agent}'>{$agent}</a>"; echo "<a href='" . htmlentities($item->referred, ENT_QUOTES) . "'><div class='dashicons dashicons-admin-links'></div> " . htmlentities(substr($item->referred, 0, 100), ENT_QUOTES) . "[...]</a></div>"; echo "</div>"; } } else { arsort($get_urls); $get_urls = array_slice($get_urls, $start, $end);
<div class="postbox-container" id="wps-postbox-container-1"> <?php do_meta_boxes($WP_Statistics->menu_slugs['overview'], 'side', ''); ?> </div> <div class="postbox-container" id="wps-postbox-container-2"> <?php do_meta_boxes($WP_Statistics->menu_slugs['overview'], 'normal', ''); ?> </div> </div> </div> <?php $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons('dashicons-update') . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons('dashicons-migrate') . '</button>'; $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons('dashicons-update') . '</button>'; $admin_url = get_admin_url() . "/admin.php?page="; $page_urls = array(); $page_urls['wps_browsers_more_button'] = $admin_url . WP_STATISTICS_BROWSERS_PAGE; $page_urls['wps_countries_more_button'] = $admin_url . WP_STATISTICS_COUNTRIES_PAGE; $page_urls['wps_exclusions_more_button'] = $admin_url . WP_STATISTICS_EXCLUSIONS_PAGE; $page_urls['wps_hits_more_button'] = $admin_url . WP_STATISTICS_HITS_PAGE; $page_urls['wps_online_more_button'] = $admin_url . WP_STATISTICS_ONLINE_PAGE; $page_urls['wps_pages_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE; $page_urls['wps_referring_more_button'] = $admin_url . WP_STATISTICS_REFERRERS_PAGE; $page_urls['wps_search_more_button'] = $admin_url . WP_STATISTICS_SEARCHES_PAGE; $page_urls['wps_words_more_button'] = $admin_url . WP_STATISTICS_WORDS_PAGE; $page_urls['wps_top_visitors_more_button'] = $admin_url . WP_STATISTICS_TOP_VISITORS_PAGE; $page_urls['wps_recent_more_button'] = $admin_url . WP_STATISTICS_VISITORS_PAGE; ?> <script type="text/javascript">
function wp_statistics_editor_inline_javascript() { $screen = get_current_screen(); if ('post' != $screen->id && 'page' != $screen->id) { return; } wp_statistics_load_widget_css_and_scripts(); $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __('Reloading...', 'wp_statistics') . '"></div>'; $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons('dashicons-update') . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons('dashicons-migrate') . '</button>'; $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons('dashicons-update') . '</button>'; $admin_url = get_admin_url() . "/admin.php?page="; $page_urls = array(); $page_urls['wp_statistics_editor_meta_box_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE . '&page-id='; ?> <script type="text/javascript"> var wp_statistics_destinations = <?php echo json_encode($page_urls); ?> ; var wp_statistics_loading_image = '<?php echo $loading_img; ?> ' function wp_statistics_wait_for_postboxes() { if( ! jQuery('#show-settings-link').is( ':visible') ) { setTimeout( wp_statistics_wait_for_postboxes, 500 ); } jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget ); jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more ); jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget ); } jQuery(document).ready(function(){ // Add the "more" and "refresh" buttons. jQuery('.postbox').each( function () { var temp = jQuery( this ); var temp_id = temp.attr( 'id' ); if( temp_id == 'wp_statistics_editor_meta_box' ) { var temp_html = temp.html(); new_text = '<?php echo $new_buttons; ?> '; new_text = new_text.replace( '{{refreshid}}', temp_id + '_refresh_button' ); new_text = new_text.replace( '{{moreid}}', temp_id + '_more_button' ); temp_html = temp_html.replace( '</button>', new_text ); temp.html( temp_html ); } }); // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code. // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once. setTimeout( wp_statistics_wait_for_postboxes, 100 ); }); </script> <?php }