Make WordPress Core


Ignore:
Timestamp:
07/18/2022 05:35:51 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Standardize on $post parameter name where appropriate.

This renames the $post_id or $id parameters to $post for functions that accept a post ID or post object:

  • get_sample_permalink()
  • get_sample_permalink_html()
  • wp_check_post_lock()
  • wp_set_post_lock()
  • get_the_tags()
  • comment_class()
  • get_comment_class()
  • get_comments_link()
  • get_comments_number()
  • comments_number()
  • get_comments_number_text()
  • comments_open()
  • pings_open()
  • comment_form()
  • do_trackbacks()
  • pingback()
  • post_permalink()
  • get_post_permalink()
  • get_edit_post_link()
  • edit_post_link()
  • get_delete_post_link()
  • post_class()
  • get_post_class()
  • the_attachment_link()
  • wp_get_attachment_link()
  • wp_list_post_revisions()
  • check_and_publish_future_post()
  • add_ping()
  • get_pung()
  • get_to_ping()
  • wp_get_post_revisions()
  • wp_get_post_revisions_url()

Additionally, $revision_id is renamed to $revision in:

  • wp_restore_post_revision()
  • wp_delete_post_revision()

Includes minor documentation improvements for consistency and code layout fixes for better readability.

Follow-up to [1599], [1794], [2881], [3303], [3851], [5302], [6633], [6716], [6985], [7103], [7149], [7747], [8011], [8638], [8643], [8695], [9138], [9273], [11425], [11922], [11956], [12284], [12810], [12923], [13023], [13171], [25567], [27156], [27473], [28558], [28602], [33659], [38852], [47276], [47366], [48622], [49544], [49597], [52095].

See #56243, #55647.

File:
1 edited

Legend:

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

    r53458 r53715  
    150150
    151151/**
    152  * Retrieves the approved comments for post $post_id.
     152 * Retrieves the approved comments for a post.
    153153 *
    154154 * @since 2.0.0
     
    860860 */
    861861function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) {
    862 
    863862    global $wpdb;
    864863
     
    14481447function wp_delete_comment( $comment_id, $force_delete = false ) {
    14491448    global $wpdb;
     1449
    14501450    $comment = get_comment( $comment_id );
    14511451    if ( ! $comment ) {
     
    19921992function wp_insert_comment( $commentdata ) {
    19931993    global $wpdb;
     1994
    19941995    $data = wp_unslash( $commentdata );
    19951996
     
    26522653function wp_update_comment_count_now( $post_id ) {
    26532654    global $wpdb;
     2655
    26542656    $post_id = (int) $post_id;
     2657
    26552658    if ( ! $post_id ) {
    26562659        return false;
     
    26612664
    26622665    $post = get_post( $post_id );
     2666
    26632667    if ( ! $post ) {
    26642668        return false;
     
    28872891 *
    28882892 * @since 1.5.0
    2889  * @since 4.7.0 `$post_id` can be a WP_Post object.
     2893 * @since 4.7.0 `$post` can be a WP_Post object.
    28902894 *
    28912895 * @global wpdb $wpdb WordPress database abstraction object.
    28922896 *
    2893  * @param int|WP_Post $post_id Post object or ID to do trackbacks on.
    2894  */
    2895 function do_trackbacks( $post_id ) {
     2897 * @param int|WP_Post $post Post ID or object to do trackbacks on.
     2898 */
     2899function do_trackbacks( $post ) {
    28962900    global $wpdb;
    2897     $post = get_post( $post_id );
     2901
     2902    $post = get_post( $post );
     2903
    28982904    if ( ! $post ) {
    28992905        return false;
     
    29022908    $to_ping = get_to_ping( $post );
    29032909    $pinged  = get_pung( $post );
     2910
    29042911    if ( empty( $to_ping ) ) {
    29052912        $wpdb->update( $wpdb->posts, array( 'to_ping' => '' ), array( 'ID' => $post->ID ) );
     
    29482955 *
    29492956 * @param int $post_id Post ID.
    2950  * @return int Same as Post ID from parameter
     2957 * @return int Same post ID as provided.
    29512958 */
    29522959function generic_ping( $post_id = 0 ) {
     
    29682975 *
    29692976 * @since 0.71
    2970  * @since 4.7.0 `$post_id` can be a WP_Post object.
     2977 * @since 4.7.0 `$post` can be a WP_Post object.
    29712978 *
    29722979 * @param string      $content Post content to check for links. If empty will retrieve from post.
    2973  * @param int|WP_Post $post_id Post Object or ID.
    2974  */
    2975 function pingback( $content, $post_id ) {
     2980 * @param int|WP_Post $post    Post ID or object.
     2981 */
     2982function pingback( $content, $post ) {
    29762983    include_once ABSPATH . WPINC . '/class-IXR.php';
    29772984    include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
     
    29802987    $post_links = array();
    29812988
    2982     $post = get_post( $post_id );
     2989    $post = get_post( $post );
     2990
    29832991    if ( ! $post ) {
    29842992        return;
     
    30333041     * @param string[] $post_links Array of link URLs to be checked (passed by reference).
    30343042     * @param string[] $pung       Array of link URLs already pinged (passed by reference).
    3035      * @param int      $post_ID    The post ID.
     3043     * @param int      $post_id    The post ID.
    30363044     */
    30373045    do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post->ID ) );
Note: See TracChangeset for help on using the changeset viewer.