Custom Classes
Editor

Block Editor Settings

Conform Gutenberg to Larva and PMC plugins.

modify_post_type_args

Modify post type args.

  • $args: array — Array of arguments for registering a post type.
  • $post_type: string — Post type key.

enable_post_type_feature

Enables custom fields for Gutenberg-enabled post types.

  • $args: array — Array of arguments for registering a post type.

add_post_type_template

Adds template to post type registration.

  • $args: array — Array of arguments for registering a post type.
  • $post_type: string — Post type key.

Filters

pmc_gutenberg_default_template

Set default template for all post types by default.

  • $template: array — template array.
  • $post_type: string — post type slug.

hide_color_picker

Prevent selection of colors not sourced from Larva tokens (those set in the add_colors_from_tokens() method of this class). The disable-custom-colors theme-supports flag disables all color overrides, including the color palette we register.

set_available_jetpack_extensions

Filter jetpack extensions.

  • $extensions: array — jetpack extensions array.

Gutenberg Helpers

Helper functions for generating content. in and outside the editor.

should_disable_admin_bar

Whether or not the admin bar should be disabled.

enable_admin_bar_query_param

Disable admin bar by query param.

  • $show_admin_bar: bool — Whether the admin var should be shown.

update_body_class

Update body class.

  • $classnames: array — array of body classes.

localize_gutenberg_config

Localize a script by key for a value.

supports_exclude_from_homepage

Localize script for if we support the pmc-exclude-posts-from-river plugin.

  • $config: array — config script for gutenberg.

Filters

pmc_supports_exclude_from_homepage

Filter to enable or disable supports_exclude_from_homepage_feature.

  • $has_exclude_plugin: bool — PMC_Exclude_Posts_From_River class exists.

get_child_attributes

Get child attributes for a parent block.

  • $block: WP_Block — block instance.
  • $name: string — block name we're looking for data for.
  • $return_all: bool — whether or not to return all attributes in an array.

replace_array_keys

Replace array's key.

  • $array: array — Array.
  • $keys: array — Array of key value pair to replace key.

set_visibility_defaults

Set visibility defaults.

  • $defaults: array — array defaults.
  • $avail: array — available values.

is_block_supported

Determine if a block is supported according to the config. NOTE: This could replace or could be extended to replace the the Gutenberg::get_instance()-\>get_by_key method potentially.

  • $config: array — Brand configuration array.
  • $block_name: string — The block name being registered.

register_block_type

Registers a block type. The recommended way is to register a block type using the metadata stored in the block.json file.

  • $args: array — Optional. Array of block type arguments.

block_class_from_string

Take a string with a block name, return the class name.

  • $string: string — string to generate classname from.

Gutenberg

Initialize core & custom Gutenberg blocks.

enable_block_editor

Enable the Block editor for the given post types.

Filters

pmc_gutenberg_enable_block_editor

Filter for overriding editor config data which comes from brand JSON.

  • $editor_config: array — Brand config array.

enqueue_block_editor_scripts

Enqueueing all block and service scripts.

filter_allowed_block_types

A wrapper method that returns our allowlist for the filter.

  • $allowed_blocks: array|bool — An array of block slugs or a boolean to allow or disallow all.
  • $block_editor_context: WP_Block_Editor_Context — The current block editor context.

maybe_enable_block_editor

Filters whether a post is able to be edited in the block editor.

  • $use_block_editor: boolean — Whether the post type can be edited or not. Default true.
  • $post_type: string — The post type being checked.

wp_layout_support

Conditionally remove wp_render_layout_support_flag as this is problematic for some blocks and removes some much-needed core goodies.

  • $core_default: string|null — The pre-rendered content. Default is null.
  • $parsed_block: array — The block being rendered.

defer_parsing_of_js

Defer loading block scripts.

  • $tag: string — full script tag.
  • $handle: string — script handle.
  • $src: string — src url.

get_core_blocks

Get all core blocks.

  • $with_core_prefix: boolean — Determine wheather core/ prefix added or not.

get_config_data

Get formatted config data.

  • $post_type: string — Post type.

filter_block_categories

Add new block category.

  • $block_categories: array — Array of registered block categories.