Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefixes all php filters with wpdocs_ #53914

Merged
merged 1 commit into from Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/reference-guides/filters/block-filters.md
Expand Up @@ -19,11 +19,11 @@ _Example_:
```php
<?php

function filter_metadata_registration( $metadata ) {
function wpdocs_filter_metadata_registration( $metadata ) {
$metadata['apiVersion'] = 1;
return $metadata;
};
add_filter( 'block_type_metadata', 'filter_metadata_registration' );
add_filter( 'block_type_metadata', 'wpdocs_filter_metadata_registration' );

register_block_type( __DIR__ );
```
Expand All @@ -40,11 +40,11 @@ The filter takes two params:
_Example:_

```php
function filter_metadata_registration( $settings, $metadata ) {
function wpdocs_filter_metadata_registration( $settings, $metadata ) {
$settings['api_version'] = $metadata['apiVersion'] + 1;
return $settings;
};
add_filter( 'block_type_metadata_settings', 'filter_metadata_registration', 10, 2 );
add_filter( 'block_type_metadata_settings', 'wpdocs_filter_metadata_registration', 10, 2 );

register_block_type( __DIR__ );
```
Expand Down Expand Up @@ -352,14 +352,14 @@ On the server, you can filter the list of blocks shown in the inserter using the
<?php
// my-plugin.php

function filter_allowed_block_types_when_post_provided( $allowed_block_types, $editor_context ) {
function wpdocs_filter_allowed_block_types_when_post_provided( $allowed_block_types, $editor_context ) {
if ( ! empty( $editor_context->post ) ) {
return array( 'core/paragraph', 'core/heading' );
}
return $allowed_block_types;
}

add_filter( 'allowed_block_types_all', 'filter_allowed_block_types_when_post_provided', 10, 2 );
add_filter( 'allowed_block_types_all', 'wpdocs_filter_allowed_block_types_when_post_provided', 10, 2 );
```

## Managing block categories
Expand All @@ -374,7 +374,7 @@ It is possible to filter the list of default block categories using the `block_c
<?php
// my-plugin.php

function filter_block_categories_when_post_provided( $block_categories, $editor_context ) {
function wpdocs_filter_block_categories_when_post_provided( $block_categories, $editor_context ) {
if ( ! empty( $editor_context->post ) ) {
array_push(
$block_categories,
Expand All @@ -388,7 +388,7 @@ function filter_block_categories_when_post_provided( $block_categories, $editor_
return $block_categories;
}

add_filter( 'block_categories_all', 'filter_block_categories_when_post_provided', 10, 2 );
add_filter( 'block_categories_all', 'wpdocs_filter_block_categories_when_post_provided', 10, 2 );
```

### `wp.blocks.updateCategory`
Expand Down
8 changes: 4 additions & 4 deletions docs/reference-guides/filters/editor-filters.md
Expand Up @@ -84,14 +84,14 @@ _Example:_
<?php
// my-plugin.php

function filter_block_editor_settings_when_post_provided( $editor_settings, $editor_context ) {
function wpdocs_filter_block_editor_settings_when_post_provided( $editor_settings, $editor_context ) {
if ( ! empty( $editor_context->post ) ) {
$editor_settings['maxUploadFileSize'] = 12345;
}
return $editor_settings;
}

add_filter( 'block_editor_settings_all', 'filter_block_editor_settings_when_post_provided', 10, 2 );
add_filter( 'block_editor_settings_all', 'wpdocs_filter_block_editor_settings_when_post_provided', 10, 2 );
```

#### `block_editor_rest_api_preload_paths`
Expand All @@ -104,14 +104,14 @@ _Example:_
<?php
// my-plugin.php

function filter_block_editor_rest_api_preload_paths_when_post_provided( $preload_paths, $editor_context ) {
function wpdocs_filter_block_editor_rest_api_preload_paths_when_post_provided( $preload_paths, $editor_context ) {
if ( ! empty( $editor_context->post ) ) {
array_push( $preload_paths, array( '/wp/v2/blocks', 'OPTIONS' ) );
}
return $preload_paths;
}

add_filter( 'block_editor_rest_api_preload_paths', 'filter_block_editor_rest_api_preload_paths_when_post_provided', 10, 2 );
add_filter( 'block_editor_rest_api_preload_paths', 'wpdocs_filter_block_editor_rest_api_preload_paths_when_post_provided', 10, 2 );
```

### Available default editor settings
Expand Down
4 changes: 2 additions & 2 deletions docs/reference-guides/filters/global-styles-filters.md
Expand Up @@ -14,7 +14,7 @@ _Example:_
This is how to pass a new color palette for the theme and disable the text color UI:

```php
function filter_theme_json_theme( $theme_json ){
function wpdocs_filter_theme_json_theme( $theme_json ){
$new_data = array(
'version' => 2,
'settings' => array(
Expand All @@ -38,5 +38,5 @@ function filter_theme_json_theme( $theme_json ){

return $theme_json->update_with( $new_data );
}
add_filter( 'wp_theme_json_data_theme', 'filter_theme_json_theme' );
add_filter( 'wp_theme_json_data_theme', 'wpdocs_filter_theme_json_theme' );
```
4 changes: 2 additions & 2 deletions docs/reference-guides/filters/parser-filters.md
Expand Up @@ -26,11 +26,11 @@ class EmptyParser {
}
}

function my_plugin_select_empty_parser( $prev_parser_class ) {
function wpdocs_select_empty_parser( $prev_parser_class ) {
return 'EmptyParser';
}

add_filter( 'block_parser_class', 'my_plugin_select_empty_parser', 10, 1 );
add_filter( 'block_parser_class', 'wpdocs_select_empty_parser', 10, 1 );
```

> **Note**: At the present time it's not possible to replace the client-side parser.