Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: general-template.php
'type' => 'monthly',
[2000] Fix | Delete
'limit' => '',
[2001] Fix | Delete
'format' => 'html',
[2002] Fix | Delete
'before' => '',
[2003] Fix | Delete
'after' => '',
[2004] Fix | Delete
'show_post_count' => false,
[2005] Fix | Delete
'echo' => 1,
[2006] Fix | Delete
'order' => 'DESC',
[2007] Fix | Delete
'post_type' => 'post',
[2008] Fix | Delete
'year' => get_query_var( 'year' ),
[2009] Fix | Delete
'monthnum' => get_query_var( 'monthnum' ),
[2010] Fix | Delete
'day' => get_query_var( 'day' ),
[2011] Fix | Delete
'w' => get_query_var( 'w' ),
[2012] Fix | Delete
);
[2013] Fix | Delete
[2014] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[2015] Fix | Delete
[2016] Fix | Delete
$post_type_object = get_post_type_object( $parsed_args['post_type'] );
[2017] Fix | Delete
if ( ! is_post_type_viewable( $post_type_object ) ) {
[2018] Fix | Delete
return;
[2019] Fix | Delete
}
[2020] Fix | Delete
[2021] Fix | Delete
$parsed_args['post_type'] = $post_type_object->name;
[2022] Fix | Delete
[2023] Fix | Delete
if ( '' === $parsed_args['type'] ) {
[2024] Fix | Delete
$parsed_args['type'] = 'monthly';
[2025] Fix | Delete
}
[2026] Fix | Delete
[2027] Fix | Delete
if ( ! empty( $parsed_args['limit'] ) ) {
[2028] Fix | Delete
$parsed_args['limit'] = absint( $parsed_args['limit'] );
[2029] Fix | Delete
$parsed_args['limit'] = ' LIMIT ' . $parsed_args['limit'];
[2030] Fix | Delete
}
[2031] Fix | Delete
[2032] Fix | Delete
$order = strtoupper( $parsed_args['order'] );
[2033] Fix | Delete
if ( 'ASC' !== $order ) {
[2034] Fix | Delete
$order = 'DESC';
[2035] Fix | Delete
}
[2036] Fix | Delete
[2037] Fix | Delete
// This is what will separate dates on weekly archive links.
[2038] Fix | Delete
$archive_week_separator = '–';
[2039] Fix | Delete
[2040] Fix | Delete
$sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] );
[2041] Fix | Delete
[2042] Fix | Delete
/**
[2043] Fix | Delete
* Filters the SQL WHERE clause for retrieving archives.
[2044] Fix | Delete
*
[2045] Fix | Delete
* @since 2.2.0
[2046] Fix | Delete
*
[2047] Fix | Delete
* @param string $sql_where Portion of SQL query containing the WHERE clause.
[2048] Fix | Delete
* @param array $parsed_args An array of default arguments.
[2049] Fix | Delete
*/
[2050] Fix | Delete
$where = apply_filters( 'getarchives_where', $sql_where, $parsed_args );
[2051] Fix | Delete
[2052] Fix | Delete
/**
[2053] Fix | Delete
* Filters the SQL JOIN clause for retrieving archives.
[2054] Fix | Delete
*
[2055] Fix | Delete
* @since 2.2.0
[2056] Fix | Delete
*
[2057] Fix | Delete
* @param string $sql_join Portion of SQL query containing JOIN clause.
[2058] Fix | Delete
* @param array $parsed_args An array of default arguments.
[2059] Fix | Delete
*/
[2060] Fix | Delete
$join = apply_filters( 'getarchives_join', '', $parsed_args );
[2061] Fix | Delete
[2062] Fix | Delete
$output = '';
[2063] Fix | Delete
[2064] Fix | Delete
$last_changed = wp_cache_get_last_changed( 'posts' );
[2065] Fix | Delete
[2066] Fix | Delete
$limit = $parsed_args['limit'];
[2067] Fix | Delete
[2068] Fix | Delete
if ( 'monthly' === $parsed_args['type'] ) {
[2069] Fix | Delete
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
[2070] Fix | Delete
$key = md5( $query );
[2071] Fix | Delete
$key = "wp_get_archives:$key:$last_changed";
[2072] Fix | Delete
$results = wp_cache_get( $key, 'post-queries' );
[2073] Fix | Delete
if ( ! $results ) {
[2074] Fix | Delete
$results = $wpdb->get_results( $query );
[2075] Fix | Delete
wp_cache_set( $key, $results, 'post-queries' );
[2076] Fix | Delete
}
[2077] Fix | Delete
if ( $results ) {
[2078] Fix | Delete
$after = $parsed_args['after'];
[2079] Fix | Delete
foreach ( (array) $results as $result ) {
[2080] Fix | Delete
$url = get_month_link( $result->year, $result->month );
[2081] Fix | Delete
if ( 'post' !== $parsed_args['post_type'] ) {
[2082] Fix | Delete
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
[2083] Fix | Delete
}
[2084] Fix | Delete
/* translators: 1: Month name, 2: 4-digit year. */
[2085] Fix | Delete
$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
[2086] Fix | Delete
if ( $parsed_args['show_post_count'] ) {
[2087] Fix | Delete
$parsed_args['after'] = ' (' . $result->posts . ')' . $after;
[2088] Fix | Delete
}
[2089] Fix | Delete
$selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month;
[2090] Fix | Delete
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
[2091] Fix | Delete
}
[2092] Fix | Delete
}
[2093] Fix | Delete
} elseif ( 'yearly' === $parsed_args['type'] ) {
[2094] Fix | Delete
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
[2095] Fix | Delete
$key = md5( $query );
[2096] Fix | Delete
$key = "wp_get_archives:$key:$last_changed";
[2097] Fix | Delete
$results = wp_cache_get( $key, 'post-queries' );
[2098] Fix | Delete
if ( ! $results ) {
[2099] Fix | Delete
$results = $wpdb->get_results( $query );
[2100] Fix | Delete
wp_cache_set( $key, $results, 'post-queries' );
[2101] Fix | Delete
}
[2102] Fix | Delete
if ( $results ) {
[2103] Fix | Delete
$after = $parsed_args['after'];
[2104] Fix | Delete
foreach ( (array) $results as $result ) {
[2105] Fix | Delete
$url = get_year_link( $result->year );
[2106] Fix | Delete
if ( 'post' !== $parsed_args['post_type'] ) {
[2107] Fix | Delete
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
[2108] Fix | Delete
}
[2109] Fix | Delete
$text = sprintf( '%d', $result->year );
[2110] Fix | Delete
if ( $parsed_args['show_post_count'] ) {
[2111] Fix | Delete
$parsed_args['after'] = ' (' . $result->posts . ')' . $after;
[2112] Fix | Delete
}
[2113] Fix | Delete
$selected = is_archive() && (string) $parsed_args['year'] === $result->year;
[2114] Fix | Delete
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
[2115] Fix | Delete
}
[2116] Fix | Delete
}
[2117] Fix | Delete
} elseif ( 'daily' === $parsed_args['type'] ) {
[2118] Fix | Delete
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
[2119] Fix | Delete
$key = md5( $query );
[2120] Fix | Delete
$key = "wp_get_archives:$key:$last_changed";
[2121] Fix | Delete
$results = wp_cache_get( $key, 'post-queries' );
[2122] Fix | Delete
if ( ! $results ) {
[2123] Fix | Delete
$results = $wpdb->get_results( $query );
[2124] Fix | Delete
wp_cache_set( $key, $results, 'post-queries' );
[2125] Fix | Delete
}
[2126] Fix | Delete
if ( $results ) {
[2127] Fix | Delete
$after = $parsed_args['after'];
[2128] Fix | Delete
foreach ( (array) $results as $result ) {
[2129] Fix | Delete
$url = get_day_link( $result->year, $result->month, $result->dayofmonth );
[2130] Fix | Delete
if ( 'post' !== $parsed_args['post_type'] ) {
[2131] Fix | Delete
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
[2132] Fix | Delete
}
[2133] Fix | Delete
$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
[2134] Fix | Delete
$text = mysql2date( get_option( 'date_format' ), $date );
[2135] Fix | Delete
if ( $parsed_args['show_post_count'] ) {
[2136] Fix | Delete
$parsed_args['after'] = ' (' . $result->posts . ')' . $after;
[2137] Fix | Delete
}
[2138] Fix | Delete
$selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month && (string) $parsed_args['day'] === $result->dayofmonth;
[2139] Fix | Delete
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
[2140] Fix | Delete
}
[2141] Fix | Delete
}
[2142] Fix | Delete
} elseif ( 'weekly' === $parsed_args['type'] ) {
[2143] Fix | Delete
$week = _wp_mysql_week( '`post_date`' );
[2144] Fix | Delete
$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
[2145] Fix | Delete
$key = md5( $query );
[2146] Fix | Delete
$key = "wp_get_archives:$key:$last_changed";
[2147] Fix | Delete
$results = wp_cache_get( $key, 'post-queries' );
[2148] Fix | Delete
if ( ! $results ) {
[2149] Fix | Delete
$results = $wpdb->get_results( $query );
[2150] Fix | Delete
wp_cache_set( $key, $results, 'post-queries' );
[2151] Fix | Delete
}
[2152] Fix | Delete
$arc_w_last = '';
[2153] Fix | Delete
if ( $results ) {
[2154] Fix | Delete
$after = $parsed_args['after'];
[2155] Fix | Delete
foreach ( (array) $results as $result ) {
[2156] Fix | Delete
if ( $result->week != $arc_w_last ) {
[2157] Fix | Delete
$arc_year = $result->yr;
[2158] Fix | Delete
$arc_w_last = $result->week;
[2159] Fix | Delete
$arc_week = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
[2160] Fix | Delete
$arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] );
[2161] Fix | Delete
$arc_week_end = date_i18n( get_option( 'date_format' ), $arc_week['end'] );
[2162] Fix | Delete
$url = add_query_arg(
[2163] Fix | Delete
array(
[2164] Fix | Delete
'm' => $arc_year,
[2165] Fix | Delete
'w' => $result->week,
[2166] Fix | Delete
),
[2167] Fix | Delete
home_url( '/' )
[2168] Fix | Delete
);
[2169] Fix | Delete
if ( 'post' !== $parsed_args['post_type'] ) {
[2170] Fix | Delete
$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
[2171] Fix | Delete
}
[2172] Fix | Delete
$text = $arc_week_start . $archive_week_separator . $arc_week_end;
[2173] Fix | Delete
if ( $parsed_args['show_post_count'] ) {
[2174] Fix | Delete
$parsed_args['after'] = ' (' . $result->posts . ')' . $after;
[2175] Fix | Delete
}
[2176] Fix | Delete
$selected = is_archive() && (string) $parsed_args['year'] === $result->yr && (string) $parsed_args['w'] === $result->week;
[2177] Fix | Delete
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
[2178] Fix | Delete
}
[2179] Fix | Delete
}
[2180] Fix | Delete
}
[2181] Fix | Delete
} elseif ( ( 'postbypost' === $parsed_args['type'] ) || ( 'alpha' === $parsed_args['type'] ) ) {
[2182] Fix | Delete
$orderby = ( 'alpha' === $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
[2183] Fix | Delete
$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
[2184] Fix | Delete
$key = md5( $query );
[2185] Fix | Delete
$key = "wp_get_archives:$key:$last_changed";
[2186] Fix | Delete
$results = wp_cache_get( $key, 'post-queries' );
[2187] Fix | Delete
if ( ! $results ) {
[2188] Fix | Delete
$results = $wpdb->get_results( $query );
[2189] Fix | Delete
wp_cache_set( $key, $results, 'post-queries' );
[2190] Fix | Delete
}
[2191] Fix | Delete
if ( $results ) {
[2192] Fix | Delete
foreach ( (array) $results as $result ) {
[2193] Fix | Delete
if ( '0000-00-00 00:00:00' !== $result->post_date ) {
[2194] Fix | Delete
$url = get_permalink( $result );
[2195] Fix | Delete
if ( $result->post_title ) {
[2196] Fix | Delete
/** This filter is documented in wp-includes/post-template.php */
[2197] Fix | Delete
$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
[2198] Fix | Delete
} else {
[2199] Fix | Delete
$text = $result->ID;
[2200] Fix | Delete
}
[2201] Fix | Delete
$selected = get_the_ID() === $result->ID;
[2202] Fix | Delete
$output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
[2203] Fix | Delete
}
[2204] Fix | Delete
}
[2205] Fix | Delete
}
[2206] Fix | Delete
}
[2207] Fix | Delete
[2208] Fix | Delete
if ( $parsed_args['echo'] ) {
[2209] Fix | Delete
echo $output;
[2210] Fix | Delete
} else {
[2211] Fix | Delete
return $output;
[2212] Fix | Delete
}
[2213] Fix | Delete
}
[2214] Fix | Delete
[2215] Fix | Delete
/**
[2216] Fix | Delete
* Gets number of days since the start of the week.
[2217] Fix | Delete
*
[2218] Fix | Delete
* @since 1.5.0
[2219] Fix | Delete
*
[2220] Fix | Delete
* @param int $num Number of day.
[2221] Fix | Delete
* @return float Days since the start of the week.
[2222] Fix | Delete
*/
[2223] Fix | Delete
function calendar_week_mod( $num ) {
[2224] Fix | Delete
$base = 7;
[2225] Fix | Delete
return ( $num - $base * floor( $num / $base ) );
[2226] Fix | Delete
}
[2227] Fix | Delete
[2228] Fix | Delete
/**
[2229] Fix | Delete
* Displays calendar with days that have posts as links.
[2230] Fix | Delete
*
[2231] Fix | Delete
* The calendar is cached, which will be retrieved, if it exists. If there are
[2232] Fix | Delete
* no posts for the month, then it will not be displayed.
[2233] Fix | Delete
*
[2234] Fix | Delete
* @since 1.0.0
[2235] Fix | Delete
*
[2236] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2237] Fix | Delete
* @global int $m
[2238] Fix | Delete
* @global int $monthnum
[2239] Fix | Delete
* @global int $year
[2240] Fix | Delete
* @global WP_Locale $wp_locale WordPress date and time locale object.
[2241] Fix | Delete
* @global array $posts
[2242] Fix | Delete
*
[2243] Fix | Delete
* @param bool $initial Optional. Whether to use initial calendar names. Default true.
[2244] Fix | Delete
* @param bool $display Optional. Whether to display the calendar output. Default true.
[2245] Fix | Delete
* @return void|string Void if `$display` argument is true, calendar HTML if `$display` is false.
[2246] Fix | Delete
*/
[2247] Fix | Delete
function get_calendar( $initial = true, $display = true ) {
[2248] Fix | Delete
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
[2249] Fix | Delete
[2250] Fix | Delete
$key = md5( $m . $monthnum . $year );
[2251] Fix | Delete
$cache = wp_cache_get( 'get_calendar', 'calendar' );
[2252] Fix | Delete
[2253] Fix | Delete
if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
[2254] Fix | Delete
/** This filter is documented in wp-includes/general-template.php */
[2255] Fix | Delete
$output = apply_filters( 'get_calendar', $cache[ $key ] );
[2256] Fix | Delete
[2257] Fix | Delete
if ( $display ) {
[2258] Fix | Delete
echo $output;
[2259] Fix | Delete
return;
[2260] Fix | Delete
}
[2261] Fix | Delete
[2262] Fix | Delete
return $output;
[2263] Fix | Delete
}
[2264] Fix | Delete
[2265] Fix | Delete
if ( ! is_array( $cache ) ) {
[2266] Fix | Delete
$cache = array();
[2267] Fix | Delete
}
[2268] Fix | Delete
[2269] Fix | Delete
// Quick check. If we have no posts at all, abort!
[2270] Fix | Delete
if ( ! $posts ) {
[2271] Fix | Delete
$gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
[2272] Fix | Delete
if ( ! $gotsome ) {
[2273] Fix | Delete
$cache[ $key ] = '';
[2274] Fix | Delete
wp_cache_set( 'get_calendar', $cache, 'calendar' );
[2275] Fix | Delete
return;
[2276] Fix | Delete
}
[2277] Fix | Delete
}
[2278] Fix | Delete
[2279] Fix | Delete
if ( isset( $_GET['w'] ) ) {
[2280] Fix | Delete
$w = (int) $_GET['w'];
[2281] Fix | Delete
}
[2282] Fix | Delete
// week_begins = 0 stands for Sunday.
[2283] Fix | Delete
$week_begins = (int) get_option( 'start_of_week' );
[2284] Fix | Delete
[2285] Fix | Delete
// Let's figure out when we are.
[2286] Fix | Delete
if ( ! empty( $monthnum ) && ! empty( $year ) ) {
[2287] Fix | Delete
$thismonth = zeroise( (int) $monthnum, 2 );
[2288] Fix | Delete
$thisyear = (int) $year;
[2289] Fix | Delete
} elseif ( ! empty( $w ) ) {
[2290] Fix | Delete
// We need to get the month from MySQL.
[2291] Fix | Delete
$thisyear = (int) substr( $m, 0, 4 );
[2292] Fix | Delete
// It seems MySQL's weeks disagree with PHP's.
[2293] Fix | Delete
$d = ( ( $w - 1 ) * 7 ) + 6;
[2294] Fix | Delete
$thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
[2295] Fix | Delete
} elseif ( ! empty( $m ) ) {
[2296] Fix | Delete
$thisyear = (int) substr( $m, 0, 4 );
[2297] Fix | Delete
if ( strlen( $m ) < 6 ) {
[2298] Fix | Delete
$thismonth = '01';
[2299] Fix | Delete
} else {
[2300] Fix | Delete
$thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
[2301] Fix | Delete
}
[2302] Fix | Delete
} else {
[2303] Fix | Delete
$thisyear = current_time( 'Y' );
[2304] Fix | Delete
$thismonth = current_time( 'm' );
[2305] Fix | Delete
}
[2306] Fix | Delete
[2307] Fix | Delete
$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
[2308] Fix | Delete
$last_day = gmdate( 't', $unixmonth );
[2309] Fix | Delete
[2310] Fix | Delete
// Get the next and previous month and year with at least one post.
[2311] Fix | Delete
$previous = $wpdb->get_row(
[2312] Fix | Delete
"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
[2313] Fix | Delete
FROM $wpdb->posts
[2314] Fix | Delete
WHERE post_date < '$thisyear-$thismonth-01'
[2315] Fix | Delete
AND post_type = 'post' AND post_status = 'publish'
[2316] Fix | Delete
ORDER BY post_date DESC
[2317] Fix | Delete
LIMIT 1"
[2318] Fix | Delete
);
[2319] Fix | Delete
$next = $wpdb->get_row(
[2320] Fix | Delete
"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
[2321] Fix | Delete
FROM $wpdb->posts
[2322] Fix | Delete
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
[2323] Fix | Delete
AND post_type = 'post' AND post_status = 'publish'
[2324] Fix | Delete
ORDER BY post_date ASC
[2325] Fix | Delete
LIMIT 1"
[2326] Fix | Delete
);
[2327] Fix | Delete
[2328] Fix | Delete
/* translators: Calendar caption: 1: Month name, 2: 4-digit year. */
[2329] Fix | Delete
$calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
[2330] Fix | Delete
$calendar_output = '<table id="wp-calendar" class="wp-calendar-table">
[2331] Fix | Delete
<caption>' . sprintf(
[2332] Fix | Delete
$calendar_caption,
[2333] Fix | Delete
$wp_locale->get_month( $thismonth ),
[2334] Fix | Delete
gmdate( 'Y', $unixmonth )
[2335] Fix | Delete
) . '</caption>
[2336] Fix | Delete
<thead>
[2337] Fix | Delete
<tr>';
[2338] Fix | Delete
[2339] Fix | Delete
$myweek = array();
[2340] Fix | Delete
[2341] Fix | Delete
for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) {
[2342] Fix | Delete
$myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 );
[2343] Fix | Delete
}
[2344] Fix | Delete
[2345] Fix | Delete
foreach ( $myweek as $wd ) {
[2346] Fix | Delete
$day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
[2347] Fix | Delete
$wd = esc_attr( $wd );
[2348] Fix | Delete
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
[2349] Fix | Delete
}
[2350] Fix | Delete
[2351] Fix | Delete
$calendar_output .= '
[2352] Fix | Delete
</tr>
[2353] Fix | Delete
</thead>
[2354] Fix | Delete
<tbody>
[2355] Fix | Delete
<tr>';
[2356] Fix | Delete
[2357] Fix | Delete
$daywithpost = array();
[2358] Fix | Delete
[2359] Fix | Delete
// Get days with posts.
[2360] Fix | Delete
$dayswithposts = $wpdb->get_results(
[2361] Fix | Delete
"SELECT DISTINCT DAYOFMONTH(post_date)
[2362] Fix | Delete
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
[2363] Fix | Delete
AND post_type = 'post' AND post_status = 'publish'
[2364] Fix | Delete
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'",
[2365] Fix | Delete
ARRAY_N
[2366] Fix | Delete
);
[2367] Fix | Delete
[2368] Fix | Delete
if ( $dayswithposts ) {
[2369] Fix | Delete
foreach ( (array) $dayswithposts as $daywith ) {
[2370] Fix | Delete
$daywithpost[] = (int) $daywith[0];
[2371] Fix | Delete
}
[2372] Fix | Delete
}
[2373] Fix | Delete
[2374] Fix | Delete
// See how much we should pad in the beginning.
[2375] Fix | Delete
$pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins );
[2376] Fix | Delete
if ( 0 != $pad ) {
[2377] Fix | Delete
$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad">&nbsp;</td>';
[2378] Fix | Delete
}
[2379] Fix | Delete
[2380] Fix | Delete
$newrow = false;
[2381] Fix | Delete
$daysinmonth = (int) gmdate( 't', $unixmonth );
[2382] Fix | Delete
[2383] Fix | Delete
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
[2384] Fix | Delete
if ( isset( $newrow ) && $newrow ) {
[2385] Fix | Delete
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
[2386] Fix | Delete
}
[2387] Fix | Delete
$newrow = false;
[2388] Fix | Delete
[2389] Fix | Delete
if ( current_time( 'j' ) == $day &&
[2390] Fix | Delete
current_time( 'm' ) == $thismonth &&
[2391] Fix | Delete
current_time( 'Y' ) == $thisyear ) {
[2392] Fix | Delete
$calendar_output .= '<td id="today">';
[2393] Fix | Delete
} else {
[2394] Fix | Delete
$calendar_output .= '<td>';
[2395] Fix | Delete
}
[2396] Fix | Delete
[2397] Fix | Delete
if ( in_array( $day, $daywithpost, true ) ) {
[2398] Fix | Delete
// Any posts today?
[2399] Fix | Delete
$date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
[2400] Fix | Delete
/* translators: Post calendar label. %s: Date. */
[2401] Fix | Delete
$label = sprintf( __( 'Posts published on %s' ), $date_format );
[2402] Fix | Delete
$calendar_output .= sprintf(
[2403] Fix | Delete
'<a href="%s" aria-label="%s">%s</a>',
[2404] Fix | Delete
get_day_link( $thisyear, $thismonth, $day ),
[2405] Fix | Delete
esc_attr( $label ),
[2406] Fix | Delete
$day
[2407] Fix | Delete
);
[2408] Fix | Delete
} else {
[2409] Fix | Delete
$calendar_output .= $day;
[2410] Fix | Delete
}
[2411] Fix | Delete
[2412] Fix | Delete
$calendar_output .= '</td>';
[2413] Fix | Delete
[2414] Fix | Delete
if ( 6 == calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
[2415] Fix | Delete
$newrow = true;
[2416] Fix | Delete
}
[2417] Fix | Delete
}
[2418] Fix | Delete
[2419] Fix | Delete
$pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
[2420] Fix | Delete
if ( 0 != $pad && 7 != $pad ) {
[2421] Fix | Delete
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
[2422] Fix | Delete
}
[2423] Fix | Delete
[2424] Fix | Delete
$calendar_output .= "\n\t</tr>\n\t</tbody>";
[2425] Fix | Delete
[2426] Fix | Delete
$calendar_output .= "\n\t</table>";
[2427] Fix | Delete
[2428] Fix | Delete
$calendar_output .= '<nav aria-label="' . __( 'Previous and next months' ) . '" class="wp-calendar-nav">';
[2429] Fix | Delete
[2430] Fix | Delete
if ( $previous ) {
[2431] Fix | Delete
$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
[2432] Fix | Delete
$wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
[2433] Fix | Delete
'</a></span>';
[2434] Fix | Delete
} else {
[2435] Fix | Delete
$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev">&nbsp;</span>';
[2436] Fix | Delete
}
[2437] Fix | Delete
[2438] Fix | Delete
$calendar_output .= "\n\t\t" . '<span class="pad">&nbsp;</span>';
[2439] Fix | Delete
[2440] Fix | Delete
if ( $next ) {
[2441] Fix | Delete
$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
[2442] Fix | Delete
$wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
[2443] Fix | Delete
' &raquo;</a></span>';
[2444] Fix | Delete
} else {
[2445] Fix | Delete
$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next">&nbsp;</span>';
[2446] Fix | Delete
}
[2447] Fix | Delete
[2448] Fix | Delete
$calendar_output .= '
[2449] Fix | Delete
</nav>';
[2450] Fix | Delete
[2451] Fix | Delete
$cache[ $key ] = $calendar_output;
[2452] Fix | Delete
wp_cache_set( 'get_calendar', $cache, 'calendar' );
[2453] Fix | Delete
[2454] Fix | Delete
if ( $display ) {
[2455] Fix | Delete
/**
[2456] Fix | Delete
* Filters the HTML calendar output.
[2457] Fix | Delete
*
[2458] Fix | Delete
* @since 3.0.0
[2459] Fix | Delete
*
[2460] Fix | Delete
* @param string $calendar_output HTML output of the calendar.
[2461] Fix | Delete
*/
[2462] Fix | Delete
echo apply_filters( 'get_calendar', $calendar_output );
[2463] Fix | Delete
return;
[2464] Fix | Delete
}
[2465] Fix | Delete
/** This filter is documented in wp-includes/general-template.php */
[2466] Fix | Delete
return apply_filters( 'get_calendar', $calendar_output );
[2467] Fix | Delete
}
[2468] Fix | Delete
[2469] Fix | Delete
/**
[2470] Fix | Delete
* Purges the cached results of get_calendar.
[2471] Fix | Delete
*
[2472] Fix | Delete
* @see get_calendar()
[2473] Fix | Delete
* @since 2.1.0
[2474] Fix | Delete
*/
[2475] Fix | Delete
function delete_get_calendar_cache() {
[2476] Fix | Delete
wp_cache_delete( 'get_calendar', 'calendar' );
[2477] Fix | Delete
}
[2478] Fix | Delete
[2479] Fix | Delete
/**
[2480] Fix | Delete
* Displays all of the allowed tags in HTML format with attributes.
[2481] Fix | Delete
*
[2482] Fix | Delete
* This is useful for displaying in the comment area, which elements and
[2483] Fix | Delete
* attributes are supported. As well as any plugins which want to display it.
[2484] Fix | Delete
*
[2485] Fix | Delete
* @since 1.0.1
[2486] Fix | Delete
* @since 4.4.0 No longer used in core.
[2487] Fix | Delete
*
[2488] Fix | Delete
* @global array $allowedtags
[2489] Fix | Delete
*
[2490] Fix | Delete
* @return string HTML allowed tags entity encoded.
[2491] Fix | Delete
*/
[2492] Fix | Delete
function allowed_tags() {
[2493] Fix | Delete
global $allowedtags;
[2494] Fix | Delete
$allowed = '';
[2495] Fix | Delete
foreach ( (array) $allowedtags as $tag => $attributes ) {
[2496] Fix | Delete
$allowed .= '<' . $tag;
[2497] Fix | Delete
if ( 0 < count( $attributes ) ) {
[2498] Fix | Delete
foreach ( $attributes as $attribute => $limits ) {
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function