Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r47018 r47122  
    1313 */
    1414
    15 // Strip, trim, kses, special chars for string saves
     15// Strip, trim, kses, special chars for string saves.
    1616foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) {
    1717    add_filter( $filter, 'sanitize_text_field' );
     
    2020}
    2121
    22 // Strip, kses, special chars for string display
     22// Strip, kses, special chars for string display.
    2323foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) {
    2424    if ( is_admin() ) {
     
    3030}
    3131
    32 // Kses only for textarea saves
     32// Kses only for textarea saves.
    3333foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
    3434    add_filter( $filter, 'wp_filter_kses' );
    3535}
    3636
    37 // Kses only for textarea admin displays
     37// Kses only for textarea admin displays.
    3838if ( is_admin() ) {
    3939    foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) {
     
    4343}
    4444
    45 // Email saves
     45// Email saves.
    4646foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) {
    4747    add_filter( $filter, 'trim' );
     
    5050}
    5151
    52 // Email admin display
     52// Email admin display.
    5353foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) {
    5454    add_filter( $filter, 'sanitize_email' );
     
    5858}
    5959
    60 // Save URL
     60// Save URL.
    6161foreach ( array(
    6262    'pre_comment_author_url',
     
    7272}
    7373
    74 // Display URL
     74// Display URL.
    7575foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid' ) as $filter ) {
    7676    if ( is_admin() ) {
     
    8383}
    8484
    85 // Slugs
     85// Slugs.
    8686add_filter( 'pre_term_slug', 'sanitize_title' );
    8787add_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data', 10, 2 );
    8888
    89 // Keys
     89// Keys.
    9090foreach ( array( 'pre_post_type', 'pre_post_status', 'pre_post_comment_status', 'pre_post_ping_status' ) as $filter ) {
    9191    add_filter( $filter, 'sanitize_key' );
    9292}
    9393
    94 // Mime types
     94// Mime types.
    9595add_filter( 'pre_post_mime_type', 'sanitize_mime_type' );
    9696add_filter( 'post_mime_type', 'sanitize_mime_type' );
    9797
    98 // Meta
     98// Meta.
    9999add_filter( 'register_meta_args', '_wp_register_meta_args_whitelist', 10, 2 );
    100100
    101 // Post meta
     101// Post meta.
    102102add_action( 'added_post_meta', 'wp_cache_set_posts_last_changed' );
    103103add_action( 'updated_post_meta', 'wp_cache_set_posts_last_changed' );
    104104add_action( 'deleted_post_meta', 'wp_cache_set_posts_last_changed' );
    105105
    106 // Term meta
     106// Term meta.
    107107add_action( 'added_term_meta', 'wp_cache_set_terms_last_changed' );
    108108add_action( 'updated_term_meta', 'wp_cache_set_terms_last_changed' );
     
    117117add_filter( 'update_term_metadata_cache', 'wp_check_term_meta_support_prefilter' );
    118118
    119 // Comment meta
     119// Comment meta.
    120120add_action( 'added_comment_meta', 'wp_cache_set_comments_last_changed' );
    121121add_action( 'updated_comment_meta', 'wp_cache_set_comments_last_changed' );
    122122add_action( 'deleted_comment_meta', 'wp_cache_set_comments_last_changed' );
    123123
    124 // Places to balance tags on input
     124// Places to balance tags on input.
    125125foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) {
    126126    add_filter( $filter, 'convert_invalid_entities' );
     
    138138}
    139139
    140 // Format WordPress
     140// Format WordPress.
    141141foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter ) {
    142142    add_filter( $filter, 'capital_P_dangit', 11 );
     
    144144add_filter( 'comment_text', 'capital_P_dangit', 31 );
    145145
    146 // Format titles
     146// Format titles.
    147147foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) {
    148148    add_filter( $filter, 'wptexturize' );
     
    158158}
    159159
    160 // Format for RSS
     160// Format for RSS.
    161161add_filter( 'term_name_rss', 'convert_chars' );
    162162
    163 // Pre save hierarchy
     163// Pre save hierarchy.
    164164add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 );
    165165add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
    166166
    167 // Display filters
     167// Display filters.
    168168add_filter( 'the_title', 'wptexturize' );
    169169add_filter( 'the_title', 'convert_chars' );
     
    210210add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run.
    211211
    212 // RSS filters
     212// RSS filters.
    213213add_filter( 'the_title_rss', 'strip_tags' );
    214214add_filter( 'the_title_rss', 'ent2ncr', 8 );
     
    227227add_filter( 'the_guid', 'esc_url' );
    228228
    229 // Email filters
     229// Email filters.
    230230add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
    231231
    232 // Mark site as no longer fresh
     232// Mark site as no longer fresh.
    233233foreach ( array( 'publish_post', 'publish_page', 'wp_ajax_save-widget', 'wp_ajax_widgets-order', 'customize_save_after' ) as $action ) {
    234234    add_action( $action, '_delete_option_fresh_site', 0 );
    235235}
    236236
    237 // Misc filters
     237// Misc filters.
    238238add_filter( 'option_ping_sites', 'privacy_ping_filter' );
    239 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop
     239add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop.
    240240add_filter( 'option_blog_charset', '_canonical_charset' );
    241241add_filter( 'option_home', '_config_wp_home' );
     
    277277add_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 );
    278278
    279 // Actions
     279// Actions.
    280280add_action( 'wp_head', '_wp_render_title_tag', 1 );
    281281add_action( 'wp_head', 'wp_enqueue_scripts', 1 );
     
    309309}
    310310
    311 // Login actions
     311// Login actions.
    312312add_filter( 'login_head', 'wp_resource_hints', 8 );
    313313add_action( 'login_head', 'wp_print_head_scripts', 9 );
     
    317317add_action( 'login_init', 'send_frame_options_header', 10, 0 );
    318318
    319 // Feed Generator Tags
     319// Feed generator tags.
    320320foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) {
    321321    add_action( $action, 'the_generator' );
    322322}
    323323
    324 // Feed Site Icon
     324// Feed Site Icon.
    325325add_action( 'atom_head', 'atom_site_icon' );
    326326add_action( 'rss2_head', 'rss2_site_icon' );
    327327
    328328
    329 // WP Cron
     329// WP Cron.
    330330if ( ! defined( 'DOING_CRON' ) ) {
    331331    add_action( 'init', 'wp_cron' );
    332332}
    333333
    334 // 2 Actions 2 Furious
     334// 2 Actions 2 Furious.
    335335add_action( 'do_feed_rdf', 'do_feed_rdf', 10, 0 );
    336336add_action( 'do_feed_rss', 'do_feed_rss', 10, 0 );
     
    360360add_action( 'welcome_panel', 'wp_welcome_panel' );
    361361
    362 // Privacy
     362// Privacy.
    363363add_action( 'user_request_action_confirmed', '_wp_privacy_account_request_confirmed' );
    364364add_action( 'user_request_action_confirmed', '_wp_privacy_send_request_confirmation_notification', 12 ); // After request marked as completed.
     
    370370add_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
    371371
    372 // Cron tasks
     372// Cron tasks.
    373373add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
    374374add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' );
     
    377377add_action( 'delete_expired_transients', 'delete_expired_transients' );
    378378
    379 // Navigation menu actions
     379// Navigation menu actions.
    380380add_action( 'delete_post', '_wp_delete_post_menu_item' );
    381381add_action( 'delete_term', '_wp_delete_tax_menu_item', 10, 3 );
     
    383383add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' );
    384384
    385 // Post Thumbnail CSS class filtering
     385// Post Thumbnail CSS class filtering.
    386386add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' );
    387387add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove' );
    388388
    389 // Redirect Old Slugs
     389// Redirect old slugs.
    390390add_action( 'template_redirect', 'wp_old_slug_redirect' );
    391391add_action( 'post_updated', 'wp_check_for_changed_slugs', 12, 3 );
    392392add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 );
    393393
    394 // Redirect Old Dates
     394// Redirect old dates.
    395395add_action( 'post_updated', 'wp_check_for_changed_dates', 12, 3 );
    396396add_action( 'attachment_updated', 'wp_check_for_changed_dates', 12, 3 );
    397397
    398 // Nonce check for Post Previews
     398// Nonce check for post previews.
    399399add_action( 'init', '_show_post_preview' );
    400400
    401 // Output JS to reset window.name for previews
     401// Output JS to reset window.name for previews.
    402402add_action( 'wp_head', 'wp_post_preview_js', 1 );
    403403
    404 // Timezone
     404// Timezone.
    405405add_filter( 'pre_option_gmt_offset', 'wp_timezone_override_offset' );
    406406
    407 // Admin Color Schemes
     407// Admin color schemes.
    408408add_action( 'admin_init', 'register_admin_color_schemes', 1 );
    409409add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
     
    415415add_filter( 'pre_option_embed_autourls', '__return_true' );
    416416
    417 // Default settings for heartbeat
     417// Default settings for heartbeat.
    418418add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' );
    419419
    420 // Check if the user is logged out
     420// Check if the user is logged out.
    421421add_action( 'admin_enqueue_scripts', 'wp_auth_check_load' );
    422422add_filter( 'heartbeat_send', 'wp_auth_check' );
    423423add_filter( 'heartbeat_nopriv_send', 'wp_auth_check' );
    424424
    425 // Default authentication filters
     425// Default authentication filters.
    426426add_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 );
    427427add_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 );
     
    452452
    453453/**
    454  * Filters formerly mixed into wp-includes
     454 * Filters formerly mixed into wp-includes.
    455455 */
    456 // Theme
     456// Theme.
    457457add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
    458458add_action( 'wp_head', '_custom_logo_header_styles' );
     
    463463add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 );
    464464
    465 // Calendar widget cache
     465// Calendar widget cache.
    466466add_action( 'save_post', 'delete_get_calendar_cache' );
    467467add_action( 'delete_post', 'delete_get_calendar_cache' );
     
    469469add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
    470470
    471 // Author
     471// Author.
    472472add_action( 'transition_post_status', '__clear_multi_author_cache' );
    473473
    474 // Post
    475 add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
     474// Post.
     475add_action( 'init', 'create_initial_post_types', 0 ); // Highest priority.
    476476add_action( 'admin_menu', '_add_post_type_submenus' );
    477477add_action( 'before_delete_post', '_reset_front_page_settings_for_post' );
     
    479479add_action( 'change_locale', 'create_initial_post_types' );
    480480
    481 // Post Formats
     481// Post Formats.
    482482add_filter( 'request', '_post_format_request' );
    483483add_filter( 'term_link', '_post_format_link', 10, 3 );
     
    486486add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
    487487
    488 // KSES
     488// KSES.
    489489add_action( 'init', 'kses_init' );
    490490add_action( 'set_current_user', 'kses_init' );
    491491
    492 // Script Loader
     492// Script Loader.
    493493add_action( 'wp_default_scripts', 'wp_default_scripts' );
    494494add_action( 'wp_default_scripts', 'wp_default_packages' );
     
    510510add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
    511511
    512 // Taxonomy
    513 add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
     512// Taxonomy.
     513add_action( 'init', 'create_initial_taxonomies', 0 ); // Highest priority.
    514514add_action( 'change_locale', 'create_initial_taxonomies' );
    515515
    516 // Canonical
     516// Canonical.
    517517add_action( 'template_redirect', 'redirect_canonical' );
    518518add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
    519519
    520 // Shortcodes
    521 add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop()
    522 
    523 // Media
     520// Shortcodes.
     521add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop().
     522
     523// Media.
    524524add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
    525525add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
    526526add_action( 'plugins_loaded', '_wp_add_additional_image_sizes', 0 );
    527527
    528 // Nav menu
     528// Nav menu.
    529529add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
    530530
    531 // Widgets
     531// Widgets.
    532532add_action( 'init', 'wp_widgets_init', 1 );
    533533
    534 // Admin Bar
     534// Admin Bar.
    535535// Don't remove. Wrong way to disable.
    536536add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
     
    541541add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
    542542
    543 // Former admin filters that can also be hooked on the front end
     543// Former admin filters that can also be hooked on the front end.
    544544add_action( 'media_buttons', 'media_buttons' );
    545545add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
    546546add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 );
    547547
    548 // Embeds
     548// Embeds.
    549549add_action( 'rest_api_init', 'wp_oembed_register_route' );
    550550add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 );
     
    581581add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 );
    582582
    583 // Capabilities
     583// Capabilities.
    584584add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 );
    585585add_filter( 'user_has_cap', 'wp_maybe_grant_resume_extensions_caps', 1 );
Note: See TracChangeset for help on using the changeset viewer.