raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * General template tags that can go anywhere in a template.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Template
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /**
mp-wp_genesis 10 * Load header template.
mp-wp_genesis 11 *
mp-wp_genesis 12 * Includes the header template for a theme or if a name is specified then a
mp-wp_genesis 13 * specialised header will be included. If the theme contains no header.php file
mp-wp_genesis 14 * then the header from the default theme will be included.
mp-wp_genesis 15 *
mp-wp_genesis 16 * For the parameter, if the file is called "header-special.php" then specify
mp-wp_genesis 17 * "special".
mp-wp_genesis 18 *
mp-wp_genesis 19 * @uses locate_template()
mp-wp_genesis 20 * @since 1.5.0
mp-wp_genesis 21 * @uses do_action() Calls 'get_header' action.
mp-wp_genesis 22 *
mp-wp_genesis 23 * @param string $name The name of the specialised header.
mp-wp_genesis 24 */
mp-wp_genesis 25 function get_header( $name = null ) {
mp-wp_genesis 26 do_action( 'get_header' );
mp-wp_genesis 27
mp-wp_genesis 28 $templates = array();
mp-wp_genesis 29 if ( isset($name) )
mp-wp_genesis 30 $templates[] = "header-{$name}.php";
mp-wp_genesis 31
mp-wp_genesis 32 $templates[] = "header.php";
mp-wp_genesis 33
mp-wp_genesis 34 if ('' == locate_template($templates, true))
mp-wp_genesis 35 load_template( get_theme_root() . '/default/header.php');
mp-wp_genesis 36 }
mp-wp_genesis 37
mp-wp_genesis 38 /**
mp-wp_genesis 39 * Load footer template.
mp-wp_genesis 40 *
mp-wp_genesis 41 * Includes the footer template for a theme or if a name is specified then a
mp-wp_genesis 42 * specialised footer will be included. If the theme contains no footer.php file
mp-wp_genesis 43 * then the footer from the default theme will be included.
mp-wp_genesis 44 *
mp-wp_genesis 45 * For the parameter, if the file is called "footer-special.php" then specify
mp-wp_genesis 46 * "special".
mp-wp_genesis 47 *
mp-wp_genesis 48 * @uses locate_template()
mp-wp_genesis 49 * @since 1.5.0
mp-wp_genesis 50 * @uses do_action() Calls 'get_footer' action.
mp-wp_genesis 51 *
mp-wp_genesis 52 * @param string $name The name of the specialised footer.
mp-wp_genesis 53 */
mp-wp_genesis 54 function get_footer( $name = null ) {
mp-wp_genesis 55 do_action( 'get_footer' );
mp-wp_genesis 56
mp-wp_genesis 57 $templates = array();
mp-wp_genesis 58 if ( isset($name) )
mp-wp_genesis 59 $templates[] = "footer-{$name}.php";
mp-wp_genesis 60
mp-wp_genesis 61 $templates[] = "footer.php";
mp-wp_genesis 62
mp-wp_genesis 63 if ('' == locate_template($templates, true))
mp-wp_genesis 64 load_template( get_theme_root() . '/default/footer.php');
mp-wp_genesis 65 }
mp-wp_genesis 66
mp-wp_genesis 67 /**
mp-wp_genesis 68 * Load sidebar template.
mp-wp_genesis 69 *
mp-wp_genesis 70 * Includes the sidebar template for a theme or if a name is specified then a
mp-wp_genesis 71 * specialised sidebar will be included. If the theme contains no sidebar.php
mp-wp_genesis 72 * file then the sidebar from the default theme will be included.
mp-wp_genesis 73 *
mp-wp_genesis 74 * For the parameter, if the file is called "sidebar-special.php" then specify
mp-wp_genesis 75 * "special".
mp-wp_genesis 76 *
mp-wp_genesis 77 * @uses locate_template()
mp-wp_genesis 78 * @since 1.5.0
mp-wp_genesis 79 * @uses do_action() Calls 'get_sidebar' action.
mp-wp_genesis 80 *
mp-wp_genesis 81 * @param string $name The name of the specialised sidebar.
mp-wp_genesis 82 */
mp-wp_genesis 83 function get_sidebar( $name = null ) {
mp-wp_genesis 84 do_action( 'get_sidebar' );
mp-wp_genesis 85
mp-wp_genesis 86 $templates = array();
mp-wp_genesis 87 if ( isset($name) )
mp-wp_genesis 88 $templates[] = "sidebar-{$name}.php";
mp-wp_genesis 89
mp-wp_genesis 90 $templates[] = "sidebar.php";
mp-wp_genesis 91
mp-wp_genesis 92 if ('' == locate_template($templates, true))
mp-wp_genesis 93 load_template( get_theme_root() . '/default/sidebar.php');
mp-wp_genesis 94 }
mp-wp_genesis 95
mp-wp_genesis 96 /**
mp-wp_genesis 97 * Display search form.
mp-wp_genesis 98 *
mp-wp_genesis 99 * Will first attempt to locate the searchform.php file in either the child or
mp-wp_genesis 100 * the parent, then load it. If it doesn't exist, then the default search form
mp-wp_genesis 101 * will be displayed.
mp-wp_genesis 102 *
mp-wp_genesis 103 * @since 2.7.0
mp-wp_genesis 104 */
mp-wp_genesis 105 function get_search_form() {
mp-wp_genesis 106 do_action( 'get_search_form' );
mp-wp_genesis 107
mp-wp_genesis 108 if ( '' != locate_template(array('searchform.php'), true) )
mp-wp_genesis 109 return;
mp-wp_genesis 110
mp-wp_genesis 111 $form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
mp-wp_genesis 112 <label class="hidden" for="s">' . __('Search for:') . '</label>
mp-wp_genesis 113 <div><input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
mp-wp_genesis 114 <input type="submit" id="searchsubmit" value="'.attribute_escape(__('Search')).'" />
mp-wp_genesis 115 </div>
mp-wp_genesis 116 </form>';
mp-wp_genesis 117
mp-wp_genesis 118 echo apply_filters('get_search_form', $form);
mp-wp_genesis 119 }
mp-wp_genesis 120
mp-wp_genesis 121 /**
mp-wp_genesis 122 * Display the Log In/Out link.
mp-wp_genesis 123 *
mp-wp_genesis 124 * Displays a link, which allows the user to navigate to the Log In page to log in
mp-wp_genesis 125 * or log out depending on whether or not they are currently logged in.
mp-wp_genesis 126 *
mp-wp_genesis 127 * @since 1.5.0
mp-wp_genesis 128 * @uses apply_filters() Calls 'loginout' hook on HTML link content.
mp-wp_genesis 129 */
mp-wp_genesis 130 function wp_loginout() {
mp-wp_genesis 131 if ( ! is_user_logged_in() )
mp-wp_genesis 132 $link = '<a href="' . wp_login_url() . '">' . __('Log in') . '</a>';
mp-wp_genesis 133 else
mp-wp_genesis 134 $link = '<a href="' . wp_logout_url() . '">' . __('Log out') . '</a>';
mp-wp_genesis 135
mp-wp_genesis 136 echo apply_filters('loginout', $link);
mp-wp_genesis 137 }
mp-wp_genesis 138
mp-wp_genesis 139 /**
mp-wp_genesis 140 * Returns the Log Out URL.
mp-wp_genesis 141 *
mp-wp_genesis 142 * Returns the URL that allows the user to log out of the site
mp-wp_genesis 143 *
mp-wp_genesis 144 * @since 2.7
mp-wp_genesis 145 * @uses wp_nonce_url() To protect against CSRF
mp-wp_genesis 146 * @uses site_url() To generate the log in URL
mp-wp_genesis 147 *
mp-wp_genesis 148 * @param string $redirect Path to redirect to on logout.
mp-wp_genesis 149 */
mp-wp_genesis 150 function wp_logout_url($redirect = '') {
mp-wp_genesis 151 if ( strlen($redirect) )
mp-wp_genesis 152 $redirect = "&redirect_to=$redirect";
mp-wp_genesis 153
mp-wp_genesis 154 return wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' );
mp-wp_genesis 155 }
mp-wp_genesis 156
mp-wp_genesis 157 /**
mp-wp_genesis 158 * Returns the Log In URL.
mp-wp_genesis 159 *
mp-wp_genesis 160 * Returns the URL that allows the user to log in to the site
mp-wp_genesis 161 *
mp-wp_genesis 162 * @since 2.7
mp-wp_genesis 163 * @uses site_url() To generate the log in URL
mp-wp_genesis 164 *
mp-wp_genesis 165 * @param string $redirect Path to redirect to on login.
mp-wp_genesis 166 */
mp-wp_genesis 167 function wp_login_url($redirect = '') {
mp-wp_genesis 168 if ( strlen($redirect) )
mp-wp_genesis 169 $redirect = "?redirect_to=$redirect";
mp-wp_genesis 170
mp-wp_genesis 171 return site_url("wp-login.php$redirect", 'login');
mp-wp_genesis 172 }
mp-wp_genesis 173
mp-wp_genesis 174 /**
mp-wp_genesis 175 * Display the Registration or Admin link.
mp-wp_genesis 176 *
mp-wp_genesis 177 * Display a link which allows the user to navigate to the registration page if
mp-wp_genesis 178 * not logged in and registration is enabled or to the dashboard if logged in.
mp-wp_genesis 179 *
mp-wp_genesis 180 * @since 1.5.0
mp-wp_genesis 181 * @uses apply_filters() Calls 'register' hook on register / admin link content.
mp-wp_genesis 182 *
mp-wp_genesis 183 * @param string $before Text to output before the link (defaults to <li>).
mp-wp_genesis 184 * @param string $after Text to output after the link (defaults to </li>).
mp-wp_genesis 185 */
mp-wp_genesis 186 function wp_register( $before = '<li>', $after = '</li>' ) {
mp-wp_genesis 187
mp-wp_genesis 188 if ( ! is_user_logged_in() ) {
mp-wp_genesis 189 if ( get_option('users_can_register') )
mp-wp_genesis 190 $link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
mp-wp_genesis 191 else
mp-wp_genesis 192 $link = '';
mp-wp_genesis 193 } else {
mp-wp_genesis 194 $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
mp-wp_genesis 195 }
mp-wp_genesis 196
mp-wp_genesis 197 echo apply_filters('register', $link);
mp-wp_genesis 198 }
mp-wp_genesis 199
mp-wp_genesis 200 /**
mp-wp_genesis 201 * Theme container function for the 'wp_meta' action.
mp-wp_genesis 202 *
mp-wp_genesis 203 * The 'wp_meta' action can have several purposes, depending on how you use it,
mp-wp_genesis 204 * but one purpose might have been to allow for theme switching.
mp-wp_genesis 205 *
mp-wp_genesis 206 * @since 1.5.0
mp-wp_genesis 207 * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
mp-wp_genesis 208 * @uses do_action() Calls 'wp_meta' hook.
mp-wp_genesis 209 */
mp-wp_genesis 210 function wp_meta() {
mp-wp_genesis 211 do_action('wp_meta');
mp-wp_genesis 212 }
mp-wp_genesis 213
mp-wp_genesis 214 /**
mp-wp_genesis 215 * Display information about the blog.
mp-wp_genesis 216 *
mp-wp_genesis 217 * @see get_bloginfo() For possible values for the parameter.
mp-wp_genesis 218 * @since 0.71
mp-wp_genesis 219 *
mp-wp_genesis 220 * @param string $show What to display.
mp-wp_genesis 221 */
mp-wp_genesis 222 function bloginfo($show='') {
mp-wp_genesis 223 echo get_bloginfo($show, 'display');
mp-wp_genesis 224 }
mp-wp_genesis 225
mp-wp_genesis 226 /**
mp-wp_genesis 227 * Retrieve information about the blog.
mp-wp_genesis 228 *
mp-wp_genesis 229 * Some show parameter values are deprecated and will be removed in future
mp-wp_genesis 230 * versions. Care should be taken to check the function contents and know what
mp-wp_genesis 231 * the deprecated blog info options are. Options without "// DEPRECATED" are
mp-wp_genesis 232 * the preferred and recommended ways to get the information.
mp-wp_genesis 233 *
mp-wp_genesis 234 * The possible values for the 'show' parameter are listed below.
mp-wp_genesis 235 * <ol>
mp-wp_genesis 236 * <li><strong>url<strong> - Blog URI to homepage.</li>
mp-wp_genesis 237 * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li>
mp-wp_genesis 238 * <li><strong>description</strong> - Secondary title</li>
mp-wp_genesis 239 * </ol>
mp-wp_genesis 240 *
mp-wp_genesis 241 * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
mp-wp_genesis 242 * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
mp-wp_genesis 243 * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
mp-wp_genesis 244 * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
mp-wp_genesis 245 *
mp-wp_genesis 246 * There are many other options and you should check the function contents:
mp-wp_genesis 247 * {@source 32 37}
mp-wp_genesis 248 *
mp-wp_genesis 249 * @since 0.71
mp-wp_genesis 250 *
mp-wp_genesis 251 * @param string $show Blog info to retrieve.
mp-wp_genesis 252 * @param string $filter How to filter what is retrieved.
mp-wp_genesis 253 * @return string Mostly string values, might be empty.
mp-wp_genesis 254 */
mp-wp_genesis 255 function get_bloginfo($show = '', $filter = 'raw') {
mp-wp_genesis 256
mp-wp_genesis 257 switch($show) {
mp-wp_genesis 258 case 'url' :
mp-wp_genesis 259 case 'home' : // DEPRECATED
mp-wp_genesis 260 case 'siteurl' : // DEPRECATED
mp-wp_genesis 261 $output = get_option('home');
mp-wp_genesis 262 break;
mp-wp_genesis 263 case 'wpurl' :
mp-wp_genesis 264 $output = get_option('siteurl');
mp-wp_genesis 265 break;
mp-wp_genesis 266 case 'description':
mp-wp_genesis 267 $output = get_option('blogdescription');
mp-wp_genesis 268 break;
mp-wp_genesis 269 case 'rdf_url':
mp-wp_genesis 270 $output = get_feed_link('rdf');
mp-wp_genesis 271 break;
mp-wp_genesis 272 case 'rss_url':
mp-wp_genesis 273 $output = get_feed_link('rss');
mp-wp_genesis 274 break;
mp-wp_genesis 275 case 'rss2_url':
mp-wp_genesis 276 $output = get_feed_link('rss2');
mp-wp_genesis 277 break;
mp-wp_genesis 278 case 'atom_url':
mp-wp_genesis 279 $output = get_feed_link('atom');
mp-wp_genesis 280 break;
mp-wp_genesis 281 case 'comments_atom_url':
mp-wp_genesis 282 $output = get_feed_link('comments_atom');
mp-wp_genesis 283 break;
mp-wp_genesis 284 case 'comments_rss2_url':
mp-wp_genesis 285 $output = get_feed_link('comments_rss2');
mp-wp_genesis 286 break;
mp-wp_genesis 287 case 'pingback_url':
mp-wp_genesis 288 $output = get_option('siteurl') .'/xmlrpc.php';
mp-wp_genesis 289 break;
mp-wp_genesis 290 case 'stylesheet_url':
mp-wp_genesis 291 $output = get_stylesheet_uri();
mp-wp_genesis 292 break;
mp-wp_genesis 293 case 'stylesheet_directory':
mp-wp_genesis 294 $output = get_stylesheet_directory_uri();
mp-wp_genesis 295 break;
mp-wp_genesis 296 case 'template_directory':
mp-wp_genesis 297 case 'template_url':
mp-wp_genesis 298 $output = get_template_directory_uri();
mp-wp_genesis 299 break;
mp-wp_genesis 300 case 'admin_email':
mp-wp_genesis 301 $output = get_option('admin_email');
mp-wp_genesis 302 break;
mp-wp_genesis 303 case 'charset':
mp-wp_genesis 304 $output = get_option('blog_charset');
mp-wp_genesis 305 if ('' == $output) $output = 'UTF-8';
mp-wp_genesis 306 break;
mp-wp_genesis 307 case 'html_type' :
mp-wp_genesis 308 $output = get_option('html_type');
mp-wp_genesis 309 break;
mp-wp_genesis 310 case 'version':
mp-wp_genesis 311 global $wp_version;
mp-wp_genesis 312 $output = $wp_version;
mp-wp_genesis 313 break;
mp-wp_genesis 314 case 'language':
mp-wp_genesis 315 $output = get_locale();
mp-wp_genesis 316 $output = str_replace('_', '-', $output);
mp-wp_genesis 317 break;
mp-wp_genesis 318 case 'text_direction':
mp-wp_genesis 319 global $wp_locale;
mp-wp_genesis 320 $output = $wp_locale->text_direction;
mp-wp_genesis 321 break;
mp-wp_genesis 322 case 'name':
mp-wp_genesis 323 default:
mp-wp_genesis 324 $output = get_option('blogname');
mp-wp_genesis 325 break;
mp-wp_genesis 326 }
mp-wp_genesis 327
mp-wp_genesis 328 $url = true;
mp-wp_genesis 329 if (strpos($show, 'url') === false &&
mp-wp_genesis 330 strpos($show, 'directory') === false &&
mp-wp_genesis 331 strpos($show, 'home') === false)
mp-wp_genesis 332 $url = false;
mp-wp_genesis 333
mp-wp_genesis 334 if ( 'display' == $filter ) {
mp-wp_genesis 335 if ( $url )
mp-wp_genesis 336 $output = apply_filters('bloginfo_url', $output, $show);
mp-wp_genesis 337 else
mp-wp_genesis 338 $output = apply_filters('bloginfo', $output, $show);
mp-wp_genesis 339 }
mp-wp_genesis 340
mp-wp_genesis 341 return $output;
mp-wp_genesis 342 }
mp-wp_genesis 343
mp-wp_genesis 344 /**
mp-wp_genesis 345 * Display or retrieve page title for all areas of blog.
mp-wp_genesis 346 *
mp-wp_genesis 347 * By default, the page title will display the separator before the page title,
mp-wp_genesis 348 * so that the blog title will be before the page title. This is not good for
mp-wp_genesis 349 * title display, since the blog title shows up on most tabs and not what is
mp-wp_genesis 350 * important, which is the page that the user is looking at.
mp-wp_genesis 351 *
mp-wp_genesis 352 * There are also SEO benefits to having the blog title after or to the 'right'
mp-wp_genesis 353 * or the page title. However, it is mostly common sense to have the blog title
mp-wp_genesis 354 * to the right with most browsers supporting tabs. You can achieve this by
mp-wp_genesis 355 * using the seplocation parameter and setting the value to 'right'. This change
mp-wp_genesis 356 * was introduced around 2.5.0, in case backwards compatibility of themes is
mp-wp_genesis 357 * important.
mp-wp_genesis 358 *
mp-wp_genesis 359 * @since 1.0.0
mp-wp_genesis 360 *
mp-wp_genesis 361 * @param string $sep Optional, default is '&raquo;'. How to separate the various items within the page title.
mp-wp_genesis 362 * @param bool $display Optional, default is true. Whether to display or retrieve title.
mp-wp_genesis 363 * @param string $seplocation Optional. Direction to display title, 'right'.
mp-wp_genesis 364 * @return string|null String on retrieve, null when displaying.
mp-wp_genesis 365 */
mp-wp_genesis 366 function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
mp-wp_genesis 367 global $wpdb, $wp_locale, $wp_query;
mp-wp_genesis 368
mp-wp_genesis 369 $cat = get_query_var('cat');
mp-wp_genesis 370 $tag = get_query_var('tag_id');
mp-wp_genesis 371 $category_name = get_query_var('category_name');
mp-wp_genesis 372 $author = get_query_var('author');
mp-wp_genesis 373 $author_name = get_query_var('author_name');
mp-wp_genesis 374 $m = get_query_var('m');
mp-wp_genesis 375 $year = get_query_var('year');
mp-wp_genesis 376 $monthnum = get_query_var('monthnum');
mp-wp_genesis 377 $day = get_query_var('day');
mp-wp_genesis 378 $title = '';
mp-wp_genesis 379
mp-wp_genesis 380 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
mp-wp_genesis 381
mp-wp_genesis 382 // If there's a category
mp-wp_genesis 383 if ( !empty($cat) ) {
mp-wp_genesis 384 // category exclusion
mp-wp_genesis 385 if ( !stristr($cat,'-') )
mp-wp_genesis 386 $title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
mp-wp_genesis 387 } elseif ( !empty($category_name) ) {
mp-wp_genesis 388 if ( stristr($category_name,'/') ) {
mp-wp_genesis 389 $category_name = explode('/',$category_name);
mp-wp_genesis 390 if ( $category_name[count($category_name)-1] )
mp-wp_genesis 391 $category_name = $category_name[count($category_name)-1]; // no trailing slash
mp-wp_genesis 392 else
mp-wp_genesis 393 $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
mp-wp_genesis 394 }
mp-wp_genesis 395 $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display');
mp-wp_genesis 396 if ( $cat )
mp-wp_genesis 397 $title = apply_filters('single_cat_title', $cat->name);
mp-wp_genesis 398 }
mp-wp_genesis 399
mp-wp_genesis 400 if ( !empty($tag) ) {
mp-wp_genesis 401 $tag = get_term($tag, 'post_tag', OBJECT, 'display');
mp-wp_genesis 402 if ( is_wp_error( $tag ) )
mp-wp_genesis 403 return $tag;
mp-wp_genesis 404 if ( ! empty($tag->name) )
mp-wp_genesis 405 $title = apply_filters('single_tag_title', $tag->name);
mp-wp_genesis 406 }
mp-wp_genesis 407
mp-wp_genesis 408 // If there's an author
mp-wp_genesis 409 if ( !empty($author) ) {
mp-wp_genesis 410 $title = get_userdata($author);
mp-wp_genesis 411 $title = $title->display_name;
mp-wp_genesis 412 }
mp-wp_genesis 413 if ( !empty($author_name) ) {
mp-wp_genesis 414 // We do a direct query here because we don't cache by nicename.
mp-wp_genesis 415 $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name));
mp-wp_genesis 416 }
mp-wp_genesis 417
mp-wp_genesis 418 // If there's a month
mp-wp_genesis 419 if ( !empty($m) ) {
mp-wp_genesis 420 $my_year = substr($m, 0, 4);
mp-wp_genesis 421 $my_month = $wp_locale->get_month(substr($m, 4, 2));
mp-wp_genesis 422 $my_day = intval(substr($m, 6, 2));
mp-wp_genesis 423 $title = "$my_year" . ($my_month ? "$t_sep$my_month" : "") . ($my_day ? "$t_sep$my_day" : "");
mp-wp_genesis 424 }
mp-wp_genesis 425
mp-wp_genesis 426 if ( !empty($year) ) {
mp-wp_genesis 427 $title = $year;
mp-wp_genesis 428 if ( !empty($monthnum) )
mp-wp_genesis 429 $title .= "$t_sep" . $wp_locale->get_month($monthnum);
mp-wp_genesis 430 if ( !empty($day) )
mp-wp_genesis 431 $title .= "$t_sep" . zeroise($day, 2);
mp-wp_genesis 432 }
mp-wp_genesis 433
mp-wp_genesis 434 // If there is a post
mp-wp_genesis 435 if ( is_single() || ( is_page() && !is_front_page() ) ) {
mp-wp_genesis 436 $post = $wp_query->get_queried_object();
mp-wp_genesis 437 $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
mp-wp_genesis 438 }
mp-wp_genesis 439
mp-wp_genesis 440 // If there's a taxonomy
mp-wp_genesis 441 if ( is_tax() ) {
mp-wp_genesis 442 $taxonomy = get_query_var( 'taxonomy' );
mp-wp_genesis 443 $tax = get_taxonomy( $taxonomy );
mp-wp_genesis 444 $tax = $tax->label;
mp-wp_genesis 445 $term = $wp_query->get_queried_object();
mp-wp_genesis 446 $term = $term->name;
mp-wp_genesis 447 $title = "$tax$t_sep$term";
mp-wp_genesis 448 }
mp-wp_genesis 449
mp-wp_genesis 450 if ( is_404() ) {
mp-wp_genesis 451 $title = __('Page not found');
mp-wp_genesis 452 }
mp-wp_genesis 453
mp-wp_genesis 454 $prefix = '';
mp-wp_genesis 455 if ( !empty($title) )
mp-wp_genesis 456 $prefix = " $sep ";
mp-wp_genesis 457
mp-wp_genesis 458 // Determines position of the separator and direction of the breadcrumb
mp-wp_genesis 459 if ( 'right' == $seplocation ) { // sep on right, so reverse the order
mp-wp_genesis 460 $title_array = explode( $t_sep, $title );
mp-wp_genesis 461 $title_array = array_reverse( $title_array );
mp-wp_genesis 462 $title = implode( " $sep ", $title_array ) . $prefix;
mp-wp_genesis 463 } else {
mp-wp_genesis 464 $title_array = explode( $t_sep, $title );
mp-wp_genesis 465 $title = $prefix . implode( " $sep ", $title_array );
mp-wp_genesis 466 }
mp-wp_genesis 467
mp-wp_genesis 468 $title = apply_filters('wp_title', $title, $sep, $seplocation);
mp-wp_genesis 469
mp-wp_genesis 470 // Send it out
mp-wp_genesis 471 if ( $display )
mp-wp_genesis 472 echo $title;
mp-wp_genesis 473 else
mp-wp_genesis 474 return $title;
mp-wp_genesis 475
mp-wp_genesis 476 }
mp-wp_genesis 477
mp-wp_genesis 478 /**
mp-wp_genesis 479 * Display or retrieve page title for post.
mp-wp_genesis 480 *
mp-wp_genesis 481 * This is optimized for single.php template file for displaying the post title.
mp-wp_genesis 482 * Only useful for posts, does not support pages for example.
mp-wp_genesis 483 *
mp-wp_genesis 484 * It does not support placing the separator after the title, but by leaving the
mp-wp_genesis 485 * prefix parameter empty, you can set the title separator manually. The prefix
mp-wp_genesis 486 * does not automatically place a space between the prefix, so if there should
mp-wp_genesis 487 * be a space, the parameter value will need to have it at the end.
mp-wp_genesis 488 *
mp-wp_genesis 489 * @since 0.71
mp-wp_genesis 490 * @uses $wpdb
mp-wp_genesis 491 *
mp-wp_genesis 492 * @param string $prefix Optional. What to display before the title.
mp-wp_genesis 493 * @param bool $display Optional, default is true. Whether to display or retrieve title.
mp-wp_genesis 494 * @return string|null Title when retrieving, null when displaying or failure.
mp-wp_genesis 495 */
mp-wp_genesis 496 function single_post_title($prefix = '', $display = true) {
mp-wp_genesis 497 global $wpdb;
mp-wp_genesis 498 $p = get_query_var('p');
mp-wp_genesis 499 $name = get_query_var('name');
mp-wp_genesis 500
mp-wp_genesis 501 if ( intval($p) || '' != $name ) {
mp-wp_genesis 502 if ( !$p )
mp-wp_genesis 503 $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name));
mp-wp_genesis 504 $post = & get_post($p);
mp-wp_genesis 505 $title = $post->post_title;
mp-wp_genesis 506 $title = apply_filters('single_post_title', $title);
mp-wp_genesis 507 if ( $display )
mp-wp_genesis 508 echo $prefix.strip_tags($title);
mp-wp_genesis 509 else
mp-wp_genesis 510 return strip_tags($title);
mp-wp_genesis 511 }
mp-wp_genesis 512 }
mp-wp_genesis 513
mp-wp_genesis 514 /**
mp-wp_genesis 515 * Display or retrieve page title for category archive.
mp-wp_genesis 516 *
mp-wp_genesis 517 * This is useful for category template file or files, because it is optimized
mp-wp_genesis 518 * for category page title and with less overhead than {@link wp_title()}.
mp-wp_genesis 519 *
mp-wp_genesis 520 * It does not support placing the separator after the title, but by leaving the
mp-wp_genesis 521 * prefix parameter empty, you can set the title separator manually. The prefix
mp-wp_genesis 522 * does not automatically place a space between the prefix, so if there should
mp-wp_genesis 523 * be a space, the parameter value will need to have it at the end.
mp-wp_genesis 524 *
mp-wp_genesis 525 * @since 0.71
mp-wp_genesis 526 *
mp-wp_genesis 527 * @param string $prefix Optional. What to display before the title.
mp-wp_genesis 528 * @param bool $display Optional, default is true. Whether to display or retrieve title.
mp-wp_genesis 529 * @return string|null Title when retrieving, null when displaying or failure.
mp-wp_genesis 530 */
mp-wp_genesis 531 function single_cat_title($prefix = '', $display = true ) {
mp-wp_genesis 532 $cat = intval( get_query_var('cat') );
mp-wp_genesis 533 if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
mp-wp_genesis 534 $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
mp-wp_genesis 535 if ( !empty($my_cat_name) ) {
mp-wp_genesis 536 if ( $display )
mp-wp_genesis 537 echo $prefix.strip_tags($my_cat_name);
mp-wp_genesis 538 else
mp-wp_genesis 539 return strip_tags($my_cat_name);
mp-wp_genesis 540 }
mp-wp_genesis 541 } else if ( is_tag() ) {
mp-wp_genesis 542 return single_tag_title($prefix, $display);
mp-wp_genesis 543 }
mp-wp_genesis 544 }
mp-wp_genesis 545
mp-wp_genesis 546 /**
mp-wp_genesis 547 * Display or retrieve page title for tag post archive.
mp-wp_genesis 548 *
mp-wp_genesis 549 * Useful for tag template files for displaying the tag page title. It has less
mp-wp_genesis 550 * overhead than {@link wp_title()}, because of its limited implementation.
mp-wp_genesis 551 *
mp-wp_genesis 552 * It does not support placing the separator after the title, but by leaving the
mp-wp_genesis 553 * prefix parameter empty, you can set the title separator manually. The prefix
mp-wp_genesis 554 * does not automatically place a space between the prefix, so if there should
mp-wp_genesis 555 * be a space, the parameter value will need to have it at the end.
mp-wp_genesis 556 *
mp-wp_genesis 557 * @since 2.3.0
mp-wp_genesis 558 *
mp-wp_genesis 559 * @param string $prefix Optional. What to display before the title.
mp-wp_genesis 560 * @param bool $display Optional, default is true. Whether to display or retrieve title.
mp-wp_genesis 561 * @return string|null Title when retrieving, null when displaying or failure.
mp-wp_genesis 562 */
mp-wp_genesis 563 function single_tag_title($prefix = '', $display = true ) {
mp-wp_genesis 564 if ( !is_tag() )
mp-wp_genesis 565 return;
mp-wp_genesis 566
mp-wp_genesis 567 $tag_id = intval( get_query_var('tag_id') );
mp-wp_genesis 568
mp-wp_genesis 569 if ( !empty($tag_id) ) {
mp-wp_genesis 570 $my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display');
mp-wp_genesis 571 if ( is_wp_error( $my_tag ) )
mp-wp_genesis 572 return false;
mp-wp_genesis 573 $my_tag_name = apply_filters('single_tag_title', $my_tag->name);
mp-wp_genesis 574 if ( !empty($my_tag_name) ) {
mp-wp_genesis 575 if ( $display )
mp-wp_genesis 576 echo $prefix . $my_tag_name;
mp-wp_genesis 577 else
mp-wp_genesis 578 return $my_tag_name;
mp-wp_genesis 579 }
mp-wp_genesis 580 }
mp-wp_genesis 581 }
mp-wp_genesis 582
mp-wp_genesis 583 /**
mp-wp_genesis 584 * Display or retrieve page title for post archive based on date.
mp-wp_genesis 585 *
mp-wp_genesis 586 * Useful for when the template only needs to display the month and year, if
mp-wp_genesis 587 * either are available. Optimized for just this purpose, so if it is all that
mp-wp_genesis 588 * is needed, should be better than {@link wp_title()}.
mp-wp_genesis 589 *
mp-wp_genesis 590 * It does not support placing the separator after the title, but by leaving the
mp-wp_genesis 591 * prefix parameter empty, you can set the title separator manually. The prefix
mp-wp_genesis 592 * does not automatically place a space between the prefix, so if there should
mp-wp_genesis 593 * be a space, the parameter value will need to have it at the end.
mp-wp_genesis 594 *
mp-wp_genesis 595 * @since 0.71
mp-wp_genesis 596 *
mp-wp_genesis 597 * @param string $prefix Optional. What to display before the title.
mp-wp_genesis 598 * @param bool $display Optional, default is true. Whether to display or retrieve title.
mp-wp_genesis 599 * @return string|null Title when retrieving, null when displaying or failure.
mp-wp_genesis 600 */
mp-wp_genesis 601 function single_month_title($prefix = '', $display = true ) {
mp-wp_genesis 602 global $wp_locale;
mp-wp_genesis 603
mp-wp_genesis 604 $m = get_query_var('m');
mp-wp_genesis 605 $year = get_query_var('year');
mp-wp_genesis 606 $monthnum = get_query_var('monthnum');
mp-wp_genesis 607
mp-wp_genesis 608 if ( !empty($monthnum) && !empty($year) ) {
mp-wp_genesis 609 $my_year = $year;
mp-wp_genesis 610 $my_month = $wp_locale->get_month($monthnum);
mp-wp_genesis 611 } elseif ( !empty($m) ) {
mp-wp_genesis 612 $my_year = substr($m, 0, 4);
mp-wp_genesis 613 $my_month = $wp_locale->get_month(substr($m, 4, 2));
mp-wp_genesis 614 }
mp-wp_genesis 615
mp-wp_genesis 616 if ( empty($my_month) )
mp-wp_genesis 617 return false;
mp-wp_genesis 618
mp-wp_genesis 619 $result = $prefix . $my_month . $prefix . $my_year;
mp-wp_genesis 620
mp-wp_genesis 621 if ( !$display )
mp-wp_genesis 622 return $result;
mp-wp_genesis 623 echo $result;
mp-wp_genesis 624 }
mp-wp_genesis 625
mp-wp_genesis 626 /**
mp-wp_genesis 627 * Retrieve archive link content based on predefined or custom code.
mp-wp_genesis 628 *
mp-wp_genesis 629 * The format can be one of four styles. The 'link' for head element, 'option'
mp-wp_genesis 630 * for use in the select element, 'html' for use in list (either ol or ul HTML
mp-wp_genesis 631 * elements). Custom content is also supported using the before and after
mp-wp_genesis 632 * parameters.
mp-wp_genesis 633 *
mp-wp_genesis 634 * The 'link' format uses the link HTML element with the <em>archives</em>
mp-wp_genesis 635 * relationship. The before and after parameters are not used. The text
mp-wp_genesis 636 * parameter is used to describe the link.
mp-wp_genesis 637 *
mp-wp_genesis 638 * The 'option' format uses the option HTML element for use in select element.
mp-wp_genesis 639 * The value is the url parameter and the before and after parameters are used
mp-wp_genesis 640 * between the text description.
mp-wp_genesis 641 *
mp-wp_genesis 642 * The 'html' format, which is the default, uses the li HTML element for use in
mp-wp_genesis 643 * the list HTML elements. The before parameter is before the link and the after
mp-wp_genesis 644 * parameter is after the closing link.
mp-wp_genesis 645 *
mp-wp_genesis 646 * The custom format uses the before parameter before the link ('a' HTML
mp-wp_genesis 647 * element) and the after parameter after the closing link tag. If the above
mp-wp_genesis 648 * three values for the format are not used, then custom format is assumed.
mp-wp_genesis 649 *
mp-wp_genesis 650 * @since 1.0.0
mp-wp_genesis 651 * @author Orien
mp-wp_genesis 652 * @link http://icecode.com/ link navigation hack by Orien
mp-wp_genesis 653 *
mp-wp_genesis 654 * @param string $url URL to archive.
mp-wp_genesis 655 * @param string $text Archive text description.
mp-wp_genesis 656 * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
mp-wp_genesis 657 * @param string $before Optional.
mp-wp_genesis 658 * @param string $after Optional.
mp-wp_genesis 659 * @return string HTML link content for archive.
mp-wp_genesis 660 */
mp-wp_genesis 661 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
mp-wp_genesis 662 $text = wptexturize($text);
mp-wp_genesis 663 $title_text = attribute_escape($text);
mp-wp_genesis 664 $url = clean_url($url);
mp-wp_genesis 665
mp-wp_genesis 666 if ('link' == $format)
mp-wp_genesis 667 $link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
mp-wp_genesis 668 elseif ('option' == $format)
mp-wp_genesis 669 $link_html = "\t<option value='$url'>$before $text $after</option>\n";
mp-wp_genesis 670 elseif ('html' == $format)
mp-wp_genesis 671 $link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
mp-wp_genesis 672 else // custom
mp-wp_genesis 673 $link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
mp-wp_genesis 674
mp-wp_genesis 675 $link_html = apply_filters( "get_archives_link", $link_html );
mp-wp_genesis 676
mp-wp_genesis 677 return $link_html;
mp-wp_genesis 678 }
mp-wp_genesis 679
mp-wp_genesis 680 /**
mp-wp_genesis 681 * Display archive links based on type and format.
mp-wp_genesis 682 *
mp-wp_genesis 683 * The 'type' argument offers a few choices and by default will display monthly
mp-wp_genesis 684 * archive links. The other options for values are 'daily', 'weekly', 'monthly',
mp-wp_genesis 685 * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
mp-wp_genesis 686 * same archive link list, the difference between the two is that 'alpha'
mp-wp_genesis 687 * will order by post title and 'postbypost' will order by post date.
mp-wp_genesis 688 *
mp-wp_genesis 689 * The date archives will logically display dates with links to the archive post
mp-wp_genesis 690 * page. The 'postbypost' and 'alpha' values for 'type' argument will display
mp-wp_genesis 691 * the post titles.
mp-wp_genesis 692 *
mp-wp_genesis 693 * The 'limit' argument will only display a limited amount of links, specified
mp-wp_genesis 694 * by the 'limit' integer value. By default, there is no limit. The
mp-wp_genesis 695 * 'show_post_count' argument will show how many posts are within the archive.
mp-wp_genesis 696 * By default, the 'show_post_count' argument is set to false.
mp-wp_genesis 697 *
mp-wp_genesis 698 * For the 'format', 'before', and 'after' arguments, see {@link
mp-wp_genesis 699 * get_archives_link()}. The values of these arguments have to do with that
mp-wp_genesis 700 * function.
mp-wp_genesis 701 *
mp-wp_genesis 702 * @since 1.2.0
mp-wp_genesis 703 *
mp-wp_genesis 704 * @param string|array $args Optional. Override defaults.
mp-wp_genesis 705 */
mp-wp_genesis 706 function wp_get_archives($args = '') {
mp-wp_genesis 707 global $wpdb, $wp_locale;
mp-wp_genesis 708
mp-wp_genesis 709 $defaults = array(
mp-wp_genesis 710 'type' => 'monthly', 'limit' => '',
mp-wp_genesis 711 'format' => 'html', 'before' => '',
mp-wp_genesis 712 'after' => '', 'show_post_count' => false,
mp-wp_genesis 713 'echo' => 1, 'start' => 1
mp-wp_genesis 714 );
mp-wp_genesis 715
mp-wp_genesis 716 $r = wp_parse_args( $args, $defaults );
mp-wp_genesis 717 extract( $r, EXTR_SKIP );
mp-wp_genesis 718
mp-wp_genesis 719 if ( '' == $type )
mp-wp_genesis 720 $type = 'monthly';
mp-wp_genesis 721
mp-wp_genesis 722 if ( '' != $limit ) {
mp-wp_genesis 723 $limit = absint($limit);
mp-wp_genesis 724 $limit = ' LIMIT '.$limit;
mp-wp_genesis 725 }
mp-wp_genesis 726
mp-wp_genesis 727 // this is what will separate dates on weekly archive links
mp-wp_genesis 728 $archive_week_separator = '&#8211;';
mp-wp_genesis 729
mp-wp_genesis 730 // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
mp-wp_genesis 731 $archive_date_format_over_ride = 0;
mp-wp_genesis 732
mp-wp_genesis 733 // options for daily archive (only if you over-ride the general date format)
mp-wp_genesis 734 $archive_day_date_format = 'Y/m/d';
mp-wp_genesis 735
mp-wp_genesis 736 // options for weekly archive (only if you over-ride the general date format)
mp-wp_genesis 737 $archive_week_start_date_format = 'Y/m/d';
mp-wp_genesis 738 $archive_week_end_date_format = 'Y/m/d';
mp-wp_genesis 739
mp-wp_genesis 740 if ( !$archive_date_format_over_ride ) {
mp-wp_genesis 741 $archive_day_date_format = get_option('date_format');
mp-wp_genesis 742 $archive_week_start_date_format = get_option('date_format');
mp-wp_genesis 743 $archive_week_end_date_format = get_option('date_format');
mp-wp_genesis 744 }
mp-wp_genesis 745
mp-wp_genesis 746 //filters
mp-wp_genesis 747 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
mp-wp_genesis 748 $join = apply_filters('getarchives_join', "", $r);
mp-wp_genesis 749
mp-wp_genesis 750 $output = '';
mp-wp_genesis 751
mp-wp_genesis 752 if ( 'monthly' == $type ) {
mp-wp_genesis 753 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where AND post_date_gmt > FROM_UNIXTIME(".$start.") GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
mp-wp_genesis 754 $key = md5($query);
mp-wp_genesis 755 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 756 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 757 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 758 $cache[ $key ] = $arcresults;
mp-wp_genesis 759 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 760 } else {
mp-wp_genesis 761 $arcresults = $cache[ $key ];
mp-wp_genesis 762 }
mp-wp_genesis 763 if ( $arcresults ) {
mp-wp_genesis 764 $afterafter = $after;
mp-wp_genesis 765 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 766 $url = get_month_link( $arcresult->year, $arcresult->month );
mp-wp_genesis 767 $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
mp-wp_genesis 768 if ( $show_post_count )
mp-wp_genesis 769 $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
mp-wp_genesis 770 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 771 }
mp-wp_genesis 772 }
mp-wp_genesis 773 } elseif ('yearly' == $type) {
mp-wp_genesis 774 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where AND post_date_gmt > FROM_UNIXTIME(".$start.") GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit";
mp-wp_genesis 775 $key = md5($query);
mp-wp_genesis 776 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 777 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 778 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 779 $cache[ $key ] = $arcresults;
mp-wp_genesis 780 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 781 } else {
mp-wp_genesis 782 $arcresults = $cache[ $key ];
mp-wp_genesis 783 }
mp-wp_genesis 784 if ($arcresults) {
mp-wp_genesis 785 $afterafter = $after;
mp-wp_genesis 786 foreach ( (array) $arcresults as $arcresult) {
mp-wp_genesis 787 $url = get_year_link($arcresult->year);
mp-wp_genesis 788 $text = sprintf('%d', $arcresult->year);
mp-wp_genesis 789 if ($show_post_count)
mp-wp_genesis 790 $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
mp-wp_genesis 791 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 792 }
mp-wp_genesis 793 }
mp-wp_genesis 794 } elseif ( 'daily' == $type ) {
mp-wp_genesis 795 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where AND post_date_gmt > FROM_UNIXTIME(".$start.") GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit";
mp-wp_genesis 796 $key = md5($query);
mp-wp_genesis 797 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 798 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 799 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 800 $cache[ $key ] = $arcresults;
mp-wp_genesis 801 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 802 } else {
mp-wp_genesis 803 $arcresults = $cache[ $key ];
mp-wp_genesis 804 }
mp-wp_genesis 805 if ( $arcresults ) {
mp-wp_genesis 806 $afterafter = $after;
mp-wp_genesis 807 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 808 $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
mp-wp_genesis 809 $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
mp-wp_genesis 810 $text = mysql2date($archive_day_date_format, $date);
mp-wp_genesis 811 if ($show_post_count)
mp-wp_genesis 812 $after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
mp-wp_genesis 813 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 814 }
mp-wp_genesis 815 }
mp-wp_genesis 816 } elseif ( 'weekly' == $type ) {
mp-wp_genesis 817 $start_of_week = get_option('start_of_week');
mp-wp_genesis 818 $query = "SELECT DISTINCT WEEK(post_date, $start_of_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 AND post_date_gmt > FROM_UNIXTIME(".$start.") GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC $limit";
mp-wp_genesis 819 $key = md5($query);
mp-wp_genesis 820 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 821 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 822 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 823 $cache[ $key ] = $arcresults;
mp-wp_genesis 824 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 825 } else {
mp-wp_genesis 826 $arcresults = $cache[ $key ];
mp-wp_genesis 827 }
mp-wp_genesis 828 $arc_w_last = '';
mp-wp_genesis 829 $afterafter = $after;
mp-wp_genesis 830 if ( $arcresults ) {
mp-wp_genesis 831 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 832 if ( $arcresult->week != $arc_w_last ) {
mp-wp_genesis 833 $arc_year = $arcresult->yr;
mp-wp_genesis 834 $arc_w_last = $arcresult->week;
mp-wp_genesis 835 $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
mp-wp_genesis 836 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
mp-wp_genesis 837 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
mp-wp_genesis 838 $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
mp-wp_genesis 839 $text = $arc_week_start . $archive_week_separator . $arc_week_end;
mp-wp_genesis 840 if ($show_post_count)
mp-wp_genesis 841 $after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
mp-wp_genesis 842 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 843 }
mp-wp_genesis 844 }
mp-wp_genesis 845 }
mp-wp_genesis 846 } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
mp-wp_genesis 847 $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC ";
mp-wp_genesis 848 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
mp-wp_genesis 849 $key = md5($query);
mp-wp_genesis 850 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 851 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 852 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 853 $cache[ $key ] = $arcresults;
mp-wp_genesis 854 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 855 } else {
mp-wp_genesis 856 $arcresults = $cache[ $key ];
mp-wp_genesis 857 }
mp-wp_genesis 858 if ( $arcresults ) {
mp-wp_genesis 859 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 860 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
mp-wp_genesis 861 $url = get_permalink($arcresult);
mp-wp_genesis 862 $arc_title = $arcresult->post_title;
mp-wp_genesis 863 if ( $arc_title )
mp-wp_genesis 864 $text = strip_tags(apply_filters('the_title', $arc_title));
mp-wp_genesis 865 else
mp-wp_genesis 866 $text = $arcresult->ID;
mp-wp_genesis 867 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 868 }
mp-wp_genesis 869 }
mp-wp_genesis 870 }
mp-wp_genesis 871 }
mp-wp_genesis 872 if ( $echo )
mp-wp_genesis 873 echo $output;
mp-wp_genesis 874 else
mp-wp_genesis 875 return $output;
mp-wp_genesis 876 }
mp-wp_genesis 877
mp-wp_genesis 878 /**
mp-wp_genesis 879 * Get number of days since the start of the week.
mp-wp_genesis 880 *
mp-wp_genesis 881 * @since 1.5.0
mp-wp_genesis 882 * @usedby get_calendar()
mp-wp_genesis 883 *
mp-wp_genesis 884 * @param int $num Number of day.
mp-wp_genesis 885 * @return int Days since the start of the week.
mp-wp_genesis 886 */
mp-wp_genesis 887 function calendar_week_mod($num) {
mp-wp_genesis 888 $base = 7;
mp-wp_genesis 889 return ($num - $base*floor($num/$base));
mp-wp_genesis 890 }
mp-wp_genesis 891
mp-wp_genesis 892 /**
mp-wp_genesis 893 * Display calendar with days that have posts as links.
mp-wp_genesis 894 *
mp-wp_genesis 895 * The calendar is cached, which will be retrieved, if it exists. If there are
mp-wp_genesis 896 * no posts for the month, then it will not be displayed.
mp-wp_genesis 897 *
mp-wp_genesis 898 * @since 1.0.0
mp-wp_genesis 899 *
mp-wp_genesis 900 * @param bool $initial Optional, default is true. Use initial calendar names.
mp-wp_genesis 901 */
mp-wp_genesis 902 function get_calendar($initial = true) {
mp-wp_genesis 903 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
mp-wp_genesis 904
mp-wp_genesis 905 $key = md5( $m . $monthnum . $year );
mp-wp_genesis 906 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
mp-wp_genesis 907 if ( isset( $cache[ $key ] ) ) {
mp-wp_genesis 908 echo $cache[ $key ];
mp-wp_genesis 909 return;
mp-wp_genesis 910 }
mp-wp_genesis 911 }
mp-wp_genesis 912
mp-wp_genesis 913 ob_start();
mp-wp_genesis 914 // Quick check. If we have no posts at all, abort!
mp-wp_genesis 915 if ( !$posts ) {
mp-wp_genesis 916 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
mp-wp_genesis 917 if ( !$gotsome )
mp-wp_genesis 918 return;
mp-wp_genesis 919 }
mp-wp_genesis 920
mp-wp_genesis 921 if ( isset($_GET['w']) )
mp-wp_genesis 922 $w = ''.intval($_GET['w']);
mp-wp_genesis 923
mp-wp_genesis 924 // week_begins = 0 stands for Sunday
mp-wp_genesis 925 $week_begins = intval(get_option('start_of_week'));
mp-wp_genesis 926
mp-wp_genesis 927 // Let's figure out when we are
mp-wp_genesis 928 if ( !empty($monthnum) && !empty($year) ) {
mp-wp_genesis 929 $thismonth = ''.zeroise(intval($monthnum), 2);
mp-wp_genesis 930 $thisyear = ''.intval($year);
mp-wp_genesis 931 } elseif ( !empty($w) ) {
mp-wp_genesis 932 // We need to get the month from MySQL
mp-wp_genesis 933 $thisyear = ''.intval(substr($m, 0, 4));
mp-wp_genesis 934 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
mp-wp_genesis 935 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
mp-wp_genesis 936 } elseif ( !empty($m) ) {
mp-wp_genesis 937 $thisyear = ''.intval(substr($m, 0, 4));
mp-wp_genesis 938 if ( strlen($m) < 6 )
mp-wp_genesis 939 $thismonth = '01';
mp-wp_genesis 940 else
mp-wp_genesis 941 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
mp-wp_genesis 942 } else {
mp-wp_genesis 943 $thisyear = gmdate('Y', current_time('timestamp'));
mp-wp_genesis 944 $thismonth = gmdate('m', current_time('timestamp'));
mp-wp_genesis 945 }
mp-wp_genesis 946
mp-wp_genesis 947 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
mp-wp_genesis 948
mp-wp_genesis 949 // Get the next and previous month and year with at least one post
mp-wp_genesis 950 $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
mp-wp_genesis 951 FROM $wpdb->posts
mp-wp_genesis 952 WHERE post_date < '$thisyear-$thismonth-01'
mp-wp_genesis 953 AND post_type = 'post' AND post_status = 'publish'
mp-wp_genesis 954 ORDER BY post_date DESC
mp-wp_genesis 955 LIMIT 1");
mp-wp_genesis 956 $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
mp-wp_genesis 957 FROM $wpdb->posts
mp-wp_genesis 958 WHERE post_date > '$thisyear-$thismonth-01'
mp-wp_genesis 959 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
mp-wp_genesis 960 AND post_type = 'post' AND post_status = 'publish'
mp-wp_genesis 961 ORDER BY post_date ASC
mp-wp_genesis 962 LIMIT 1");
mp-wp_genesis 963
mp-wp_genesis 964 echo '<table id="wp-calendar" summary="' . __('Calendar') . '">
mp-wp_genesis 965 <caption>' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
mp-wp_genesis 966 <thead>
mp-wp_genesis 967 <tr>';
mp-wp_genesis 968
mp-wp_genesis 969 $myweek = array();
mp-wp_genesis 970
mp-wp_genesis 971 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
mp-wp_genesis 972 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
mp-wp_genesis 973 }
mp-wp_genesis 974
mp-wp_genesis 975 foreach ( $myweek as $wd ) {
mp-wp_genesis 976 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
mp-wp_genesis 977 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
mp-wp_genesis 978 }
mp-wp_genesis 979
mp-wp_genesis 980 echo '
mp-wp_genesis 981 </tr>
mp-wp_genesis 982 </thead>
mp-wp_genesis 983
mp-wp_genesis 984 <tfoot>
mp-wp_genesis 985 <tr>';
mp-wp_genesis 986
mp-wp_genesis 987 if ( $previous ) {
mp-wp_genesis 988 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
mp-wp_genesis 989 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
mp-wp_genesis 990 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>';
mp-wp_genesis 991 } else {
mp-wp_genesis 992 echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
mp-wp_genesis 993 }
mp-wp_genesis 994
mp-wp_genesis 995 echo "\n\t\t".'<td class="pad">&nbsp;</td>';
mp-wp_genesis 996
mp-wp_genesis 997 if ( $next ) {
mp-wp_genesis 998 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
mp-wp_genesis 999 get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month),
mp-wp_genesis 1000 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>';
mp-wp_genesis 1001 } else {
mp-wp_genesis 1002 echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
mp-wp_genesis 1003 }
mp-wp_genesis 1004
mp-wp_genesis 1005 echo '
mp-wp_genesis 1006 </tr>
mp-wp_genesis 1007 </tfoot>
mp-wp_genesis 1008
mp-wp_genesis 1009 <tbody>
mp-wp_genesis 1010 <tr>';
mp-wp_genesis 1011
mp-wp_genesis 1012 // Get days with posts
mp-wp_genesis 1013 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
mp-wp_genesis 1014 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
mp-wp_genesis 1015 AND YEAR(post_date) = '$thisyear'
mp-wp_genesis 1016 AND post_type = 'post' AND post_status = 'publish'
mp-wp_genesis 1017 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
mp-wp_genesis 1018 if ( $dayswithposts ) {
mp-wp_genesis 1019 foreach ( (array) $dayswithposts as $daywith ) {
mp-wp_genesis 1020 $daywithpost[] = $daywith[0];
mp-wp_genesis 1021 }
mp-wp_genesis 1022 } else {
mp-wp_genesis 1023 $daywithpost = array();
mp-wp_genesis 1024 }
mp-wp_genesis 1025
mp-wp_genesis 1026 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false)
mp-wp_genesis 1027 $ak_title_separator = "\n";
mp-wp_genesis 1028 else
mp-wp_genesis 1029 $ak_title_separator = ', ';
mp-wp_genesis 1030
mp-wp_genesis 1031 $ak_titles_for_day = array();
mp-wp_genesis 1032 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
mp-wp_genesis 1033 ."FROM $wpdb->posts "
mp-wp_genesis 1034 ."WHERE YEAR(post_date) = '$thisyear' "
mp-wp_genesis 1035 ."AND MONTH(post_date) = '$thismonth' "
mp-wp_genesis 1036 ."AND post_date < '".current_time('mysql')."' "
mp-wp_genesis 1037 ."AND post_type = 'post' AND post_status = 'publish'"
mp-wp_genesis 1038 );
mp-wp_genesis 1039 if ( $ak_post_titles ) {
mp-wp_genesis 1040 foreach ( (array) $ak_post_titles as $ak_post_title ) {
mp-wp_genesis 1041
mp-wp_genesis 1042 $post_title = apply_filters( "the_title", $ak_post_title->post_title );
mp-wp_genesis 1043 $post_title = str_replace('"', '&quot;', wptexturize( $post_title ));
mp-wp_genesis 1044
mp-wp_genesis 1045 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
mp-wp_genesis 1046 $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
mp-wp_genesis 1047 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
mp-wp_genesis 1048 $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
mp-wp_genesis 1049 else
mp-wp_genesis 1050 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
mp-wp_genesis 1051 }
mp-wp_genesis 1052 }
mp-wp_genesis 1053
mp-wp_genesis 1054
mp-wp_genesis 1055 // See how much we should pad in the beginning
mp-wp_genesis 1056 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
mp-wp_genesis 1057 if ( 0 != $pad )
mp-wp_genesis 1058 echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
mp-wp_genesis 1059
mp-wp_genesis 1060 $daysinmonth = intval(date('t', $unixmonth));
mp-wp_genesis 1061 for ( $day = 1; $day <= $daysinmonth; ++$day ) {
mp-wp_genesis 1062 if ( isset($newrow) && $newrow )
mp-wp_genesis 1063 echo "\n\t</tr>\n\t<tr>\n\t\t";
mp-wp_genesis 1064 $newrow = false;
mp-wp_genesis 1065
mp-wp_genesis 1066 if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) )
mp-wp_genesis 1067 echo '<td id="today">';
mp-wp_genesis 1068 else
mp-wp_genesis 1069 echo '<td>';
mp-wp_genesis 1070
mp-wp_genesis 1071 if ( in_array($day, $daywithpost) ) // any posts today?
mp-wp_genesis 1072 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
mp-wp_genesis 1073 else
mp-wp_genesis 1074 echo $day;
mp-wp_genesis 1075 echo '</td>';
mp-wp_genesis 1076
mp-wp_genesis 1077 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
mp-wp_genesis 1078 $newrow = true;
mp-wp_genesis 1079 }
mp-wp_genesis 1080
mp-wp_genesis 1081 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
mp-wp_genesis 1082 if ( $pad != 0 && $pad != 7 )
mp-wp_genesis 1083 echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
mp-wp_genesis 1084
mp-wp_genesis 1085 echo "\n\t</tr>\n\t</tbody>\n\t</table>";
mp-wp_genesis 1086
mp-wp_genesis 1087 $output = ob_get_contents();
mp-wp_genesis 1088 ob_end_clean();
mp-wp_genesis 1089 echo $output;
mp-wp_genesis 1090 $cache[ $key ] = $output;
mp-wp_genesis 1091 wp_cache_set( 'get_calendar', $cache, 'calendar' );
mp-wp_genesis 1092 }
mp-wp_genesis 1093
mp-wp_genesis 1094 /**
mp-wp_genesis 1095 * Purge the cached results of get_calendar.
mp-wp_genesis 1096 *
mp-wp_genesis 1097 * @see get_calendar
mp-wp_genesis 1098 * @since 2.1.0
mp-wp_genesis 1099 */
mp-wp_genesis 1100 function delete_get_calendar_cache() {
mp-wp_genesis 1101 wp_cache_delete( 'get_calendar', 'calendar' );
mp-wp_genesis 1102 }
mp-wp_genesis 1103 add_action( 'save_post', 'delete_get_calendar_cache' );
mp-wp_genesis 1104 add_action( 'delete_post', 'delete_get_calendar_cache' );
mp-wp_genesis 1105 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
mp-wp_genesis 1106 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
mp-wp_genesis 1107 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
mp-wp_genesis 1108
mp-wp_genesis 1109 /**
mp-wp_genesis 1110 * Display all of the allowed tags in HTML format with attributes.
mp-wp_genesis 1111 *
mp-wp_genesis 1112 * This is useful for displaying in the comment area, which elements and
mp-wp_genesis 1113 * attributes are supported. As well as any plugins which want to display it.
mp-wp_genesis 1114 *
mp-wp_genesis 1115 * @since 1.0.1
mp-wp_genesis 1116 * @uses $allowedtags
mp-wp_genesis 1117 *
mp-wp_genesis 1118 * @return string HTML allowed tags entity encoded.
mp-wp_genesis 1119 */
mp-wp_genesis 1120 function allowed_tags() {
mp-wp_genesis 1121 global $allowedtags;
mp-wp_genesis 1122 $allowed = '';
mp-wp_genesis 1123 foreach ( (array) $allowedtags as $tag => $attributes ) {
mp-wp_genesis 1124 $allowed .= '<'.$tag;
mp-wp_genesis 1125 if ( 0 < count($attributes) ) {
mp-wp_genesis 1126 foreach ( $attributes as $attribute => $limits ) {
mp-wp_genesis 1127 $allowed .= ' '.$attribute.'=""';
mp-wp_genesis 1128 }
mp-wp_genesis 1129 }
mp-wp_genesis 1130 $allowed .= '> ';
mp-wp_genesis 1131 }
mp-wp_genesis 1132 return htmlentities($allowed);
mp-wp_genesis 1133 }
mp-wp_genesis 1134
mp-wp_genesis 1135 /***** Date/Time tags *****/
mp-wp_genesis 1136
mp-wp_genesis 1137 /**
mp-wp_genesis 1138 * Outputs the date in iso8601 format for xml files.
mp-wp_genesis 1139 *
mp-wp_genesis 1140 * @since 1.0.0
mp-wp_genesis 1141 */
mp-wp_genesis 1142 function the_date_xml() {
mp-wp_genesis 1143 global $post;
mp-wp_genesis 1144 echo mysql2date('Y-m-d', $post->post_date);
mp-wp_genesis 1145 }
mp-wp_genesis 1146
mp-wp_genesis 1147 /**
mp-wp_genesis 1148 * Display or Retrieve the date the post was written.
mp-wp_genesis 1149 *
mp-wp_genesis 1150 * Will only output the date if the current post's date is different from the
mp-wp_genesis 1151 * previous one output.
mp-wp_genesis 1152 *
mp-wp_genesis 1153 * @since 0.71
mp-wp_genesis 1154 *
mp-wp_genesis 1155 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
mp-wp_genesis 1156 * @param string $before Optional. Output before the date.
mp-wp_genesis 1157 * @param string $after Optional. Output after the date.
mp-wp_genesis 1158 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
mp-wp_genesis 1159 * @return string|null Null if displaying, string if retrieving.
mp-wp_genesis 1160 */
mp-wp_genesis 1161 function the_date($d='', $before='', $after='', $echo = true) {
mp-wp_genesis 1162 global $post, $day, $previousday;
mp-wp_genesis 1163 $the_date = '';
mp-wp_genesis 1164 if ( $day != $previousday ) {
mp-wp_genesis 1165 $the_date .= $before;
mp-wp_genesis 1166 if ( $d=='' )
mp-wp_genesis 1167 $the_date .= mysql2date(get_option('date_format'), $post->post_date);
mp-wp_genesis 1168 else
mp-wp_genesis 1169 $the_date .= mysql2date($d, $post->post_date);
mp-wp_genesis 1170 $the_date .= $after;
mp-wp_genesis 1171 $previousday = $day;
mp-wp_genesis 1172 }
mp-wp_genesis 1173 $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
mp-wp_genesis 1174 if ( $echo )
mp-wp_genesis 1175 echo $the_date;
mp-wp_genesis 1176 else
mp-wp_genesis 1177 return $the_date;
mp-wp_genesis 1178 }
mp-wp_genesis 1179
mp-wp_genesis 1180 /**
mp-wp_genesis 1181 * Display the date on which the post was last modified.
mp-wp_genesis 1182 *
mp-wp_genesis 1183 * @since 2.1.0
mp-wp_genesis 1184 *
mp-wp_genesis 1185 * @param string $d Optional. PHP date format.
mp-wp_genesis 1186 * @return string
mp-wp_genesis 1187 */
mp-wp_genesis 1188 function the_modified_date($d = '') {
mp-wp_genesis 1189 echo apply_filters('the_modified_date', get_the_modified_date($d), $d);
mp-wp_genesis 1190 }
mp-wp_genesis 1191
mp-wp_genesis 1192 /**
mp-wp_genesis 1193 * Retrieve the date on which the post was last modified.
mp-wp_genesis 1194 *
mp-wp_genesis 1195 * @since 2.1.0
mp-wp_genesis 1196 *
mp-wp_genesis 1197 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
mp-wp_genesis 1198 * @return string
mp-wp_genesis 1199 */
mp-wp_genesis 1200 function get_the_modified_date($d = '') {
mp-wp_genesis 1201 if ( '' == $d )
mp-wp_genesis 1202 $the_time = get_post_modified_time(get_option('date_format'));
mp-wp_genesis 1203 else
mp-wp_genesis 1204 $the_time = get_post_modified_time($d);
mp-wp_genesis 1205 return apply_filters('get_the_modified_date', $the_time, $d);
mp-wp_genesis 1206 }
mp-wp_genesis 1207
mp-wp_genesis 1208 /**
mp-wp_genesis 1209 * Display the time at which the post was written.
mp-wp_genesis 1210 *
mp-wp_genesis 1211 * @since 0.71
mp-wp_genesis 1212 *
mp-wp_genesis 1213 * @param string $d Either 'G', 'U', or php date format.
mp-wp_genesis 1214 */
mp-wp_genesis 1215 function the_time( $d = '' ) {
mp-wp_genesis 1216 echo apply_filters('the_time', get_the_time( $d ), $d);
mp-wp_genesis 1217 }
mp-wp_genesis 1218
mp-wp_genesis 1219 /**
mp-wp_genesis 1220 * Retrieve the time at which the post was written.
mp-wp_genesis 1221 *
mp-wp_genesis 1222 * @since 1.5.0
mp-wp_genesis 1223 *
mp-wp_genesis 1224 * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
mp-wp_genesis 1225 * @param int|object $post Optional post ID or object. Default is global $post object.
mp-wp_genesis 1226 * @return string
mp-wp_genesis 1227 */
mp-wp_genesis 1228 function get_the_time( $d = '', $post = null ) {
mp-wp_genesis 1229 $post = get_post($post);
mp-wp_genesis 1230
mp-wp_genesis 1231 if ( '' == $d )
mp-wp_genesis 1232 $the_time = get_post_time(get_option('time_format'), false, $post);
mp-wp_genesis 1233 else
mp-wp_genesis 1234 $the_time = get_post_time($d, false, $post);
mp-wp_genesis 1235 return apply_filters('get_the_time', $the_time, $d, $post);
mp-wp_genesis 1236 }
mp-wp_genesis 1237
mp-wp_genesis 1238 /**
mp-wp_genesis 1239 * Retrieve the time at which the post was written.
mp-wp_genesis 1240 *
mp-wp_genesis 1241 * @since 2.0.0
mp-wp_genesis 1242 *
mp-wp_genesis 1243 * @param string $d Either 'G', 'U', or php date format.
mp-wp_genesis 1244 * @param bool $gmt Whether of not to return the gmt time.
mp-wp_genesis 1245 * @param int|object $post Optional post ID or object. Default is global $post object.
mp-wp_genesis 1246 * @return string
mp-wp_genesis 1247 */
mp-wp_genesis 1248 function get_post_time( $d = 'U', $gmt = false, $post = null ) { // returns timestamp
mp-wp_genesis 1249 $post = get_post($post);
mp-wp_genesis 1250
mp-wp_genesis 1251 if ( $gmt )
mp-wp_genesis 1252 $time = $post->post_date_gmt;
mp-wp_genesis 1253 else
mp-wp_genesis 1254 $time = $post->post_date;
mp-wp_genesis 1255
mp-wp_genesis 1256 $time = mysql2date($d, $time);
mp-wp_genesis 1257 return apply_filters('get_post_time', $time, $d, $gmt);
mp-wp_genesis 1258 }
mp-wp_genesis 1259
mp-wp_genesis 1260 /**
mp-wp_genesis 1261 * Display the time at which the post was last modified.
mp-wp_genesis 1262 *
mp-wp_genesis 1263 * @since 2.0.0
mp-wp_genesis 1264 *
mp-wp_genesis 1265 * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
mp-wp_genesis 1266 */
mp-wp_genesis 1267 function the_modified_time($d = '') {
mp-wp_genesis 1268 echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
mp-wp_genesis 1269 }
mp-wp_genesis 1270
mp-wp_genesis 1271 /**
mp-wp_genesis 1272 * Retrieve the time at which the post was last modified.
mp-wp_genesis 1273 *
mp-wp_genesis 1274 * @since 2.0.0
mp-wp_genesis 1275 *
mp-wp_genesis 1276 * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
mp-wp_genesis 1277 * @return string
mp-wp_genesis 1278 */
mp-wp_genesis 1279 function get_the_modified_time($d = '') {
mp-wp_genesis 1280 if ( '' == $d )
mp-wp_genesis 1281 $the_time = get_post_modified_time(get_option('time_format'));
mp-wp_genesis 1282 else
mp-wp_genesis 1283 $the_time = get_post_modified_time($d);
mp-wp_genesis 1284 return apply_filters('get_the_modified_time', $the_time, $d);
mp-wp_genesis 1285 }
mp-wp_genesis 1286
mp-wp_genesis 1287 /**
mp-wp_genesis 1288 * Retrieve the time at which the post was last modified.
mp-wp_genesis 1289 *
mp-wp_genesis 1290 * @since 2.0.0
mp-wp_genesis 1291 *
mp-wp_genesis 1292 * @param string $d Either 'G', 'U', or php date format.
mp-wp_genesis 1293 * @param bool $gmt Whether of not to return the gmt time.
mp-wp_genesis 1294 * @return string Returns timestamp
mp-wp_genesis 1295 */
mp-wp_genesis 1296 function get_post_modified_time( $d = 'U', $gmt = false ) {
mp-wp_genesis 1297 global $post;
mp-wp_genesis 1298
mp-wp_genesis 1299 if ( $gmt )
mp-wp_genesis 1300 $time = $post->post_modified_gmt;
mp-wp_genesis 1301 else
mp-wp_genesis 1302 $time = $post->post_modified;
mp-wp_genesis 1303 $time = mysql2date($d, $time);
mp-wp_genesis 1304
mp-wp_genesis 1305 return apply_filters('get_the_modified_time', $time, $d, $gmt);
mp-wp_genesis 1306 }
mp-wp_genesis 1307
mp-wp_genesis 1308 /**
mp-wp_genesis 1309 * Display the weekday on which the post was written.
mp-wp_genesis 1310 *
mp-wp_genesis 1311 * @since 0.71
mp-wp_genesis 1312 * @uses $wp_locale
mp-wp_genesis 1313 * @uses $post
mp-wp_genesis 1314 */
mp-wp_genesis 1315 function the_weekday() {
mp-wp_genesis 1316 global $wp_locale, $post;
mp-wp_genesis 1317 $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
mp-wp_genesis 1318 $the_weekday = apply_filters('the_weekday', $the_weekday);
mp-wp_genesis 1319 echo $the_weekday;
mp-wp_genesis 1320 }
mp-wp_genesis 1321
mp-wp_genesis 1322 /**
mp-wp_genesis 1323 * Display the weekday on which the post was written.
mp-wp_genesis 1324 *
mp-wp_genesis 1325 * Will only output the weekday if the current post's weekday is different from
mp-wp_genesis 1326 * the previous one output.
mp-wp_genesis 1327 *
mp-wp_genesis 1328 * @since 0.71
mp-wp_genesis 1329 *
mp-wp_genesis 1330 * @param string $before output before the date.
mp-wp_genesis 1331 * @param string $after output after the date.
mp-wp_genesis 1332 */
mp-wp_genesis 1333 function the_weekday_date($before='',$after='') {
mp-wp_genesis 1334 global $wp_locale, $post, $day, $previousweekday;
mp-wp_genesis 1335 $the_weekday_date = '';
mp-wp_genesis 1336 if ( $day != $previousweekday ) {
mp-wp_genesis 1337 $the_weekday_date .= $before;
mp-wp_genesis 1338 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date));
mp-wp_genesis 1339 $the_weekday_date .= $after;
mp-wp_genesis 1340 $previousweekday = $day;
mp-wp_genesis 1341 }
mp-wp_genesis 1342 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
mp-wp_genesis 1343 echo $the_weekday_date;
mp-wp_genesis 1344 }
mp-wp_genesis 1345
mp-wp_genesis 1346 /**
mp-wp_genesis 1347 * Fire the wp_head action
mp-wp_genesis 1348 *
mp-wp_genesis 1349 * @since 1.2.0
mp-wp_genesis 1350 * @uses do_action() Calls 'wp_head' hook.
mp-wp_genesis 1351 */
mp-wp_genesis 1352 function wp_head() {
mp-wp_genesis 1353 do_action('wp_head');
mp-wp_genesis 1354 }
mp-wp_genesis 1355
mp-wp_genesis 1356 /**
mp-wp_genesis 1357 * Fire the wp_footer action
mp-wp_genesis 1358 *
mp-wp_genesis 1359 * @since 1.5.1
mp-wp_genesis 1360 * @uses do_action() Calls 'wp_footer' hook.
mp-wp_genesis 1361 */
mp-wp_genesis 1362 function wp_footer() {
mp-wp_genesis 1363 do_action('wp_footer');
mp-wp_genesis 1364 }
mp-wp_genesis 1365
mp-wp_genesis 1366 /**
mp-wp_genesis 1367 * Display the link to the Really Simple Discovery service endpoint.
mp-wp_genesis 1368 *
mp-wp_genesis 1369 * @link http://archipelago.phrasewise.com/rsd
mp-wp_genesis 1370 * @since 2.0.0
mp-wp_genesis 1371 */
mp-wp_genesis 1372 function rsd_link() {
mp-wp_genesis 1373 echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
mp-wp_genesis 1374 }
mp-wp_genesis 1375
mp-wp_genesis 1376 /**
mp-wp_genesis 1377 * Display the link to the Windows Live Writer manifest file.
mp-wp_genesis 1378 *
mp-wp_genesis 1379 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
mp-wp_genesis 1380 * @since 2.3.1
mp-wp_genesis 1381 */
mp-wp_genesis 1382 function wlwmanifest_link() {
mp-wp_genesis 1383 echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
mp-wp_genesis 1384 . get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
mp-wp_genesis 1385 }
mp-wp_genesis 1386
mp-wp_genesis 1387 /**
mp-wp_genesis 1388 * Display a noindex meta tag if required by the blog configuration.
mp-wp_genesis 1389 *
mp-wp_genesis 1390 * If a blog is marked as not being public then the noindex meta tag will be
mp-wp_genesis 1391 * output to tell web robots not to index the page content.
mp-wp_genesis 1392 *
mp-wp_genesis 1393 * @since 2.1.0
mp-wp_genesis 1394 */
mp-wp_genesis 1395 function noindex() {
mp-wp_genesis 1396 // If the blog is not public, tell robots to go away.
mp-wp_genesis 1397 if ( '0' == get_option('blog_public') )
mp-wp_genesis 1398 echo "<meta name='robots' content='noindex,nofollow' />\n";
mp-wp_genesis 1399 }
mp-wp_genesis 1400
mp-wp_genesis 1401 /**
mp-wp_genesis 1402 * Determine if TinyMCE is available.
mp-wp_genesis 1403 *
mp-wp_genesis 1404 * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
mp-wp_genesis 1405 *
mp-wp_genesis 1406 * @since 2.1.0
mp-wp_genesis 1407 *
mp-wp_genesis 1408 * @return bool Whether of not TinyMCE exists.
mp-wp_genesis 1409 */
mp-wp_genesis 1410 function rich_edit_exists() {
mp-wp_genesis 1411 global $wp_rich_edit_exists;
mp-wp_genesis 1412 if ( !isset($wp_rich_edit_exists) )
mp-wp_genesis 1413 $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
mp-wp_genesis 1414 return $wp_rich_edit_exists;
mp-wp_genesis 1415 }
mp-wp_genesis 1416
mp-wp_genesis 1417 /**
mp-wp_genesis 1418 * Whether or not the user should have a WYSIWIG editor.
mp-wp_genesis 1419 *
mp-wp_genesis 1420 * Checks that the user requires a WYSIWIG editor and that the editor is
mp-wp_genesis 1421 * supported in the users browser.
mp-wp_genesis 1422 *
mp-wp_genesis 1423 * @since 2.0.0
mp-wp_genesis 1424 *
mp-wp_genesis 1425 * @return bool
mp-wp_genesis 1426 */
mp-wp_genesis 1427 function user_can_richedit() {
mp-wp_genesis 1428 global $wp_rich_edit, $pagenow;
mp-wp_genesis 1429
mp-wp_genesis 1430 if ( !isset( $wp_rich_edit) ) {
mp-wp_genesis 1431 if ( get_user_option( 'rich_editing' ) == 'true' &&
mp-wp_genesis 1432 ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
mp-wp_genesis 1433 !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) )
mp-wp_genesis 1434 && 'comment.php' != $pagenow ) {
mp-wp_genesis 1435 $wp_rich_edit = true;
mp-wp_genesis 1436 } else {
mp-wp_genesis 1437 $wp_rich_edit = false;
mp-wp_genesis 1438 }
mp-wp_genesis 1439 }
mp-wp_genesis 1440
mp-wp_genesis 1441 return apply_filters('user_can_richedit', $wp_rich_edit);
mp-wp_genesis 1442 }
mp-wp_genesis 1443
mp-wp_genesis 1444 /**
mp-wp_genesis 1445 * Find out which editor should be displayed by default.
mp-wp_genesis 1446 *
mp-wp_genesis 1447 * Works out which of the two editors to display as the current editor for a
mp-wp_genesis 1448 * user.
mp-wp_genesis 1449 *
mp-wp_genesis 1450 * @since 2.5.0
mp-wp_genesis 1451 *
mp-wp_genesis 1452 * @return string Either 'tinymce', or 'html', or 'test'
mp-wp_genesis 1453 */
mp-wp_genesis 1454 function wp_default_editor() {
mp-wp_genesis 1455 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
mp-wp_genesis 1456 if ( $user = wp_get_current_user() ) { // look for cookie
mp-wp_genesis 1457 $ed = get_user_setting('editor', 'tinymce');
mp-wp_genesis 1458 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
mp-wp_genesis 1459 }
mp-wp_genesis 1460 return apply_filters( 'wp_default_editor', $r ); // filter
mp-wp_genesis 1461 }
mp-wp_genesis 1462
mp-wp_genesis 1463 /**
mp-wp_genesis 1464 * Display visual editor forms: TinyMCE, or HTML, or both.
mp-wp_genesis 1465 *
mp-wp_genesis 1466 * The amount of rows the text area will have for the content has to be between
mp-wp_genesis 1467 * 3 and 100 or will default at 12. There is only one option used for all users,
mp-wp_genesis 1468 * named 'default_post_edit_rows'.
mp-wp_genesis 1469 *
mp-wp_genesis 1470 * If the user can not use the rich editor (TinyMCE), then the switch button
mp-wp_genesis 1471 * will not be displayed.
mp-wp_genesis 1472 *
mp-wp_genesis 1473 * @since 2.1.0
mp-wp_genesis 1474 *
mp-wp_genesis 1475 * @param string $content Textarea content.
mp-wp_genesis 1476 * @param string $id HTML ID attribute value.
mp-wp_genesis 1477 * @param string $prev_id HTML ID name for switching back and forth between visual editors.
mp-wp_genesis 1478 * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
mp-wp_genesis 1479 * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
mp-wp_genesis 1480 */
mp-wp_genesis 1481 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) {
mp-wp_genesis 1482 $rows = get_option('default_post_edit_rows');
mp-wp_genesis 1483 if (($rows < 3) || ($rows > 100))
mp-wp_genesis 1484 $rows = 12;
mp-wp_genesis 1485
mp-wp_genesis 1486 if ( !current_user_can( 'upload_files' ) )
mp-wp_genesis 1487 $media_buttons = false;
mp-wp_genesis 1488
mp-wp_genesis 1489 $richedit = user_can_richedit();
mp-wp_genesis 1490 $rows = "rows='$rows'";
mp-wp_genesis 1491
mp-wp_genesis 1492 if ( $richedit || $media_buttons ) { ?>
mp-wp_genesis 1493 <div id="editor-toolbar">
mp-wp_genesis 1494 <?php if ( $richedit ) {
mp-wp_genesis 1495 $wp_default_editor = wp_default_editor(); ?>
mp-wp_genesis 1496 <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
mp-wp_genesis 1497 <?php if ( 'html' == $wp_default_editor ) {
mp-wp_genesis 1498 add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
mp-wp_genesis 1499 <a id="edButtonHTML" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
mp-wp_genesis 1500 <a id="edButtonPreview" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
mp-wp_genesis 1501 <?php } else {
mp-wp_genesis 1502 add_filter('the_editor_content', 'wp_richedit_pre'); ?>
mp-wp_genesis 1503 <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
mp-wp_genesis 1504 <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
mp-wp_genesis 1505 <?php }
mp-wp_genesis 1506 }
mp-wp_genesis 1507
mp-wp_genesis 1508 if ( $media_buttons ) { ?>
mp-wp_genesis 1509 <div id="media-buttons" class="hide-if-no-js">
mp-wp_genesis 1510 <?php do_action( 'media_buttons' ); ?>
mp-wp_genesis 1511 </div>
mp-wp_genesis 1512 <?php } ?>
mp-wp_genesis 1513 </div>
mp-wp_genesis 1514 <?php } ?>
mp-wp_genesis 1515
mp-wp_genesis 1516 <div id="quicktags">
mp-wp_genesis 1517 <?php wp_print_scripts( 'quicktags' ); ?>
mp-wp_genesis 1518 <script type="text/javascript">edToolbar()</script>
mp-wp_genesis 1519 </div>
mp-wp_genesis 1520
mp-wp_genesis 1521 <?php $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea $rows cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
mp-wp_genesis 1522 $the_editor_content = apply_filters('the_editor_content', $content);
mp-wp_genesis 1523
mp-wp_genesis 1524 printf($the_editor, $the_editor_content);
mp-wp_genesis 1525
mp-wp_genesis 1526 ?>
mp-wp_genesis 1527 <script type="text/javascript">
mp-wp_genesis 1528 // <![CDATA[
mp-wp_genesis 1529 edCanvas = document.getElementById('<?php echo $id; ?>');
mp-wp_genesis 1530 <?php if ( user_can_richedit() && $prev_id ) { ?>
mp-wp_genesis 1531 var dotabkey = true;
mp-wp_genesis 1532 // If tinyMCE is defined.
mp-wp_genesis 1533 if ( typeof tinyMCE != 'undefined' ) {
mp-wp_genesis 1534 // This code is meant to allow tabbing from Title to Post (TinyMCE).
mp-wp_genesis 1535 jQuery('#<?php echo $prev_id; ?>')[jQuery.browser.opera ? 'keypress' : 'keydown'](function (e) {
mp-wp_genesis 1536 if (e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
mp-wp_genesis 1537 if ( (jQuery("#post_ID").val() < 1) && (jQuery("#title").val().length > 0) ) { autosave(); }
mp-wp_genesis 1538 if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
mp-wp_genesis 1539 e.preventDefault();
mp-wp_genesis 1540 dotabkey = false;
mp-wp_genesis 1541 tinyMCE.activeEditor.focus();
mp-wp_genesis 1542 return false;
mp-wp_genesis 1543 }
mp-wp_genesis 1544 }
mp-wp_genesis 1545 });
mp-wp_genesis 1546 }
mp-wp_genesis 1547 <?php } ?>
mp-wp_genesis 1548 // ]]>
mp-wp_genesis 1549 </script>
mp-wp_genesis 1550 <?php
mp-wp_genesis 1551 }
mp-wp_genesis 1552
mp-wp_genesis 1553 /**
mp-wp_genesis 1554 * Retrieve the contents of the search WordPress query variable.
mp-wp_genesis 1555 *
mp-wp_genesis 1556 * @since 2.3.0
mp-wp_genesis 1557 *
mp-wp_genesis 1558 * @return string
mp-wp_genesis 1559 */
mp-wp_genesis 1560 function get_search_query() {
mp-wp_genesis 1561 return apply_filters( 'get_search_query', stripslashes( get_query_var( 's' ) ) );
mp-wp_genesis 1562 }
mp-wp_genesis 1563
mp-wp_genesis 1564 /**
mp-wp_genesis 1565 * Display the contents of the search query variable.
mp-wp_genesis 1566 *
mp-wp_genesis 1567 * The search query string is passed through {@link attribute_escape()}
mp-wp_genesis 1568 * to ensure that it is safe for placing in an html attribute.
mp-wp_genesis 1569 *
mp-wp_genesis 1570 * @uses attribute_escape
mp-wp_genesis 1571 * @since 2.1.0
mp-wp_genesis 1572 */
mp-wp_genesis 1573 function the_search_query() {
mp-wp_genesis 1574 echo attribute_escape( apply_filters( 'the_search_query', get_search_query() ) );
mp-wp_genesis 1575 }
mp-wp_genesis 1576
mp-wp_genesis 1577 /**
mp-wp_genesis 1578 * Display the language attributes for the html tag.
mp-wp_genesis 1579 *
mp-wp_genesis 1580 * Builds up a set of html attributes containing the text direction and language
mp-wp_genesis 1581 * information for the page.
mp-wp_genesis 1582 *
mp-wp_genesis 1583 * @since 2.1.0
mp-wp_genesis 1584 *
mp-wp_genesis 1585 * @param string $doctype The type of html document (xhtml|html).
mp-wp_genesis 1586 */
mp-wp_genesis 1587 function language_attributes($doctype = 'html') {
mp-wp_genesis 1588 $attributes = array();
mp-wp_genesis 1589 $output = '';
mp-wp_genesis 1590
mp-wp_genesis 1591 if ( $dir = get_bloginfo('text_direction') )
mp-wp_genesis 1592 $attributes[] = "dir=\"$dir\"";
mp-wp_genesis 1593
mp-wp_genesis 1594 if ( $lang = get_bloginfo('language') ) {
mp-wp_genesis 1595 if ( get_option('html_type') == 'text/html' || $doctype == 'xhtml' )
mp-wp_genesis 1596 $attributes[] = "lang=\"$lang\"";
mp-wp_genesis 1597
mp-wp_genesis 1598 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
mp-wp_genesis 1599 $attributes[] = "xml:lang=\"$lang\"";
mp-wp_genesis 1600 }
mp-wp_genesis 1601
mp-wp_genesis 1602 $output = implode(' ', $attributes);
mp-wp_genesis 1603 $output = apply_filters('language_attributes', $output);
mp-wp_genesis 1604 echo $output;
mp-wp_genesis 1605 }
mp-wp_genesis 1606
mp-wp_genesis 1607 /**
mp-wp_genesis 1608 * Retrieve paginated link for archive post pages.
mp-wp_genesis 1609 *
mp-wp_genesis 1610 * Technically, the function can be used to create paginated link list for any
mp-wp_genesis 1611 * area. The 'base' argument is used to reference the url, which will be used to
mp-wp_genesis 1612 * create the paginated links. The 'format' argument is then used for replacing
mp-wp_genesis 1613 * the page number. It is however, most likely and by default, to be used on the
mp-wp_genesis 1614 * archive post pages.
mp-wp_genesis 1615 *
mp-wp_genesis 1616 * The 'type' argument controls format of the returned value. The default is
mp-wp_genesis 1617 * 'plain', which is just a string with the links separated by a newline
mp-wp_genesis 1618 * character. The other possible values are either 'array' or 'list'. The
mp-wp_genesis 1619 * 'array' value will return an array of the paginated link list to offer full
mp-wp_genesis 1620 * control of display. The 'list' value will place all of the paginated links in
mp-wp_genesis 1621 * an unordered HTML list.
mp-wp_genesis 1622 *
mp-wp_genesis 1623 * The 'total' argument is the total amount of pages and is an integer. The
mp-wp_genesis 1624 * 'current' argument is the current page number and is also an integer.
mp-wp_genesis 1625 *
mp-wp_genesis 1626 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
mp-wp_genesis 1627 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
mp-wp_genesis 1628 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
mp-wp_genesis 1629 * and the '%#%' is also required. The '%#%' will be replaced with the page
mp-wp_genesis 1630 * number.
mp-wp_genesis 1631 *
mp-wp_genesis 1632 * You can include the previous and next links in the list by setting the
mp-wp_genesis 1633 * 'prev_next' argument to true, which it is by default. You can set the
mp-wp_genesis 1634 * previous text, by using the 'prev_text' argument. You can set the next text
mp-wp_genesis 1635 * by setting the 'next_text' argument.
mp-wp_genesis 1636 *
mp-wp_genesis 1637 * If the 'show_all' argument is set to true, then it will show all of the pages
mp-wp_genesis 1638 * instead of a short list of the pages near the current page. By default, the
mp-wp_genesis 1639 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
mp-wp_genesis 1640 * arguments. The 'end_size' argument is how many numbers on either the start
mp-wp_genesis 1641 * and the end list edges, by default is 1. The 'mid_size' argument is how many
mp-wp_genesis 1642 * numbers to either side of current page, but not including current page.
mp-wp_genesis 1643 *
mp-wp_genesis 1644 * It is possible to add query vars to the link by using the 'add_args' argument
mp-wp_genesis 1645 * and see {@link add_query_arg()} for more information.
mp-wp_genesis 1646 *
mp-wp_genesis 1647 * @since 2.1.0
mp-wp_genesis 1648 *
mp-wp_genesis 1649 * @param string|array $args Optional. Override defaults.
mp-wp_genesis 1650 * @return array|string String of page links or array of page links.
mp-wp_genesis 1651 */
mp-wp_genesis 1652 function paginate_links( $args = '' ) {
mp-wp_genesis 1653 $defaults = array(
mp-wp_genesis 1654 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
mp-wp_genesis 1655 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
mp-wp_genesis 1656 'total' => 1,
mp-wp_genesis 1657 'current' => 0,
mp-wp_genesis 1658 'show_all' => false,
mp-wp_genesis 1659 'prev_next' => true,
mp-wp_genesis 1660 'prev_text' => __('&laquo; Previous'),
mp-wp_genesis 1661 'next_text' => __('Next &raquo;'),
mp-wp_genesis 1662 'end_size' => 1,
mp-wp_genesis 1663 'mid_size' => 2,
mp-wp_genesis 1664 'type' => 'plain',
mp-wp_genesis 1665 'add_args' => false, // array of query args to add
mp-wp_genesis 1666 'add_fragment' => ''
mp-wp_genesis 1667 );
mp-wp_genesis 1668
mp-wp_genesis 1669 $args = wp_parse_args( $args, $defaults );
mp-wp_genesis 1670 extract($args, EXTR_SKIP);
mp-wp_genesis 1671
mp-wp_genesis 1672 // Who knows what else people pass in $args
mp-wp_genesis 1673 $total = (int) $total;
mp-wp_genesis 1674 if ( $total < 2 )
mp-wp_genesis 1675 return;
mp-wp_genesis 1676 $current = (int) $current;
mp-wp_genesis 1677 $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default.
mp-wp_genesis 1678 $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
mp-wp_genesis 1679 $add_args = is_array($add_args) ? $add_args : false;
mp-wp_genesis 1680 $r = '';
mp-wp_genesis 1681 $page_links = array();
mp-wp_genesis 1682 $n = 0;
mp-wp_genesis 1683 $dots = false;
mp-wp_genesis 1684
mp-wp_genesis 1685 if ( $prev_next && $current && 1 < $current ) :
mp-wp_genesis 1686 $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
mp-wp_genesis 1687 $link = str_replace('%#%', $current - 1, $link);
mp-wp_genesis 1688 if ( $add_args )
mp-wp_genesis 1689 $link = add_query_arg( $add_args, $link );
mp-wp_genesis 1690 $link .= $add_fragment;
mp-wp_genesis 1691 $page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>";
mp-wp_genesis 1692 endif;
mp-wp_genesis 1693 for ( $n = 1; $n <= $total; $n++ ) :
mp-wp_genesis 1694 $n_display = number_format_i18n($n);
mp-wp_genesis 1695 if ( $n == $current ) :
mp-wp_genesis 1696 $page_links[] = "<span class='page-numbers current'>$n_display</span>";
mp-wp_genesis 1697 $dots = true;
mp-wp_genesis 1698 else :
mp-wp_genesis 1699 if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
mp-wp_genesis 1700 $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
mp-wp_genesis 1701 $link = str_replace('%#%', $n, $link);
mp-wp_genesis 1702 if ( $add_args )
mp-wp_genesis 1703 $link = add_query_arg( $add_args, $link );
mp-wp_genesis 1704 $link .= $add_fragment;
mp-wp_genesis 1705 $page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n_display</a>";
mp-wp_genesis 1706 $dots = true;
mp-wp_genesis 1707 elseif ( $dots && !$show_all ) :
mp-wp_genesis 1708 $page_links[] = "<span class='page-numbers dots'>...</span>";
mp-wp_genesis 1709 $dots = false;
mp-wp_genesis 1710 endif;
mp-wp_genesis 1711 endif;
mp-wp_genesis 1712 endfor;
mp-wp_genesis 1713 if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
mp-wp_genesis 1714 $link = str_replace('%_%', $format, $base);
mp-wp_genesis 1715 $link = str_replace('%#%', $current + 1, $link);
mp-wp_genesis 1716 if ( $add_args )
mp-wp_genesis 1717 $link = add_query_arg( $add_args, $link );
mp-wp_genesis 1718 $link .= $add_fragment;
mp-wp_genesis 1719 $page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>";
mp-wp_genesis 1720 endif;
mp-wp_genesis 1721 switch ( $type ) :
mp-wp_genesis 1722 case 'array' :
mp-wp_genesis 1723 return $page_links;
mp-wp_genesis 1724 break;
mp-wp_genesis 1725 case 'list' :
mp-wp_genesis 1726 $r .= "<ul class='page-numbers'>\n\t<li>";
mp-wp_genesis 1727 $r .= join("</li>\n\t<li>", $page_links);
mp-wp_genesis 1728 $r .= "</li>\n</ul>\n";
mp-wp_genesis 1729 break;
mp-wp_genesis 1730 default :
mp-wp_genesis 1731 $r = join("\n", $page_links);
mp-wp_genesis 1732 break;
mp-wp_genesis 1733 endswitch;
mp-wp_genesis 1734 return $r;
mp-wp_genesis 1735 }
mp-wp_genesis 1736
mp-wp_genesis 1737 /**
mp-wp_genesis 1738 * Registers an admin colour scheme css file.
mp-wp_genesis 1739 *
mp-wp_genesis 1740 * Allows a plugin to register a new admin colour scheme. For example:
mp-wp_genesis 1741 * <code>
mp-wp_genesis 1742 * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
mp-wp_genesis 1743 * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
mp-wp_genesis 1744 * </code>
mp-wp_genesis 1745 *
mp-wp_genesis 1746 * @since 2.5.0
mp-wp_genesis 1747 *
mp-wp_genesis 1748 * @param string $key The unique key for this theme.
mp-wp_genesis 1749 * @param string $name The name of the theme.
mp-wp_genesis 1750 * @param string $url The url of the css file containing the colour scheme.
mp-wp_genesis 1751 * @param array @colors An array of CSS color definitions which are used to give the user a feel for the theme.
mp-wp_genesis 1752 */
mp-wp_genesis 1753 function wp_admin_css_color($key, $name, $url, $colors = array()) {
mp-wp_genesis 1754 global $_wp_admin_css_colors;
mp-wp_genesis 1755
mp-wp_genesis 1756 if ( !isset($_wp_admin_css_colors) )
mp-wp_genesis 1757 $_wp_admin_css_colors = array();
mp-wp_genesis 1758
mp-wp_genesis 1759 $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
mp-wp_genesis 1760 }
mp-wp_genesis 1761
mp-wp_genesis 1762 /**
mp-wp_genesis 1763 * Display the URL of a WordPress admin CSS file.
mp-wp_genesis 1764 *
mp-wp_genesis 1765 * @see WP_Styles::_css_href and its style_loader_src filter.
mp-wp_genesis 1766 *
mp-wp_genesis 1767 * @since 2.3.0
mp-wp_genesis 1768 *
mp-wp_genesis 1769 * @param string $file file relative to wp-admin/ without its ".css" extension.
mp-wp_genesis 1770 */
mp-wp_genesis 1771 function wp_admin_css_uri( $file = 'wp-admin' ) {
mp-wp_genesis 1772 if ( defined('WP_INSTALLING') ) {
mp-wp_genesis 1773 $_file = "./$file.css";
mp-wp_genesis 1774 } else {
mp-wp_genesis 1775 $_file = admin_url("$file.css");
mp-wp_genesis 1776 }
mp-wp_genesis 1777 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
mp-wp_genesis 1778
mp-wp_genesis 1779 return apply_filters( 'wp_admin_css_uri', $_file, $file );
mp-wp_genesis 1780 }
mp-wp_genesis 1781
mp-wp_genesis 1782 /**
mp-wp_genesis 1783 * Enqueues or directly prints a stylesheet link to the specified CSS file.
mp-wp_genesis 1784 *
mp-wp_genesis 1785 * "Intelligently" decides to enqueue or to print the CSS file. If the
mp-wp_genesis 1786 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
mp-wp_genesis 1787 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
mp-wp_genesis 1788 * be printed. Printing may be forced by passing TRUE as the $force_echo
mp-wp_genesis 1789 * (second) parameter.
mp-wp_genesis 1790 *
mp-wp_genesis 1791 * For backward compatibility with WordPress 2.3 calling method: If the $file
mp-wp_genesis 1792 * (first) parameter does not correspond to a registered CSS file, we assume
mp-wp_genesis 1793 * $file is a file relative to wp-admin/ without its ".css" extension. A
mp-wp_genesis 1794 * stylesheet link to that generated URL is printed.
mp-wp_genesis 1795 *
mp-wp_genesis 1796 * @package WordPress
mp-wp_genesis 1797 * @since 2.3.0
mp-wp_genesis 1798 * @uses $wp_styles WordPress Styles Object
mp-wp_genesis 1799 *
mp-wp_genesis 1800 * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/
mp-wp_genesis 1801 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
mp-wp_genesis 1802 */
mp-wp_genesis 1803 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
mp-wp_genesis 1804 global $wp_styles;
mp-wp_genesis 1805 if ( !is_a($wp_styles, 'WP_Styles') )
mp-wp_genesis 1806 $wp_styles = new WP_Styles();
mp-wp_genesis 1807
mp-wp_genesis 1808 // For backward compatibility
mp-wp_genesis 1809 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
mp-wp_genesis 1810
mp-wp_genesis 1811 if ( $wp_styles->query( $handle ) ) {
mp-wp_genesis 1812 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
mp-wp_genesis 1813 wp_print_styles( $handle );
mp-wp_genesis 1814 else // Add to style queue
mp-wp_genesis 1815 wp_enqueue_style( $handle );
mp-wp_genesis 1816 return;
mp-wp_genesis 1817 }
mp-wp_genesis 1818
mp-wp_genesis 1819 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
mp-wp_genesis 1820 if ( 'rtl' == get_bloginfo( 'text_direction' ) )
mp-wp_genesis 1821 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
mp-wp_genesis 1822 }
mp-wp_genesis 1823
mp-wp_genesis 1824 /**
mp-wp_genesis 1825 * Enqueues the default ThickBox js and css.
mp-wp_genesis 1826 *
mp-wp_genesis 1827 * If any of the settings need to be changed, this can be done with another js
mp-wp_genesis 1828 * file similar to media-upload.js and theme-preview.js. That file should
mp-wp_genesis 1829 * require array('thickbox') to ensure it is loaded after.
mp-wp_genesis 1830 *
mp-wp_genesis 1831 * @since 2.5.0
mp-wp_genesis 1832 */
mp-wp_genesis 1833 function add_thickbox() {
mp-wp_genesis 1834 wp_enqueue_script( 'thickbox' );
mp-wp_genesis 1835 wp_enqueue_style( 'thickbox' );
mp-wp_genesis 1836 }
mp-wp_genesis 1837
mp-wp_genesis 1838 /**
mp-wp_genesis 1839 * Display the XHTML generator that is generated on the wp_head hook.
mp-wp_genesis 1840 *
mp-wp_genesis 1841 * @since 2.5.0
mp-wp_genesis 1842 */
mp-wp_genesis 1843 function wp_generator() {
mp-wp_genesis 1844 the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
mp-wp_genesis 1845 }
mp-wp_genesis 1846
mp-wp_genesis 1847 /**
mp-wp_genesis 1848 * Display the generator XML or Comment for RSS, ATOM, etc.
mp-wp_genesis 1849 *
mp-wp_genesis 1850 * Returns the correct generator type for the requested output format. Allows
mp-wp_genesis 1851 * for a plugin to filter generators overall the the_generator filter.
mp-wp_genesis 1852 *
mp-wp_genesis 1853 * @since 2.5.0
mp-wp_genesis 1854 * @uses apply_filters() Calls 'the_generator' hook.
mp-wp_genesis 1855 *
mp-wp_genesis 1856 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
mp-wp_genesis 1857 */
mp-wp_genesis 1858 function the_generator( $type ) {
mp-wp_genesis 1859 echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
mp-wp_genesis 1860 }
mp-wp_genesis 1861
mp-wp_genesis 1862 /**
mp-wp_genesis 1863 * Creates the generator XML or Comment for RSS, ATOM, etc.
mp-wp_genesis 1864 *
mp-wp_genesis 1865 * Returns the correct generator type for the requested output format. Allows
mp-wp_genesis 1866 * for a plugin to filter generators on an individual basis using the
mp-wp_genesis 1867 * 'get_the_generator_{$type}' filter.
mp-wp_genesis 1868 *
mp-wp_genesis 1869 * @since 2.5.0
mp-wp_genesis 1870 * @uses apply_filters() Calls 'get_the_generator_$type' hook.
mp-wp_genesis 1871 *
mp-wp_genesis 1872 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
mp-wp_genesis 1873 * @return string The HTML content for the generator.
mp-wp_genesis 1874 */
mp-wp_genesis 1875 function get_the_generator( $type ) {
mp-wp_genesis 1876 switch ($type) {
mp-wp_genesis 1877 case 'html':
mp-wp_genesis 1878 $gen = '<meta name="generator" content="Polimedia">' . "\n";
mp-wp_genesis 1879 break;
mp-wp_genesis 1880 case 'xhtml':
mp-wp_genesis 1881 $gen = '<meta name="generator" content="Polimedia " />' . "\n";
mp-wp_genesis 1882 break;
mp-wp_genesis 1883 case 'atom':
mp-wp_genesis 1884 $gen = '<generator uri="http://polimedia.us/" version="1.0">Polimedia</generator>';
mp-wp_genesis 1885 break;
mp-wp_genesis 1886 case 'rss2':
mp-wp_genesis 1887 $gen = '<generator>http://polimedia.us</generator>';
mp-wp_genesis 1888 break;
mp-wp_genesis 1889 case 'rdf':
mp-wp_genesis 1890 $gen = '<admin:generatorAgent rdf:resource="http://polimedia.us" />';
mp-wp_genesis 1891 break;
mp-wp_genesis 1892 case 'comment':
mp-wp_genesis 1893 $gen = '<!-- generator="Polimedia/" -->';
mp-wp_genesis 1894 break;
mp-wp_genesis 1895 case 'export':
mp-wp_genesis 1896 $gen = '<!-- generator="Polimedia/" created="'. date('Y-m-d H:i') . '"-->';
mp-wp_genesis 1897 break;
mp-wp_genesis 1898 }
mp-wp_genesis 1899 return apply_filters( "get_the_generator_{$type}", $gen, $type );
mp-wp_genesis 1900 }
mp-wp_genesis 1901
mp-wp_genesis 1902 ?>