[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentyfourteen/inc/ -> featured-content.php (summary)

(no description)

File Size: 519 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Featured_Content:: (16 methods):
  setup()
  init()
  wp_loaded()
  get_featured_posts()
  get_featured_post_ids()
  get_sticky_posts()
  delete_transient()
  pre_get_posts()
  delete_post_tag()
  hide_featured_term()
  hide_the_featured_term()
  register_setting()
  customize_register()
  enqueue_scripts()
  get_setting()
  validate_settings()


Class: Featured_Content  - X-Ref

Twenty Fourteen Featured Content

This module allows you to define a subset of posts to be displayed
in the theme's Featured Content area.

For maximum compatibility with different methods of posting users
will designate a featured post tag to associate posts with. Since
this tag now has special meaning beyond that of a normal tags, users
will have the ability to hide it from the front end of their site.
setup()   X-Ref
Instantiate.

All custom functionality will be hooked into the "init" action.


init()   X-Ref
Conditionally hook into WordPress.

Theme must declare that they support this module by adding
add_theme_support( 'featured-content' ); during after_setup_theme.

If no theme support is found there is no need to hook into WordPress.
We'll just return early instead.


wp_loaded()   X-Ref
Hide "featured" tag from the front end.

Has to run on wp_loaded so that the preview filters of the Customizer
have a chance to alter the value.


get_featured_posts()   X-Ref
Get featured posts.

return: array Array of featured posts.

get_featured_post_ids()   X-Ref
Get featured post IDs

This function will return the an array containing the
post IDs of all featured posts.

Sets the "featured_content_ids" transient.

return: array Array of post IDs.

get_sticky_posts()   X-Ref
Return an array with IDs of posts marked as sticky.

return: array Array of sticky posts.

delete_transient()   X-Ref
Delete featured content IDs transient.

Hooks in the "save_post" action.


pre_get_posts( $query )   X-Ref
Exclude featured posts from the home page blog query.

Filter the home page posts, and remove any featured post ID's from it.
Hooked onto the 'pre_get_posts' action, this changes the parameters of
the query before it gets any posts.

return: WP_Query Possibly-modified WP_Query.
param: WP_Query $query WP_Query object.

delete_post_tag( $tag_id )   X-Ref
Reset tag option when the saved tag is deleted.

It's important to mention that the transient needs to be deleted,
too. While it may not be obvious by looking at the function alone,
the transient is deleted by Featured_Content::validate_settings().

Hooks in the "delete_post_tag" action.

param: int $tag_id The term_id of the tag that has been deleted.

hide_featured_term( $terms, $taxonomies, $args )   X-Ref
Hide featured tag from displaying when global terms are queried from the front end.

Hooks into the "get_terms" filter.

return: array A filtered array of terms.
param: array $terms      List of term objects. This is the return value of get_terms().
param: array $taxonomies An array of taxonomy slugs.
param: array $args       An array of get_terms() arguments.

hide_the_featured_term( $terms, $id, $taxonomy )   X-Ref
Hide featured tag from display when terms associated with a post object
are queried from the front end.

Hooks into the "get_the_terms" filter.

return: array Filtered array of terms.
param: array $terms    A list of term objects. This is the return value of get_the_terms().
param: int   $id       The ID field for the post object that terms are associated with.
param: array $taxonomy An array of taxonomy slugs.

register_setting()   X-Ref
Register custom setting on the Settings -> Reading screen.


customize_register( $wp_customize )   X-Ref
Add settings to the Customizer.

param: WP_Customize_Manager $wp_customize Customizer object.

enqueue_scripts()   X-Ref
Enqueue the tag suggestion script.


get_setting( $key = 'all' )   X-Ref
Get featured content settings.

Get all settings recognized by this module. This function
will return all settings whether or not they have been stored
in the database yet. This ensures that all keys are available
at all times.

In the event that you only require one setting, you may pass
its name as the first parameter to the function and only that
value will be returned.

return: mixed Array of all settings by default. A single value if passed as first parameter.
param: string $key The key of a recognized setting.

validate_settings( $input )   X-Ref
Validate featured content settings.

Make sure that all user supplied content is in an expected
format before saving to the database. This function will also
delete the transient set in Featured_Content::get_featured_content().

return: array Validated settings output.
param: array $input Array of settings input.



Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref