Skip to content

Commit cf3dbbc

Browse files
authored
Docs: prefixes all php filters with wpdocs_ (#53914)
1 parent d1d1921 commit cf3dbbc

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

docs/reference-guides/filters/block-filters.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ _Example_:
1919
```php
2020
<?php
2121

22-
function filter_metadata_registration( $metadata ) {
22+
function wpdocs_filter_metadata_registration( $metadata ) {
2323
$metadata['apiVersion'] = 1;
2424
return $metadata;
2525
};
26-
add_filter( 'block_type_metadata', 'filter_metadata_registration' );
26+
add_filter( 'block_type_metadata', 'wpdocs_filter_metadata_registration' );
2727

2828
register_block_type( __DIR__ );
2929
```
@@ -40,11 +40,11 @@ The filter takes two params:
4040
_Example:_
4141

4242
```php
43-
function filter_metadata_registration( $settings, $metadata ) {
43+
function wpdocs_filter_metadata_registration( $settings, $metadata ) {
4444
$settings['api_version'] = $metadata['apiVersion'] + 1;
4545
return $settings;
4646
};
47-
add_filter( 'block_type_metadata_settings', 'filter_metadata_registration', 10, 2 );
47+
add_filter( 'block_type_metadata_settings', 'wpdocs_filter_metadata_registration', 10, 2 );
4848

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

355-
function filter_allowed_block_types_when_post_provided( $allowed_block_types, $editor_context ) {
355+
function wpdocs_filter_allowed_block_types_when_post_provided( $allowed_block_types, $editor_context ) {
356356
if ( ! empty( $editor_context->post ) ) {
357357
return array( 'core/paragraph', 'core/heading' );
358358
}
359359
return $allowed_block_types;
360360
}
361361

362-
add_filter( 'allowed_block_types_all', 'filter_allowed_block_types_when_post_provided', 10, 2 );
362+
add_filter( 'allowed_block_types_all', 'wpdocs_filter_allowed_block_types_when_post_provided', 10, 2 );
363363
```
364364

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

377-
function filter_block_categories_when_post_provided( $block_categories, $editor_context ) {
377+
function wpdocs_filter_block_categories_when_post_provided( $block_categories, $editor_context ) {
378378
if ( ! empty( $editor_context->post ) ) {
379379
array_push(
380380
$block_categories,
@@ -388,7 +388,7 @@ function filter_block_categories_when_post_provided( $block_categories, $editor_
388388
return $block_categories;
389389
}
390390

391-
add_filter( 'block_categories_all', 'filter_block_categories_when_post_provided', 10, 2 );
391+
add_filter( 'block_categories_all', 'wpdocs_filter_block_categories_when_post_provided', 10, 2 );
392392
```
393393

394394
### `wp.blocks.updateCategory`

docs/reference-guides/filters/editor-filters.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ _Example:_
8484
<?php
8585
// my-plugin.php
8686

87-
function filter_block_editor_settings_when_post_provided( $editor_settings, $editor_context ) {
87+
function wpdocs_filter_block_editor_settings_when_post_provided( $editor_settings, $editor_context ) {
8888
if ( ! empty( $editor_context->post ) ) {
8989
$editor_settings['maxUploadFileSize'] = 12345;
9090
}
9191
return $editor_settings;
9292
}
9393

94-
add_filter( 'block_editor_settings_all', 'filter_block_editor_settings_when_post_provided', 10, 2 );
94+
add_filter( 'block_editor_settings_all', 'wpdocs_filter_block_editor_settings_when_post_provided', 10, 2 );
9595
```
9696

9797
#### `block_editor_rest_api_preload_paths`
@@ -104,14 +104,14 @@ _Example:_
104104
<?php
105105
// my-plugin.php
106106

107-
function filter_block_editor_rest_api_preload_paths_when_post_provided( $preload_paths, $editor_context ) {
107+
function wpdocs_filter_block_editor_rest_api_preload_paths_when_post_provided( $preload_paths, $editor_context ) {
108108
if ( ! empty( $editor_context->post ) ) {
109109
array_push( $preload_paths, array( '/wp/v2/blocks', 'OPTIONS' ) );
110110
}
111111
return $preload_paths;
112112
}
113113

114-
add_filter( 'block_editor_rest_api_preload_paths', 'filter_block_editor_rest_api_preload_paths_when_post_provided', 10, 2 );
114+
add_filter( 'block_editor_rest_api_preload_paths', 'wpdocs_filter_block_editor_rest_api_preload_paths_when_post_provided', 10, 2 );
115115
```
116116

117117
### Available default editor settings

docs/reference-guides/filters/global-styles-filters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _Example:_
1414
This is how to pass a new color palette for the theme and disable the text color UI:
1515

1616
```php
17-
function filter_theme_json_theme( $theme_json ){
17+
function wpdocs_filter_theme_json_theme( $theme_json ){
1818
$new_data = array(
1919
'version' => 2,
2020
'settings' => array(
@@ -38,5 +38,5 @@ function filter_theme_json_theme( $theme_json ){
3838

3939
return $theme_json->update_with( $new_data );
4040
}
41-
add_filter( 'wp_theme_json_data_theme', 'filter_theme_json_theme' );
41+
add_filter( 'wp_theme_json_data_theme', 'wpdocs_filter_theme_json_theme' );
4242
```

docs/reference-guides/filters/parser-filters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class EmptyParser {
2626
}
2727
}
2828

29-
function my_plugin_select_empty_parser( $prev_parser_class ) {
29+
function wpdocs_select_empty_parser( $prev_parser_class ) {
3030
return 'EmptyParser';
3131
}
3232

33-
add_filter( 'block_parser_class', 'my_plugin_select_empty_parser', 10, 1 );
33+
add_filter( 'block_parser_class', 'wpdocs_select_empty_parser', 10, 1 );
3434
```
3535

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

0 commit comments

Comments
 (0)