Ticket #11842: 11842.2.diff
File 11842.2.diff, 7.1 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(); … … 1021 1034 1022 1035 /* translators: Calendar caption: 1: month name, 2: 4-digit year */ 1023 1036 $calendar_caption = _x('%1$s %2$s', 'calendar caption'); 1024 echo'<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">1037 $calendar_output .= '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '"> 1025 1038 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> 1026 1039 <thead> 1027 1040 <tr>'; … … 1035 1048 foreach ( $myweek as $wd ) { 1036 1049 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 1037 1050 $wd = esc_attr($wd); 1038 echo"\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";1051 $calendar_output .= "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 1039 1052 } 1040 1053 1041 echo'1054 $calendar_output .= ' 1042 1055 </tr> 1043 1056 </thead> 1044 1057 … … 1046 1059 <tr>'; 1047 1060 1048 1061 if ( $previous ) { 1049 echo"\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .1062 $calendar_output .= "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . 1050 1063 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 1051 1064 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 1065 } else { 1053 echo"\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';1066 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; 1054 1067 } 1055 1068 1056 echo"\n\t\t".'<td class="pad"> </td>';1069 $calendar_output .= "\n\t\t".'<td class="pad"> </td>'; 1057 1070 1058 1071 if ( $next ) { 1059 echo"\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .1072 $calendar_output .= "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . 1060 1073 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 1074 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 1075 } else { 1063 echo"\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';1076 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; 1064 1077 } 1065 1078 1066 echo'1079 $calendar_output .= ' 1067 1080 </tr> 1068 1081 </tfoot> 1069 1082 … … 1115 1128 // See how much we should pad in the beginning 1116 1129 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); 1117 1130 if ( 0 != $pad ) 1118 echo"\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';1131 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>'; 1119 1132 1120 1133 $daysinmonth = intval(date('t', $unixmonth)); 1121 1134 for ( $day = 1; $day <= $daysinmonth; ++$day ) { 1122 1135 if ( isset($newrow) && $newrow ) 1123 echo"\n\t</tr>\n\t<tr>\n\t\t";1136 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; 1124 1137 $newrow = false; 1125 1138 1126 1139 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) ) 1127 echo'<td id="today">';1140 $calendar_output .= '<td id="today">'; 1128 1141 else 1129 echo'<td>';1142 $calendar_output .= '<td>'; 1130 1143 1131 1144 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>";1145 $calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>"; 1133 1146 else 1134 echo$day;1135 echo'</td>';1147 $calendar_output .= $day; 1148 $calendar_output .= '</td>'; 1136 1149 1137 1150 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) 1138 1151 $newrow = true; … … 1140 1153 1141 1154 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); 1142 1155 if ( $pad != 0 && $pad != 7 ) 1143 echo"\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';1156 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>'; 1144 1157 1145 echo"\n\t</tr>\n\t</tbody>\n\t</table>";1158 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; 1146 1159 1147 $output = ob_get_contents();1148 ob_end_clean();1149 echo $output;1150 1160 $cache[ $key ] = $output; 1151 1161 wp_cache_set( 'get_calendar', $cache, 'calendar' ); 1162 1163 if ( $echo ) 1164 echo $calendar_output; 1165 else 1166 return $calendar_output; 1167 1152 1168 } 1153 1169 1154 1170 /**