cookbook
Table of Contents
Classes
- Updater
- Theme updater.
Constants
- THEME_NAME = 'GP-cookbook'
- Define the theme name constant.
Functions
- add_course_filter() : void
- Show a course filter on selected archive pages.
- modify_archive_order() : void
- Change sort order of archive pages where required.
- archive_redirect() : void
- Redirect selected archive pages.
- modify_archive_title() : string
- Remove prefix for taxonomy name from archive titles.
- set_excerpt() : string
- Set excerpt if no custom excerpt.
- register_scripts() : void
- Register scripts.
- register_styles() : void
- Register styles.
- enqueue_assets() : void
- Enqueue the scripts and styles.
- disable_child_theme_load() : bool
- Prevent generatepress from loading child theme stylesheet.
- get_asset_path() : string
- Return the asset path.
- get_asset_uri() : string
- Return the asset URI.
- get_asset_url() : string
- Return the asset URL (with version).
- get_asset_version() : string
- Return the version.
- get_style_tag() : string
- Create a stylesheet link tag.
- add_image_sizes() : void
- Add custom image sizes.
- filter_image_attributes() : array<string|int, mixed>
- Filter the image attributes.
- ingredient_meta_data() : void
- Show ingredient meta data at top of post.
- ingredient_columns() : bool
- Add generatepress column handling to ingredient custom post type.
- print_cover_description() : string
- Maybe add description to print front pages.
- print_cover_subtitle() : string
- Add subtitle to print front pages.
- disable_lazy_load() : array<string|int, mixed>
- Disable lazy load on print images.
- get_print_args() : array<string|int, mixed>
- Get arguments for the print page.
- set_search_placeholder_text() : string
- Set search placeholder text.
- enqueue_single_assets() : void
- Enqueue the scripts and styles for single posts.
- filter_related_posts() : array<string|int, mixed>
- Filter the related posts query args to add related post list.
- filter_query_loop_args() : array<string|int, mixed>
- Filter the selected query loop args for specific views.
- filter_private_title() : string
- Filters the text prepended to the post title of private posts.
- get_theme_metadata() : string
- Return a metadata value.
- remove_admin_bar() : void
- Hide WordPress admin bar for all but administrator.
- remove_image_nav() : void
- Remove #main anchor from attachment links.
- theme_support() : void
- Override theme supported features.
- post_type_support() : void
- Add feature support to post types.
- title_separator() : string
- Set page title separator.
- read_more_link() : bool
- Change the read more link to prevent scroll on target page.
- disable_schema() : bool
- Override theme generated schema.
- get_scroll_offset() : int
- Get the offset from top of page for smooth scroll.
- filter_main_menu() : array<string|int, mixed>
- Filter the user's name into the "member" primary menu item.
- filter_nutrition_label() : array<string|int, string>
- Filter the attributes of the nutrition label.
- filter_private_notes() : array<string|int, string>
- Filter the attributes of the private notes.
- filter_recipe_cook_mode() : array<string|int, string>
- Filter the attributes of the cook mode toggle.
- filter_recipe_download_pdf() : array<string|int, string>
- Filter the attributes of the download PDF button.
- filter_recipe_equipment() : array<string|int, string>
- Filter the attributes of the recipe equipment display.
- filter_recipe_image() : array<string|int, string>
- Filter the attributes of the recipe image display.
- filter_recipe_ingredients() : array<string|int, string>
- Filter the attributes of the recipe ingredients display.
- filter_recipe_instructions() : array<string|int, string>
- Filter the attributes of the recipe instructions display.
- filter_recipe_jump_to_comments() : array<string|int, string>
- Filter the attributes of the jump to comments button.
- filter_recipe_jump() : array<string|int, string>
- Filter the attributes of the jump to recipe button.
- filter_recipe_media_toggle() : array<string|int, string>
- Filter the attributes of the recipe media toggle.
- filter_recipe_meta_container() : array<string|int, string>
- Filter the attributes of the recipe metadata container.
- filter_recipe_name() : array<string|int, string>
- Filter the attributes of the recipe name display.
- filter_recipe_notes() : array<string|int, string>
- Filter the attributes of the recipe notes.
- filter_recipe_nutrition() : array<string|int, string>
- Filter the attributes of a single recipe nutrition field.
- filter_recipe_print() : array<string|int, string>
- Filter the attributes of the recipe print button.
- filter_recipe_rating() : array<string|int, string>
- Filter the attributes of the recipe rating display.
- filter_recipe_servings() : array<string|int, string>
- Filter the attributes of the recipe ajustable servings.
- filter_recipe_summary() : array<string|int, string>
- Filter the attributes of the recipe summary.
- filter_recipe_tag() : array<string|int, string>
- Filter the attributes of the recipe tag container.
- filter_recipe_time() : array<string|int, string>
- Filter the attributes of the recipe individual time container.
- filter_recipe_unit_conversion() : array<string|int, string>
- Filter the attributes of the unit conversion control.
- filter_icon_sources() : array<string|int, mixed>
- Filter the SVG icon sources.
- filter_print_assets() : array<string|int, mixed>
- Filter the assets used for printing.
- filter_public_script() : array<string|int, mixed>
- Filter the public js variables.
- set_button_attributes() : array<string|int, string>
- Set the attributes of the template buttons.
- set_label_attributes() : array<string|int, string>
- Set the attributes of the meta labels.
- set_toggle_attributes() : array<string|int, string>
- Set the attributes of the toggle switches.
- add_rankmath_hooks() : void
- Add the rankmath hooks.
- modify_breadcrumb_html() : string
- Modify the breadcrumb HTML.
- modify_toc_content() : string
- Modify the TOC HTML.
Constants
THEME_NAME
Define the theme name constant.
public
mixed
THEME_NAME
= 'GP-cookbook'
Tags
Functions
add_course_filter()
Show a course filter on selected archive pages.
add_course_filter(WP_Term $archive_term) : void
Parameters
- $archive_term : WP_Term
-
The archive term.
Tags
modify_archive_order()
Change sort order of archive pages where required.
modify_archive_order(WP_Query $query) : void
- Do not change order on admin pages.
Parameters
- $query : WP_Query
-
The WP_Query instance (passed by reference).
Tags
archive_redirect()
Redirect selected archive pages.
archive_redirect() : void
- Redirect top level recipes category archive to content page.
Tags
modify_archive_title()
Remove prefix for taxonomy name from archive titles.
modify_archive_title(string $title, string $original_title, string $prefix) : string
- Leave date and author prefixes unchanged.
Parameters
- $title : string
-
Archive title.
- $original_title : string
-
Archive title without prefix.
- $prefix : string
-
Archive title prefix.
Tags
Return values
string —The (maybe) modified archive title.
set_excerpt()
Set excerpt if no custom excerpt.
set_excerpt(string $text, string $raw_excerpt) : string
- If no explicit excerpt is set, generate an excerpt from the complete first paragraph of the content.
Parameters
- $text : string
-
The trimmed text.
- $raw_excerpt : string
-
The text prior to trimming.
Tags
Return values
string —The (maybe) modified excerpt.
register_scripts()
Register scripts.
register_scripts() : void
- The asset must start with a leading slash. It is relative to the assets directory.
Tags
register_styles()
Register styles.
register_styles() : void
- The asset must start with a leading slash. It is relative to the assets directory.
Tags
enqueue_assets()
Enqueue the scripts and styles.
enqueue_assets() : void
Tags
disable_child_theme_load()
Prevent generatepress from loading child theme stylesheet.
disable_child_theme_load() : bool
- The stylesheet will have dependencies added and enqueued late in loadng process,
Tags
Return values
boolget_asset_path()
Return the asset path.
get_asset_path(string $asset) : string
Parameters
- $asset : string
-
The target asset.
Tags
Return values
string —The fully qualified filesystem path to the asset.
get_asset_uri()
Return the asset URI.
get_asset_uri(string $asset) : string
Parameters
- $asset : string
-
The target asset.
Tags
Return values
string —The resource URI.
get_asset_url()
Return the asset URL (with version).
get_asset_url(string $asset) : string
Parameters
- $asset : string
-
The target asset.
Tags
Return values
string —The resource URL including version info.
get_asset_version()
Return the version.
get_asset_version(string $asset_path) : string
Parameters
- $asset_path : string
-
The fully qualified asset path.
Tags
Return values
string —The resource version.
get_style_tag()
Create a stylesheet link tag.
get_style_tag(string $asset) : string
- Allow direct loading of stylesheets where wp_enqueue is not used.
Parameters
- $asset : string
-
The path of the stylesheet.
Tags
Return values
string —The link tag markup.
add_image_sizes()
Add custom image sizes.
add_image_sizes() : void
Add cropping to default medium image. Specify the size the 400px wide size. Add proportional size for medium images. Add 1160px wide 4x3 ratio for featured and in-post full-width images. Add 1160px wide proportional size for attachment pages.
Tags
filter_image_attributes()
Filter the image attributes.
filter_image_attributes(array<string|int, mixed> $attr, WP_Post $attachment, array<string|int, mixed>|string $size) : array<string|int, mixed>
Parameters
- $attr : array<string|int, mixed>
-
Array of attribute values for the image markup, keyed by attribute name.
- $attachment : WP_Post
-
Image attachment post.
- $size : array<string|int, mixed>|string
-
Requested image size.
Tags
Return values
array<string|int, mixed> —The modified attribute values for markup.
ingredient_meta_data()
Show ingredient meta data at top of post.
ingredient_meta_data() : void
Tags
ingredient_columns()
Add generatepress column handling to ingredient custom post type.
ingredient_columns(bool $columns) : bool
Parameters
- $columns : bool
-
Apply columns flag.
Tags
Return values
boolprint_cover_description()
Maybe add description to print front pages.
print_cover_description(string $description[, array<string|int, mixed> $args = array() ]) : string
Chooses the description to display determined by page content.
Parameters
- $description : string
-
The page description to be filtered.
- $args : array<string|int, mixed> = array()
-
Content arguments.
Tags
Return values
string —The filtered description.
print_cover_subtitle()
Add subtitle to print front pages.
print_cover_subtitle(string $subtitle[, array<string|int, mixed> $args = array() ]) : string
Chooses the subtitle to display determined by content type.
Parameters
- $subtitle : string
-
The page subtitle to be filtered.
- $args : array<string|int, mixed> = array()
-
Content arguments.
Tags
Return values
string —The filtered subtitle.
disable_lazy_load()
Disable lazy load on print images.
disable_lazy_load(array<string|int, mixed> $attr, WP_Post $attachment, array<string|int, mixed>|string $size) : array<string|int, mixed>
Parameters
- $attr : array<string|int, mixed>
-
Array of attribute values for the image markup, keyed by attribute name.
- $attachment : WP_Post
-
Image attachment post.
- $size : array<string|int, mixed>|string
-
Requested image size.
Tags
Return values
array<string|int, mixed> —The modified attribute values for markup.
get_print_args()
Get arguments for the print page.
get_print_args() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The array of print arguments.
set_search_placeholder_text()
Set search placeholder text.
set_search_placeholder_text() : string
Tags
Return values
string —Search placeholder text.
enqueue_single_assets()
Enqueue the scripts and styles for single posts.
enqueue_single_assets() : void
Tags
filter_related_posts()
Filter the related posts query args to add related post list.
filter_related_posts(array<string|int, mixed> $qv, array<string|int, mixed> $attributes) : array<string|int, mixed>
Parameters
- $qv : array<string|int, mixed>
-
The WP_Query args.
- $attributes : array<string|int, mixed>
-
The Generateblocks Query Loop block attributes.
Tags
Return values
array<string|int, mixed> —The (maybe) modified query arguments.
filter_query_loop_args()
Filter the selected query loop args for specific views.
filter_query_loop_args(array<string|int, mixed> $qv, array<string|int, mixed> $attributes) : array<string|int, mixed>
Parameters
- $qv : array<string|int, mixed>
-
The WP_Query args.
- $attributes : array<string|int, mixed>
-
The Generateblocks Query Loop block attributes.
Tags
Return values
array<string|int, mixed> —The (maybe) modified query arguments.
filter_private_title()
Filters the text prepended to the post title of private posts.
filter_private_title(string $prepend, WP_Post $post) : string
- Single pages or posts have no prepended text.
- Prepend a subscriber-only notice everywhere else.
Parameters
- $prepend : string
-
Text displayed before the post title. Default 'Private: %s'.
- $post : WP_Post
-
Current post object.
Tags
Return values
string —The (maybe) modified prepend string.
get_theme_metadata()
Return a metadata value.
get_theme_metadata(string $field) : string
Parameters
- $field : string
-
The field to search for.
Tags
Return values
string —The metadata value.
remove_admin_bar()
Hide WordPress admin bar for all but administrator.
remove_admin_bar() : void
Tags
remove_image_nav()
Remove #main anchor from attachment links.
remove_image_nav() : void
Tags
theme_support()
Override theme supported features.
theme_support() : void
Tags
post_type_support()
Add feature support to post types.
post_type_support() : void
- Enable the excerpt meta box in page edit screen.
Tags
title_separator()
Set page title separator.
title_separator(string $separator) : string
Parameters
- $separator : string
-
Document title separator.
Tags
Return values
string —Modified document title separator.
read_more_link()
Change the read more link to prevent scroll on target page.
read_more_link() : bool
Tags
Return values
bool —Scroll to
disable_schema()
Override theme generated schema.
disable_schema() : bool
- Now uses RankMath generated schema.
Tags
Return values
boolget_scroll_offset()
Get the offset from top of page for smooth scroll.
get_scroll_offset() : int
Tags
Return values
int —The number of pixels to offset the scroll.
filter_main_menu()
Filter the user's name into the "member" primary menu item.
filter_main_menu(array<string|int, mixed> $sorted_menu_items, object $args) : array<string|int, mixed>
Parameters
- $sorted_menu_items : array<string|int, mixed>
-
The menu items, sorted by each menu item’s menu order.
- $args : object
-
An object containing the wp_nav_menu() arguments.
Tags
Return values
array<string|int, mixed> —The (maybe) modified menu items.
filter_nutrition_label()
Filter the attributes of the nutrition label.
filter_nutrition_label(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_private_notes()
Filter the attributes of the private notes.
filter_private_notes(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_cook_mode()
Filter the attributes of the cook mode toggle.
filter_recipe_cook_mode(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_download_pdf()
Filter the attributes of the download PDF button.
filter_recipe_download_pdf(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_equipment()
Filter the attributes of the recipe equipment display.
filter_recipe_equipment(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
- The header and group tags that specify heading level MUST be set in HTML template. This allows different heading levels between print and display use cases.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_image()
Filter the attributes of the recipe image display.
filter_recipe_image(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
- The image size MUST be declared in the HTML template.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_ingredients()
Filter the attributes of the recipe ingredients display.
filter_recipe_ingredients(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
- The header and group tags that specify heading level MUST be set in HTML template. This allows different heading levels between print and display use cases.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_instructions()
Filter the attributes of the recipe instructions display.
filter_recipe_instructions(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
- The header and group tags that specify heading level MUST be set in HTML template. This allows different heading levels between print and display use cases.
- The associated ingredients setting MUST be set in the HTML template. Set 'ingredients_position' to 'none | after' to allow the template to determine the display of the associated ingredients list.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_jump_to_comments()
Filter the attributes of the jump to comments button.
filter_recipe_jump_to_comments(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_jump()
Filter the attributes of the jump to recipe button.
filter_recipe_jump(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_media_toggle()
Filter the attributes of the recipe media toggle.
filter_recipe_media_toggle(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_meta_container()
Filter the attributes of the recipe metadata container.
filter_recipe_meta_container(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_name()
Filter the attributes of the recipe name display.
filter_recipe_name(array<string|int, string> $attributes) : array<string|int, string>
Replaces the inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_notes()
Filter the attributes of the recipe notes.
filter_recipe_notes(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_nutrition()
Filter the attributes of a single recipe nutrition field.
filter_recipe_nutrition(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_print()
Filter the attributes of the recipe print button.
filter_recipe_print(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_rating()
Filter the attributes of the recipe rating display.
filter_recipe_rating(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_servings()
Filter the attributes of the recipe ajustable servings.
filter_recipe_servings(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_summary()
Filter the attributes of the recipe summary.
filter_recipe_summary(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_tag()
Filter the attributes of the recipe tag container.
filter_recipe_tag(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_time()
Filter the attributes of the recipe individual time container.
filter_recipe_time(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_recipe_unit_conversion()
Filter the attributes of the unit conversion control.
filter_recipe_unit_conversion(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
filter_icon_sources()
Filter the SVG icon sources.
filter_icon_sources(array<string|int, mixed> $sources) : array<string|int, mixed>
- Add the pNet svg icon assets to default list.
Parameters
- $sources : array<string|int, mixed>
-
The default sources.
Tags
Return values
array<string|int, mixed> —The modified sources.
filter_print_assets()
Filter the assets used for printing.
filter_print_assets(array<string|int, mixed> $output, array<string|int, mixed> $print_args) : array<string|int, mixed>
Parameters
- $output : array<string|int, mixed>
-
The print output arguments.
- $print_args : array<string|int, mixed>
-
The print arguments.
Tags
Return values
array<string|int, mixed> —The modified output arguments.
filter_public_script()
Filter the public js variables.
filter_public_script(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
The default variables.
Tags
Return values
array<string|int, mixed> —The modified variables.
set_button_attributes()
Set the attributes of the template buttons.
set_button_attributes(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
set_label_attributes()
Set the attributes of the meta labels.
set_label_attributes(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
set_toggle_attributes()
Set the attributes of the toggle switches.
set_toggle_attributes(array<string|int, string> $attributes) : array<string|int, string>
- Replaces inline style attributes to allow site styles.
Parameters
- $attributes : array<string|int, string>
-
The shortcode attributes.
Tags
Return values
array<string|int, string> —The modified attributes.
add_rankmath_hooks()
Add the rankmath hooks.
add_rankmath_hooks() : void
- This approach is recommended by RankMath.
Tags
modify_breadcrumb_html()
Modify the breadcrumb HTML.
modify_breadcrumb_html(string $html, array<string|int, mixed> $crumbs, object $breadcrumbs) : string
- Remove the whitespace from the separator breadcrumb item.
Parameters
- $html : string
-
The breadcrumb HTML.
- $crumbs : array<string|int, mixed>
-
The breadcrumb items.
- $breadcrumbs : object
-
The breadcrumbs object.
Tags
Return values
string —The modified breadcrumb HTML content.
modify_toc_content()
Modify the TOC HTML.
modify_toc_content(string $block_content, array<string|int, mixed> $block, WP_Block $instance) : string
- Add smooth-scroll class to list items.
Parameters
- $block_content : string
-
The block content.
- $block : array<string|int, mixed>
-
The full block, including name and attributes.
- $instance : WP_Block
-
The instance of the rank-math/toc-block.
Tags
Return values
string —The modified TOC block HTML content.