Changeset 45378
- Timestamp:
- 05/22/2019 09:57:29 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r45377 r45378 2341 2341 global $currentday, $previousday; 2342 2342 2343 $the_date = ''; 2344 2343 2345 if ( is_new_day() ) { 2344 2346 $the_date = $before . get_the_date( $d ) . $after; 2345 2347 $previousday = $currentday; 2346 2347 /** 2348 * Filters the date a post was published for display.2349 *2350 * @since 0.712351 *2352 * @param string $the_date The formatted date string.2353 * @param string $d PHP date format. Defaults to 'date_format' option2354 * if not specified.2355 * @param string $before HTML output before the date.2356 * @param string $after HTML output afterthe date.2357 */2358 $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );2359 2360 if ( $echo ) { 2361 echo $the_date;2362 } else {2363 return $the_date;2364 }2348 } 2349 2350 /** 2351 * Filters the date a post was published for display. 2352 * 2353 * @since 0.71 2354 * 2355 * @param string $the_date The formatted date string. 2356 * @param string $d PHP date format. Defaults to 'date_format' option 2357 * if not specified. 2358 * @param string $before HTML output before the date. 2359 * @param string $after HTML output after the date. 2360 */ 2361 $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after ); 2362 2363 if ( $echo ) { 2364 echo $the_date; 2365 } else { 2366 return $the_date; 2365 2367 } 2366 2368 } … … 2701 2703 * @since 0.71 2702 2704 * 2703 * @global WP_Locale $wp_locale 2704 * @global string $currentday 2705 * @global string $previous weekday The day of the previous post in the loop.2705 * @global WP_Locale $wp_locale The WordPress date and time locale object. 2706 * @global string $currentday The day of the current post in the loop. 2707 * @global string $previousday The day of the previous post in the loop. 2706 2708 * 2707 2709 * @param string $before Optional. Output before the date. … … 2709 2711 */ 2710 2712 function the_weekday_date( $before = '', $after = '' ) { 2711 global $wp_locale, $currentday, $previousweekday; 2713 global $wp_locale, $currentday, $previousday; 2714 2712 2715 $the_weekday_date = ''; 2713 if ( $currentday != $previousweekday ) { 2716 2717 if ( is_new_day() ) { 2714 2718 $the_weekday_date .= $before; 2715 2719 $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); 2716 2720 $the_weekday_date .= $after; 2717 $previous weekday= $currentday;2721 $previousday = $currentday; 2718 2722 } 2719 2723 … … 2727 2731 * @param string $after The HTML to output after the date. 2728 2732 */ 2729 $the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after ); 2730 echo $the_weekday_date; 2733 echo apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after ); 2731 2734 } 2732 2735 -
trunk/tests/phpunit/tests/date/theDate.php
r43591 r45378 82 82 return $input; 83 83 } 84 85 /** 86 * @ticket 33750 87 */ 88 function test_the_date() { 89 ob_start(); 90 the_date(); 91 $actual = ob_get_clean(); 92 $this->assertEquals( '', $actual ); 93 94 $GLOBALS['post'] = self::factory()->post->create_and_get( 95 array( 96 'post_date' => '2015-09-16 08:00:00', 97 ) 98 ); 99 100 ob_start(); 101 $GLOBALS['currentday'] = '18.09.15'; 102 $GLOBALS['previousday'] = '17.09.15'; 103 the_date(); 104 $this->assertEquals( 'September 16, 2015', ob_get_clean() ); 105 106 ob_start(); 107 $GLOBALS['currentday'] = '18.09.15'; 108 $GLOBALS['previousday'] = '17.09.15'; 109 the_date( 'Y' ); 110 $this->assertEquals( '2015', ob_get_clean() ); 111 112 ob_start(); 113 $GLOBALS['currentday'] = '18.09.15'; 114 $GLOBALS['previousday'] = '17.09.15'; 115 the_date( 'Y', 'before ', ' after' ); 116 $this->assertEquals( 'before 2015 after', ob_get_clean() ); 117 118 ob_start(); 119 $GLOBALS['currentday'] = '18.09.15'; 120 $GLOBALS['previousday'] = '17.09.15'; 121 the_date( 'Y', 'before ', ' after', false ); 122 $this->assertEquals( '', ob_get_clean() ); 123 } 124 125 /** 126 * @ticket 47354 127 */ 128 function test_the_weekday_date() { 129 ob_start(); 130 the_weekday_date(); 131 $actual = ob_get_clean(); 132 $this->assertEquals( '', $actual ); 133 134 $GLOBALS['post'] = self::factory()->post->create_and_get( 135 array( 136 'post_date' => '2015-09-16 08:00:00', 137 ) 138 ); 139 140 ob_start(); 141 $GLOBALS['currentday'] = '18.09.15'; 142 $GLOBALS['previousday'] = '17.09.15'; 143 the_weekday_date(); 144 $this->assertEquals( 'Wednesday', ob_get_clean() ); 145 146 ob_start(); 147 $GLOBALS['currentday'] = '18.09.15'; 148 $GLOBALS['previousday'] = '17.09.15'; 149 the_weekday_date( 'before ', ' after' ); 150 $this->assertEquals( 'before Wednesday after', ob_get_clean() ); 151 } 84 152 } -
trunk/tests/phpunit/tests/functions.php
r45270 r45378 914 914 $json = wp_json_encode( $data, 0, 1 ); 915 915 $this->assertFalse( $json ); 916 }917 918 /**919 * @ticket 33750920 */921 function test_the_date() {922 ob_start();923 the_date();924 $actual = ob_get_clean();925 $this->assertEquals( '', $actual );926 927 $GLOBALS['post'] = self::factory()->post->create_and_get(928 array(929 'post_date' => '2015-09-16 08:00:00',930 )931 );932 933 ob_start();934 $GLOBALS['currentday'] = '18.09.15';935 $GLOBALS['previousday'] = '17.09.15';936 the_date();937 $this->assertEquals( 'September 16, 2015', ob_get_clean() );938 939 ob_start();940 $GLOBALS['currentday'] = '18.09.15';941 $GLOBALS['previousday'] = '17.09.15';942 the_date( 'Y' );943 $this->assertEquals( '2015', ob_get_clean() );944 945 ob_start();946 $GLOBALS['currentday'] = '18.09.15';947 $GLOBALS['previousday'] = '17.09.15';948 the_date( 'Y', 'before ', ' after' );949 $this->assertEquals( 'before 2015 after', ob_get_clean() );950 951 ob_start();952 $GLOBALS['currentday'] = '18.09.15';953 $GLOBALS['previousday'] = '17.09.15';954 the_date( 'Y', 'before ', ' after', false );955 $this->assertEquals( '', ob_get_clean() );956 916 } 957 917
Note: See TracChangeset
for help on using the changeset viewer.