Changeset 13048
- Timestamp:
- 02/10/2010 06:37:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r12982 r13048 112 112 * 113 113 * @since 2.7.0 114 */ 115 function get_search_form() { 114 * @param boolean $echo Default to echo and not return the form. 115 */ 116 function get_search_form($echo = true) { 116 117 do_action( 'get_search_form' ); 117 118 … … 129 130 </form>'; 130 131 131 echo apply_filters('get_search_form', $form); 132 if ( $echo ) 133 echo apply_filters('get_search_form', $form); 134 else 135 return apply_filters('get_search_form', $form); 132 136 } 133 137 … … 142 146 * 143 147 * @param string $redirect Optional path to redirect to on login/logout. 144 */ 145 function wp_loginout($redirect = '') { 148 * @param boolean $echo Default to echo and not return the link. 149 */ 150 function wp_loginout($redirect = '', $echo = true) { 146 151 if ( ! is_user_logged_in() ) 147 152 $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>'; 148 153 else 149 154 $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>'; 150 151 echo apply_filters('loginout', $link); 155 156 if ( $echo ) 157 echo apply_filters('loginout', $link); 158 else 159 return apply_filters('loginout', $link); 152 160 } 153 161 … … 281 289 * @param string $before Text to output before the link (defaults to <li>). 282 290 * @param string $after Text to output after the link (defaults to </li>). 283 */ 284 function wp_register( $before = '<li>', $after = '</li>' ) { 291 * @param boolean $echo Default to echo and not return the link. 292 */ 293 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) { 285 294 286 295 if ( ! is_user_logged_in() ) { … … 292 301 $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after; 293 302 } 294 295 echo apply_filters('register', $link); 303 304 if ( $echo ) 305 echo apply_filters('register', $link); 306 else 307 return apply_filters('register', $link); 296 308 } 297 309 … … 1002 1014 * 1003 1015 * @param bool $initial Optional, default is true. Use initial calendar names. 1004 */ 1005 function get_calendar($initial = true) { 1016 * @param bool $echo Optional, default is true. Set to false for return. 1017 */ 1018 function get_calendar($initial = true, $echo = true) { 1006 1019 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; 1007 1020 … … 1009 1022 $key = md5( $m . $monthnum . $year ); 1010 1023 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) { 1011 if ( is_array($cache) && isset( $cache[ $key ] ) ) { 1012 echo $cache[ $key ]; 1013 return; 1024 if ( is_array($cache) && isset( $cache[ $key ] ) ) { 1025 if ( $echo ) 1026 echo apply_filters( 'get_calendar', $cache[$key] ); 1027 else 1028 return apply_filters( 'get_calendar', $cache[$key] ); 1014 1029 } 1015 1030 } … … 1028 1043 } 1029 1044 1030 ob_start();1031 1045 if ( isset($_GET['w']) ) 1032 1046 $w = ''.intval($_GET['w']); … … 1074 1088 /* translators: Calendar caption: 1: month name, 2: 4-digit year */ 1075 1089 $calendar_caption = _x('%1$s %2$s', 'calendar caption'); 1076 echo '<table id="wp-calendar">1090 $calendar_output .= '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '"> 1077 1091 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> 1078 1092 <thead> … … 1088 1102 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 1089 1103 $wd = esc_attr($wd); 1090 echo"\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";1091 } 1092 1093 echo'1104 $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>"; 1105 } 1106 1107 $calendar_output .= ' 1094 1108 </tr> 1095 1109 </thead> … … 1099 1113 1100 1114 if ( $previous ) { 1101 echo "\n\t\t".'<td colspan="3" id="prev"><a href="' . 1102 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 1103 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; 1115 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; 1104 1116 } else { 1105 echo"\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';1106 } 1107 1108 echo"\n\t\t".'<td class="pad"> </td>';1117 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; 1118 } 1119 1120 $calendar_output .= "\n\t\t".'<td class="pad"> </td>'; 1109 1121 1110 1122 if ( $next ) { 1111 echo "\n\t\t".'<td colspan="3" id="next"><a href="' . 1112 get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month) , 1113 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>'; 1123 $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>'; 1114 1124 } else { 1115 echo"\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';1116 } 1117 1118 echo'1125 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; 1126 } 1127 1128 $calendar_output .= ' 1119 1129 </tr> 1120 1130 </tfoot> … … 1168 1178 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); 1169 1179 if ( 0 != $pad ) 1170 echo"\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';1180 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>'; 1171 1181 1172 1182 $daysinmonth = intval(date('t', $unixmonth)); 1173 1183 for ( $day = 1; $day <= $daysinmonth; ++$day ) { 1174 1184 if ( isset($newrow) && $newrow ) 1175 echo"\n\t</tr>\n\t<tr>\n\t\t";1185 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; 1176 1186 $newrow = false; 1177 1187 1178 1188 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) ) 1179 echo'<td id="today">';1189 $calendar_output .= '<td id="today">'; 1180 1190 else 1181 echo'<td>';1191 $calendar_output .= '<td>'; 1182 1192 1183 1193 if ( in_array($day, $daywithpost) ) // any posts today? 1184 echo'<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>";1194 $calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>"; 1185 1195 else 1186 echo$day;1187 echo'</td>';1196 $calendar_output .= $day; 1197 $calendar_output .= '</td>'; 1188 1198 1189 1199 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) … … 1193 1203 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); 1194 1204 if ( $pad != 0 && $pad != 7 ) 1195 echo "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>'; 1196 1197 echo "\n\t</tr>\n\t</tbody>\n\t</table>"; 1198 1199 $output = ob_get_contents(); 1200 ob_end_clean(); 1201 echo $output; 1205 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>'; 1206 1207 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; 1208 1202 1209 $cache[ $key ] = $output; 1203 1210 wp_cache_set( 'get_calendar', $cache, 'calendar' ); 1211 1212 if ( $echo ) 1213 echo apply_filters( 'get_calendar', $calendar_output ); 1214 else 1215 return apply_filters( 'get_calendar', $calendar_output ); 1216 1204 1217 } 1205 1218
Note: See TracChangeset
for help on using the changeset viewer.