PHP 클래스 Jetpack_RelatedPosts, jetpack

파일 보기 프로젝트 열기: automattic/jetpack 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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