Make WordPress Core

Ticket #11842: 11842.2.diff

File 11842.2.diff, 7.1 KB (added by ShaneF, 15 years ago)

removed 'ob_end_clean()'

  • general-template.php

     
    111111 * search. To give a few examples of what it can be used for.
    112112 *
    113113 * @since 2.7.0
     114 * @param boolean $echo Default to echo and not return the form.
    114115 */
    115 function get_search_form() {
     116function get_search_form($echo = true) {
    116117        do_action( 'get_search_form' );
    117118
    118119        $search_form_template = locate_template(array('searchform.php'));
     
    128129        </div>
    129130        </form>';
    130131
    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);
    132136}
    133137
    134138/**
     
    141145 * @uses apply_filters() Calls 'loginout' hook on HTML link content.
    142146 *
    143147 * @param string $redirect Optional path to redirect to on login/logout.
     148 * @param boolean $echo Default to echo and not return the link.
    144149 */
    145 function wp_loginout($redirect = '') {
     150function wp_loginout($redirect = '', $echo = true) {
    146151        if ( ! is_user_logged_in() )
    147152                $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
    148153        else
    149154                $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);
    152160}
    153161
    154162/**
     
    228236 *
    229237 * @param string $before Text to output before the link (defaults to <li>).
    230238 * @param string $after Text to output after the link (defaults to </li>).
     239 * @param boolean $echo Default to echo and not return the link.
    231240 */
    232 function wp_register( $before = '<li>', $after = '</li>' ) {
     241function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
    233242
    234243        if ( ! is_user_logged_in() ) {
    235244                if ( get_option('users_can_register') )
     
    239248        } else {
    240249                $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    241250        }
    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);
    244256}
    245257
    246258/**
     
    949961 * @since 1.0.0
    950962 *
    951963 * @param bool $initial Optional, default is true. Use initial calendar names.
     964 * @param bool $echo Optional, default is true. Set to false for return.
    952965 */
    953 function get_calendar($initial = true) {
     966function get_calendar($initial = true, $echo = true) {
    954967        global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
    955968
    956969        $cache = array();
     
    10211034
    10221035        /* translators: Calendar caption: 1: month name, 2: 4-digit year */
    10231036        $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') . '">
    10251038        <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
    10261039        <thead>
    10271040        <tr>';
     
    10351048        foreach ( $myweek as $wd ) {
    10361049                $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
    10371050                $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>";
    10391052        }
    10401053
    1041         echo '
     1054        $calendar_output .= '
    10421055        </tr>
    10431056        </thead>
    10441057
     
    10461059        <tr>';
    10471060
    10481061        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="' .
    10501063                get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
    10511064                        date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
    10521065        } else {
    1053                 echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
     1066                $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    10541067        }
    10551068
    1056         echo "\n\t\t".'<td class="pad">&nbsp;</td>';
     1069        $calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
    10571070
    10581071        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="' .
    10601073                get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month) ,
    10611074                        date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
    10621075        } else {
    1063                 echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
     1076                $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
    10641077        }
    10651078
    1066         echo '
     1079        $calendar_output .= '
    10671080        </tr>
    10681081        </tfoot>
    10691082
     
    11151128        // See how much we should pad in the beginning
    11161129        $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
    11171130        if ( 0 != $pad )
    1118                 echo "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
     1131                $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
    11191132
    11201133        $daysinmonth = intval(date('t', $unixmonth));
    11211134        for ( $day = 1; $day <= $daysinmonth; ++$day ) {
    11221135                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";
    11241137                $newrow = false;
    11251138
    11261139                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">';
    11281141                else
    1129                         echo '<td>';
     1142                        $calendar_output .= '<td>';
    11301143
    11311144                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>";
    11331146                else
    1134                         echo $day;
    1135                 echo '</td>';
     1147                        $calendar_output .= $day;
     1148                $calendar_output .= '</td>';
    11361149
    11371150                if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
    11381151                        $newrow = true;
     
    11401153
    11411154        $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
    11421155        if ( $pad != 0 && $pad != 7 )
    1143                 echo "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
     1156                $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
    11441157
    1145         echo "\n\t</tr>\n\t</tbody>\n\t</table>";
     1158        $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
    11461159
    1147         $output = ob_get_contents();
    1148         ob_end_clean();
    1149         echo $output;
    11501160        $cache[ $key ] = $output;
    11511161        wp_cache_set( 'get_calendar', $cache, 'calendar' );
     1162
     1163        if ( $echo )
     1164                echo $calendar_output;
     1165        else
     1166                return $calendar_output;
     1167
    11521168}
    11531169
    11541170/**