wp_font_dir()wp-includes/fonts.php | Returns an array containing the current fonts upload directory’s path and URL.
|
WP_Block_Bindings_Registry::register()wp-includes/class-wp-block-bindings-registry.php | Registers a new block bindings source.
|
WP_REST_Font_Faces_Controller::handle_font_file_upload()wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php | Handles the upload of a font file using wp_handle_upload() .
|
_wp_footnotes_kses_init_filters()wp-includes/blocks.php | Adds the filters for footnotes meta field.
|
wp_initialize_theme_preview_hooks()wp-includes/theme-previews.php | Add filters and actions to enable Block Theme Previews in the Site Editor.
|
_wp_get_iframed_editor_assets()wp-includes/block-editor.php | Collect the block editor assets that need to be loaded into the editor’s iframe.
|
WP_REST_Menu_Items_Controller::prepare_item_for_response()wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php | Prepares a single post output for response.
|
WP_REST_Global_Styles_Controller::prepare_item_for_response()wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php | Prepare a global styles config output for response.
|
_add_default_theme_supports()wp-includes/theme.php | Adds default theme supports for block themes when the ‘after_setup_theme’ action fires.
|
wp_enqueue_block_style()wp-includes/script-loader.php | Enqueues a stylesheet for a specific block.
|
WP_Widget_Block::__construct()wp-includes/widgets/class-wp-widget-block.php | Sets up a new Block widget instance.
|
wp_enqueue_global_styles()wp-includes/script-loader.php | Enqueues the global styles defined via theme.json.
|
WP_Sitemaps_Renderer::check_for_simple_xml_availability()wp-includes/sitemaps/class-wp-sitemaps-renderer.php | Checks for the availability of the SimpleXML extension and errors if missing.
|
WP_Sitemaps::init()wp-includes/sitemaps/class-wp-sitemaps.php | Initiates all sitemap functionality.
|
wp_pre_kses_block_attributes()wp-includes/formatting.php | Removes non-allowable HTML from parsed block attribute values when filtering in the post context.
|
enqueue_block_styles_assets()wp-includes/script-loader.php | Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.
|
WP_Site_Health::__construct()wp-admin/includes/class-wp-site-health.php | WP_Site_Health constructor.
|
wp_init_targeted_link_rel_filters()wp-includes/formatting.php | Adds all filters modifying the rel attribute of targeted links.
|
wp_get_active_and_valid_themes()wp-includes/load.php | Retrieves an array of active and valid themes.
|
update_sitemeta_cache()wp-includes/ms-site.php | Updates metadata cache for list of site IDs.
|
WP_REST_Post_Search_Handler::prepare_item()wp-includes/rest-api/search/class-wp-rest-post-search-handler.php | Prepares the search result for a given post ID.
|
do_blocks()wp-includes/blocks.php | Parses dynamic blocks out of post_content and re-renders them.
|
_restore_wpautop_hook()wp-includes/blocks.php | If do_blocks() needs to remove wpautop() from the the_content filter, this re-adds it afterwards, for subsequent the_content usage.
|
wpdb::placeholder_escape()wp-includes/class-wpdb.php | Generates and returns a placeholder escape string for use in queries returned by ::prepare().
|
WP_Widget_Custom_HTML::widget()wp-includes/widgets/class-wp-widget-custom-html.php | Outputs the content for the current Custom HTML widget instance.
|
WP_Widget_Media::_register_one()wp-includes/widgets/class-wp-widget-media.php | Add hooks while registering all widget instances of this widget class.
|
WP_Widget_Media_Video::render_media()wp-includes/widgets/class-wp-widget-media-video.php | Render the media on the frontend.
|
WP_Customize_Manager::save_changeset_post()wp-includes/class-wp-customize-manager.php | Saves the post for the loaded changeset.
|
WP_REST_Attachments_Controller::prepare_items_query()wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php | Determines the allowed query_vars for a get_items() response and prepares for WP_Query.
|
WP_REST_Posts_Controller::prepare_item_for_response()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Prepares a single post output for response.
|
WP_REST_Posts_Controller::get_item_permissions_check()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Checks if a given request has access to read a post.
|
WP_REST_Posts_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves a collection of posts.
|
WP_REST_Comments_Controller::check_read_post_permission()wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Checks if the post can be read.
|
WP_Locale_Switcher::init()wp-includes/class-wp-locale-switcher.php | Initializes the locale switcher.
|
WP_Taxonomy::add_hooks()wp-includes/class-wp-taxonomy.php | Registers the ajax callback for the meta box.
|
WP_Customize_Nav_Menus::insert_auto_draft_post()wp-includes/class-wp-customize-nav-menus.php | Adds a new auto-draft post.
|
WP_Customize_Custom_CSS_Setting::preview()wp-includes/customize/class-wp-customize-custom-css-setting.php | Add filter to preview post value.
|
WP_Metadata_Lazyloader::queue_objects()wp-includes/class-wp-metadata-lazyloader.php | Adds objects to the metadata lazy-load queue.
|
WP_Customize_Widgets::render_widget_partial()wp-includes/class-wp-customize-widgets.php | Renders a specific widget using the supplied sidebar arguments.
|
WP_Customize_Widgets::selective_refresh_init()wp-includes/class-wp-customize-widgets.php | Adds hooks for selective refresh.
|
rest_cookie_check_errors()wp-includes/rest-api.php | Checks for errors when using cookie-based authentication.
|
rest_api_default_filters()wp-includes/rest-api.php | Registers the default REST API filters.
|
wp_handle_comment_submission()wp-includes/comment.php | Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form.
|
WP_Screen::render_view_mode()wp-admin/includes/class-wp-screen.php | Renders the list table view mode preferences.
|
WP_Customize_Nav_Menu_Setting::update()wp-includes/customize/class-wp-customize-nav-menu-setting.php | Create/update the nav_menu term for this setting.
|
WP_Customize_Nav_Menu_Setting::preview()wp-includes/customize/class-wp-customize-nav-menu-setting.php | Handle previewing the setting.
|
WP_Customize_Nav_Menu_Item_Setting::update()wp-includes/customize/class-wp-customize-nav-menu-item-setting.php | Creates/updates the nav_menu_item post for this setting.
|
WP_Customize_Nav_Menu_Item_Setting::preview()wp-includes/customize/class-wp-customize-nav-menu-item-setting.php | Handle previewing the setting.
|
WP_Customize_Nav_Menus_Panel::render_screen_options()wp-includes/customize/class-wp-customize-nav-menus-panel.php | Render screen options for Menus.
|
WP_Customize_Nav_Menus::customize_preview_init()wp-includes/class-wp-customize-nav-menus.php | Adds hooks for the Customizer preview.
|
WP_Customize_Nav_Menus::customize_register()wp-includes/class-wp-customize-nav-menus.php | Adds the customizer settings and controls.
|
WP_Customize_Nav_Menus::__construct()wp-includes/class-wp-customize-nav-menus.php | Constructor.
|
WP_Site_Icon::get_post_metadata()wp-admin/includes/class-wp-site-icon.php | Adds custom image sizes when meta data for an image is requested, that happens to be used as Site Icon.
|
WP_Site_Icon::__construct()wp-admin/includes/class-wp-site-icon.php | Registers actions and filters.
|
wp_ajax_crop_image()wp-admin/includes/ajax-actions.php | Handles cropping an image via AJAX.
|
wp_edit_attachments_query_vars()wp-admin/includes/post.php | Returns the query variables for the current attachments request.
|
_WP_List_Table_Compat::__construct()wp-admin/includes/class-wp-list-table-compat.php | Constructor.
|
login_header()wp-login.php | Outputs the login page header.
|
WP_Automatic_Updater::update()wp-admin/includes/class-wp-automatic-updater.php | Updates an item, if appropriate.
|
Language_Pack_Upgrader::bulk_upgrade()wp-admin/includes/class-language-pack-upgrader.php | Upgrades several language packs at once.
|
Plugin_Upgrader::bulk_upgrade()wp-admin/includes/class-plugin-upgrader.php | Upgrades several plugins at once.
|
Theme_Upgrader::check_parent_theme_filter()wp-admin/includes/class-theme-upgrader.php | Checks if a child theme is being installed and its parent also needs to be installed.
|
Theme_Upgrader::install()wp-admin/includes/class-theme-upgrader.php | Install a theme package.
|
Theme_Upgrader::upgrade()wp-admin/includes/class-theme-upgrader.php | Upgrades a theme.
|
Theme_Upgrader::bulk_upgrade()wp-admin/includes/class-theme-upgrader.php | Upgrades several themes at once.
|
Plugin_Upgrader::install()wp-admin/includes/class-plugin-upgrader.php | Install a plugin package.
|
Plugin_Upgrader::upgrade()wp-admin/includes/class-plugin-upgrader.php | Upgrades a plugin.
|
WP_Screen::render_per_page_options()wp-admin/includes/class-wp-screen.php | Renders the items per page option.
|
wp_update_core()wp-admin/includes/deprecated.php | This was once used to kick-off the Core Updater.
|
wp_update_plugin()wp-admin/includes/deprecated.php | This was once used to kick-off the Plugin Updater.
|
wp_update_theme()wp-admin/includes/deprecated.php | This was once used to kick-off the Theme Updater.
|
WP_List_Table::__construct()wp-admin/includes/class-wp-list-table.php | Constructor.
|
wp_dashboard_setup()wp-admin/includes/dashboard.php | Registers dashboard widgets.
|
register_setting()wp-includes/option.php | Registers a setting and its data.
|
media_upload_type_form()wp-admin/includes/media.php | Outputs the legacy media upload form for a given media type.
|
media_upload_gallery_form()wp-admin/includes/media.php | Adds gallery form to upload iframe.
|
media_upload_library_form()wp-admin/includes/media.php | Outputs the legacy media upload form for the media library.
|
wp_ajax_query_attachments()wp-admin/includes/ajax-actions.php | Handles querying attachments via AJAX.
|
wp_ajax_replyto_comment()wp-admin/includes/ajax-actions.php | Handles replying to a comment via AJAX.
|
wp_link_manager_disabled_message()wp-admin/includes/bookmark.php | Outputs the ‘disabled’ message for the WordPress Link Manager.
|
WP_Media_List_Table::display_rows()wp-admin/includes/class-wp-media-list-table.php | |
WP_Importer::get_page()wp-admin/includes/class-wp-importer.php | Gets URL.
|
WP_Comments_List_Table::__construct()wp-admin/includes/class-wp-comments-list-table.php | Constructor.
|
wp_nav_menu_setup()wp-admin/includes/nav-menu.php | Register nav menu meta boxes and advanced menu items.
|
wp_list_widget_controls()wp-admin/includes/widgets.php | Show the widgets and their settings for a sidebar.
|
WP_Posts_List_Table::display_rows()wp-admin/includes/class-wp-posts-list-table.php | |
do_core_upgrade()wp-admin/update-core.php | Upgrades WordPress core display.
|
WP_Customize_Manager::customize_preview_init()wp-includes/class-wp-customize-manager.php | Prints JavaScript settings.
|
WP_Customize_Manager::start_previewing_theme()wp-includes/class-wp-customize-manager.php | If the theme to be previewed isn’t the active theme, add filter callbacks to swap it out at runtime.
|
WP_Customize_Manager::__construct()wp-includes/class-wp-customize-manager.php | Constructor.
|
wp_trim_excerpt()wp-includes/formatting.php | Generates an excerpt from the content, if needed.
|
kses_init_filters()wp-includes/kses.php | Adds all KSES input form content filters.
|
_default_wp_die_handler()wp-includes/functions.php | Kills WordPress execution and displays HTML page with an error message.
|
WP_Widget_Text::widget()wp-includes/widgets/class-wp-widget-text.php | Outputs the content for the current Text widget instance.
|
WP_Widget_Text::form()wp-includes/widgets/class-wp-widget-text.php | Outputs the Text widget settings form.
|
WP_Embed::__construct()wp-includes/class-wp-embed.php | Constructor
|
do_shortcode()wp-includes/shortcodes.php | Searches content for shortcodes and filter shortcodes through their hooks.
|
WP_oEmbed::__construct()wp-includes/class-wp-oembed.php | Constructor.
|
add_action()wp-includes/plugin.php | Adds a callback function to an action hook.
|
WP_Customize_Setting::__construct()wp-includes/class-wp-customize-setting.php | Constructor.
|
WP_Customize_Setting::preview()wp-includes/class-wp-customize-setting.php | Add filters to supply the setting’s value when accessed.
|
wp_signon()wp-includes/user.php | Authenticates and logs a user in with ‘remember’ capability.
|
_set_preview()wp-includes/revision.php | Sets up the post object for preview based on the post autosave.
|
_show_post_preview()wp-includes/revision.php | Filters the latest content for preview from the post autosave.
|
ms_upload_constants()wp-includes/ms-default-constants.php | Defines Multisite upload constants.
|
Walker_Comment::start_el()wp-includes/class-walker-comment.php | Starts the element output.
|
WP_Customize_Widgets::start_capturing_option_updates()wp-includes/class-wp-customize-widgets.php | Begins keeping track of changes to widget options, caching new values.
|
WP_Customize_Widgets::capture_filter_pre_update_option()wp-includes/class-wp-customize-widgets.php | Pre-filters captured option values before updating.
|
WP_Customize_Widgets::__construct()wp-includes/class-wp-customize-widgets.php | Initial loader.
|
WP_Customize_Widgets::override_sidebars_widgets_for_theme_switch()wp-includes/class-wp-customize-widgets.php | Override sidebars_widgets for theme switch.
|
WP_Customize_Widgets::customize_register()wp-includes/class-wp-customize-widgets.php | Registers Customizer settings and controls for all sidebars and widgets.
|
wp_update_comment()wp-includes/comment.php | Updates an existing comment in the database.
|
check_comment_flood_db()wp-includes/comment.php | Hooks WP’s native database-based comment-flood check.
|
register_meta()wp-includes/meta.php | Registers a meta key.
|
_WP_Editors::editor()wp-includes/class-wp-editor.php | Outputs the HTML for a single instance of the editor.
|
Example: Let’s add extra sections to TwentySeventeen Front page.
By default, TwentySeventeen theme has 4 sections for the front page. This example will make them 6
To pass a variable to the called function of the filter, you can use closures (since PHP 5.3+) when the argument is not available in the original coded apply_filters. For example:
Example: Let display custom length of post excerpt.
By default, WordPress display 57 character. you can set custom length using above code. this time except length will be 40. it is a nice and easiest use of add_filter.
Example: If you want to inject a CLASS/ID CSS in content. Let’s add extra CLASS/ID to post content.
In the special case you have to add a filter before WordPress starts, you can create and pre-populate the global
$wp_filter
array instead of using the not-yet availableadd_filter
(oradd_action
) function:WP_Hook::build_preinitialized_hooks
will automatically take care of the rest.Though to remove your filter, you can only use the remove_all_filters() function.
The Callback
$function_to_add
need not be defined until the Filter hook fires. This means that:add_filter
function does not check that$function_to_add
existsfunction
statement for$function_to_add
can be defined after theadd_filter
statement, even in a conditional (e.g. –if
block) where the$function_to_add
function does not actually exist until after theadd_filter
function executesPoint 3 needs to be considered during Testing or Quality Control
An undefined $function_to_add function detected when a Filter hook fires is reported as a Warning error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'reg_public1' not found or invalid function name in /var/www/example.com/public_html/wp-includes/class-wp-hook.php on line 288
If you output something inside the callback, the output location is unpredictable.
Cause: the returned value is actually used somewhere else (more likely a bit far from where the function would be called). Therefore the output will go where the function was called while the return value is used somewhere else. I’m not sure when you would use this though :).
Example
The filter
img_caption_shortcode
is applied inmedia.php
using the following call:The target filter function will be called with three arguments:
” <= This is normally the value the filter will be modifying
$attr
$content
In order for the filter function to actually receive the full argument list, the call to
add_filter()
must be modified to specify there are 3 arguments on the parameter list.