PHP Class The_Neverending_Home_Page, jetpack

Mostra file Open project: automattic/jetpack Class Usage Examples

Public Properties

Property Type Description
$option_name_enabled Don't access directly, instead use self::get_settings().
$settings
$the_time Initialize our static variables

Public Methods

Method Description
__construct ( ) : null Register actions and filters, plus parse IS settings
action_template_redirect ( ) : null Does the legwork to determine whether the feature is enabled.
action_wp_footer ( ) : string Provide IS with a list of the scripts and stylesheets already present on the page.
action_wp_footer_settings ( ) : string Prints the relevant infinite scroll settings in JS.
action_wp_head ( ) Alias for renamed class method.
ajax_response ( ) Our own Ajax response, avoiding calling admin-ajax
ajax_url ( ) : string Returns the Ajax url
allowed_query_vars ( array $allowed_vars ) : array Update the $allowed_vars array with the standard WP public and private query vars, as well as taxonomy vars
archive_supports_infinity ( ) : boolean Allow plugins to filter what archives Infinite Scroll supports
body_class ( $classes ) Adds an 'infinite-scroll' class to the body.
enqueue_spinner_scripts ( ) Enqueue spinner scripts.
filter_grunion_redirect_url ( string $url ) : string Ensure that IS doesn't interfere with Grunion by stripping IS query arguments from the Grunion redirect URL.
filter_infinite_scroll_results ( $results, $query_args, $wp_query ) : array Identify additional scripts required by the latest set of IS posts and provide the necessary data to the IS response handler.
footer ( ) : string The Infinite Blog Footer
get_excluded_posts ( ) : array In case IS is activated on search page, we have to exclude initially loaded posts which match the keyword by title, not the content as they are displayed before content-matching ones
get_last_post_date ( ) : string Grab the timestamp for the initial query's last post.
get_query_sort_field ( $query = null ) : string Returns the appropriate wp_posts table field for a given query's 'orderby' parameter, if applicable.
get_query_vars ( ) : array In case IS is active on search, we have to exclude posts matched by title rather than by post_content in order to prevent dupes on next pages
get_settings ( ) : object Parse IS settings provided by theme
get_taxonomy_vars ( ) : array Returns an array of stock and custom taxonomy query vars
got_infinity ( ) Has infinite scroll been triggered?
has_only_title_matching_posts ( ) : boolean This function checks whether all posts returned by initial wp_query match the keyword by title The code used in this function is borrowed from WP_Query class where it is used to construct like conditions for keywords
has_wrapper ( ) : boolean Check if the IS output should be wrapped in a div.
infinite_setting_html ( ) HTML code to display a checkbox true/false option for the infinite_scroll setting.
inject_query_args ( array $query_args ) : array Update the $query_args array with the parameters provided via AJAX/GET.
is_last_batch ( ) Is this guaranteed to be the last batch of posts?
posts_per_page_query ( object $query ) : null Let's overwrite the default post_per_page setting to always display a fixed amount.
preserve_more_tag ( $array ) The more tag will be ignored by default if the blog page isn't our homepage.
query ( ) : string Runs the query and returns the results via JSON.
query_time_filter ( string $where, object $query ) : string Create a where clause that will make sure post queries will always return results prior to (descending sort) or before (ascending sort) the last post date.
render ( ) : string Rendering fallback used when themes don't specify their own handler.
settings_api_init ( ) : null Add a checkbox field to Settings > Reading for enabling infinite scroll.
wp_query ( ) : object Retrieve the query used with Infinite Scroll

Private Methods

Method Description
default_footer ( ) : string Render default IS footer
get_request_parameters ( ) : string Return query string for current request, prefixed with '?'.
get_request_path ( ) : string | boolean Build path data for current request.

Method Details

__construct() public method

Register actions and filters, plus parse IS settings
public __construct ( ) : null
return null

action_template_redirect() public method

Does the legwork to determine whether the feature is enabled.
public action_template_redirect ( ) : null
return null

action_wp_head() public method

Previously, JS settings object was unnecessarily output in the document head. When the hook was changed, the method name no longer made sense.
public action_wp_head ( )

ajax_response() public method

Our own Ajax response, avoiding calling admin-ajax
public ajax_response ( )

ajax_url() public method

Returns the Ajax url
public ajax_url ( ) : string
return string

allowed_query_vars() public method

Update the $allowed_vars array with the standard WP public and private query vars, as well as taxonomy vars
public allowed_query_vars ( array $allowed_vars ) : array
$allowed_vars array
return array

archive_supports_infinity() public static method

Allow plugins to filter what archives Infinite Scroll supports
public static archive_supports_infinity ( ) : boolean
return boolean

body_class() public method

Adds an 'infinite-scroll' class to the body.
public body_class ( $classes )

enqueue_spinner_scripts() public method

Enqueue spinner scripts.

filter_grunion_redirect_url() public method

When arguments are present, Grunion redirects to the IS AJAX endpoint.
public filter_grunion_redirect_url ( string $url ) : string
$url string
return string

filter_infinite_scroll_results() public method

Identify additional scripts required by the latest set of IS posts and provide the necessary data to the IS response handler.
public filter_infinite_scroll_results ( $results, $query_args, $wp_query ) : array
return array

get_excluded_posts() public method

In case IS is activated on search page, we have to exclude initially loaded posts which match the keyword by title, not the content as they are displayed before content-matching ones
public get_excluded_posts ( ) : array
return array

get_last_post_date() public method

This takes into account the query's 'orderby' parameter and returns false if the posts are not ordered by date.
public get_last_post_date ( ) : string
return string 'Y-m-d H:i:s' or false

get_query_sort_field() public method

Returns the appropriate wp_posts table field for a given query's 'orderby' parameter, if applicable.
public get_query_sort_field ( $query = null ) : string
return string or false

get_query_vars() public method

In case IS is active on search, we have to exclude posts matched by title rather than by post_content in order to prevent dupes on next pages
public get_query_vars ( ) : array
return array

get_settings() static public method

Parse IS settings provided by theme
static public get_settings ( ) : object
return object

get_taxonomy_vars() public method

Returns an array of stock and custom taxonomy query vars
public get_taxonomy_vars ( ) : array
return array

got_infinity() static public method

Has infinite scroll been triggered?
static public got_infinity ( )

has_only_title_matching_posts() public method

This function checks whether all posts returned by initial wp_query match the keyword by title The code used in this function is borrowed from WP_Query class where it is used to construct like conditions for keywords

has_wrapper() public method

Setting value can be a boolean or a string specifying the class applied to the div.
public has_wrapper ( ) : boolean
return boolean

infinite_setting_html() public method

HTML code to display a checkbox true/false option for the infinite_scroll setting.

inject_query_args() public method

Update the $query_args array with the parameters provided via AJAX/GET.
public inject_query_args ( array $query_args ) : array
$query_args array
return array

is_last_batch() static public method

Is this guaranteed to be the last batch of posts?
static public is_last_batch ( )

posts_per_page_query() public method

Let's overwrite the default post_per_page setting to always display a fixed amount.
public posts_per_page_query ( object $query ) : null
$query object
return null

preserve_more_tag() public method

Let's force the $more global to false.
public preserve_more_tag ( $array )

query() public method

Triggered by an AJAX request.
public query ( ) : string
return string or null

query_time_filter() public method

Create a where clause that will make sure post queries will always return results prior to (descending sort) or before (ascending sort) the last post date.
public query_time_filter ( string $where, object $query ) : string
$where string
$query object
return string

render() public method

Rendering fallback used when themes don't specify their own handler.
public render ( ) : string
return string

settings_api_init() public method

Only show if the current theme supports infinity.
public settings_api_init ( ) : null
return null

wp_query() static public method

Retrieve the query used with Infinite Scroll
static public wp_query ( ) : object
return object

Property Details

$option_name_enabled static_oe public_oe property

Don't access directly, instead use self::get_settings().
static public $option_name_enabled

$settings static_oe public_oe property

static public $settings

$the_time static_oe public_oe property

Initialize our static variables
static public $the_time