~canonical-sysadmins/wordpress/4.7.2

« back to all changes in this revision

Viewing changes to wp-includes/post-template.php

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
/**
57
57
 * Sanitize the current title when retrieving or displaying.
58
58
 *
59
 
 * Works like {@link the_title()}, except the parameters can be in a string or
 
59
 * Works like the_title(), except the parameters can be in a string or
60
60
 * an array. See the function for what can be override in the $args parameter.
61
61
 *
62
 
 * The title before it is displayed will have the tags stripped and {@link
63
 
 * esc_attr()} before it is passed to the user or displayed. The default
64
 
 * as with {@link the_title()}, is to display the title.
 
62
 * The title before it is displayed will have the tags stripped and esc_attr()
 
63
 * before it is passed to the user or displayed. The default as with the_title(),
 
64
 * is to display the title.
65
65
 *
66
66
 * @since 2.3.0
67
67
 *
117
117
                if ( ! empty( $post->post_password ) ) {
118
118
 
119
119
                        /**
120
 
                         * Filter the text prepended to the post title for protected posts.
 
120
                         * Filters the text prepended to the post title for protected posts.
121
121
                         *
122
122
                         * The filter is only applied on the front end.
123
123
                         *
132
132
                } elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) {
133
133
 
134
134
                        /**
135
 
                         * Filter the text prepended to the post title of private posts.
 
135
                         * Filters the text prepended to the post title of private posts.
136
136
                         *
137
137
                         * The filter is only applied on the front end.
138
138
                         *
148
148
        }
149
149
 
150
150
        /**
151
 
         * Filter the post title.
 
151
         * Filters the post title.
152
152
         *
153
153
         * @since 0.71
154
154
         *
178
178
        $id   = isset( $post->ID ) ? $post->ID : 0;
179
179
 
180
180
        /**
181
 
         * Filter the escaped Global Unique Identifier (guid) of the post.
 
181
         * Filters the escaped Global Unique Identifier (guid) of the post.
182
182
         *
183
183
         * @since 4.2.0
184
184
         *
209
209
        $id   = isset( $post->ID ) ? $post->ID : 0;
210
210
 
211
211
        /**
212
 
         * Filter the Global Unique Identifier (guid) of the post.
 
212
         * Filters the Global Unique Identifier (guid) of the post.
213
213
         *
214
214
         * @since 1.5.0
215
215
         *
231
231
        $content = get_the_content( $more_link_text, $strip_teaser );
232
232
 
233
233
        /**
234
 
         * Filter the post content.
 
234
         * Filters the post content.
235
235
         *
236
236
         * @since 0.71
237
237
         *
262
262
 
263
263
        $post = get_post();
264
264
 
265
 
        if ( null === $more_link_text )
266
 
                $more_link_text = __( '(more…)' );
 
265
        if ( null === $more_link_text ) {
 
266
                $more_link_text = sprintf(
 
267
                        '<span aria-label="%1$s">%2$s</span>',
 
268
                        sprintf(
 
269
                                /* translators: %s: Name of current post */
 
270
                                __( 'Continue reading %s' ),
 
271
                                the_title_attribute( array( 'echo' => false ) )
 
272
                        ),
 
273
                        __( '(more&hellip;)' )
 
274
                );
 
275
        }
267
276
 
268
277
        $output = '';
269
278
        $has_teaser = false;
303
312
                        if ( ! empty( $more_link_text ) )
304
313
 
305
314
                                /**
306
 
                                 * Filter the Read More link text.
 
315
                                 * Filters the Read More link text.
307
316
                                 *
308
317
                                 * @since 2.8.0
309
318
                                 *
342
351
function the_excerpt() {
343
352
 
344
353
        /**
345
 
         * Filter the displayed post excerpt.
 
354
         * Filters the displayed post excerpt.
346
355
         *
347
356
         * @since 0.71
348
357
         *
364
373
 */
365
374
function get_the_excerpt( $post = null ) {
366
375
        if ( is_bool( $post ) ) {
367
 
                _deprecated_argument( __FUNCTION__, '2.3' );
 
376
                _deprecated_argument( __FUNCTION__, '2.3.0' );
368
377
        }
369
378
 
370
379
        $post = get_post( $post );
377
386
        }
378
387
 
379
388
        /**
380
 
         * Filter the retrieved post excerpt.
 
389
         * Filters the retrieved post excerpt.
381
390
         *
382
391
         * @since 1.2.0
383
392
         * @since 4.5.0 Introduced the `$post` parameter.
415
424
}
416
425
 
417
426
/**
418
 
 * Retrieve the classes for the post div as an array.
 
427
 * Retrieves the classes for the post div as an array.
419
428
 *
420
429
 * The class names are many. If the post is a sticky, then the 'sticky'
421
430
 * class name. The class 'hentry' is always added to each post. If the post has a
422
431
 * post thumbnail, 'has-post-thumbnail' is added as a class. For each taxonomy that
423
432
 * the post belongs to, a class will be added of the format '{$taxonomy}-{$slug}' -
424
 
 * eg 'category-foo' or 'my_custom_taxonomy-bar'. The 'post_tag' taxonomy is a special
 
433
 * eg 'category-foo' or 'my_custom_taxonomy-bar'.
 
434
 *
 
435
 * The 'post_tag' taxonomy is a special
425
436
 * case; the class has the 'tag-' prefix instead of 'post_tag-'. All classes are
426
 
 * passed through the filter, 'post_class' with the list of classes, followed by
 
437
 * passed through the filter, {@see 'post_class'}, with the list of classes, followed by
427
438
 * $class parameter value, with the post ID as the last parameter.
428
439
 *
429
440
 * @since 2.7.0
521
532
        $classes = array_map( 'esc_attr', $classes );
522
533
 
523
534
        /**
524
 
         * Filter the list of CSS classes for the current post.
 
535
         * Filters the list of CSS classes for the current post.
525
536
         *
526
537
         * @since 2.7.0
527
538
         *
745
756
        $classes = array_map( 'esc_attr', $classes );
746
757
 
747
758
        /**
748
 
         * Filter the list of CSS body classes for the current post or page.
 
759
         * Filters the list of CSS body classes for the current post or page.
749
760
         *
750
761
         * @since 2.8.0
751
762
         *
841
852
        $params = wp_parse_args( $args, $defaults );
842
853
 
843
854
        /**
844
 
         * Filter the arguments used in retrieving page links for paginated posts.
 
855
         * Filters the arguments used in retrieving page links for paginated posts.
845
856
         *
846
857
         * @since 3.0.0
847
858
         *
859
870
                                        $link = _wp_link_page( $i ) . $link . '</a>';
860
871
                                }
861
872
                                /**
862
 
                                 * Filter the HTML output of individual page number links.
 
873
                                 * Filters the HTML output of individual page number links.
863
874
                                 *
864
875
                                 * @since 3.6.0
865
876
                                 *
897
908
        }
898
909
 
899
910
        /**
900
 
         * Filter the HTML output of page links for paginated posts.
 
911
         * Filters the HTML output of page links for paginated posts.
901
912
         *
902
913
         * @since 3.6.0
903
914
         *
994
1005
                        $value = implode($values,', ');
995
1006
 
996
1007
                        /**
997
 
                         * Filter the HTML output of the li element in the post custom fields list.
 
1008
                         * Filters the HTML output of the li element in the post custom fields list.
998
1009
                         *
999
1010
                         * @since 2.2.0
1000
1011
                         *
1078
1089
        }
1079
1090
 
1080
1091
        /**
1081
 
         * Filter the HTML output of a list of pages as a drop down.
 
1092
         * Filters the HTML output of a list of pages as a drop down.
1082
1093
         *
1083
1094
         * @since 2.1.0
1084
1095
         * @since 4.4.0 `$r` and `$pages` added as arguments.
1154
1165
        $exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array();
1155
1166
 
1156
1167
        /**
1157
 
         * Filter the array of pages to exclude from the pages list.
 
1168
         * Filters the array of pages to exclude from the pages list.
1158
1169
         *
1159
1170
         * @since 2.1.0
1160
1171
         *
1188
1199
        }
1189
1200
 
1190
1201
        /**
1191
 
         * Filter the HTML output of the pages to list.
 
1202
         * Filters the HTML output of the pages to list.
1192
1203
         *
1193
1204
         * @since 1.5.1
1194
1205
         * @since 4.4.0 `$pages` added as arguments.
1209
1220
}
1210
1221
 
1211
1222
/**
1212
 
 * Display or retrieve list of pages with optional home link.
 
1223
 * Displays or retrieves a list of pages with an optional home link.
1213
1224
 *
1214
 
 * The arguments are listed below and part of the arguments are for {@link
1215
 
 * wp_list_pages()} function. Check that function for more info on those
1216
 
 * arguments.
 
1225
 * The arguments are listed below and part of the arguments are for wp_list_pages()} function.
 
1226
 * Check that function for more info on those arguments.
1217
1227
 *
1218
1228
 * @since 2.7.0
1219
1229
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
1254
1264
        $args = wp_parse_args( $args, $defaults );
1255
1265
 
1256
1266
        /**
1257
 
         * Filter the arguments used to generate a page-based menu.
 
1267
         * Filters the arguments used to generate a page-based menu.
1258
1268
         *
1259
1269
         * @since 2.7.0
1260
1270
         *
1325
1335
        $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
1326
1336
 
1327
1337
        /**
1328
 
         * Filter the HTML output of a page-based menu.
 
1338
         * Filters the HTML output of a page-based menu.
1329
1339
         *
1330
1340
         * @since 2.7.0
1331
1341
         *
1407
1417
 */
1408
1418
function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
1409
1419
        if ( !empty( $deprecated ) )
1410
 
                _deprecated_argument( __FUNCTION__, '2.5' );
 
1420
                _deprecated_argument( __FUNCTION__, '2.5.0' );
1411
1421
 
1412
1422
        if ( $fullsize )
1413
1423
                echo wp_get_attachment_link($id, 'full', $permalink);
1453
1463
                $link_text = $_post->post_title;
1454
1464
 
1455
1465
        /**
1456
 
         * Filter a retrieved attachment page link.
 
1466
         * Filters a retrieved attachment page link.
1457
1467
         *
1458
1468
         * @since 2.7.0
1459
1469
         *
1503
1513
        }
1504
1514
 
1505
1515
        /**
1506
 
         * Filter the attachment markup to be prepended to the post content.
 
1516
         * Filters the attachment markup to be prepended to the post content.
1507
1517
         *
1508
1518
         * @since 2.0.0
1509
1519
         *
1537
1547
        ';
1538
1548
 
1539
1549
        /**
1540
 
         * Filter the HTML output for the protected post password form.
 
1550
         * Filters the HTML output for the protected post password form.
1541
1551
         *
1542
1552
         * If modifying the password field, please note that the core database schema
1543
1553
         * limits the password field to 20 characters regardless of the value of the
1621
1631
        if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
1622
1632
                return false;
1623
1633
 
1624
 
        /* translators: revision date format, see http://php.net/date */
 
1634
        /* translators: revision date format, see https://secure.php.net/date */
1625
1635
        $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
1626
1636
        /* translators: 1: date */
1627
1637
        $autosavef = _x( '%1$s [Autosave]', 'post revision title extra' );
1657
1667
                return false;
1658
1668
 
1659
1669
        $author = get_the_author_meta( 'display_name', $revision->post_author );
1660
 
        /* translators: revision date format, see http://php.net/date */
 
1670
        /* translators: revision date format, see https://secure.php.net/date */
1661
1671
        $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
1662
1672
 
1663
1673
        $gravatar = get_avatar( $revision->post_author, 24 );
1684
1694
                $revision_date_author = sprintf( $autosavef, $revision_date_author );
1685
1695
 
1686
1696
        /**
1687
 
         * Filter the formatted author and date for a revision.
 
1697
         * Filters the formatted author and date for a revision.
1688
1698
         *
1689
1699
         * @since 4.4.0
1690
1700
         *
1714
1724
        // $args array with (parent, format, right, left, type) deprecated since 3.6
1715
1725
        if ( is_array( $type ) ) {
1716
1726
                $type = ! empty( $type['type'] ) ? $type['type']  : $type;
1717
 
                _deprecated_argument( __FUNCTION__, '3.6' );
 
1727
                _deprecated_argument( __FUNCTION__, '3.6.0' );
1718
1728
        }
1719
1729
 
1720
1730
        if ( ! $revisions = wp_get_post_revisions( $post->ID ) )