Changeset 47287 for trunk/src/wp-includes/general-template.php
- Timestamp:
- 02/14/2020 12:05:43 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/general-template.php (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r47230 r47287 2345 2345 * @global string $previousday The day of the previous post in the loop. 2346 2346 * 2347 * @param string $ dOptional. PHP date format defaults to the date_format option if not specified.2347 * @param string $format Optional. PHP date format defaults to the date_format option if not specified. 2348 2348 * @param string $before Optional. Output before the date. 2349 2349 * @param string $after Optional. Output after the date. … … 2351 2351 * @return string|void String if retrieving. 2352 2352 */ 2353 function the_date( $ d= '', $before = '', $after = '', $echo = true ) {2353 function the_date( $format = '', $before = '', $after = '', $echo = true ) { 2354 2354 global $currentday, $previousday; 2355 2355 … … 2357 2357 2358 2358 if ( is_new_day() ) { 2359 $the_date = $before . get_the_date( $ d) . $after;2359 $the_date = $before . get_the_date( $format ) . $after; 2360 2360 $previousday = $currentday; 2361 2361 } … … 2367 2367 * 2368 2368 * @param string $the_date The formatted date string. 2369 * @param string $ dPHP date format. Defaults to 'date_format' option2369 * @param string $format PHP date format. Defaults to 'date_format' option 2370 2370 * if not specified. 2371 2371 * @param string $before HTML output before the date. 2372 2372 * @param string $after HTML output after the date. 2373 2373 */ 2374 $the_date = apply_filters( 'the_date', $the_date, $ d, $before, $after );2374 $the_date = apply_filters( 'the_date', $the_date, $format, $before, $after ); 2375 2375 2376 2376 if ( $echo ) { … … 2389 2389 * @since 3.0.0 2390 2390 * 2391 * @param string $ dOptional. PHP date format defaults to the date_format option if not specified.2392 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.2391 * @param string $format Optional. PHP date format defaults to the date_format option if not specified. 2392 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. 2393 2393 * @return string|false Date the current post was written. False on failure. 2394 2394 */ 2395 function get_the_date( $ d= '', $post = null ) {2395 function get_the_date( $format = '', $post = null ) { 2396 2396 $post = get_post( $post ); 2397 2397 … … 2400 2400 } 2401 2401 2402 if ( '' == $ d) {2402 if ( '' == $format ) { 2403 2403 $the_date = get_post_time( get_option( 'date_format' ), false, $post, true ); 2404 2404 } else { 2405 $the_date = get_post_time( $ d, false, $post, true );2405 $the_date = get_post_time( $format, false, $post, true ); 2406 2406 } 2407 2407 … … 2412 2412 * 2413 2413 * @param string $the_date The formatted date. 2414 * @param string $ dPHP date format. Defaults to 'date_format' option2414 * @param string $format PHP date format. Defaults to 'date_format' option 2415 2415 * if not specified. 2416 2416 * @param int|WP_Post $post The post object or ID. 2417 2417 */ 2418 return apply_filters( 'get_the_date', $the_date, $ d, $post );2418 return apply_filters( 'get_the_date', $the_date, $format, $post ); 2419 2419 } 2420 2420 … … 2424 2424 * @since 2.1.0 2425 2425 * 2426 * @param string $ dOptional. PHP date format defaults to the date_format option if not specified.2426 * @param string $format Optional. PHP date format defaults to the date_format option if not specified. 2427 2427 * @param string $before Optional. Output before the date. 2428 2428 * @param string $after Optional. Output after the date. … … 2430 2430 * @return string|void String if retrieving. 2431 2431 */ 2432 function the_modified_date( $ d= '', $before = '', $after = '', $echo = true ) {2433 $the_modified_date = $before . get_the_modified_date( $ d) . $after;2432 function the_modified_date( $format = '', $before = '', $after = '', $echo = true ) { 2433 $the_modified_date = $before . get_the_modified_date( $format ) . $after; 2434 2434 2435 2435 /** … … 2439 2439 * 2440 2440 * @param string $the_modified_date The last modified date. 2441 * @param string $ dPHP date format. Defaults to 'date_format' option2441 * @param string $format PHP date format. Defaults to 'date_format' option 2442 2442 * if not specified. 2443 2443 * @param string $before HTML output before the date. 2444 2444 * @param string $after HTML output after the date. 2445 2445 */ 2446 $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $ d, $before, $after );2446 $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $format, $before, $after ); 2447 2447 2448 2448 if ( $echo ) { … … 2460 2460 * @since 4.6.0 Added the `$post` parameter. 2461 2461 * 2462 * @param string $ dOptional. PHP date format defaults to the date_format option if not specified.2463 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.2462 * @param string $format Optional. PHP date format defaults to the date_format option if not specified. 2463 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. 2464 2464 * @return string|false Date the current post was modified. False on failure. 2465 2465 */ 2466 function get_the_modified_date( $ d= '', $post = null ) {2466 function get_the_modified_date( $format = '', $post = null ) { 2467 2467 $post = get_post( $post ); 2468 2468 … … 2470 2470 // For backward compatibility, failures go through the filter below. 2471 2471 $the_time = false; 2472 } elseif ( empty( $ d) ) {2472 } elseif ( empty( $format ) ) { 2473 2473 $the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true ); 2474 2474 } else { 2475 $the_time = get_post_modified_time( $ d, false, $post, true );2475 $the_time = get_post_modified_time( $format, false, $post, true ); 2476 2476 } 2477 2477 … … 2483 2483 * 2484 2484 * @param string|bool $the_time The formatted date or false if no post is found. 2485 * @param string $ dPHP date format. Defaults to value specified in2485 * @param string $format PHP date format. Defaults to value specified in 2486 2486 * 'date_format' option. 2487 2487 * @param WP_Post|null $post WP_Post object or null if no post is found. 2488 2488 */ 2489 return apply_filters( 'get_the_modified_date', $the_time, $ d, $post );2489 return apply_filters( 'get_the_modified_date', $the_time, $format, $post ); 2490 2490 } 2491 2491 … … 2495 2495 * @since 0.71 2496 2496 * 2497 * @param string $ d Either 'G', 'U', or phpdate format.2498 */ 2499 function the_time( $ d= '' ) {2497 * @param string $format Either 'G', 'U', or PHP date format. 2498 */ 2499 function the_time( $format = '' ) { 2500 2500 /** 2501 2501 * Filters the time a post was written for display. … … 2504 2504 * 2505 2505 * @param string $get_the_time The formatted time. 2506 * @param string $ dThe time format. Accepts 'G', 'U',2507 * or phpdate format.2508 */ 2509 echo apply_filters( 'the_time', get_the_time( $ d ), $d);2506 * @param string $format The time format. Accepts 'G', 'U', 2507 * or PHP date format. 2508 */ 2509 echo apply_filters( 'the_time', get_the_time( $format ), $format ); 2510 2510 } 2511 2511 … … 2515 2515 * @since 1.5.0 2516 2516 * 2517 * @param string $d Optional. Format to use for retrieving the time the post 2518 * was written. Either 'G', 'U', or php date format defaults 2519 * to the value specified in the time_format option. Default empty. 2520 * @param int|WP_Post $post WP_Post object or ID. Default is global `$post` object. 2521 * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure. 2522 */ 2523 function get_the_time( $d = '', $post = null ) { 2517 * @param string $format Optional. Format to use for retrieving the time the post 2518 * was written. Either 'G', 'U', or PHP date format defaults 2519 * to the value specified in the time_format option. Default empty. 2520 * @param int|WP_Post $post WP_Post object or ID. Default is global `$post` object. 2521 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. 2522 * False on failure. 2523 */ 2524 function get_the_time( $format = '', $post = null ) { 2524 2525 $post = get_post( $post ); 2525 2526 … … 2528 2529 } 2529 2530 2530 if ( '' == $ d) {2531 if ( '' == $format ) { 2531 2532 $the_time = get_post_time( get_option( 'time_format' ), false, $post, true ); 2532 2533 } else { 2533 $the_time = get_post_time( $ d, false, $post, true );2534 $the_time = get_post_time( $format, false, $post, true ); 2534 2535 } 2535 2536 … … 2540 2541 * 2541 2542 * @param string $the_time The formatted time. 2542 * @param string $ dFormat to use for retrieving the time the post was written.2543 * Accepts 'G', 'U', or phpdate format value specified2543 * @param string $format Format to use for retrieving the time the post was written. 2544 * Accepts 'G', 'U', or PHP date format value specified 2544 2545 * in 'time_format' option. Default empty. 2545 2546 * @param int|WP_Post $post WP_Post object or ID. 2546 2547 */ 2547 return apply_filters( 'get_the_time', $the_time, $ d, $post );2548 return apply_filters( 'get_the_time', $the_time, $format, $post ); 2548 2549 } 2549 2550 … … 2553 2554 * @since 2.0.0 2554 2555 * 2555 * @param string $ dOptional. Format to use for retrieving the time the post2556 * was written. Either 'G', 'U', or phpdate format. Default 'U'.2556 * @param string $format Optional. Format to use for retrieving the time the post 2557 * was written. Either 'G', 'U', or PHP date format. Default 'U'. 2557 2558 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false. 2558 2559 * @param int|WP_Post $post WP_Post object or ID. Default is global `$post` object. 2559 2560 * @param bool $translate Whether to translate the time string. Default false. 2560 * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure. 2561 */ 2562 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { 2561 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. 2562 * False on failure. 2563 */ 2564 function get_post_time( $format = 'U', $gmt = false, $post = null, $translate = false ) { 2563 2565 $post = get_post( $post ); 2564 2566 … … 2574 2576 } 2575 2577 2576 if ( 'U' === $ d || 'G' === $d) {2578 if ( 'U' === $format || 'G' === $format ) { 2577 2579 $time = $datetime->getTimestamp(); 2578 2580 … … 2582 2584 } 2583 2585 } elseif ( $translate ) { 2584 $time = wp_date( $ d, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );2586 $time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null ); 2585 2587 } else { 2586 2588 if ( $gmt ) { … … 2588 2590 } 2589 2591 2590 $time = $datetime->format( $ d);2592 $time = $datetime->format( $format ); 2591 2593 } 2592 2594 … … 2596 2598 * @since 2.6.0 2597 2599 * 2598 * @param string $time The formatted time.2599 * @param string $ dFormat to use for retrieving the time the post was written.2600 * Accepts 'G', 'U', or phpdate format. Default 'U'.2601 * @param bool $gmt Whether to retrieve the GMT time. Default false.2602 */ 2603 return apply_filters( 'get_post_time', $time, $ d, $gmt );2600 * @param string $time The formatted time. 2601 * @param string $format Format to use for retrieving the time the post was written. 2602 * Accepts 'G', 'U', or PHP date format. Default 'U'. 2603 * @param bool $gmt Whether to retrieve the GMT time. Default false. 2604 */ 2605 return apply_filters( 'get_post_time', $time, $format, $gmt ); 2604 2606 } 2605 2607 … … 2681 2683 * @since 2.0.0 2682 2684 * 2683 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option. 2684 */ 2685 function the_modified_time( $d = '' ) { 2685 * @param string $format Optional. Either 'G', 'U', or PHP date format defaults 2686 * to the value specified in the time_format option. 2687 */ 2688 function the_modified_time( $format = '' ) { 2686 2689 /** 2687 2690 * Filters the localized time a post was last modified, for display. … … 2690 2693 * 2691 2694 * @param string $get_the_modified_time The formatted time. 2692 * @param string $ dThe time format. Accepts 'G', 'U',2693 * or phpdate format. Defaults to value2695 * @param string $format The time format. Accepts 'G', 'U', 2696 * or PHP date format. Defaults to value 2694 2697 * specified in 'time_format' option. 2695 2698 */ 2696 echo apply_filters( 'the_modified_time', get_the_modified_time( $ d ), $d);2699 echo apply_filters( 'the_modified_time', get_the_modified_time( $format ), $format ); 2697 2700 } 2698 2701 … … 2703 2706 * @since 4.6.0 Added the `$post` parameter. 2704 2707 * 2705 * @param string $ dOptional. Format to use for retrieving the time the post2706 * was modified. Either 'G', 'U', or phpdate format defaults2707 * to the value specified in the time_format option. Default empty.2708 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.2708 * @param string $format Optional. Format to use for retrieving the time the post 2709 * was modified. Either 'G', 'U', or PHP date format defaults 2710 * to the value specified in the time_format option. Default empty. 2711 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. 2709 2712 * @return string|false Formatted date string or Unix timestamp. False on failure. 2710 2713 */ 2711 function get_the_modified_time( $ d= '', $post = null ) {2714 function get_the_modified_time( $format = '', $post = null ) { 2712 2715 $post = get_post( $post ); 2713 2716 … … 2715 2718 // For backward compatibility, failures go through the filter below. 2716 2719 $the_time = false; 2717 } elseif ( empty( $ d) ) {2720 } elseif ( empty( $format ) ) { 2718 2721 $the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true ); 2719 2722 } else { 2720 $the_time = get_post_modified_time( $ d, false, $post, true );2723 $the_time = get_post_modified_time( $format, false, $post, true ); 2721 2724 } 2722 2725 … … 2728 2731 * 2729 2732 * @param string|bool $the_time The formatted time or false if no post is found. 2730 * @param string $ dFormat to use for retrieving the time the post was2731 * written. Accepts 'G', 'U', or phpdate format. Defaults2733 * @param string $format Format to use for retrieving the time the post was 2734 * written. Accepts 'G', 'U', or PHP date format. Defaults 2732 2735 * to value specified in 'time_format' option. 2733 2736 * @param WP_Post|null $post WP_Post object or null if no post is found. 2734 2737 */ 2735 return apply_filters( 'get_the_modified_time', $the_time, $ d, $post );2738 return apply_filters( 'get_the_modified_time', $the_time, $format, $post ); 2736 2739 } 2737 2740 … … 2741 2744 * @since 2.0.0 2742 2745 * 2743 * @param string $ dOptional. Format to use for retrieving the time the post2744 * was modified. Either 'G', 'U', or phpdate format. Default 'U'.2746 * @param string $format Optional. Format to use for retrieving the time the post 2747 * was modified. Either 'G', 'U', or PHP date format. Default 'U'. 2745 2748 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false. 2746 2749 * @param int|WP_Post $post WP_Post object or ID. Default is global `$post` object. 2747 2750 * @param bool $translate Whether to translate the time string. Default false. 2748 * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure. 2749 */ 2750 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { 2751 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'. 2752 * False on failure. 2753 */ 2754 function get_post_modified_time( $format = 'U', $gmt = false, $post = null, $translate = false ) { 2751 2755 $post = get_post( $post ); 2752 2756 … … 2762 2766 } 2763 2767 2764 if ( 'U' === $ d || 'G' === $d) {2768 if ( 'U' === $format || 'G' === $format ) { 2765 2769 $time = $datetime->getTimestamp(); 2766 2770 … … 2770 2774 } 2771 2775 } elseif ( $translate ) { 2772 $time = wp_date( $ d, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );2776 $time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null ); 2773 2777 } else { 2774 2778 if ( $gmt ) { … … 2776 2780 } 2777 2781 2778 $time = $datetime->format( $ d);2782 $time = $datetime->format( $format ); 2779 2783 } 2780 2784 … … 2784 2788 * @since 2.8.0 2785 2789 * 2786 * @param string $time The formatted time.2787 * @param string $ dFormat to use for retrieving the time the post was modified.2788 * Accepts 'G', 'U', or phpdate format. Default 'U'.2789 * @param bool $gmt Whether to retrieve the GMT time. Default false.2790 */ 2791 return apply_filters( 'get_post_modified_time', $time, $ d, $gmt );2790 * @param string $time The formatted time. 2791 * @param string $format Format to use for retrieving the time the post was modified. 2792 * Accepts 'G', 'U', or PHP date format. Default 'U'. 2793 * @param bool $gmt Whether to retrieve the GMT time. Default false. 2794 */ 2795 return apply_filters( 'get_post_modified_time', $time, $format, $gmt ); 2792 2796 } 2793 2797
Note: See TracChangeset
for help on using the changeset viewer.