', $popup_user_width, $popup_user_percent, $popup_display_end, $popup_user_manual_show, $popup_user_notshow_onclose, $popup_user_notshow_onclose_all, get_the_ID(), $popup_trigger_oncomment, $popup_display_exit, $popup_window_popafter); $output .= ''; $output .= '
'; if ($popup_window_title != '') { $output .= sprintf('

%1$s

', stripslashes($popup_window_title)); } if ($popup_user_message != '') { $output .= sprintf('
%1$s
', stripslashes($popup_user_message)); } $output .= '
'; $output .= '
'; $output .= ''; $output .= '
'; $output .= '
'; $output .= '

'.stripslashes($post_details['title_plain']).'

'; $output .= '
'.stripslashes($post_details['description']).'
'; $output .= '
'; $output .= '
'; $output .= $share_buttons; if (!empty($popup_second_title)) { $popup_second_title = stripslashes($popup_second_title); $popup_second_title = do_shortcode($popup_second_title); $output .= sprintf('

%1$s

', $popup_second_title); } if ($popup_second_type == "fans") { if (!empty($popup_second_fans)) { $popup_second_fans = stripslashes($popup_second_fans); $popup_second_fans = do_shortcode($popup_second_fans); $output .= '
'.$popup_second_fans.'
'; } } if ($popup_second_type == "html") { if (!empty($popup_second_html)) { $popup_second_html = stripslashes($popup_second_html); $popup_second_html = do_shortcode($popup_second_html); $output .= '
'.$popup_second_html.'
'; } } if ($popup_second_type == "top") { $leading_posts = self::leading_posts_from_analytics_for7days(); $output .= '
'; $output .= self::prepare_leadingposts_html($leading_posts); $output .= '
'; } $output .= '
'; if ($popup_window_popafter != '') { $output .= ''; } $output .= ''; $output .= ""; $output .= '
'; return $output; } public static function leading_posts_from_analytics_for7days() { global $wpdb; $table_name = $wpdb->prefix . ESSB3_TRACKER_TABLE; $toDate = date ( "Y-m-d" ); $fromDate = date ( "Y-m-d", strtotime ( date ( "Y-m-d", strtotime ( date ( "Y-m-d" ) ) ) . "-8 days" ) ); $query = ""; //foreach($essb_networks as $k => $v) { $query .= "SELECT essb_post_id, COUNT( essb_post_id ) AS cnt"; $query .= ' FROM '.$table_name .' WHERE essb_date BETWEEN "'.$fromDate.'" AND "'.$toDate.'" GROUP BY essb_post_id ORDER BY cnt DESC'; $post_stats = $wpdb->get_results ( $query ); $limit = 3; $cnt = 0; $result_posts = array(); if (isset($post_stats)) { foreach ( $post_stats as $rec ) { $post_permalink = get_permalink($rec->essb_post_id); $post_title = get_the_title($rec->essb_post_id); $post_excerpt = essb_core_helper_get_excerpt_by_id($rec->essb_post_id); $post_image = has_post_thumbnail( $rec->essb_post_id ) ? wp_get_attachment_image_src( get_post_thumbnail_id( $rec->essb_post_id ), 'single-post-thumbnail' ) : ''; $image = ($post_image != '') ? $post_image[0] : ''; $cnt++; $result_posts[] = array("title" => $post_title, "url" => $post_permalink, "excerpt" => $post_excerpt, "image" => $image); if ($limit < $cnt) { break; } } } return $result_posts; } public static function prepare_leadingposts_html($posts_data) { $output = ""; foreach ($posts_data as $post_object) { $output .= '
'; if (!empty($post_object['image'])) { $output .= ''; } $output .= '

'.$post_object['title'].'

'; $output .= $post_object['excerpt'].'
'; $output .= '
'; } return $output; } }