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 '»'. 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 = '»', $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 $title_text = attribute_escape($text);
mp-wp_genesis 663 $url = clean_url($url);
mp-wp_genesis 664
mp-wp_genesis 665 if ('link' == $format)
mp-wp_genesis 666 $link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
mp-wp_genesis 667 elseif ('option' == $format)
mp-wp_genesis 668 $link_html = "\t<option value='$url'>$before $text $after</option>\n";
mp-wp_genesis 669 elseif ('html' == $format)
mp-wp_genesis 670 $link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
mp-wp_genesis 671 else // custom
mp-wp_genesis 672 $link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
mp-wp_genesis 673
mp-wp_genesis 674 $link_html = apply_filters( "get_archives_link", $link_html );
mp-wp_genesis 675
mp-wp_genesis 676 return $link_html;
mp-wp_genesis 677 }
mp-wp_genesis 678
mp-wp_genesis 679 /**
mp-wp_genesis 680 * Display archive links based on type and format.
mp-wp_genesis 681 *
mp-wp_genesis 682 * The 'type' argument offers a few choices and by default will display monthly
mp-wp_genesis 683 * archive links. The other options for values are 'daily', 'weekly', 'monthly',
mp-wp_genesis 684 * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
mp-wp_genesis 685 * same archive link list, the difference between the two is that 'alpha'
mp-wp_genesis 686 * will order by post title and 'postbypost' will order by post date.
mp-wp_genesis 687 *
mp-wp_genesis 688 * The date archives will logically display dates with links to the archive post
mp-wp_genesis 689 * page. The 'postbypost' and 'alpha' values for 'type' argument will display
mp-wp_genesis 690 * the post titles.
mp-wp_genesis 691 *
mp-wp_genesis 692 * The 'limit' argument will only display a limited amount of links, specified
mp-wp_genesis 693 * by the 'limit' integer value. By default, there is no limit. The
mp-wp_genesis 694 * 'show_post_count' argument will show how many posts are within the archive.
mp-wp_genesis 695 * By default, the 'show_post_count' argument is set to false.
mp-wp_genesis 696 *
mp-wp_genesis 697 * For the 'format', 'before', and 'after' arguments, see {@link
mp-wp_genesis 698 * get_archives_link()}. The values of these arguments have to do with that
mp-wp_genesis 699 * function.
mp-wp_genesis 700 *
mp-wp_genesis 701 * @since 1.2.0
mp-wp_genesis 702 *
mp-wp_genesis 703 * @param string|array $args Optional. Override defaults.
mp-wp_genesis 704 */
mp-wp_genesis 705 function wp_get_archives($args = '') {
mp-wp_genesis 706 global $wpdb, $wp_locale;
mp-wp_genesis 707
mp-wp_genesis 708 $defaults = array(
mp-wp_genesis 709 'type' => 'monthly', 'limit' => '',
mp-wp_genesis 710 'format' => 'html', 'before' => '',
mp-wp_genesis 711 'after' => '', 'show_post_count' => false,
mp-wp_genesis 712 'echo' => 1, 'start' => 1
mp-wp_genesis 713 );
mp-wp_genesis 714
mp-wp_genesis 715 $r = wp_parse_args( $args, $defaults );
mp-wp_genesis 716 extract( $r, EXTR_SKIP );
mp-wp_genesis 717
mp-wp_genesis 718 if ( '' == $type )
mp-wp_genesis 719 $type = 'monthly';
mp-wp_genesis 720
mp-wp_genesis 721 if ( '' != $limit ) {
mp-wp_genesis 722 $limit = absint($limit);
mp-wp_genesis 723 $limit = ' LIMIT '.$limit;
mp-wp_genesis 724 }
mp-wp_genesis 725
mp-wp_genesis 726 // this is what will separate dates on weekly archive links
mp-wp_genesis 727 $archive_week_separator = '–';
mp-wp_genesis 728
mp-wp_genesis 729 // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
mp-wp_genesis 730 $archive_date_format_over_ride = 0;
mp-wp_genesis 731
mp-wp_genesis 732 // options for daily archive (only if you over-ride the general date format)
mp-wp_genesis 733 $archive_day_date_format = 'Y/m/d';
mp-wp_genesis 734
mp-wp_genesis 735 // options for weekly archive (only if you over-ride the general date format)
mp-wp_genesis 736 $archive_week_start_date_format = 'Y/m/d';
mp-wp_genesis 737 $archive_week_end_date_format = 'Y/m/d';
mp-wp_genesis 738
mp-wp_genesis 739 if ( !$archive_date_format_over_ride ) {
mp-wp_genesis 740 $archive_day_date_format = get_option('date_format');
mp-wp_genesis 741 $archive_week_start_date_format = get_option('date_format');
mp-wp_genesis 742 $archive_week_end_date_format = get_option('date_format');
mp-wp_genesis 743 }
mp-wp_genesis 744
mp-wp_genesis 745 //filters
mp-wp_genesis 746 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
mp-wp_genesis 747 $join = apply_filters('getarchives_join', "", $r);
mp-wp_genesis 748
mp-wp_genesis 749 $output = '';
mp-wp_genesis 750
mp-wp_genesis 751 if ( 'monthly' == $type ) {
mp-wp_genesis 752 $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 753 $key = md5($query);
mp-wp_genesis 754 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 755 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 756 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 757 $cache[ $key ] = $arcresults;
mp-wp_genesis 758 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 759 } else {
mp-wp_genesis 760 $arcresults = $cache[ $key ];
mp-wp_genesis 761 }
mp-wp_genesis 762 if ( $arcresults ) {
mp-wp_genesis 763 $afterafter = $after;
mp-wp_genesis 764 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 765 $url = get_month_link( $arcresult->year, $arcresult->month );
mp-wp_genesis 766 $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
mp-wp_genesis 767 if ( $show_post_count )
mp-wp_genesis 768 $after = ' ('.$arcresult->posts.')' . $afterafter;
mp-wp_genesis 769 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 770 }
mp-wp_genesis 771 }
mp-wp_genesis 772 } elseif ('yearly' == $type) {
mp-wp_genesis 773 $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 774 $key = md5($query);
mp-wp_genesis 775 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 776 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 777 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 778 $cache[ $key ] = $arcresults;
mp-wp_genesis 779 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 780 } else {
mp-wp_genesis 781 $arcresults = $cache[ $key ];
mp-wp_genesis 782 }
mp-wp_genesis 783 if ($arcresults) {
mp-wp_genesis 784 $afterafter = $after;
mp-wp_genesis 785 foreach ( (array) $arcresults as $arcresult) {
mp-wp_genesis 786 $url = get_year_link($arcresult->year);
mp-wp_genesis 787 $text = sprintf('%d', $arcresult->year);
mp-wp_genesis 788 if ($show_post_count)
mp-wp_genesis 789 $after = ' ('.$arcresult->posts.')' . $afterafter;
mp-wp_genesis 790 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 791 }
mp-wp_genesis 792 }
mp-wp_genesis 793 } elseif ( 'daily' == $type ) {
mp-wp_genesis 794 $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 795 $key = md5($query);
mp-wp_genesis 796 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 797 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 798 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 799 $cache[ $key ] = $arcresults;
mp-wp_genesis 800 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 801 } else {
mp-wp_genesis 802 $arcresults = $cache[ $key ];
mp-wp_genesis 803 }
mp-wp_genesis 804 if ( $arcresults ) {
mp-wp_genesis 805 $afterafter = $after;
mp-wp_genesis 806 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 807 $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
mp-wp_genesis 808 $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
mp-wp_genesis 809 $text = mysql2date($archive_day_date_format, $date);
mp-wp_genesis 810 if ($show_post_count)
mp-wp_genesis 811 $after = ' ('.$arcresult->posts.')'.$afterafter;
mp-wp_genesis 812 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 813 }
mp-wp_genesis 814 }
mp-wp_genesis 815 } elseif ( 'weekly' == $type ) {
mp-wp_genesis 816 $start_of_week = get_option('start_of_week');
mp-wp_genesis 817 $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 818 $key = md5($query);
mp-wp_genesis 819 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 820 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 821 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 822 $cache[ $key ] = $arcresults;
mp-wp_genesis 823 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 824 } else {
mp-wp_genesis 825 $arcresults = $cache[ $key ];
mp-wp_genesis 826 }
mp-wp_genesis 827 $arc_w_last = '';
mp-wp_genesis 828 $afterafter = $after;
mp-wp_genesis 829 if ( $arcresults ) {
mp-wp_genesis 830 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 831 if ( $arcresult->week != $arc_w_last ) {
mp-wp_genesis 832 $arc_year = $arcresult->yr;
mp-wp_genesis 833 $arc_w_last = $arcresult->week;
mp-wp_genesis 834 $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
mp-wp_genesis 835 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
mp-wp_genesis 836 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
mp-wp_genesis 837 $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
mp-wp_genesis 838 $text = $arc_week_start . $archive_week_separator . $arc_week_end;
mp-wp_genesis 839 if ($show_post_count)
mp-wp_genesis 840 $after = ' ('.$arcresult->posts.')'.$afterafter;
mp-wp_genesis 841 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 842 }
mp-wp_genesis 843 }
mp-wp_genesis 844 }
mp-wp_genesis 845 } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
mp-wp_genesis 846 $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC ";
mp-wp_genesis 847 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
mp-wp_genesis 848 $key = md5($query);
mp-wp_genesis 849 $cache = wp_cache_get( 'wp_get_archives' , 'general');
mp-wp_genesis 850 if ( !isset( $cache[ $key ] ) ) {
mp-wp_genesis 851 $arcresults = $wpdb->get_results($query);
mp-wp_genesis 852 $cache[ $key ] = $arcresults;
mp-wp_genesis 853 wp_cache_add( 'wp_get_archives', $cache, 'general' );
mp-wp_genesis 854 } else {
mp-wp_genesis 855 $arcresults = $cache[ $key ];
mp-wp_genesis 856 }
mp-wp_genesis 857 if ( $arcresults ) {
mp-wp_genesis 858 foreach ( (array) $arcresults as $arcresult ) {
mp-wp_genesis 859 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
mp-wp_genesis 860 $url = get_permalink($arcresult);
mp-wp_genesis 861 $arc_title = $arcresult->post_title;
mp-wp_genesis 862 if ( $arc_title )
mp-wp_genesis 863 $text = strip_tags(apply_filters('the_title', $arc_title));
mp-wp_genesis 864 else
mp-wp_genesis 865 $text = $arcresult->ID;
mp-wp_genesis 866 $output .= get_archives_link($url, $text, $format, $before, $after);
mp-wp_genesis 867 }
mp-wp_genesis 868 }
mp-wp_genesis 869 }
mp-wp_genesis 870 }
mp-wp_genesis 871 if ( $echo )
mp-wp_genesis 872 echo $output;
mp-wp_genesis 873 else
mp-wp_genesis 874 return $output;
mp-wp_genesis 875 }
mp-wp_genesis 876
mp-wp_genesis 877 /**
mp-wp_genesis 878 * Get number of days since the start of the week.
mp-wp_genesis 879 *
mp-wp_genesis 880 * @since 1.5.0
mp-wp_genesis 881 * @usedby get_calendar()
mp-wp_genesis 882 *
mp-wp_genesis 883 * @param int $num Number of day.
mp-wp_genesis 884 * @return int Days since the start of the week.
mp-wp_genesis 885 */
mp-wp_genesis 886 function calendar_week_mod($num) {
mp-wp_genesis 887 $base = 7;
mp-wp_genesis 888 return ($num - $base*floor($num/$base));
mp-wp_genesis 889 }
mp-wp_genesis 890
mp-wp_genesis 891 /**
mp-wp_genesis 892 * Display calendar with days that have posts as links.
mp-wp_genesis 893 *
mp-wp_genesis 894 * The calendar is cached, which will be retrieved, if it exists. If there are
mp-wp_genesis 895 * no posts for the month, then it will not be displayed.
mp-wp_genesis 896 *
mp-wp_genesis 897 * @since 1.0.0
mp-wp_genesis 898 *
mp-wp_genesis 899 * @param bool $initial Optional, default is true. Use initial calendar names.
mp-wp_genesis 900 */
mp-wp_genesis 901 function get_calendar($initial = true) {
mp-wp_genesis 902 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
mp-wp_genesis 903
mp-wp_genesis 904 $key = md5( $m . $monthnum . $year );
mp-wp_genesis 905 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
mp-wp_genesis 906 if ( isset( $cache[ $key ] ) ) {
mp-wp_genesis 907 echo $cache[ $key ];
mp-wp_genesis 908 return;
mp-wp_genesis 909 }
mp-wp_genesis 910 }
mp-wp_genesis 911
mp-wp_genesis 912 ob_start();
mp-wp_genesis 913 // Quick check. If we have no posts at all, abort!
mp-wp_genesis 914 if ( !$posts ) {
mp-wp_genesis 915 $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 916 if ( !$gotsome )
mp-wp_genesis 917 return;
mp-wp_genesis 918 }
mp-wp_genesis 919
mp-wp_genesis 920 if ( isset($_GET['w']) )
mp-wp_genesis 921 $w = ''.intval($_GET['w']);
mp-wp_genesis 922
mp-wp_genesis 923 // week_begins = 0 stands for Sunday
mp-wp_genesis 924 $week_begins = intval(get_option('start_of_week'));
mp-wp_genesis 925
mp-wp_genesis 926 // Let's figure out when we are
mp-wp_genesis 927 if ( !empty($monthnum) && !empty($year) ) {
mp-wp_genesis 928 $thismonth = ''.zeroise(intval($monthnum), 2);
mp-wp_genesis 929 $thisyear = ''.intval($year);
mp-wp_genesis 930 } elseif ( !empty($w) ) {
mp-wp_genesis 931 // We need to get the month from MySQL
mp-wp_genesis 932 $thisyear = ''.intval(substr($m, 0, 4));
mp-wp_genesis 933 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
mp-wp_genesis 934 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
mp-wp_genesis 935 } elseif ( !empty($m) ) {
mp-wp_genesis 936 $thisyear = ''.intval(substr($m, 0, 4));
mp-wp_genesis 937 if ( strlen($m) < 6 )
mp-wp_genesis 938 $thismonth = '01';
mp-wp_genesis 939 else
mp-wp_genesis 940 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
mp-wp_genesis 941 } else {
mp-wp_genesis 942 $thisyear = gmdate('Y', current_time('timestamp'));
mp-wp_genesis 943 $thismonth = gmdate('m', current_time('timestamp'));
mp-wp_genesis 944 }
mp-wp_genesis 945
mp-wp_genesis 946 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
mp-wp_genesis 947
mp-wp_genesis 948 // Get the next and previous month and year with at least one post
mp-wp_genesis 949 $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
mp-wp_genesis 950 FROM $wpdb->posts
mp-wp_genesis 951 WHERE post_date < '$thisyear-$thismonth-01'
mp-wp_genesis 952 AND post_type = 'post' AND post_status = 'publish'
mp-wp_genesis 953 ORDER BY post_date DESC
mp-wp_genesis 954 LIMIT 1");
mp-wp_genesis 955 $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
mp-wp_genesis 956 FROM $wpdb->posts
mp-wp_genesis 957 WHERE post_date > '$thisyear-$thismonth-01'
mp-wp_genesis 958 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
mp-wp_genesis 959 AND post_type = 'post' AND post_status = 'publish'
mp-wp_genesis 960 ORDER BY post_date ASC
mp-wp_genesis 961 LIMIT 1");
mp-wp_genesis 962
mp-wp_genesis 963 echo '<table id="wp-calendar" summary="' . __('Calendar') . '">
mp-wp_genesis 964 <caption>' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
mp-wp_genesis 965 <thead>
mp-wp_genesis 966 <tr>';
mp-wp_genesis 967
mp-wp_genesis 968 $myweek = array();
mp-wp_genesis 969
mp-wp_genesis 970 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
mp-wp_genesis 971 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
mp-wp_genesis 972 }
mp-wp_genesis 973
mp-wp_genesis 974 foreach ( $myweek as $wd ) {
mp-wp_genesis 975 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
mp-wp_genesis 976 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
mp-wp_genesis 977 }
mp-wp_genesis 978
mp-wp_genesis 979 echo '
mp-wp_genesis 980 </tr>
mp-wp_genesis 981 </thead>
mp-wp_genesis 982
mp-wp_genesis 983 <tfoot>
mp-wp_genesis 984 <tr>';
mp-wp_genesis 985
mp-wp_genesis 986 if ( $previous ) {
mp-wp_genesis 987 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
mp-wp_genesis 988 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 989 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
mp-wp_genesis 990 } else {
mp-wp_genesis 991 echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
mp-wp_genesis 992 }
mp-wp_genesis 993
mp-wp_genesis 994 echo "\n\t\t".'<td class="pad"> </td>';
mp-wp_genesis 995
mp-wp_genesis 996 if ( $next ) {
mp-wp_genesis 997 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
mp-wp_genesis 998 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 999 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
mp-wp_genesis 1000 } else {
mp-wp_genesis 1001 echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
mp-wp_genesis 1002 }
mp-wp_genesis 1003
mp-wp_genesis 1004 echo '
mp-wp_genesis 1005 </tr>
mp-wp_genesis 1006 </tfoot>
mp-wp_genesis 1007
mp-wp_genesis 1008 <tbody>
mp-wp_genesis 1009 <tr>';
mp-wp_genesis 1010
mp-wp_genesis 1011 // Get days with posts
mp-wp_genesis 1012 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
mp-wp_genesis 1013 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
mp-wp_genesis 1014 AND YEAR(post_date) = '$thisyear'
mp-wp_genesis 1015 AND post_type = 'post' AND post_status = 'publish'
mp-wp_genesis 1016 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
mp-wp_genesis 1017 if ( $dayswithposts ) {
mp-wp_genesis 1018 foreach ( (array) $dayswithposts as $daywith ) {
mp-wp_genesis 1019 $daywithpost[] = $daywith[0];
mp-wp_genesis 1020 }
mp-wp_genesis 1021 } else {
mp-wp_genesis 1022 $daywithpost = array();
mp-wp_genesis 1023 }
mp-wp_genesis 1024
mp-wp_genesis 1025 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 1026 $ak_title_separator = "\n";
mp-wp_genesis 1027 else
mp-wp_genesis 1028 $ak_title_separator = ', ';
mp-wp_genesis 1029
mp-wp_genesis 1030 $ak_titles_for_day = array();
mp-wp_genesis 1031 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
mp-wp_genesis 1032 ."FROM $wpdb->posts "
mp-wp_genesis 1033 ."WHERE YEAR(post_date) = '$thisyear' "
mp-wp_genesis 1034 ."AND MONTH(post_date) = '$thismonth' "
mp-wp_genesis 1035 ."AND post_date < '".current_time('mysql')."' "
mp-wp_genesis 1036 ."AND post_type = 'post' AND post_status = 'publish'"
mp-wp_genesis 1037 );
mp-wp_genesis 1038 if ( $ak_post_titles ) {
mp-wp_genesis 1039 foreach ( (array) $ak_post_titles as $ak_post_title ) {
mp-wp_genesis 1040
mp-wp_genesis 1041 $post_title = apply_filters( "the_title", $ak_post_title->post_title );
mp-wp_remove-all-... 1042 $post_title = str_replace('"', '"', $post_title );
mp-wp_genesis 1043
mp-wp_genesis 1044 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
mp-wp_genesis 1045 $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
mp-wp_genesis 1046 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
mp-wp_genesis 1047 $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
mp-wp_genesis 1048 else
mp-wp_genesis 1049 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
mp-wp_genesis 1050 }
mp-wp_genesis 1051 }
mp-wp_genesis 1052
mp-wp_genesis 1053
mp-wp_genesis 1054 // See how much we should pad in the beginning
mp-wp_genesis 1055 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
mp-wp_genesis 1056 if ( 0 != $pad )
mp-wp_genesis 1057 echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>';
mp-wp_genesis 1058
mp-wp_genesis 1059 $daysinmonth = intval(date('t', $unixmonth));
mp-wp_genesis 1060 for ( $day = 1; $day <= $daysinmonth; ++$day ) {
mp-wp_genesis 1061 if ( isset($newrow) && $newrow )
mp-wp_genesis 1062 echo "\n\t</tr>\n\t<tr>\n\t\t";
mp-wp_genesis 1063 $newrow = false;
mp-wp_genesis 1064
mp-wp_genesis 1065 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 1066 echo '<td id="today">';
mp-wp_genesis 1067 else
mp-wp_genesis 1068 echo '<td>';
mp-wp_genesis 1069
mp-wp_genesis 1070 if ( in_array($day, $daywithpost) ) // any posts today?
mp-wp_genesis 1071 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
mp-wp_genesis 1072 else
mp-wp_genesis 1073 echo $day;
mp-wp_genesis 1074 echo '</td>';
mp-wp_genesis 1075
mp-wp_genesis 1076 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
mp-wp_genesis 1077 $newrow = true;
mp-wp_genesis 1078 }
mp-wp_genesis 1079
mp-wp_genesis 1080 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
mp-wp_genesis 1081 if ( $pad != 0 && $pad != 7 )
mp-wp_genesis 1082 echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>';
mp-wp_genesis 1083
mp-wp_genesis 1084 echo "\n\t</tr>\n\t</tbody>\n\t</table>";
mp-wp_genesis 1085
mp-wp_genesis 1086 $output = ob_get_contents();
mp-wp_genesis 1087 ob_end_clean();
mp-wp_genesis 1088 echo $output;
mp-wp_genesis 1089 $cache[ $key ] = $output;
mp-wp_genesis 1090 wp_cache_set( 'get_calendar', $cache, 'calendar' );
mp-wp_genesis 1091 }
mp-wp_genesis 1092
mp-wp_genesis 1093 /**
mp-wp_genesis 1094 * Purge the cached results of get_calendar.
mp-wp_genesis 1095 *
mp-wp_genesis 1096 * @see get_calendar
mp-wp_genesis 1097 * @since 2.1.0
mp-wp_genesis 1098 */
mp-wp_genesis 1099 function delete_get_calendar_cache() {
mp-wp_genesis 1100 wp_cache_delete( 'get_calendar', 'calendar' );
mp-wp_genesis 1101 }
mp-wp_genesis 1102 add_action( 'save_post', 'delete_get_calendar_cache' );
mp-wp_genesis 1103 add_action( 'delete_post', 'delete_get_calendar_cache' );
mp-wp_genesis 1104 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
mp-wp_genesis 1105 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
mp-wp_genesis 1106 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
mp-wp_genesis 1107
mp-wp_genesis 1108 /**
mp-wp_genesis 1109 * Display all of the allowed tags in HTML format with attributes.
mp-wp_genesis 1110 *
mp-wp_genesis 1111 * This is useful for displaying in the comment area, which elements and
mp-wp_genesis 1112 * attributes are supported. As well as any plugins which want to display it.
mp-wp_genesis 1113 *
mp-wp_genesis 1114 * @since 1.0.1
mp-wp_genesis 1115 * @uses $allowedtags
mp-wp_genesis 1116 *
mp-wp_genesis 1117 * @return string HTML allowed tags entity encoded.
mp-wp_genesis 1118 */
mp-wp_genesis 1119 function allowed_tags() {
mp-wp_genesis 1120 global $allowedtags;
mp-wp_genesis 1121 $allowed = '';
mp-wp_genesis 1122 foreach ( (array) $allowedtags as $tag => $attributes ) {
mp-wp_genesis 1123 $allowed .= '<'.$tag;
mp-wp_genesis 1124 if ( 0 < count($attributes) ) {
mp-wp_genesis 1125 foreach ( $attributes as $attribute => $limits ) {
mp-wp_genesis 1126 $allowed .= ' '.$attribute.'=""';
mp-wp_genesis 1127 }
mp-wp_genesis 1128 }
mp-wp_genesis 1129 $allowed .= '> ';
mp-wp_genesis 1130 }
mp-wp_genesis 1131 return htmlentities($allowed);
mp-wp_genesis 1132 }
mp-wp_genesis 1133
mp-wp_genesis 1134 /***** Date/Time tags *****/
mp-wp_genesis 1135
mp-wp_genesis 1136 /**
mp-wp_genesis 1137 * Outputs the date in iso8601 format for xml files.
mp-wp_genesis 1138 *
mp-wp_genesis 1139 * @since 1.0.0
mp-wp_genesis 1140 */
mp-wp_genesis 1141 function the_date_xml() {
mp-wp_genesis 1142 global $post;
mp-wp_genesis 1143 echo mysql2date('Y-m-d', $post->post_date);
mp-wp_genesis 1144 }
mp-wp_genesis 1145
mp-wp_genesis 1146 /**
mp-wp_genesis 1147 * Display or Retrieve the date the post was written.
mp-wp_genesis 1148 *
mp-wp_genesis 1149 * Will only output the date if the current post's date is different from the
mp-wp_genesis 1150 * previous one output.
mp-wp_genesis 1151 *
mp-wp_genesis 1152 * @since 0.71
mp-wp_genesis 1153 *
mp-wp_genesis 1154 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
mp-wp_genesis 1155 * @param string $before Optional. Output before the date.
mp-wp_genesis 1156 * @param string $after Optional. Output after the date.
mp-wp_genesis 1157 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
mp-wp_genesis 1158 * @return string|null Null if displaying, string if retrieving.
mp-wp_genesis 1159 */
mp-wp_genesis 1160 function the_date($d='', $before='', $after='', $echo = true) {
mp-wp_genesis 1161 global $post, $day, $previousday;
mp-wp_genesis 1162 $the_date = '';
mp-wp_genesis 1163 if ( $day != $previousday ) {
mp-wp_genesis 1164 $the_date .= $before;
mp-wp_genesis 1165 if ( $d=='' )
mp-wp_genesis 1166 $the_date .= mysql2date(get_option('date_format'), $post->post_date);
mp-wp_genesis 1167 else
mp-wp_genesis 1168 $the_date .= mysql2date($d, $post->post_date);
mp-wp_genesis 1169 $the_date .= $after;
mp-wp_genesis 1170 $previousday = $day;
mp-wp_genesis 1171 }
mp-wp_genesis 1172 $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
mp-wp_genesis 1173 if ( $echo )
mp-wp_genesis 1174 echo $the_date;
mp-wp_genesis 1175 else
mp-wp_genesis 1176 return $the_date;
mp-wp_genesis 1177 }
mp-wp_genesis 1178
mp-wp_genesis 1179 /**
mp-wp_genesis 1180 * Display the date on which the post was last modified.
mp-wp_genesis 1181 *
mp-wp_genesis 1182 * @since 2.1.0
mp-wp_genesis 1183 *
mp-wp_genesis 1184 * @param string $d Optional. PHP date format.
mp-wp_genesis 1185 * @return string
mp-wp_genesis 1186 */
mp-wp_genesis 1187 function the_modified_date($d = '') {
mp-wp_genesis 1188 echo apply_filters('the_modified_date', get_the_modified_date($d), $d);
mp-wp_genesis 1189 }
mp-wp_genesis 1190
mp-wp_genesis 1191 /**
mp-wp_genesis 1192 * Retrieve the date on which the post was last modified.
mp-wp_genesis 1193 *
mp-wp_genesis 1194 * @since 2.1.0
mp-wp_genesis 1195 *
mp-wp_genesis 1196 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
mp-wp_genesis 1197 * @return string
mp-wp_genesis 1198 */
mp-wp_genesis 1199 function get_the_modified_date($d = '') {
mp-wp_genesis 1200 if ( '' == $d )
mp-wp_genesis 1201 $the_time = get_post_modified_time(get_option('date_format'));
mp-wp_genesis 1202 else
mp-wp_genesis 1203 $the_time = get_post_modified_time($d);
mp-wp_genesis 1204 return apply_filters('get_the_modified_date', $the_time, $d);
mp-wp_genesis 1205 }
mp-wp_genesis 1206
mp-wp_genesis 1207 /**
mp-wp_genesis 1208 * Display the time at which the post was written.
mp-wp_genesis 1209 *
mp-wp_genesis 1210 * @since 0.71
mp-wp_genesis 1211 *
mp-wp_genesis 1212 * @param string $d Either 'G', 'U', or php date format.
mp-wp_genesis 1213 */
mp-wp_genesis 1214 function the_time( $d = '' ) {
mp-wp_genesis 1215 echo apply_filters('the_time', get_the_time( $d ), $d);
mp-wp_genesis 1216 }
mp-wp_genesis 1217
mp-wp_genesis 1218 /**
mp-wp_genesis 1219 * Retrieve the time at which the post was written.
mp-wp_genesis 1220 *
mp-wp_genesis 1221 * @since 1.5.0
mp-wp_genesis 1222 *
mp-wp_genesis 1223 * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
mp-wp_genesis 1224 * @param int|object $post Optional post ID or object. Default is global $post object.
mp-wp_genesis 1225 * @return string
mp-wp_genesis 1226 */
mp-wp_genesis 1227 function get_the_time( $d = '', $post = null ) {
mp-wp_genesis 1228 $post = get_post($post);
mp-wp_genesis 1229
mp-wp_genesis 1230 if ( '' == $d )
mp-wp_genesis 1231 $the_time = get_post_time(get_option('time_format'), false, $post);
mp-wp_genesis 1232 else
mp-wp_genesis 1233 $the_time = get_post_time($d, false, $post);
mp-wp_genesis 1234 return apply_filters('get_the_time', $the_time, $d, $post);
mp-wp_genesis 1235 }
mp-wp_genesis 1236
mp-wp_genesis 1237 /**
mp-wp_genesis 1238 * Retrieve the time at which the post was written.
mp-wp_genesis 1239 *
mp-wp_genesis 1240 * @since 2.0.0
mp-wp_genesis 1241 *
mp-wp_genesis 1242 * @param string $d Either 'G', 'U', or php date format.
mp-wp_genesis 1243 * @param bool $gmt Whether of not to return the gmt time.
mp-wp_genesis 1244 * @param int|object $post Optional post ID or object. Default is global $post object.
mp-wp_genesis 1245 * @return string
mp-wp_genesis 1246 */
mp-wp_genesis 1247 function get_post_time( $d = 'U', $gmt = false, $post = null ) { // returns timestamp
mp-wp_genesis 1248 $post = get_post($post);
mp-wp_genesis 1249
mp-wp_genesis 1250 if ( $gmt )
mp-wp_genesis 1251 $time = $post->post_date_gmt;
mp-wp_genesis 1252 else
mp-wp_genesis 1253 $time = $post->post_date;
mp-wp_genesis 1254
mp-wp_genesis 1255 $time = mysql2date($d, $time);
mp-wp_genesis 1256 return apply_filters('get_post_time', $time, $d, $gmt);
mp-wp_genesis 1257 }
mp-wp_genesis 1258
mp-wp_genesis 1259 /**
mp-wp_genesis 1260 * Display the time at which the post was last modified.
mp-wp_genesis 1261 *
mp-wp_genesis 1262 * @since 2.0.0
mp-wp_genesis 1263 *
mp-wp_genesis 1264 * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
mp-wp_genesis 1265 */
mp-wp_genesis 1266 function the_modified_time($d = '') {
mp-wp_genesis 1267 echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
mp-wp_genesis 1268 }
mp-wp_genesis 1269
mp-wp_genesis 1270 /**
mp-wp_genesis 1271 * Retrieve the time at which the post was last modified.
mp-wp_genesis 1272 *
mp-wp_genesis 1273 * @since 2.0.0
mp-wp_genesis 1274 *
mp-wp_genesis 1275 * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
mp-wp_genesis 1276 * @return string
mp-wp_genesis 1277 */
mp-wp_genesis 1278 function get_the_modified_time($d = '') {
mp-wp_genesis 1279 if ( '' == $d )
mp-wp_genesis 1280 $the_time = get_post_modified_time(get_option('time_format'));
mp-wp_genesis 1281 else
mp-wp_genesis 1282 $the_time = get_post_modified_time($d);
mp-wp_genesis 1283 return apply_filters('get_the_modified_time', $the_time, $d);
mp-wp_genesis 1284 }
mp-wp_genesis 1285
mp-wp_genesis 1286 /**
mp-wp_genesis 1287 * Retrieve the time at which the post was last modified.
mp-wp_genesis 1288 *
mp-wp_genesis 1289 * @since 2.0.0
mp-wp_genesis 1290 *
mp-wp_genesis 1291 * @param string $d Either 'G', 'U', or php date format.
mp-wp_genesis 1292 * @param bool $gmt Whether of not to return the gmt time.
mp-wp_genesis 1293 * @return string Returns timestamp
mp-wp_genesis 1294 */
mp-wp_genesis 1295 function get_post_modified_time( $d = 'U', $gmt = false ) {
mp-wp_genesis 1296 global $post;
mp-wp_genesis 1297
mp-wp_genesis 1298 if ( $gmt )
mp-wp_genesis 1299 $time = $post->post_modified_gmt;
mp-wp_genesis 1300 else
mp-wp_genesis 1301 $time = $post->post_modified;
mp-wp_genesis 1302 $time = mysql2date($d, $time);
mp-wp_genesis 1303
mp-wp_genesis 1304 return apply_filters('get_the_modified_time', $time, $d, $gmt);
mp-wp_genesis 1305 }
mp-wp_genesis 1306
mp-wp_genesis 1307 /**
mp-wp_genesis 1308 * Display the weekday on which the post was written.
mp-wp_genesis 1309 *
mp-wp_genesis 1310 * @since 0.71
mp-wp_genesis 1311 * @uses $wp_locale
mp-wp_genesis 1312 * @uses $post
mp-wp_genesis 1313 */
mp-wp_genesis 1314 function the_weekday() {
mp-wp_genesis 1315 global $wp_locale, $post;
mp-wp_genesis 1316 $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
mp-wp_genesis 1317 $the_weekday = apply_filters('the_weekday', $the_weekday);
mp-wp_genesis 1318 echo $the_weekday;
mp-wp_genesis 1319 }
mp-wp_genesis 1320
mp-wp_genesis 1321 /**
mp-wp_genesis 1322 * Display the weekday on which the post was written.
mp-wp_genesis 1323 *
mp-wp_genesis 1324 * Will only output the weekday if the current post's weekday is different from
mp-wp_genesis 1325 * the previous one output.
mp-wp_genesis 1326 *
mp-wp_genesis 1327 * @since 0.71
mp-wp_genesis 1328 *
mp-wp_genesis 1329 * @param string $before output before the date.
mp-wp_genesis 1330 * @param string $after output after the date.
mp-wp_genesis 1331 */
mp-wp_genesis 1332 function the_weekday_date($before='',$after='') {
mp-wp_genesis 1333 global $wp_locale, $post, $day, $previousweekday;
mp-wp_genesis 1334 $the_weekday_date = '';
mp-wp_genesis 1335 if ( $day != $previousweekday ) {
mp-wp_genesis 1336 $the_weekday_date .= $before;
mp-wp_genesis 1337 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date));
mp-wp_genesis 1338 $the_weekday_date .= $after;
mp-wp_genesis 1339 $previousweekday = $day;
mp-wp_genesis 1340 }
mp-wp_genesis 1341 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
mp-wp_genesis 1342 echo $the_weekday_date;
mp-wp_genesis 1343 }
mp-wp_genesis 1344
mp-wp_genesis 1345 /**
mp-wp_genesis 1346 * Fire the wp_head action
mp-wp_genesis 1347 *
mp-wp_genesis 1348 * @since 1.2.0
mp-wp_genesis 1349 * @uses do_action() Calls 'wp_head' hook.
mp-wp_genesis 1350 */
mp-wp_genesis 1351 function wp_head() {
mp-wp_genesis 1352 do_action('wp_head');
mp-wp_genesis 1353 }
mp-wp_genesis 1354
mp-wp_genesis 1355 /**
mp-wp_genesis 1356 * Fire the wp_footer action
mp-wp_genesis 1357 *
mp-wp_genesis 1358 * @since 1.5.1
mp-wp_genesis 1359 * @uses do_action() Calls 'wp_footer' hook.
mp-wp_genesis 1360 */
mp-wp_genesis 1361 function wp_footer() {
mp-wp_genesis 1362 do_action('wp_footer');
mp-wp_genesis 1363 }
mp-wp_genesis 1364
mp-wp_genesis 1365 /**
mp-wp_genesis 1366 * Display the link to the Really Simple Discovery service endpoint.
mp-wp_genesis 1367 *
mp-wp_genesis 1368 * @link http://archipelago.phrasewise.com/rsd
mp-wp_genesis 1369 * @since 2.0.0
mp-wp_genesis 1370 */
mp-wp_genesis 1371 function rsd_link() {
mp-wp_genesis 1372 echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
mp-wp_genesis 1373 }
mp-wp_genesis 1374
mp-wp_genesis 1375 /**
mp-wp_genesis 1376 * Display the link to the Windows Live Writer manifest file.
mp-wp_genesis 1377 *
mp-wp_genesis 1378 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
mp-wp_genesis 1379 * @since 2.3.1
mp-wp_genesis 1380 */
mp-wp_genesis 1381 function wlwmanifest_link() {
mp-wp_genesis 1382 echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
mp-wp_genesis 1383 . get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
mp-wp_genesis 1384 }
mp-wp_genesis 1385
mp-wp_genesis 1386 /**
mp-wp_genesis 1387 * Display a noindex meta tag if required by the blog configuration.
mp-wp_genesis 1388 *
mp-wp_genesis 1389 * If a blog is marked as not being public then the noindex meta tag will be
mp-wp_genesis 1390 * output to tell web robots not to index the page content.
mp-wp_genesis 1391 *
mp-wp_genesis 1392 * @since 2.1.0
mp-wp_genesis 1393 */
mp-wp_genesis 1394 function noindex() {
mp-wp_genesis 1395 // If the blog is not public, tell robots to go away.
mp-wp_genesis 1396 if ( '0' == get_option('blog_public') )
mp-wp_genesis 1397 echo "<meta name='robots' content='noindex,nofollow' />\n";
mp-wp_genesis 1398 }
mp-wp_genesis 1399
mp-wp_genesis 1400 /**
mp-wp_remove-tiny... 1401 * Display HTML editor form.
mp-wp_genesis 1402 *
mp-wp_genesis 1403 * The amount of rows the text area will have for the content has to be between
mp-wp_genesis 1404 * 3 and 100 or will default at 12. There is only one option used for all users,
mp-wp_genesis 1405 * named 'default_post_edit_rows'.
mp-wp_genesis 1406 *
mp-wp_genesis 1407 * @since 2.1.0
mp-wp_genesis 1408 *
mp-wp_genesis 1409 * @param string $content Textarea content.
mp-wp_genesis 1410 * @param string $id HTML ID attribute value.
mp-wp_genesis 1411 * @param string $prev_id HTML ID name for switching back and forth between visual editors.
mp-wp_genesis 1412 * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
mp-wp_genesis 1413 */
mp-wp_remove-all-... 1414 function the_editor($content, $id = 'content', $prev_id = 'title', $tab_index = 2) {
mp-wp_genesis 1415 $rows = get_option('default_post_edit_rows');
mp-wp_genesis 1416 if (($rows < 3) || ($rows > 100))
mp-wp_genesis 1417 $rows = 12;
mp-wp_genesis 1418
mp-wp_genesis 1419 $rows = "rows='$rows'";
mp-wp_genesis 1420
mp-wp_remove-all-... 1421 $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 1422 $the_editor_content = apply_filters('the_editor_content', $content);
mp-wp_genesis 1423
mp-wp_genesis 1424 printf($the_editor, $the_editor_content);
mp-wp_genesis 1425 }
mp-wp_genesis 1426
mp-wp_genesis 1427 /**
mp-wp_genesis 1428 * Retrieve the contents of the search WordPress query variable.
mp-wp_genesis 1429 *
mp-wp_genesis 1430 * @since 2.3.0
mp-wp_genesis 1431 *
mp-wp_genesis 1432 * @return string
mp-wp_genesis 1433 */
mp-wp_genesis 1434 function get_search_query() {
mp-wp_genesis 1435 return apply_filters( 'get_search_query', stripslashes( get_query_var( 's' ) ) );
mp-wp_genesis 1436 }
mp-wp_genesis 1437
mp-wp_genesis 1438 /**
mp-wp_genesis 1439 * Display the contents of the search query variable.
mp-wp_genesis 1440 *
mp-wp_genesis 1441 * The search query string is passed through {@link attribute_escape()}
mp-wp_genesis 1442 * to ensure that it is safe for placing in an html attribute.
mp-wp_genesis 1443 *
mp-wp_genesis 1444 * @uses attribute_escape
mp-wp_genesis 1445 * @since 2.1.0
mp-wp_genesis 1446 */
mp-wp_genesis 1447 function the_search_query() {
mp-wp_genesis 1448 echo attribute_escape( apply_filters( 'the_search_query', get_search_query() ) );
mp-wp_genesis 1449 }
mp-wp_genesis 1450
mp-wp_genesis 1451 /**
mp-wp_genesis 1452 * Display the language attributes for the html tag.
mp-wp_genesis 1453 *
mp-wp_genesis 1454 * Builds up a set of html attributes containing the text direction and language
mp-wp_genesis 1455 * information for the page.
mp-wp_genesis 1456 *
mp-wp_genesis 1457 * @since 2.1.0
mp-wp_genesis 1458 *
mp-wp_genesis 1459 * @param string $doctype The type of html document (xhtml|html).
mp-wp_genesis 1460 */
mp-wp_genesis 1461 function language_attributes($doctype = 'html') {
mp-wp_genesis 1462 $attributes = array();
mp-wp_genesis 1463 $output = '';
mp-wp_genesis 1464
mp-wp_genesis 1465 if ( $dir = get_bloginfo('text_direction') )
mp-wp_genesis 1466 $attributes[] = "dir=\"$dir\"";
mp-wp_genesis 1467
mp-wp_genesis 1468 if ( $lang = get_bloginfo('language') ) {
mp-wp_genesis 1469 if ( get_option('html_type') == 'text/html' || $doctype == 'xhtml' )
mp-wp_genesis 1470 $attributes[] = "lang=\"$lang\"";
mp-wp_genesis 1471
mp-wp_genesis 1472 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
mp-wp_genesis 1473 $attributes[] = "xml:lang=\"$lang\"";
mp-wp_genesis 1474 }
mp-wp_genesis 1475
mp-wp_genesis 1476 $output = implode(' ', $attributes);
mp-wp_genesis 1477 $output = apply_filters('language_attributes', $output);
mp-wp_genesis 1478 echo $output;
mp-wp_genesis 1479 }
mp-wp_genesis 1480
mp-wp_genesis 1481 /**
mp-wp_genesis 1482 * Retrieve paginated link for archive post pages.
mp-wp_genesis 1483 *
mp-wp_genesis 1484 * Technically, the function can be used to create paginated link list for any
mp-wp_genesis 1485 * area. The 'base' argument is used to reference the url, which will be used to
mp-wp_genesis 1486 * create the paginated links. The 'format' argument is then used for replacing
mp-wp_genesis 1487 * the page number. It is however, most likely and by default, to be used on the
mp-wp_genesis 1488 * archive post pages.
mp-wp_genesis 1489 *
mp-wp_genesis 1490 * The 'type' argument controls format of the returned value. The default is
mp-wp_genesis 1491 * 'plain', which is just a string with the links separated by a newline
mp-wp_genesis 1492 * character. The other possible values are either 'array' or 'list'. The
mp-wp_genesis 1493 * 'array' value will return an array of the paginated link list to offer full
mp-wp_genesis 1494 * control of display. The 'list' value will place all of the paginated links in
mp-wp_genesis 1495 * an unordered HTML list.
mp-wp_genesis 1496 *
mp-wp_genesis 1497 * The 'total' argument is the total amount of pages and is an integer. The
mp-wp_genesis 1498 * 'current' argument is the current page number and is also an integer.
mp-wp_genesis 1499 *
mp-wp_genesis 1500 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
mp-wp_genesis 1501 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
mp-wp_genesis 1502 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
mp-wp_genesis 1503 * and the '%#%' is also required. The '%#%' will be replaced with the page
mp-wp_genesis 1504 * number.
mp-wp_genesis 1505 *
mp-wp_genesis 1506 * You can include the previous and next links in the list by setting the
mp-wp_genesis 1507 * 'prev_next' argument to true, which it is by default. You can set the
mp-wp_genesis 1508 * previous text, by using the 'prev_text' argument. You can set the next text
mp-wp_genesis 1509 * by setting the 'next_text' argument.
mp-wp_genesis 1510 *
mp-wp_genesis 1511 * If the 'show_all' argument is set to true, then it will show all of the pages
mp-wp_genesis 1512 * instead of a short list of the pages near the current page. By default, the
mp-wp_genesis 1513 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
mp-wp_genesis 1514 * arguments. The 'end_size' argument is how many numbers on either the start
mp-wp_genesis 1515 * and the end list edges, by default is 1. The 'mid_size' argument is how many
mp-wp_genesis 1516 * numbers to either side of current page, but not including current page.
mp-wp_genesis 1517 *
mp-wp_genesis 1518 * It is possible to add query vars to the link by using the 'add_args' argument
mp-wp_genesis 1519 * and see {@link add_query_arg()} for more information.
mp-wp_genesis 1520 *
mp-wp_genesis 1521 * @since 2.1.0
mp-wp_genesis 1522 *
mp-wp_genesis 1523 * @param string|array $args Optional. Override defaults.
mp-wp_genesis 1524 * @return array|string String of page links or array of page links.
mp-wp_genesis 1525 */
mp-wp_genesis 1526 function paginate_links( $args = '' ) {
mp-wp_genesis 1527 $defaults = array(
mp-wp_genesis 1528 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
mp-wp_genesis 1529 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
mp-wp_genesis 1530 'total' => 1,
mp-wp_genesis 1531 'current' => 0,
mp-wp_genesis 1532 'show_all' => false,
mp-wp_genesis 1533 'prev_next' => true,
mp-wp_genesis 1534 'prev_text' => __('« Previous'),
mp-wp_genesis 1535 'next_text' => __('Next »'),
mp-wp_genesis 1536 'end_size' => 1,
mp-wp_genesis 1537 'mid_size' => 2,
mp-wp_genesis 1538 'type' => 'plain',
mp-wp_genesis 1539 'add_args' => false, // array of query args to add
mp-wp_genesis 1540 'add_fragment' => ''
mp-wp_genesis 1541 );
mp-wp_genesis 1542
mp-wp_genesis 1543 $args = wp_parse_args( $args, $defaults );
mp-wp_genesis 1544 extract($args, EXTR_SKIP);
mp-wp_genesis 1545
mp-wp_genesis 1546 // Who knows what else people pass in $args
mp-wp_genesis 1547 $total = (int) $total;
mp-wp_genesis 1548 if ( $total < 2 )
mp-wp_genesis 1549 return;
mp-wp_genesis 1550 $current = (int) $current;
mp-wp_genesis 1551 $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default.
mp-wp_genesis 1552 $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
mp-wp_genesis 1553 $add_args = is_array($add_args) ? $add_args : false;
mp-wp_genesis 1554 $r = '';
mp-wp_genesis 1555 $page_links = array();
mp-wp_genesis 1556 $n = 0;
mp-wp_genesis 1557 $dots = false;
mp-wp_genesis 1558
mp-wp_genesis 1559 if ( $prev_next && $current && 1 < $current ) :
mp-wp_genesis 1560 $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
mp-wp_genesis 1561 $link = str_replace('%#%', $current - 1, $link);
mp-wp_genesis 1562 if ( $add_args )
mp-wp_genesis 1563 $link = add_query_arg( $add_args, $link );
mp-wp_genesis 1564 $link .= $add_fragment;
mp-wp_genesis 1565 $page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>";
mp-wp_genesis 1566 endif;
mp-wp_genesis 1567 for ( $n = 1; $n <= $total; $n++ ) :
mp-wp_genesis 1568 $n_display = number_format_i18n($n);
mp-wp_genesis 1569 if ( $n == $current ) :
mp-wp_genesis 1570 $page_links[] = "<span class='page-numbers current'>$n_display</span>";
mp-wp_genesis 1571 $dots = true;
mp-wp_genesis 1572 else :
mp-wp_genesis 1573 if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
mp-wp_genesis 1574 $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
mp-wp_genesis 1575 $link = str_replace('%#%', $n, $link);
mp-wp_genesis 1576 if ( $add_args )
mp-wp_genesis 1577 $link = add_query_arg( $add_args, $link );
mp-wp_genesis 1578 $link .= $add_fragment;
mp-wp_genesis 1579 $page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n_display</a>";
mp-wp_genesis 1580 $dots = true;
mp-wp_genesis 1581 elseif ( $dots && !$show_all ) :
mp-wp_genesis 1582 $page_links[] = "<span class='page-numbers dots'>...</span>";
mp-wp_genesis 1583 $dots = false;
mp-wp_genesis 1584 endif;
mp-wp_genesis 1585 endif;
mp-wp_genesis 1586 endfor;
mp-wp_genesis 1587 if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
mp-wp_genesis 1588 $link = str_replace('%_%', $format, $base);
mp-wp_genesis 1589 $link = str_replace('%#%', $current + 1, $link);
mp-wp_genesis 1590 if ( $add_args )
mp-wp_genesis 1591 $link = add_query_arg( $add_args, $link );
mp-wp_genesis 1592 $link .= $add_fragment;
mp-wp_genesis 1593 $page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>";
mp-wp_genesis 1594 endif;
mp-wp_genesis 1595 switch ( $type ) :
mp-wp_genesis 1596 case 'array' :
mp-wp_genesis 1597 return $page_links;
mp-wp_genesis 1598 break;
mp-wp_genesis 1599 case 'list' :
mp-wp_genesis 1600 $r .= "<ul class='page-numbers'>\n\t<li>";
mp-wp_genesis 1601 $r .= join("</li>\n\t<li>", $page_links);
mp-wp_genesis 1602 $r .= "</li>\n</ul>\n";
mp-wp_genesis 1603 break;
mp-wp_genesis 1604 default :
mp-wp_genesis 1605 $r = join("\n", $page_links);
mp-wp_genesis 1606 break;
mp-wp_genesis 1607 endswitch;
mp-wp_genesis 1608 return $r;
mp-wp_genesis 1609 }
mp-wp_genesis 1610
mp-wp_genesis 1611 /**
mp-wp_genesis 1612 * Display the URL of a WordPress admin CSS file.
mp-wp_genesis 1613 *
mp-wp_genesis 1614 * @see WP_Styles::_css_href and its style_loader_src filter.
mp-wp_genesis 1615 *
mp-wp_genesis 1616 * @since 2.3.0
mp-wp_genesis 1617 *
mp-wp_genesis 1618 * @param string $file file relative to wp-admin/ without its ".css" extension.
mp-wp_genesis 1619 */
mp-wp_genesis 1620 function wp_admin_css_uri( $file = 'wp-admin' ) {
mp-wp_genesis 1621 if ( defined('WP_INSTALLING') ) {
mp-wp_genesis 1622 $_file = "./$file.css";
mp-wp_genesis 1623 } else {
mp-wp_genesis 1624 $_file = admin_url("$file.css");
mp-wp_genesis 1625 }
mp-wp_genesis 1626 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
mp-wp_genesis 1627
mp-wp_genesis 1628 return apply_filters( 'wp_admin_css_uri', $_file, $file );
mp-wp_genesis 1629 }
mp-wp_genesis 1630
mp-wp_genesis 1631 /**
mp-wp_genesis 1632 * Enqueues or directly prints a stylesheet link to the specified CSS file.
mp-wp_genesis 1633 *
mp-wp_genesis 1634 * "Intelligently" decides to enqueue or to print the CSS file. If the
mp-wp_genesis 1635 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
mp-wp_genesis 1636 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
mp-wp_genesis 1637 * be printed. Printing may be forced by passing TRUE as the $force_echo
mp-wp_genesis 1638 * (second) parameter.
mp-wp_genesis 1639 *
mp-wp_genesis 1640 * For backward compatibility with WordPress 2.3 calling method: If the $file
mp-wp_genesis 1641 * (first) parameter does not correspond to a registered CSS file, we assume
mp-wp_genesis 1642 * $file is a file relative to wp-admin/ without its ".css" extension. A
mp-wp_genesis 1643 * stylesheet link to that generated URL is printed.
mp-wp_genesis 1644 *
mp-wp_genesis 1645 * @package WordPress
mp-wp_genesis 1646 * @since 2.3.0
mp-wp_genesis 1647 * @uses $wp_styles WordPress Styles Object
mp-wp_genesis 1648 *
mp-wp_genesis 1649 * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/
mp-wp_genesis 1650 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
mp-wp_genesis 1651 */
mp-wp_genesis 1652 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
mp-wp_genesis 1653 global $wp_styles;
mp-wp_genesis 1654 if ( !is_a($wp_styles, 'WP_Styles') )
mp-wp_genesis 1655 $wp_styles = new WP_Styles();
mp-wp_genesis 1656
mp-wp_genesis 1657 // For backward compatibility
mp-wp_genesis 1658 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
mp-wp_genesis 1659
mp-wp_genesis 1660 if ( $wp_styles->query( $handle ) ) {
mp-wp_genesis 1661 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
mp-wp_genesis 1662 wp_print_styles( $handle );
mp-wp_genesis 1663 else // Add to style queue
mp-wp_genesis 1664 wp_enqueue_style( $handle );
mp-wp_genesis 1665 return;
mp-wp_genesis 1666 }
mp-wp_genesis 1667
mp-wp_genesis 1668 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 1669 if ( 'rtl' == get_bloginfo( 'text_direction' ) )
mp-wp_genesis 1670 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 1671 }
mp-wp_genesis 1672
mp-wp_genesis 1673 /**
mp-wp_genesis 1674 * Display the XHTML generator that is generated on the wp_head hook.
mp-wp_genesis 1675 *
mp-wp_genesis 1676 * @since 2.5.0
mp-wp_genesis 1677 */
mp-wp_genesis 1678 function wp_generator() {
mp-wp_genesis 1679 the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
mp-wp_genesis 1680 }
mp-wp_genesis 1681
mp-wp_genesis 1682 /**
mp-wp_genesis 1683 * Display the generator XML or Comment for RSS, ATOM, etc.
mp-wp_genesis 1684 *
mp-wp_genesis 1685 * Returns the correct generator type for the requested output format. Allows
mp-wp_genesis 1686 * for a plugin to filter generators overall the the_generator filter.
mp-wp_genesis 1687 *
mp-wp_genesis 1688 * @since 2.5.0
mp-wp_genesis 1689 * @uses apply_filters() Calls 'the_generator' hook.
mp-wp_genesis 1690 *
mp-wp_genesis 1691 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
mp-wp_genesis 1692 */
mp-wp_genesis 1693 function the_generator( $type ) {
mp-wp_genesis 1694 echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
mp-wp_genesis 1695 }
mp-wp_genesis 1696
mp-wp_genesis 1697 /**
mp-wp_genesis 1698 * Creates the generator XML or Comment for RSS, ATOM, etc.
mp-wp_genesis 1699 *
mp-wp_genesis 1700 * Returns the correct generator type for the requested output format. Allows
mp-wp_genesis 1701 * for a plugin to filter generators on an individual basis using the
mp-wp_genesis 1702 * 'get_the_generator_{$type}' filter.
mp-wp_genesis 1703 *
mp-wp_genesis 1704 * @since 2.5.0
mp-wp_genesis 1705 * @uses apply_filters() Calls 'get_the_generator_$type' hook.
mp-wp_genesis 1706 *
mp-wp_genesis 1707 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
mp-wp_genesis 1708 * @return string The HTML content for the generator.
mp-wp_genesis 1709 */
mp-wp_genesis 1710 function get_the_generator( $type ) {
mp-wp_genesis 1711 switch ($type) {
mp-wp_genesis 1712 case 'html':
mp-wp_genesis 1713 $gen = '<meta name="generator" content="Polimedia">' . "\n";
mp-wp_genesis 1714 break;
mp-wp_genesis 1715 case 'xhtml':
mp-wp_genesis 1716 $gen = '<meta name="generator" content="Polimedia " />' . "\n";
mp-wp_genesis 1717 break;
mp-wp_genesis 1718 case 'atom':
mp-wp_genesis 1719 $gen = '<generator uri="http://polimedia.us/" version="1.0">Polimedia</generator>';
mp-wp_genesis 1720 break;
mp-wp_genesis 1721 case 'rss2':
mp-wp_genesis 1722 $gen = '<generator>http://polimedia.us</generator>';
mp-wp_genesis 1723 break;
mp-wp_genesis 1724 case 'rdf':
mp-wp_genesis 1725 $gen = '<admin:generatorAgent rdf:resource="http://polimedia.us" />';
mp-wp_genesis 1726 break;
mp-wp_genesis 1727 case 'comment':
mp-wp_genesis 1728 $gen = '<!-- generator="Polimedia/" -->';
mp-wp_genesis 1729 break;
mp-wp_genesis 1730 case 'export':
mp-wp_genesis 1731 $gen = '<!-- generator="Polimedia/" created="'. date('Y-m-d H:i') . '"-->';
mp-wp_genesis 1732 break;
mp-wp_genesis 1733 }
mp-wp_genesis 1734 return apply_filters( "get_the_generator_{$type}", $gen, $type );
mp-wp_genesis 1735 }
mp-wp_genesis 1736
mp-wp_genesis 1737 ?>