PHP Класс Jetpack_RelatedPosts, jetpack

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_allow_feature_toggle
$_blog_charset
$_blog_id_local
$_blog_id_wpcom
$_convert_charset
$_found_shortcode
$_options
$_previous_post_id

Открытые методы

Метод Описание
__construct ( integer $blog_id_local, integer $blog_id_wpcom ) : null Constructor for Jetpack_RelatedPosts.
action_admin_init ( ) : null Add a checkbox field to Settings > Reading for enabling related posts.
action_frontend_init ( ) Load related posts assets if it's a elegiable front end page or execute search and return JSON if it's an endpoint request.
filter_add_target_to_dom ( string $content ) Adds a target to the post content to load related posts into if a shortcode for it did not already exist.
get_for_post_id ( integer $post_id, array $args ) : array Gets an array of related posts that match the given post_id.
get_options ( ) : array Gets options set for Jetpack_RelatedPosts and merge with defaults.
get_target_html ( ) Returns the HTML for the related posts section.
get_target_html_unsupported ( ) Returns the HTML for the related posts section if it's running in the loop or other instances where we don't support related posts.
init ( ) : Jetpack_RelatedPosts Creates and returns a static instance of Jetpack_RelatedPosts.
init_raw ( ) : Jetpack_RelatedPosts Creates and returns a static instance of Jetpack_RelatedPosts_Raw.
parse_options ( array $input ) : array Parses input and returnes normalized options array.
print_setting_head ( ) Head JS/CSS for admin settings page.
print_setting_html ( ) HTML for admin settings page.
rest_get_related_posts ( array $object, string $field_name, WP_REST_Request $request ) : array Build an array of Related Posts.
rest_register_related_posts ( ) : null Add Related Posts to the REST API Post response.
test_for_shortcode ( string $content ) Looks for our shortcode on the unfiltered content, this has to execute early.

Защищенные методы

Метод Описание
_action_frontend_init_ajax ( array $excludes ) : null Generate and output ajax response for related posts API call.
_action_frontend_init_page ( ) : null Adds filters and enqueues assets.
_allow_feature_toggle ( )
_enabled_for_request ( ) : boolean Determines if the current post is able to use related posts.
_enqueue_assets ( $script, $style ) : null Enqueues assets needed to do async loading of related posts.
_filter_non_public_posts ( array $related_posts ) : array Filter out any hits that are not public anymore.
_generate_related_post_context ( integer $post_id ) : string Generates a context for the related content (second line in related post output).
_generate_related_post_image_params ( integer $post_id ) : string Generates the thumbnail image to be used for the post. Uses the image as returned by Jetpack_PostImages::get_image()
_get_coalesced_range ( array $date_range ) : array Takes a range and coalesces it into a month interval bracketed by a time as determined by the blog_id to enhance caching.
_get_es_filters_from_args ( integer $post_id, array $args ) : array Creates an array of ElasticSearch filters based on the post_id and args.
_get_excerpt ( string $post_excerpt, string $post_content ) : string Returns a plain text post excerpt for title attribute of links.
_get_related_post_data_for_post ( integer $post_id, integer $position, integer $origin ) : array Returns a UTF-8 encoded array of post information for the given post_id
_get_related_post_ids ( integer $post_id, integer $size, array $filters ) : array Get array of related posts matched by ElasticSearch.
_get_related_posts ( integer $post_id, integer $size, array $filters ) : array Workhorse method to return array of related posts matched by ElasticSearch.
_get_title ( string $post_title, string $post_content ) : string Returns either the title or a small excerpt to use as title for post.
_log_click ( $post_id, $to_post_id, $link_position ) : null Logs clicks for clickthrough analysis and related result tuning.
_setup_shortcode ( ) : null Sets up the shortcode processing.
_to_utf8 ( string $text ) : string Returns the string UTF-8 encoded

Описание методов

__construct() публичный Метод

Constructor for Jetpack_RelatedPosts.
public __construct ( integer $blog_id_local, integer $blog_id_wpcom ) : null
$blog_id_local integer
$blog_id_wpcom integer
Результат null

_action_frontend_init_ajax() защищенный Метод

NOTE: Calls exit() to end all further processing after payload has been outputed.
protected _action_frontend_init_ajax ( array $excludes ) : null
$excludes array array of post_ids to exclude
Результат null

_action_frontend_init_page() защищенный Метод

Adds filters and enqueues assets.
protected _action_frontend_init_page ( ) : null
Результат null

_allow_feature_toggle() защищенный Метод

protected _allow_feature_toggle ( )

_enabled_for_request() защищенный Метод

Determines if the current post is able to use related posts.
protected _enabled_for_request ( ) : boolean
Результат boolean

_enqueue_assets() защищенный Метод

Enqueues assets needed to do async loading of related posts.
protected _enqueue_assets ( $script, $style ) : null
Результат null

_filter_non_public_posts() защищенный Метод

Filter out any hits that are not public anymore.
protected _filter_non_public_posts ( array $related_posts ) : array
$related_posts array
Результат array

_generate_related_post_context() защищенный Метод

Order of importance: - First category (Not 'Uncategorized') - First post tag - Number of comments
protected _generate_related_post_context ( integer $post_id ) : string
$post_id integer
Результат string

_generate_related_post_image_params() защищенный Метод

Generates the thumbnail image to be used for the post. Uses the image as returned by Jetpack_PostImages::get_image()
protected _generate_related_post_image_params ( integer $post_id ) : string
$post_id integer
Результат string

_get_coalesced_range() защищенный Метод

Takes a range and coalesces it into a month interval bracketed by a time as determined by the blog_id to enhance caching.
protected _get_coalesced_range ( array $date_range ) : array
$date_range array
Результат array

_get_es_filters_from_args() защищенный Метод

Creates an array of ElasticSearch filters based on the post_id and args.
protected _get_es_filters_from_args ( integer $post_id, array $args ) : array
$post_id integer
$args array
Результат array

_get_excerpt() защищенный Метод

Returns a plain text post excerpt for title attribute of links.
protected _get_excerpt ( string $post_excerpt, string $post_content ) : string
$post_excerpt string
$post_content string
Результат string

_get_related_post_data_for_post() защищенный Метод

Returns a UTF-8 encoded array of post information for the given post_id
protected _get_related_post_data_for_post ( integer $post_id, integer $position, integer $origin ) : array
$post_id integer
$position integer
$origin integer The post id that this is related to
Результат array

_get_related_post_ids() защищенный Метод

Get array of related posts matched by ElasticSearch.
protected _get_related_post_ids ( integer $post_id, integer $size, array $filters ) : array
$post_id integer
$size integer
$filters array
Результат array

_get_title() защищенный Метод

Returns either the title or a small excerpt to use as title for post.
protected _get_title ( string $post_title, string $post_content ) : string
$post_title string
$post_content string
Результат string

_log_click() защищенный Метод

Logs clicks for clickthrough analysis and related result tuning.
protected _log_click ( $post_id, $to_post_id, $link_position ) : null
Результат null

_setup_shortcode() защищенный Метод

Sets up the shortcode processing.
protected _setup_shortcode ( ) : null
Результат null

_to_utf8() защищенный Метод

Returns the string UTF-8 encoded
protected _to_utf8 ( string $text ) : string
$text string
Результат string

action_admin_init() публичный Метод

Add a checkbox field to Settings > Reading for enabling related posts.
public action_admin_init ( ) : null
Результат null

action_frontend_init() публичный Метод

Load related posts assets if it's a elegiable front end page or execute search and return JSON if it's an endpoint request.

filter_add_target_to_dom() публичный Метод

Adds a target to the post content to load related posts into if a shortcode for it did not already exist.
public filter_add_target_to_dom ( string $content )
$content string

get_for_post_id() публичный Метод

Gets an array of related posts that match the given post_id.
public get_for_post_id ( integer $post_id, array $args ) : array
$post_id integer
$args array - params to use when building ElasticSearch filters to narrow down the search domain.
Результат array

get_options() публичный Метод

Gets options set for Jetpack_RelatedPosts and merge with defaults.
public get_options ( ) : array
Результат array

get_target_html() публичный Метод

Returns the HTML for the related posts section.
public get_target_html ( )

get_target_html_unsupported() публичный Метод

Returns the HTML for the related posts section if it's running in the loop or other instances where we don't support related posts.

init() публичный статический Метод

Creates and returns a static instance of Jetpack_RelatedPosts.
public static init ( ) : Jetpack_RelatedPosts
Результат Jetpack_RelatedPosts

init_raw() публичный статический Метод

Creates and returns a static instance of Jetpack_RelatedPosts_Raw.
public static init_raw ( ) : Jetpack_RelatedPosts
Результат Jetpack_RelatedPosts

parse_options() публичный Метод

Parses input and returnes normalized options array.
public parse_options ( array $input ) : array
$input array
Результат array

print_setting_head() публичный Метод

Head JS/CSS for admin settings page.
public print_setting_head ( )

print_setting_html() публичный Метод

HTML for admin settings page.
public print_setting_html ( )

test_for_shortcode() публичный Метод

Looks for our shortcode on the unfiltered content, this has to execute early.
public test_for_shortcode ( string $content )
$content string

Описание свойств

$_allow_feature_toggle защищенное свойство

protected $_allow_feature_toggle

$_blog_charset защищенное свойство

protected $_blog_charset

$_blog_id_local защищенное свойство

protected $_blog_id_local

$_blog_id_wpcom защищенное свойство

protected $_blog_id_wpcom

$_convert_charset защищенное свойство

protected $_convert_charset

$_found_shortcode защищенное свойство

protected $_found_shortcode

$_options защищенное свойство

protected $_options

$_previous_post_id защищенное свойство

protected $_previous_post_id