Make WordPress Core

Ticket #27431: 27431.2.diff

File 27431.2.diff, 10.1 KB (added by kpdesign, 11 years ago)

Second pass

  • src/wp-admin/includes/class-wp-posts-list-table.php

     
    9090                $post_type = $this->screen->post_type;
    9191                $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
    9292
    93                 /**
    94                  * Filter the number of posts displayed per page on the Posts list table.
    95                  *
    96                  * @since 2.8.0
    97                  *
    98                  * @param int    $per_page  Number of posts to be displayed. Default 20.
    99                  * @param string $post_type The post type.
    100                  */
     93                /** This filter is documented in wp-admin/includes/post.php */
    10194                $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
    10295
    10396                if ( $this->hierarchical_display )
  • src/wp-admin/includes/post.php

     
    274274                }
    275275
    276276                $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
     277
    277278                /** This filter is documented in wp-admin/includes/media.php */
    278279                $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data );
    279280        }
     
    495496                $post = new WP_Post( $post );
    496497        }
    497498
     499        /**
     500         * Filter the default post content initially used in the "Write Post" post form.
     501         *
     502         * @since 1.5.0
     503         *
     504         * @param string  $post_content Default post content.
     505         * @param WP_Post $post         Post object.
     506         */
    498507        $post->post_content = apply_filters( 'default_content', $post_content, $post );
    499         $post->post_title   = apply_filters( 'default_title',   $post_title, $post   );
     508
     509        /**
     510         * Filter the default post title initially used in the "Write Post" post form.
     511         *
     512         * @since 1.5.0
     513         *
     514         * @param string  $post_title Default post title.
     515         * @param WP_Post $post       Post object.
     516         */
     517        $post->post_title = apply_filters( 'default_title', $post_title, $post );
     518
     519        /**
     520         * Filter the default post excerpt initially used in the "Write Post" post form.
     521         *
     522         * @since 1.5.0
     523         *
     524         * @param string  $post_excerpt Default post excerpt.
     525         * @param WP_Post $post         Post object.
     526         */
    500527        $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
    501528        $post->post_name = '';
    502529
     
    865892        if ( empty( $posts_per_page ) || $posts_per_page < 1 )
    866893                $posts_per_page = 20;
    867894
     895        /**
     896         * Filter the number of items per page to show for a specific 'per_page' type.
     897         *
     898         * The dynamic hook name, $per_page, refers to a hook name comprised of the post type,
     899         * preceded by 'edit_', and succeeded by '_per_page', e.g. 'edit_$post_type_per_page'.
     900         *
     901         * Some examples of filter hooks generated here include: 'edit_attachment_per_page',
     902         * 'edit_post_per_page', 'edit_page_per_page', etc.
     903         *
     904         * @since 3.0.0
     905         *
     906         * @param int $posts_per_page Number of posts to display per page for the given 'per_page'
     907         *                            type. Default 20.
     908         */
    868909        $posts_per_page = apply_filters( $per_page, $posts_per_page );
     910
     911        /**
     912         * Filter the number of posts displayed per page when specifically listing "posts".
     913         *
     914         * @since 2.8.0
     915         *
     916         * @param int    $per_page  Number of posts to be displayed. Default 20.
     917         * @param string $post_type The post type.
     918         */
    869919        $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type );
    870920
    871921        $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
     
    906956 * can be passed in, which will override the arguments set by this function.
    907957 *
    908958 * @since 2.5.0
    909  * @uses apply_filters() Calls 'upload_per_page' on posts_per_page argument
    910959 *
    911960 * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
    912961 * @return array
     
    927976        $media_per_page = (int) get_user_option( 'upload_per_page' );
    928977        if ( empty( $media_per_page ) || $media_per_page < 1 )
    929978                $media_per_page = 20;
     979
     980        /**
     981         * Filter the number of items to list per page when listing media items.
     982         *
     983         * @since 2.9.0
     984         *
     985         * @param int $media_per_page Number of media to list. Default 20.
     986         */
    930987        $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
    931988
    932989        $post_mime_types = get_post_mime_types();
     
    9661023                $classes = array( '' );
    9671024        }
    9681025
     1026        /**
     1027         * Filter the postbox classes for a specific screen and screen ID combo.
     1028         *
     1029         * The dynamic portions of the hook name, $page, and $id, refer to
     1030         * the screen, and screen ID, respectively.
     1031         *
     1032         * @since 3.2.0
     1033         *
     1034         * @param array $classes An array of postbox classes.
     1035         */
    9691036        $classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes );
    9701037        return implode( ' ', $classes );
    9711038}
     
    10171084                $uri = untrailingslashit($uri);
    10181085                $uri = strrev( stristr( strrev( $uri ), '/' ) );
    10191086                $uri = untrailingslashit($uri);
     1087
     1088                /** This filter is documented in wp-admin/edit-tag-form.php */
    10201089                $uri = apply_filters( 'editable_slug', $uri );
    10211090                if ( !empty($uri) )
    10221091                        $uri .= '/';
     
    10231092                $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
    10241093        }
    10251094
    1026         $permalink = array($permalink, apply_filters('editable_slug', $post->post_name));
     1095        /** This filter is documented in wp-admin/edit-tag-form.php */
     1096        $permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name ) );
    10271097        $post->post_status = $original_status;
    10281098        $post->post_date = $original_date;
    10291099        $post->post_name = $original_name;
     
    10671137                if ( isset( $view_post ) )
    10681138                        $return .= "<span id='view-post-btn'><a href='$permalink' class='button button-small'>$view_post</a></span>\n";
    10691139
    1070                 $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
     1140                /**
     1141                 * Filter the sample permalink HTML markup to return.
     1142                 *
     1143                 * @since 2.9.0
     1144                 *
     1145                 * @param string      $return    Sample permalink HTML markup.
     1146                 * @param int|WP_Post $id        Post object or ID.
     1147                 * @param string      $new_title New sample permalink title.
     1148                 * @param string      $new_slug  New sample permalink slug.
     1149                 */
     1150                $return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
    10711151
    10721152                return $return;
    10731153        }
     
    10991179                $return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
    11001180        }
    11011181
    1102         $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
     1182        /** This filter is documented in wp-admin/includes/post.php */
     1183        $return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
    11031184
    11041185        return $return;
    11051186}
     
    11371218                $content_width = $old_content_width;
    11381219        }
    11391220
     1221        /**
     1222         * Filter the admin post thumbnail HTML markup to return.
     1223         *
     1224         * @since 2.9.0
     1225         *
     1226         * @param string $content Admin post thumbnail HTML markup.
     1227         * @param int    $post_id Post ID.
     1228         */
    11401229        return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID );
    11411230}
    11421231
     
    11591248        $time = $lock[0];
    11601249        $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
    11611250
     1251        /** This filter is documented in wp-admin/includes/ajax-actions.php */
    11621252        $time_window = apply_filters( 'wp_check_post_lock_window', 150 );
    11631253
    11641254        if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
     
    12031293                $user = get_userdata( $user_id );
    12041294
    12051295        if ( $user ) {
     1296                /**
     1297                 * Filter whether to show the post locked dialog.
     1298                 *
     1299                 * Returning a falsey value to the filter will short-circuit displaying the dialog.
     1300                 *
     1301                 * @since 3.6.0
     1302                 *
     1303                 * @param bool         $display Whether to display the dialog. Default true.
     1304                 * @param WP_User|bool $user    WP_User object on success, false otherwise.
     1305                 */
    12061306                if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
    12071307                        return;
    12081308
     
    12451345                        $preview_link = '';
    12461346                }
    12471347
     1348                /** This filter is documented in wp-admin/includes/meta-boxes.php */
    12481349                $preview_link = apply_filters( 'preview_post_link', $preview_link );
     1350
     1351                /**
     1352                 * Filter whether to allow the post lock to be overridden.
     1353                 *
     1354                 * Returning a falsey value to the filter will disable the ability
     1355                 * to override the post lock.
     1356                 *
     1357                 * @since 3.6.0
     1358                 *
     1359                 * @param bool    $override Whether to allow overriding post locks. Default true.
     1360                 * @param WP_Post $post     Post object.
     1361                 * @param WP_User $user     User object.
     1362                 */
    12491363                $override = apply_filters( 'override_post_lock', true, $post, $user );
    12501364                $tab_last = $override ? '' : ' wp-tab-last';
    12511365
     
    12591373                                printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) );
    12601374                ?>
    12611375                </p>
    1262                 <?php do_action( 'post_locked_dialog', $post ); ?>
     1376                <?php
     1377                /**
     1378                 * Fires inside the post locked dialog before the buttons are displayed.
     1379                 *
     1380                 * @since 3.6.0
     1381                 *
     1382                 * @param WP_Post $post Post object.
     1383                 */
     1384                do_action( 'post_locked_dialog', $post );
     1385                ?>
    12631386                <p>
    12641387                <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
    12651388                <?php if ( $preview_link ) { ?>
     
    12871410                        <span class="locked-saving hidden"><img src="images/wpspin_light-2x.gif" width="16" height="16" /> <?php _e('Saving revision...'); ?></span>
    12881411                        <span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span>
    12891412                        </p>
    1290                         <?php do_action( 'post_lock_lost_dialog', $post ); ?>
     1413                        <?php
     1414                        /**
     1415                         * Fires inside the dialog displayed when a user has lost the post lock.
     1416                         *
     1417                         * @since 3.6.0
     1418                         *
     1419                         * @param WP_Post $post Post object.
     1420                         */
     1421                        do_action( 'post_lock_lost_dialog', $post );
     1422                        ?>
    12911423                        <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p>
    12921424                </div>
    12931425                <?php
     
    14121544        }
    14131545
    14141546        $url = add_query_arg( $query_args, get_permalink( $post->ID ) );
     1547
     1548        /** This filter is documented in wp-admin/includes/meta-boxes.php */
    14151549        return apply_filters( 'preview_post_link', $url );
    14161550}
    14171551