Ticket #11842: 11842.3.diff
File 11842.3.diff, 7.3 KB (added by , 15 years ago) |
---|
-
general-template.php
111 111 * search. To give a few examples of what it can be used for. 112 112 * 113 113 * @since 2.7.0 114 * @param boolean $echo Default to echo and not return the form. 114 115 */ 115 function get_search_form( ) {116 function get_search_form($echo = true) { 116 117 do_action( 'get_search_form' ); 117 118 118 119 $search_form_template = locate_template(array('searchform.php')); … … 128 129 </div> 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 134 138 /** … … 141 145 * @uses apply_filters() Calls 'loginout' hook on HTML link content. 142 146 * 143 147 * @param string $redirect Optional path to redirect to on login/logout. 148 * @param boolean $echo Default to echo and not return the link. 144 149 */ 145 function wp_loginout($redirect = '' ) {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 154 162 /** … … 228 236 * 229 237 * @param string $before Text to output before the link (defaults to <li>). 230 238 * @param string $after Text to output after the link (defaults to </li>). 239 * @param boolean $echo Default to echo and not return the link. 231 240 */ 232 function wp_register( $before = '<li>', $after = '</li>' ) {241 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) { 233 242 234 243 if ( ! is_user_logged_in() ) { 235 244 if ( get_option('users_can_register') ) … … 239 248 } else { 240 249 $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after; 241 250 } 242 243 echo apply_filters('register', $link); 251 252 if ( $echo ) 253 echo apply_filters('register', $link); 254 else 255 return apply_filters('register', $link); 244 256 } 245 257 246 258 /** … … 949 961 * @since 1.0.0 950 962 * 951 963 * @param bool $initial Optional, default is true. Use initial calendar names. 964 * @param bool $echo Optional, default is true. Set to false for return. 952 965 */ 953 function get_calendar($initial = true ) {966 function get_calendar($initial = true, $echo = true) { 954 967 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; 955 968 956 969 $cache = array(); … … 975 988 } 976 989 } 977 990 978 ob_start();979 991 if ( isset($_GET['w']) ) 980 992 $w = ''.intval($_GET['w']); 981 993 … … 1021 1033 1022 1034 /* translators: Calendar caption: 1: month name, 2: 4-digit year */ 1023 1035 $calendar_caption = _x('%1$s %2$s', 'calendar caption'); 1024 echo'<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">1036 $calendar_output .= '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '"> 1025 1037 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> 1026 1038 <thead> 1027 1039 <tr>'; … … 1035 1047 foreach ( $myweek as $wd ) { 1036 1048 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 1037 1049 $wd = esc_attr($wd); 1038 echo"\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";1050 $calendar_output .= "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 1039 1051 } 1040 1052 1041 echo'1053 $calendar_output .= ' 1042 1054 </tr> 1043 1055 </thead> 1044 1056 … … 1046 1058 <tr>'; 1047 1059 1048 1060 if ( $previous ) { 1049 echo"\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .1061 $calendar_output .= "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . 1050 1062 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 1051 1063 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; 1052 1064 } else { 1053 echo"\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';1065 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; 1054 1066 } 1055 1067 1056 echo"\n\t\t".'<td class="pad"> </td>';1068 $calendar_output .= "\n\t\t".'<td class="pad"> </td>'; 1057 1069 1058 1070 if ( $next ) { 1059 echo"\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .1071 $calendar_output .= "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . 1060 1072 get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month) , 1061 1073 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>'; 1062 1074 } else { 1063 echo"\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';1075 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; 1064 1076 } 1065 1077 1066 echo'1078 $calendar_output .= ' 1067 1079 </tr> 1068 1080 </tfoot> 1069 1081 … … 1115 1127 // See how much we should pad in the beginning 1116 1128 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); 1117 1129 if ( 0 != $pad ) 1118 echo"\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';1130 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>'; 1119 1131 1120 1132 $daysinmonth = intval(date('t', $unixmonth)); 1121 1133 for ( $day = 1; $day <= $daysinmonth; ++$day ) { 1122 1134 if ( isset($newrow) && $newrow ) 1123 echo"\n\t</tr>\n\t<tr>\n\t\t";1135 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; 1124 1136 $newrow = false; 1125 1137 1126 1138 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) ) 1127 echo'<td id="today">';1139 $calendar_output .= '<td id="today">'; 1128 1140 else 1129 echo'<td>';1141 $calendar_output .= '<td>'; 1130 1142 1131 1143 if ( in_array($day, $daywithpost) ) // any posts today? 1132 echo'<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>";1144 $calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>"; 1133 1145 else 1134 echo$day;1135 echo'</td>';1146 $calendar_output .= $day; 1147 $calendar_output .= '</td>'; 1136 1148 1137 1149 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) 1138 1150 $newrow = true; … … 1140 1152 1141 1153 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); 1142 1154 if ( $pad != 0 && $pad != 7 ) 1143 echo"\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';1155 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>'; 1144 1156 1145 echo"\n\t</tr>\n\t</tbody>\n\t</table>";1157 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; 1146 1158 1147 $output = ob_get_contents();1148 ob_end_clean();1149 echo $output;1150 1159 $cache[ $key ] = $output; 1151 1160 wp_cache_set( 'get_calendar', $cache, 'calendar' ); 1161 1162 if ( $echo ) 1163 echo apply_filters( 'get_calendar', $calendar_output ); 1164 else 1165 return apply_filters( 'get_calendar', $calendar_output ); 1166 1152 1167 } 1153 1168 1154 1169 /**