X7ROOT File Manager
Current Path:
/home/okeydcqc/public_html/wp-content/plugins/jetpack/_inc/lib
home
/
okeydcqc
/
public_html
/
wp-content
/
plugins
/
jetpack
/
_inc
/
lib
/
ðŸ“
..
ðŸ“
admin-pages
📄
class-jetpack-ai-helper.php
(14.21 KB)
📄
class-jetpack-blog-stats-helper.php
(2.73 KB)
📄
class-jetpack-currencies.php
(4.73 KB)
📄
class-jetpack-instagram-gallery-helper.php
(2.92 KB)
📄
class-jetpack-mapbox-helper.php
(3.16 KB)
📄
class-jetpack-podcast-feed-locator.php
(3.47 KB)
📄
class-jetpack-podcast-helper.php
(20.23 KB)
📄
class-jetpack-recommendations.php
(15.24 KB)
📄
class-jetpack-top-posts-helper.php
(4.48 KB)
📄
class.color.php
(21.79 KB)
📄
class.core-rest-api-endpoints.php
(148.07 KB)
📄
class.jetpack-automatic-install-skin.php
(293 B)
📄
class.jetpack-iframe-embed.php
(3.1 KB)
📄
class.jetpack-password-checker.php
(32.45 KB)
📄
class.jetpack-search-performance-logger.php
(3.62 KB)
📄
class.media-extractor.php
(21.57 KB)
📄
class.media-summary.php
(15.43 KB)
📄
class.media.php
(15.56 KB)
📄
components.php
(3.04 KB)
ðŸ“
core-api
ðŸ“
debugger
📄
debugger.php
(872 B)
📄
icalendar-reader.php
(33.11 KB)
ðŸ“
markdown
📄
markdown.php
(344 B)
📄
plans.php
(1.89 KB)
📄
plugins.php
(209 B)
📄
tonesque.php
(6.85 KB)
📄
widgets.php
(26.19 KB)
Editing: class-jetpack-top-posts-helper.php
<?php /** * Top Posts & Pages block helper. * * @package automattic/jetpack */ use Automattic\Jetpack\Stats\WPCOM_Stats; /** * Class Jetpack_Top_Posts_Helper */ class Jetpack_Top_Posts_Helper { /** * Returns user's top posts. * * @param int $period Period of days to draw stats from. * @param int $items_count Optional. Number of items to display. * @param string $types Optional. Content types to include. * @return array */ public static function get_top_posts( $period, $items_count = null, $types = null ) { $all_time_days = floor( ( time() - strtotime( get_option( 'site_created_date' ) ) ) / ( 60 * 60 * 24 * 365 ) ); // While we only display ten posts, users can filter out content types. // As such, we should obtain a few spare posts from the Stats endpoint. $posts_to_obtain_count = 30; // We should not override cache when displaying the block on the frontend. // But we should allow instant preview of changes when editing the block. $is_rendering_block = ! empty( $types ); $override_cache = ! $is_rendering_block; $query_args = array( 'max' => $posts_to_obtain_count, 'summarize' => true, 'num' => $period !== 'all-time' ? $period : $all_time_days, 'period' => 'day', ); // Atomic or self-hosted sites via WPCOM public v1.1 endpoint. if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) { $data = ( new WPCOM_Stats() )->get_top_posts( $query_args, $override_cache ); } else { // Directly access posts on WPCOM, as Simple sites run on the same environment. require_lib( 'jetpack-stats' ); if ( class_exists( '\Jetpack\Stats\Top_Posts' ) ) { // @phan-suppress-next-line PhanUndeclaredClassMethod $data = ( new \Jetpack\Stats\Top_Posts() )->get_top_posts( get_current_blog_id(), $query_args ); } else { $data = array( 'summary' => array( 'postviews' => array() ) ); } } if ( is_wp_error( $data ) ) { $data = array( 'summary' => array( 'postviews' => array() ) ); } // Remove posts that have subsequently been deleted. $data['summary']['postviews'] = array_filter( $data['summary']['postviews'], function ( $item ) { return get_post_status( $item['id'] ) === 'publish'; } ); $posts_retrieved = is_countable( $data['summary']['postviews'] ) ? count( $data['summary']['postviews'] ) : 0; // Fallback to random posts if user does not have enough top content. if ( $posts_retrieved < $posts_to_obtain_count ) { $args = array( 'numberposts' => $posts_to_obtain_count - $posts_retrieved, 'exclude' => array_column( $data['summary']['postviews'], 'id' ), 'orderby' => 'rand', 'post_status' => 'publish', ); $random_posts = get_posts( $args ); foreach ( $random_posts as $post ) { $random_posts_data = array( 'id' => $post->ID, 'href' => get_permalink( $post->ID ), 'date' => $post->post_date, 'title' => $post->post_title, 'type' => 'post', 'public' => true, ); $data['summary']['postviews'][] = $random_posts_data; } $data['summary']['postviews'] = array_slice( $data['summary']['postviews'], 0, 10 ); } $top_posts = array(); foreach ( $data['summary']['postviews'] as $post ) { $post_id = $post['id']; $thumbnail = get_the_post_thumbnail_url( $post_id ); if ( ! $thumbnail ) { $post_images = get_attached_media( 'image', $post_id ); $post_image = reset( $post_images ); if ( $post_image ) { $thumbnail = wp_get_attachment_url( $post_image->ID ); } } if ( $post['public'] ) { $top_posts[] = array( 'id' => $post_id, 'author' => get_the_author_meta( 'display_name', get_post_field( 'post_author', $post_id ) ), 'context' => get_the_category( $post_id ) ? get_the_category( $post_id ) : get_the_tags( $post_id ), 'href' => $post['href'], 'date' => get_the_date( '', $post_id ), 'title' => $post['title'], 'type' => $post['type'], 'public' => $post['public'], 'views' => isset( $post['views'] ) ? $post['views'] : 0, 'thumbnail' => $thumbnail, ); } } // This applies for rendering the block front-end, but not for editing it. if ( $is_rendering_block ) { $acceptable_types = explode( ',', $types ); $top_posts = array_filter( $top_posts, function ( $item ) use ( $acceptable_types ) { return in_array( $item['type'], $acceptable_types, true ); } ); $top_posts = array_slice( $top_posts, 0, $items_count ); } return $top_posts; } }
Upload File
Create Folder