wp/wp-includes/general-template.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * General template tags that can go anywhere in a template.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Template
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * Load header template.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * Includes the header template for a theme or if a name is specified then a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * specialised header will be included.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 * For the parameter, if the file is called "header-special.php" then specify
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 * "special".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
 * @param string $name The name of the specialised header.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
function get_header( $name = null ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
	 * Fires before the header template file is loaded.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
	 * The hook allows a specific header template file to be used in place of the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
	 * default header template file. If your file is called header-new.php,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
	 * you would specify the filename in the hook as get_header( 'new' ).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
	 * @since 2.8.0 $name parameter added.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
	 * @param string $name Name of the specific header file to use.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
	do_action( 'get_header', $name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	$templates = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	$name = (string) $name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
	if ( '' !== $name )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
		$templates[] = "header-{$name}.php";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	$templates[] = 'header.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	// Backward compat code will be removed in a future release
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	if ('' == locate_template($templates, true))
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		load_template( ABSPATH . WPINC . '/theme-compat/header.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
 * Load footer template.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
 * Includes the footer template for a theme or if a name is specified then a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
 * specialised footer will be included.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
 * For the parameter, if the file is called "footer-special.php" then specify
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
 * "special".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
 * @param string $name The name of the specialised footer.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
function get_footer( $name = null ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    64
	 * Fires before the footer template file is loaded.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    65
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    66
	 * The hook allows a specific footer template file to be used in place of the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    67
	 * default footer template file. If your file is called footer-new.php,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
	 * you would specify the filename in the hook as get_footer( 'new' ).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
	 * @since 2.8.0 $name parameter added.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    73
	 * @param string $name Name of the specific footer file to use.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    74
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
	do_action( 'get_footer', $name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
	$templates = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	$name = (string) $name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
	if ( '' !== $name )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		$templates[] = "footer-{$name}.php";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	$templates[] = 'footer.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	// Backward compat code will be removed in a future release
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	if ('' == locate_template($templates, true))
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
 * Load sidebar template.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
 * Includes the sidebar template for a theme or if a name is specified then a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
 * specialised sidebar will be included.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
 * For the parameter, if the file is called "sidebar-special.php" then specify
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
 * "special".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
 * @param string $name The name of the specialised sidebar.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
function get_sidebar( $name = null ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   103
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   104
	 * Fires before the sidebar template file is loaded.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   105
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
	 * The hook allows a specific sidebar template file to be used in place of the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   107
	 * default sidebar template file. If your file is called sidebar-new.php,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
	 * you would specify the filename in the hook as get_sidebar( 'new' ).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   109
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   111
	 * @since 2.8.0 $name parameter added.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
	 * @param string $name Name of the specific sidebar file to use.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   114
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
	do_action( 'get_sidebar', $name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
	$templates = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
	$name = (string) $name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
	if ( '' !== $name )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
		$templates[] = "sidebar-{$name}.php";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
	$templates[] = 'sidebar.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
	// Backward compat code will be removed in a future release
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
	if ('' == locate_template($templates, true))
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
		load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
 * Load a template part into a template
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
 * Makes it easy for a theme to reuse sections of code in a easy to overload way
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
 * for child themes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
 * Includes the named template part for a theme or if a name is specified then a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
 * specialised part will be included. If the theme contains no {slug}.php file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
 * then no template will be included.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
 * The template is included using require, not require_once, so you may include the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
 * same template part multiple times.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
 * For the $name parameter, if the file is called "{slug}-special.php" then specify
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
 * "special".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
 * @param string $slug The slug name for the generic template.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
 * @param string $name The name of the specialised template.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
function get_template_part( $slug, $name = null ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   152
	 * Fires before the specified template part file is loaded.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   153
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
	 * The dynamic portion of the hook name, `$slug`, refers to the slug name
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
	 * for the generic template part.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   157
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   158
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
	 * @param string $slug The slug name for the generic template.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   160
	 * @param string $name The name of the specialized template.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   161
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
	do_action( "get_template_part_{$slug}", $slug, $name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	$templates = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
	$name = (string) $name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
	if ( '' !== $name )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
		$templates[] = "{$slug}-{$name}.php";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	$templates[] = "{$slug}.php";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
	locate_template($templates, true, false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
 * Display search form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
 * Will first attempt to locate the searchform.php file in either the child or
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
 * the parent, then load it. If it doesn't exist, then the default search form
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
 * will be displayed. The default search form is HTML, which will be displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
 * There is a filter applied to the search form HTML in order to edit or replace
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
 * it. The filter is 'get_search_form'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
 * This function is primarily used by themes which want to hardcode the search
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
 * form into the sidebar and also by the search widget in WordPress.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
 * There is also an action that is called whenever the function is run called,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
 * 'pre_get_search_form'. This can be useful for outputting JavaScript that the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
 * search relies on or various formatting that applies to the beginning of the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
 * search. To give a few examples of what it can be used for.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
 * @param boolean $echo Default to echo and not return the form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
 * @return string|null String when retrieving, null when displaying or if searchform.php exists.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
function get_search_form( $echo = true ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   197
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   198
	 * Fires before the search form is retrieved, at the start of get_search_form().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   199
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   200
	 * @since 2.7.0 as 'get_search_form' action.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   201
	 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
	 * @link https://core.trac.wordpress.org/ticket/19321
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
	do_action( 'pre_get_search_form' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
	 * Filter the HTML format of the search form.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   211
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
	 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   213
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   214
	 * @param string $format The type of markup to use in the search form.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   215
	 *                       Accepts 'html5', 'xhtml'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   216
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
	$format = apply_filters( 'search_form_format', $format );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
	$search_form_template = locate_template( 'searchform.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
	if ( '' != $search_form_template ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		ob_start();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		require( $search_form_template );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
		$form = ob_get_clean();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
		if ( 'html5' == $format ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
			$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
				<label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . esc_attr_x( 'Search for:', 'label' ) . '" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
				</label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
				<input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
			</form>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
			$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
				<div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
					<label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
					<input type="text" value="' . get_search_query() . '" name="s" id="s" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
					<input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
				</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
			</form>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   244
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   245
	 * Filter the HTML output of the search form.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   246
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   247
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   248
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
	 * @param string $form The search form HTML output.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   250
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
	$result = apply_filters( 'get_search_form', $form );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
	if ( null === $result )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
		$result = $form;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
	if ( $echo )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
		echo $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
		return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
 * Display the Log In/Out link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
 * Displays a link, which allows users to navigate to the Log In page to log in
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
 * or log out depending on whether they are currently logged in.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
 * @param string $redirect Optional path to redirect to on login/logout.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
 * @param boolean $echo Default to echo and not return the link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
 * @return string|null String when retrieving, null when displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
function wp_loginout($redirect = '', $echo = true) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
	if ( ! is_user_logged_in() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   280
	if ( $echo ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   281
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   282
		 * Filter the HTML output for the Log In/Log Out link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   283
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
		 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   285
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   286
		 * @param string $link The HTML link content.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   287
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   288
		echo apply_filters( 'loginout', $link );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   289
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   290
		/** This filter is documented in wp-includes/general-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   291
		return apply_filters( 'loginout', $link );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   292
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
 * Returns the Log Out URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
 * Returns the URL that allows the user to log out of the site.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
 * @param string $redirect Path to redirect to on logout.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
 * @return string A log out URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
function wp_logout_url($redirect = '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
	$args = array( 'action' => 'logout' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
	if ( !empty($redirect) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
		$args['redirect_to'] = urlencode( $redirect );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   315
	 * Filter the logout URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   316
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   318
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
	 * @param string $logout_url The Log Out URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   320
	 * @param string $redirect   Path to redirect to on logout.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   321
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   322
	return apply_filters( 'logout_url', $logout_url, $redirect );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
 * Returns the Log In URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
 * Returns the URL that allows the user to log in to the site.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
 * @param string $redirect Path to redirect to on login.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
 * @return string A log in URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
function wp_login_url($redirect = '', $force_reauth = false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
	$login_url = site_url('wp-login.php', 'login');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
	if ( !empty($redirect) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
		$login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
	if ( $force_reauth )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
		$login_url = add_query_arg('reauth', '1', $login_url);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
	 * Filter the login URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
	 * @since 4.2.0 The `$force_reauth` parameter was added.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   351
	 * @param string $login_url    The login URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
	 * @param string $redirect     The path to redirect to on login, if supplied.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   353
	 * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   355
	return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
 * Returns the user registration URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
 * Returns the URL that allows the user to register on the site.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
 * @since 3.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   365
 * @return string User registration URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
function wp_registration_url() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   368
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   369
	 * Filter the user registration URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   370
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   371
	 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   372
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   373
	 * @param string $register The user registration URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   374
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
 * Provides a simple login form for use anywhere within WordPress. By default, it echoes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
 * the HTML immediately. Pass array('echo'=>false) to return the string instead.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
 * @since 3.0.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   383
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
 * @param array $args Configuration options to modify the form output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
 * @return string|null String when retrieving, null when displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
function wp_login_form( $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
		'echo' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
		'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
		'form_id' => 'loginform',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
		'label_username' => __( 'Username' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
		'label_password' => __( 'Password' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
		'label_remember' => __( 'Remember Me' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
		'label_log_in' => __( 'Log In' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
		'id_username' => 'user_login',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
		'id_password' => 'user_pass',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
		'id_remember' => 'rememberme',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
		'id_submit' => 'wp-submit',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
		'remember' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
		'value_username' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
		'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
	);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   404
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   405
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   406
	 * Filter the default login form output arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   407
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   408
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   409
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   410
	 * @see wp_login_form()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   411
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   412
	 * @param array $defaults An array of default login form arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
	$args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   416
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   417
	 * Filter content to display at the top of the login form.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   418
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   419
	 * The filter evaluates just following the opening form tag element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   420
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   421
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   422
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   423
	 * @param string $content Content to display. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   424
	 * @param array  $args    Array of login form arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   426
	$login_form_top = apply_filters( 'login_form_top', '', $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   427
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   428
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   429
	 * Filter content to display in the middle of the login form.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   430
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   431
	 * The filter evaluates just following the location where the 'login-password'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   432
	 * field is displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   433
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   434
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   435
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   436
	 * @param string $content Content to display. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   437
	 * @param array  $args    Array of login form arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   438
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   439
	$login_form_middle = apply_filters( 'login_form_middle', '', $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   440
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   441
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   442
	 * Filter content to display at the bottom of the login form.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   443
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   444
	 * The filter evaluates just preceding the closing form tag element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   445
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   446
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   447
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   448
	 * @param string $content Content to display. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   449
	 * @param array  $args    Array of login form arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   450
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   451
	$login_form_bottom = apply_filters( 'login_form_bottom', '', $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   452
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
	$form = '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
		<form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   455
			' . $login_form_top . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
			<p class="login-username">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
				<label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
				<input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
			</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
			<p class="login-password">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
				<label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
				<input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
			</p>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   464
			' . $login_form_middle . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
			' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
			<p class="login-submit">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
				<input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
				<input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
			</p>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   470
			' . $login_form_bottom . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
		</form>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
	if ( $args['echo'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
		echo $form;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
		return $form;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
 * Returns the Lost Password URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
 * Returns the URL that allows the user to retrieve the lost password
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
 * @param string $redirect Path to redirect to on login.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
 * @return string Lost password URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
function wp_lostpassword_url( $redirect = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
	$args = array( 'action' => 'lostpassword' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
	if ( !empty($redirect) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
		$args['redirect_to'] = $redirect;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
	$lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   496
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   497
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   498
	 * Filter the Lost Password URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   499
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   500
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   502
	 * @param string $lostpassword_url The lost password page URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   503
	 * @param string $redirect         The path to redirect to on login.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   504
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
	return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
 * Display the Registration or Admin link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
 * Display a link which allows the user to navigate to the registration page if
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
 * not logged in and registration is enabled or to the dashboard if logged in.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   516
 * @param string $before Text to output before the link. Default `<li>`.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   517
 * @param string $after Text to output after the link. Default `</li>`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
 * @param boolean $echo Default to echo and not return the link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
 * @return string|null String when retrieving, null when displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
	if ( ! is_user_logged_in() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
		if ( get_option('users_can_register') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
			$link = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   532
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   533
	 * Filter the HTML link to the Registration or Admin page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   534
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   535
	 * Users are sent to the admin page if logged-in, or the registration page
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   536
	 * if enabled and logged-out.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   537
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   538
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   539
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   540
	 * @param string $link The HTML code for the link to the Registration or Admin page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   541
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
	$link = apply_filters( 'register', $link );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   544
	if ( $echo ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
		echo $link;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   546
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   547
		return $link;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   548
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
 * Theme container function for the 'wp_meta' action.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
 * The 'wp_meta' action can have several purposes, depending on how you use it,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
 * but one purpose might have been to allow for theme switching.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
 * @since 1.5.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   558
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   559
 * @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
function wp_meta() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   562
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   563
	 * Fires before displaying echoed content in the sidebar.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   564
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   565
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   566
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   567
	do_action( 'wp_meta' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
 * Display information about the blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
 * @see get_bloginfo() For possible values for the parameter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
 * @param string $show What to display.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
function bloginfo( $show='' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
	echo get_bloginfo( $show, 'display' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
 * Retrieve information about the blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
 * Some show parameter values are deprecated and will be removed in future
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   586
 * versions. These options will trigger the {@see _deprecated_argument()}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   587
 * function. The deprecated blog info options are listed in the function
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
 * contents.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
 * The possible values for the 'show' parameter are listed below.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   592
 * 1. url - Blog URI to homepage.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   593
 * 2. wpurl - Blog URI path to WordPress.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
 * 3. description - Secondary title
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   596
 * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
 * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
 * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
 * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
 * @param string $show Blog info to retrieve.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
 * @param string $filter How to filter what is retrieved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
 * @return string Mostly string values, might be empty.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
function get_bloginfo( $show = '', $filter = 'raw' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
	switch( $show ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
		case 'home' : // DEPRECATED
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
		case 'siteurl' : // DEPRECATED
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   612
			_deprecated_argument( __FUNCTION__, '2.2', sprintf(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
				/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   614
				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   615
				'<code>' . $show . '</code>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   616
				'<code>bloginfo()</code>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   617
				'<code>url</code>'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   618
			) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
		case 'url' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
			$output = home_url();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
		case 'wpurl' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
			$output = site_url();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
		case 'description':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
			$output = get_option('blogdescription');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
		case 'rdf_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
			$output = get_feed_link('rdf');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
		case 'rss_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
			$output = get_feed_link('rss');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   633
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
		case 'rss2_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
			$output = get_feed_link('rss2');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
		case 'atom_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
			$output = get_feed_link('atom');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
		case 'comments_atom_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
			$output = get_feed_link('comments_atom');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
		case 'comments_rss2_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
			$output = get_feed_link('comments_rss2');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
		case 'pingback_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
			$output = site_url( 'xmlrpc.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
		case 'stylesheet_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
			$output = get_stylesheet_uri();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
		case 'stylesheet_directory':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
			$output = get_stylesheet_directory_uri();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
		case 'template_directory':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
		case 'template_url':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
			$output = get_template_directory_uri();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
		case 'admin_email':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
			$output = get_option('admin_email');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
		case 'charset':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
			$output = get_option('blog_charset');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
			if ('' == $output) $output = 'UTF-8';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
		case 'html_type' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
			$output = get_option('html_type');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
		case 'version':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
			global $wp_version;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
			$output = $wp_version;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
		case 'language':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
			$output = get_locale();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
			$output = str_replace('_', '-', $output);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
		case 'text_direction':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   678
			_deprecated_argument( __FUNCTION__, '2.2', sprintf(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   679
				/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   680
				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   681
				'<code>' . $show . '</code>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   682
				'<code>bloginfo()</code>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   683
				'<code>is_rtl()</code>'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   684
			) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
			if ( function_exists( 'is_rtl' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
				$output = is_rtl() ? 'rtl' : 'ltr';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
				$output = 'ltr';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
		case 'name':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
		default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
			$output = get_option('blogname');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
	$url = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
	if (strpos($show, 'url') === false &&
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
		strpos($show, 'directory') === false &&
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
		strpos($show, 'home') === false)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
		$url = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
	if ( 'display' == $filter ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   704
		if ( $url ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   705
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   706
			 * Filter the URL returned by get_bloginfo().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   707
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   708
			 * @since 2.0.5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   709
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   710
			 * @param mixed $output The URL returned by bloginfo().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   711
			 * @param mixed $show   Type of information requested.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   712
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   713
			$output = apply_filters( 'bloginfo_url', $output, $show );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   714
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   715
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   716
			 * Filter the site information returned by get_bloginfo().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   717
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   718
			 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   719
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   720
			 * @param mixed $output The requested non-URL site information.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   721
			 * @param mixed $show   Type of information requested.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   722
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   723
			$output = apply_filters( 'bloginfo', $output, $show );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   724
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
	return $output;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
 * Display title tag with contents.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
 * @ignore
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   734
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   735
 * @access private
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   736
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
 * @see wp_title()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   738
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   739
function _wp_render_title_tag() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   740
	if ( ! current_theme_supports( 'title-tag' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   741
		return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   742
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   743
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   744
	// This can only work internally on wp_head.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   745
	if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   746
		return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   747
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   748
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   749
	echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   750
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   751
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   752
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
 * Display or retrieve page title for all areas of blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
 * By default, the page title will display the separator before the page title,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
 * so that the blog title will be before the page title. This is not good for
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
 * title display, since the blog title shows up on most tabs and not what is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
 * important, which is the page that the user is looking at.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
 * There are also SEO benefits to having the blog title after or to the 'right'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
 * or the page title. However, it is mostly common sense to have the blog title
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
 * to the right with most browsers supporting tabs. You can achieve this by
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
 * using the seplocation parameter and setting the value to 'right'. This change
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
 * was introduced around 2.5.0, in case backwards compatibility of themes is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
 * important.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
 * @param string $sep Optional, default is '&raquo;'. How to separate the various items within the page title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
 * @param string $seplocation Optional. Direction to display title, 'right'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
 * @return string|null String on retrieve, null when displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   775
	global $wp_locale, $page, $paged;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
	$m = get_query_var('m');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
	$year = get_query_var('year');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
	$monthnum = get_query_var('monthnum');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
	$day = get_query_var('day');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
	$search = get_query_var('s');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
	$title = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
	$t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
	// If there is a post
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
	if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
		$title = single_post_title( '', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
	// If there's a post type archive
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
	if ( is_post_type_archive() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
		$post_type = get_query_var( 'post_type' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
		if ( is_array( $post_type ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
			$post_type = reset( $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
		$post_type_object = get_post_type_object( $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
		if ( ! $post_type_object->has_archive )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
			$title = post_type_archive_title( '', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
	// If there's a category or tag
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
	if ( is_category() || is_tag() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
		$title = single_term_title( '', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
	// If there's a taxonomy
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
	if ( is_tax() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   808
		$term = get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
		if ( $term ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   810
			$tax = get_taxonomy( $term->taxonomy );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
			$title = single_term_title( $tax->labels->name . $t_sep, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
	// If there's an author
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   816
	if ( is_author() && ! is_post_type_archive() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
		$author = get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
		if ( $author )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
			$title = $author->display_name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
	// Post type archives with has_archive should override terms.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
	if ( is_post_type_archive() && $post_type_object->has_archive )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
		$title = post_type_archive_title( '', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
	// If there's a month
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
	if ( is_archive() && !empty($m) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
		$my_year = substr($m, 0, 4);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
		$my_month = $wp_locale->get_month(substr($m, 4, 2));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   830
		$my_day = intval(substr($m, 6, 2));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   831
		$title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   832
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   833
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   834
	// If there's a year
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   835
	if ( is_archive() && !empty($year) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   836
		$title = $year;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
		if ( !empty($monthnum) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   838
			$title .= $t_sep . $wp_locale->get_month($monthnum);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   839
		if ( !empty($day) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
			$title .= $t_sep . zeroise($day, 2);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   841
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   842
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
	// If it's a search
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
	if ( is_search() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
		/* translators: 1: separator, 2: search phrase */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
		$title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
	// If it's a 404 page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
	if ( is_404() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
		$title = __('Page not found');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
	$prefix = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
	if ( !empty($title) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
		$prefix = " $sep ";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   858
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   859
	 * Filter the parts of the page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   860
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   861
	 * @since 4.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   862
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   863
	 * @param array $title_array Parts of the page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   864
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   865
	$title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   866
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
 	// Determines position of the separator and direction of the breadcrumb
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
		$title_array = array_reverse( $title_array );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
		$title = implode( " $sep ", $title_array ) . $prefix;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
		$title = $prefix . implode( " $sep ", $title_array );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   875
	if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   876
		$title .= get_bloginfo( 'name', 'display' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   877
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   878
		$site_description = get_bloginfo( 'description', 'display' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   879
		if ( $site_description && ( is_home() || is_front_page() ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   880
			$title .= " $sep $site_description";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   881
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   882
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   883
		if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   884
			$title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   885
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   886
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   887
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   888
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   889
	 * Filter the text of the page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   890
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   891
	 * @since 2.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   892
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   893
	 * @param string $title       Page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   894
	 * @param string $sep         Title separator.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   895
	 * @param string $seplocation Location of the separator (left or right).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   897
	$title = apply_filters( 'wp_title', $title, $sep, $seplocation );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   898
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   899
	// Send it out
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   900
	if ( $display )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
		echo $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
		return $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
 * Display or retrieve page title for post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   910
 * This is optimized for single.php template file for displaying the post title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
 * It does not support placing the separator after the title, but by leaving the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   913
 * prefix parameter empty, you can set the title separator manually. The prefix
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   914
 * does not automatically place a space between the prefix, so if there should
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
 * be a space, the parameter value will need to have it at the end.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   918
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
 * @param string $prefix Optional. What to display before the title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
 * @return string|null Title when retrieving, null when displaying or failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
function single_post_title($prefix = '', $display = true) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
	$_post = get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
	if ( !isset($_post->post_title) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   929
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   930
	 * Filter the page title for a single post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   931
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   932
	 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   933
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   934
	 * @param string $_post_title The single post page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   935
	 * @param object $_post       The current queried object as returned by get_queried_object().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   936
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   937
	$title = apply_filters( 'single_post_title', $_post->post_title, $_post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
	if ( $display )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
		echo $prefix . $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
		return $prefix . $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
 * Display or retrieve title for a post type archive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
 * This is optimized for archive.php and archive-{$post_type}.php template files
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
 * for displaying the title of the post type.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
 * @param string $prefix Optional. What to display before the title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
 * @return string|null Title when retrieving, null when displaying or failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
function post_type_archive_title( $prefix = '', $display = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
	if ( ! is_post_type_archive() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
	$post_type = get_query_var( 'post_type' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
	if ( is_array( $post_type ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
		$post_type = reset( $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   964
	$post_type_obj = get_post_type_object( $post_type );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   965
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   966
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   967
	 * Filter the post type archive title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   968
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   969
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   970
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   971
	 * @param string $post_type_name Post type 'name' label.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   972
	 * @param string $post_type      Post type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   973
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   974
	$title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   976
	if ( $display )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   977
		echo $prefix . $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   978
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
		return $prefix . $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
 * Display or retrieve page title for category archive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
 * This is useful for category template file or files, because it is optimized
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
 * for category page title and with less overhead than {@link wp_title()}.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
 * It does not support placing the separator after the title, but by leaving the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
 * prefix parameter empty, you can set the title separator manually. The prefix
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   990
 * does not automatically place a space between the prefix, so if there should
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
 * be a space, the parameter value will need to have it at the end.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   992
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   994
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
 * @param string $prefix Optional. What to display before the title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
 * @return string|null Title when retrieving, null when displaying or failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
function single_cat_title( $prefix = '', $display = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
	return single_term_title( $prefix, $display );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1003
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
 * Display or retrieve page title for tag post archive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1006
 * Useful for tag template files for displaying the tag page title. It has less
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
 * overhead than {@link wp_title()}, because of its limited implementation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1008
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
 * It does not support placing the separator after the title, but by leaving the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
 * prefix parameter empty, you can set the title separator manually. The prefix
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1011
 * does not automatically place a space between the prefix, so if there should
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
 * be a space, the parameter value will need to have it at the end.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1015
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
 * @param string $prefix Optional. What to display before the title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
 * @return string|null Title when retrieving, null when displaying or failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
function single_tag_title( $prefix = '', $display = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
	return single_term_title( $prefix, $display );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1022
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1025
 * Display or retrieve page title for taxonomy term archive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
 * Useful for taxonomy term template files for displaying the taxonomy term page title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
 * It has less overhead than {@link wp_title()}, because of its limited implementation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
 * It does not support placing the separator after the title, but by leaving the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
 * prefix parameter empty, you can set the title separator manually. The prefix
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
 * does not automatically place a space between the prefix, so if there should
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
 * be a space, the parameter value will need to have it at the end.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
 * @param string $prefix Optional. What to display before the title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
 * @return string|null Title when retrieving, null when displaying or failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
function single_term_title( $prefix = '', $display = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
	$term = get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
	if ( !$term )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1047
	if ( is_category() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1048
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1049
		 * Filter the category archive page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1050
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1051
		 * @since 2.0.10
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1052
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1053
		 * @param string $term_name Category name for archive being displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1054
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
		$term_name = apply_filters( 'single_cat_title', $term->name );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1056
	} elseif ( is_tag() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1057
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1058
		 * Filter the tag archive page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1059
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1060
		 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1061
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1062
		 * @param string $term_name Tag name for archive being displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1063
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
		$term_name = apply_filters( 'single_tag_title', $term->name );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1065
	} elseif ( is_tax() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1066
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1067
		 * Filter the custom taxonomy archive page title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1068
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1069
		 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1070
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1071
		 * @param string $term_name Term name for archive being displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1072
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
		$term_name = apply_filters( 'single_term_title', $term->name );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1074
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1076
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
	if ( empty( $term_name ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
	if ( $display )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
		echo $prefix . $term_name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
		return $prefix . $term_name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1087
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
 * Display or retrieve page title for post archive based on date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1089
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
 * Useful for when the template only needs to display the month and year, if
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
 * either are available. Optimized for just this purpose, so if it is all that
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
 * is needed, should be better than {@link wp_title()}.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
 * It does not support placing the separator after the title, but by leaving the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
 * prefix parameter empty, you can set the title separator manually. The prefix
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
 * does not automatically place a space between the prefix, so if there should
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
 * be a space, the parameter value will need to have it at the end.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
 * @param string $prefix Optional. What to display before the title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
 * @return string|null Title when retrieving, null when displaying or failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
function single_month_title($prefix = '', $display = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
	global $wp_locale;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
	$m = get_query_var('m');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
	$year = get_query_var('year');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
	$monthnum = get_query_var('monthnum');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
	if ( !empty($monthnum) && !empty($year) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
		$my_year = $year;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
		$my_month = $wp_locale->get_month($monthnum);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
	} elseif ( !empty($m) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
		$my_year = substr($m, 0, 4);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
		$my_month = $wp_locale->get_month(substr($m, 4, 2));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
	if ( empty($my_month) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
	$result = $prefix . $my_month . $prefix . $my_year;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
	if ( !$display )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
		return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
	echo $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1131
 * Display the archive title based on the queried object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1132
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1133
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1134
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1135
 * @see get_the_archive_title()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1136
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1137
 * @param string $before Optional. Content to prepend to the title. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1138
 * @param string $after  Optional. Content to append to the title. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1139
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1140
function the_archive_title( $before = '', $after = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1141
	$title = get_the_archive_title();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1142
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1143
	if ( ! empty( $title ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1144
		echo $before . $title . $after;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1145
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1146
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1147
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1148
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1149
 * Retrieve the archive title based on the queried object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1150
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1151
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1152
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1153
 * @return string Archive title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1154
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1155
function get_the_archive_title() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1156
	if ( is_category() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1157
		$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1158
	} elseif ( is_tag() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1159
		$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1160
	} elseif ( is_author() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1161
		$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1162
	} elseif ( is_year() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1163
		$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1164
	} elseif ( is_month() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1165
		$title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1166
	} elseif ( is_day() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1167
		$title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1168
	} elseif ( is_tax( 'post_format' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1169
		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1170
			$title = _x( 'Asides', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1171
		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1172
			$title = _x( 'Galleries', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1173
		} elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1174
			$title = _x( 'Images', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1175
		} elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1176
			$title = _x( 'Videos', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1177
		} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1178
			$title = _x( 'Quotes', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1179
		} elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1180
			$title = _x( 'Links', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1181
		} elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1182
			$title = _x( 'Statuses', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1183
		} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1184
			$title = _x( 'Audio', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1185
		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1186
			$title = _x( 'Chats', 'post format archive title' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1187
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1188
	} elseif ( is_post_type_archive() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1189
		$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1190
	} elseif ( is_tax() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1191
		$tax = get_taxonomy( get_queried_object()->taxonomy );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1192
		/* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1193
		$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1194
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1195
		$title = __( 'Archives' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1196
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1197
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1198
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1199
	 * Filter the archive title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1200
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1201
	 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1202
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1203
	 * @param string $title Archive title to be displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1204
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1205
	return apply_filters( 'get_the_archive_title', $title );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1206
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1207
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1208
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1209
 * Display category, tag, or term description.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1210
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1211
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1212
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1213
 * @see get_the_archive_description()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1214
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1215
 * @param string $before Optional. Content to prepend to the description. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1216
 * @param string $after  Optional. Content to append to the description. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1217
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1218
function the_archive_description( $before = '', $after = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1219
	$description = get_the_archive_description();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1220
	if ( $description ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1221
		echo $before . $description . $after;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1222
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1223
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1224
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1225
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1226
 * Retrieve category, tag, or term description.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1227
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1228
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1229
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1230
 * @return string Archive description.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1231
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1232
function get_the_archive_description() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1233
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1234
	 * Filter the archive description.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1235
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1236
	 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1237
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1238
	 * @see term_description()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1239
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1240
	 * @param string $description Archive description to be displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1241
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1242
	return apply_filters( 'get_the_archive_description', term_description() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1243
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1244
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1245
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1246
 * Retrieve archive link content based on predefined or custom code.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1247
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1248
 * The format can be one of four styles. The 'link' for head element, 'option'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1249
 * for use in the select element, 'html' for use in list (either ol or ul HTML
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1250
 * elements). Custom content is also supported using the before and after
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
 * parameters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1253
 * The 'link' format uses the `<link>` HTML element with the **archives**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1254
 * relationship. The before and after parameters are not used. The text
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1255
 * parameter is used to describe the link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1256
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
 * The 'option' format uses the option HTML element for use in select element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
 * The value is the url parameter and the before and after parameters are used
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
 * between the text description.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
 * The 'html' format, which is the default, uses the li HTML element for use in
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
 * the list HTML elements. The before parameter is before the link and the after
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
 * parameter is after the closing link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1265
 * The custom format uses the before parameter before the link ('a' HTML
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1266
 * element) and the after parameter after the closing link tag. If the above
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1267
 * three values for the format are not used, then custom format is assumed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1269
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1270
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1271
 * @todo Properly document optional arguments as such
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1272
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
 * @param string $url URL to archive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1274
 * @param string $text Archive text description.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1275
 * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1276
 * @param string $before Optional.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1277
 * @param string $after Optional.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1278
 * @return string HTML link content for archive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1279
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1280
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1281
	$text = wptexturize($text);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1282
	$url = esc_url($url);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1283
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1284
	if ('link' == $format)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1285
		$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1286
	elseif ('option' == $format)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1287
		$link_html = "\t<option value='$url'>$before $text $after</option>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1288
	elseif ('html' == $format)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1289
		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1290
	else // custom
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1291
		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1292
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1293
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1294
	 * Filter the archive link content.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1295
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1296
	 * @since 2.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1297
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1298
	 * @param string $link_html The archive HTML link content.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1299
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1300
	$link_html = apply_filters( 'get_archives_link', $link_html );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1301
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
	return $link_html;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1304
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1305
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
 * Display archive links based on type and format.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1307
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1308
 * @since 1.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1309
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1310
 * @see get_archives_link()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1311
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1312
 * @param string|array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1313
 *     Default archive links arguments. Optional.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1314
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1315
 *     @type string     $type            Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1316
 *                                       'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1317
 *                                       display the same archive link list as well as post titles instead
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1318
 *                                       of displaying dates. The difference between the two is that 'alpha'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1319
 *                                       will order by post title and 'postbypost' will order by post date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1320
 *                                       Default 'monthly'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1321
 *     @type string|int $limit           Number of links to limit the query to. Default empty (no limit).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1322
 *     @type string     $format          Format each link should take using the $before and $after args.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1323
 *                                       Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1324
 *                                       (`<li>` tag), or a custom format, which generates a link anchor
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1325
 *                                       with $before preceding and $after succeeding. Default 'html'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1326
 *     @type string     $before          Markup to prepend to the beginning of each link. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1327
 *     @type string     $after           Markup to append to the end of each link. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1328
 *     @type bool       $show_post_count Whether to display the post count alongside the link. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1329
 *     @type bool|int   $echo            Whether to echo or return the links list. Default 1|true to echo.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1330
 *     @type string     $order           Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1331
 *                                       Default 'DESC'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1332
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1333
 * @return string|null String when retrieving, null when displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1334
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1335
function wp_get_archives( $args = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
	global $wpdb, $wp_locale;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
		'type' => 'monthly', 'limit' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
		'format' => 'html', 'before' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1341
		'after' => '', 'show_post_count' => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1342
		'echo' => 1, 'order' => 'DESC',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1344
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1345
	$r = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1346
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1347
	if ( '' == $r['type'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1348
		$r['type'] = 'monthly';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1349
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1350
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1351
	if ( ! empty( $r['limit'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1352
		$r['limit'] = absint( $r['limit'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1353
		$r['limit'] = ' LIMIT ' . $r['limit'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1354
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1355
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1356
	$order = strtoupper( $r['order'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1357
	if ( $order !== 'ASC' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1358
		$order = 'DESC';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1359
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
	// this is what will separate dates on weekly archive links
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
	$archive_week_separator = '&#8211;';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1363
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
	// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
	$archive_date_format_over_ride = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
	// options for daily archive (only if you over-ride the general date format)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1368
	$archive_day_date_format = 'Y/m/d';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1369
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
	// options for weekly archive (only if you over-ride the general date format)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1371
	$archive_week_start_date_format = 'Y/m/d';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
	$archive_week_end_date_format	= 'Y/m/d';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1374
	if ( ! $archive_date_format_over_ride ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1375
		$archive_day_date_format = get_option( 'date_format' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1376
		$archive_week_start_date_format = get_option( 'date_format' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1377
		$archive_week_end_date_format = get_option( 'date_format' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1378
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1379
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1380
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1381
	 * Filter the SQL WHERE clause for retrieving archives.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1382
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1383
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1384
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1385
	 * @param string $sql_where Portion of SQL query containing the WHERE clause.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1386
	 * @param array  $r         An array of default arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1387
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1388
	$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1389
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1390
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1391
	 * Filter the SQL JOIN clause for retrieving archives.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1392
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1393
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1394
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1395
	 * @param string $sql_join Portion of SQL query containing JOIN clause.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1396
	 * @param array  $r        An array of default arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1397
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1398
	$join = apply_filters( 'getarchives_join', '', $r );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1399
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1400
	$output = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1401
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1402
	$last_changed = wp_cache_get( 'last_changed', 'posts' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1403
	if ( ! $last_changed ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1404
		$last_changed = microtime();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1405
		wp_cache_set( 'last_changed', $last_changed, 'posts' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1406
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1407
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1408
	$limit = $r['limit'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1409
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1410
	if ( 'monthly' == $r['type'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
		$key = md5( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1413
		$key = "wp_get_archives:$key:$last_changed";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1414
		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1415
			$results = $wpdb->get_results( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1416
			wp_cache_set( $key, $results, 'posts' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1417
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1418
		if ( $results ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1419
			$after = $r['after'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1420
			foreach ( (array) $results as $result ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1421
				$url = get_month_link( $result->year, $result->month );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
				/* translators: 1: month name, 2: 4-digit year */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1423
				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1424
				if ( $r['show_post_count'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1425
					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1426
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1427
				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1428
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1429
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1430
	} elseif ( 'yearly' == $r['type'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1431
		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1432
		$key = md5( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1433
		$key = "wp_get_archives:$key:$last_changed";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
			$results = $wpdb->get_results( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
			wp_cache_set( $key, $results, 'posts' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1437
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1438
		if ( $results ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1439
			$after = $r['after'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1440
			foreach ( (array) $results as $result) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1441
				$url = get_year_link( $result->year );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1442
				$text = sprintf( '%d', $result->year );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1443
				if ( $r['show_post_count'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1444
					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1445
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1446
				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1448
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1449
	} elseif ( 'daily' == $r['type'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1450
		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
		$key = md5( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
		$key = "wp_get_archives:$key:$last_changed";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1453
		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1454
			$results = $wpdb->get_results( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
			wp_cache_set( $key, $results, 'posts' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
		if ( $results ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1458
			$after = $r['after'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
			foreach ( (array) $results as $result ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1460
				$url  = get_day_link( $result->year, $result->month, $result->dayofmonth );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1461
				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1462
				$text = mysql2date( $archive_day_date_format, $date );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1463
				if ( $r['show_post_count'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1464
					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1465
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1466
				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1468
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1469
	} elseif ( 'weekly' == $r['type'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1470
		$week = _wp_mysql_week( '`post_date`' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1471
		$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1472
		$key = md5( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
		$key = "wp_get_archives:$key:$last_changed";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1474
		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
			$results = $wpdb->get_results( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1476
			wp_cache_set( $key, $results, 'posts' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
		$arc_w_last = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
		if ( $results ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1480
			$after = $r['after'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1481
			foreach ( (array) $results as $result ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1482
				if ( $result->week != $arc_w_last ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1483
					$arc_year       = $result->yr;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1484
					$arc_w_last     = $result->week;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1485
					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1486
					$arc_week_start = date_i18n( $archive_week_start_date_format, $arc_week['start'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1487
					$arc_week_end   = date_i18n( $archive_week_end_date_format, $arc_week['end'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1488
					$url            = sprintf( '%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $result->week );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1489
					$text           = $arc_week_start . $archive_week_separator . $arc_week_end;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1490
					if ( $r['show_post_count'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1491
						$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
					}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1493
					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1494
				}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1495
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1496
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1497
	} elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1498
		$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1499
		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1500
		$key = md5( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1501
		$key = "wp_get_archives:$key:$last_changed";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1502
		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1503
			$results = $wpdb->get_results( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1504
			wp_cache_set( $key, $results, 'posts' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1505
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1506
		if ( $results ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1507
			foreach ( (array) $results as $result ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1508
				if ( $result->post_date != '0000-00-00 00:00:00' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1509
					$url = get_permalink( $result );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1510
					if ( $result->post_title ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1511
						/** This filter is documented in wp-includes/post-template.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1512
						$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
					} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1514
						$text = $result->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1515
					}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1516
					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1517
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1518
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1519
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1520
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1521
	if ( $r['echo'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1522
		echo $output;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1523
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1524
		return $output;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1525
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1526
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1527
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1529
 * Get number of days since the start of the week.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1530
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1531
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1532
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1533
 * @param int $num Number of day.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1534
 * @return int Days since the start of the week.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1535
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1536
function calendar_week_mod($num) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1537
	$base = 7;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1538
	return ($num - $base*floor($num/$base));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1539
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1540
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1541
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1542
 * Display calendar with days that have posts as links.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1543
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
 * The calendar is cached, which will be retrieved, if it exists. If there are
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
 * no posts for the month, then it will not be displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1546
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1548
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1549
 * @param bool $initial Optional, default is true. Use initial calendar names.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1550
 * @param bool $echo Optional, default is true. Set to false for return.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1551
 * @return string|null String when retrieving, null when displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1552
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1553
function get_calendar($initial = true, $echo = true) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1554
	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1555
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1556
	$key = md5( $m . $monthnum . $year );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1557
	if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1558
		if ( is_array($cache) && isset( $cache[ $key ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1559
			if ( $echo ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1560
				/** This filter is documented in wp-includes/general-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1561
				echo apply_filters( 'get_calendar', $cache[$key] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1562
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1563
			} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1564
				/** This filter is documented in wp-includes/general-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1565
				return apply_filters( 'get_calendar', $cache[$key] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1566
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1567
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1568
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1569
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1570
	if ( !is_array($cache) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
		$cache = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1573
	// Quick check. If we have no posts at all, abort!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1574
	if ( !$posts ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1575
		$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1576
		if ( !$gotsome ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1577
			$cache[ $key ] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1578
			wp_cache_set( 'get_calendar', $cache, 'calendar' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1579
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1580
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1581
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1582
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1583
	if ( isset($_GET['w']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1584
		$w = ''.intval($_GET['w']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1585
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1586
	// week_begins = 0 stands for Sunday
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1587
	$week_begins = intval(get_option('start_of_week'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1588
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1589
	// Let's figure out when we are
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1590
	if ( !empty($monthnum) && !empty($year) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1591
		$thismonth = ''.zeroise(intval($monthnum), 2);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1592
		$thisyear = ''.intval($year);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1593
	} elseif ( !empty($w) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
		// We need to get the month from MySQL
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1595
		$thisyear = ''.intval(substr($m, 0, 4));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1596
		$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1597
		$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1598
	} elseif ( !empty($m) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1599
		$thisyear = ''.intval(substr($m, 0, 4));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1600
		if ( strlen($m) < 6 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1601
				$thismonth = '01';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1602
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1603
				$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1604
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1605
		$thisyear = gmdate('Y', current_time('timestamp'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1606
		$thismonth = gmdate('m', current_time('timestamp'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1607
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1608
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1609
	$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1610
	$last_day = date('t', $unixmonth);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1611
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1612
	// Get the next and previous month and year with at least one post
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1613
	$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1614
		FROM $wpdb->posts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1615
		WHERE post_date < '$thisyear-$thismonth-01'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1616
		AND post_type = 'post' AND post_status = 'publish'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1617
			ORDER BY post_date DESC
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1618
			LIMIT 1");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1619
	$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
		FROM $wpdb->posts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1621
		WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
		AND post_type = 'post' AND post_status = 'publish'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1623
			ORDER BY post_date ASC
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
			LIMIT 1");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1625
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1626
	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1627
	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1628
	$calendar_output = '<table id="wp-calendar">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1629
	<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1630
	<thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1631
	<tr>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1632
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1633
	$myweek = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1634
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1635
	for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
		$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1637
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1638
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1639
	foreach ( $myweek as $wd ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1640
		$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1641
		$wd = esc_attr($wd);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1642
		$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1643
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1644
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1645
	$calendar_output .= '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1647
	</thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1648
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1649
	<tfoot>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1650
	<tr>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1651
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1652
	if ( $previous ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1653
		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1654
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1656
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1658
	$calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1660
	if ( $next ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1661
		$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1662
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
		$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1664
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1665
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1666
	$calendar_output .= '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1668
	</tfoot>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1669
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1670
	<tbody>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1671
	<tr>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1672
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1673
	$daywithpost = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1674
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1675
	// Get days with posts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1676
	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1677
		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1678
		AND post_type = 'post' AND post_status = 'publish'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1679
		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
	if ( $dayswithposts ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
		foreach ( (array) $dayswithposts as $daywith ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1682
			$daywithpost[] = $daywith[0];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1684
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1685
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1686
	if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
		$ak_title_separator = "\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1688
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1689
		$ak_title_separator = ', ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1690
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1691
	$ak_titles_for_day = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1692
	$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1693
		."FROM $wpdb->posts "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1694
		."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1695
		."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1696
		."AND post_type = 'post' AND post_status = 'publish'"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1698
	if ( $ak_post_titles ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1699
		foreach ( (array) $ak_post_titles as $ak_post_title ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1700
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1701
				/** This filter is documented in wp-includes/post-template.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1702
				$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1703
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1704
				if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1705
					$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1706
				if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1707
					$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1708
				else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1709
					$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1710
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1711
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1712
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1713
	// See how much we should pad in the beginning
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
	$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
	if ( 0 != $pad )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1716
		$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1717
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1718
	$daysinmonth = intval(date('t', $unixmonth));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1719
	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
		if ( isset($newrow) && $newrow )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
		$newrow = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
		if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
			$calendar_output .= '<td id="today">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1726
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
			$calendar_output .= '<td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1728
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1729
		if ( in_array($day, $daywithpost) ) // any posts today?
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1730
				$calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1731
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1732
			$calendar_output .= $day;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1733
		$calendar_output .= '</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1734
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
		if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1736
			$newrow = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1737
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1738
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1739
	$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1740
	if ( $pad != 0 && $pad != 7 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1741
		$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1742
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1744
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1745
	$cache[ $key ] = $calendar_output;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1746
	wp_cache_set( 'get_calendar', $cache, 'calendar' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1747
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1748
	if ( $echo ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1749
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1750
		 * Filter the HTML calendar output.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1751
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1752
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1753
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1754
		 * @param string $calendar_output HTML output of the calendar.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1755
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1756
		echo apply_filters( 'get_calendar', $calendar_output );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1757
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1758
		/** This filter is documented in wp-includes/general-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1759
		return apply_filters( 'get_calendar', $calendar_output );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1760
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1761
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1762
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1763
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
 * Purge the cached results of get_calendar.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
 * @see get_calendar
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1768
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1769
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1770
function delete_get_calendar_cache() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1771
	wp_cache_delete( 'get_calendar', 'calendar' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1772
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1774
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
 * Display all of the allowed tags in HTML format with attributes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1777
 * This is useful for displaying in the comment area, which elements and
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1778
 * attributes are supported. As well as any plugins which want to display it.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1779
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
 * @since 1.0.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
 * @uses $allowedtags
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1783
 * @return string HTML allowed tags entity encoded.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1785
function allowed_tags() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
	global $allowedtags;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1787
	$allowed = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1788
	foreach ( (array) $allowedtags as $tag => $attributes ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1789
		$allowed .= '<'.$tag;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1790
		if ( 0 < count($attributes) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1791
			foreach ( $attributes as $attribute => $limits ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1792
				$allowed .= ' '.$attribute.'=""';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1793
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1794
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1795
		$allowed .= '> ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1796
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
	return htmlentities($allowed);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
/***** Date/Time tags *****/
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1801
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1802
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1803
 * Outputs the date in iso8601 format for xml files.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1804
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1805
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1806
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1807
function the_date_xml() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
	echo mysql2date( 'Y-m-d', get_post()->post_date, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1809
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1811
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1812
 * Display or Retrieve the date the current post was written (once per date)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1814
 * Will only output the date if the current post's date is different from the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
 * previous one output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1817
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1818
 * function is called several times for each post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1819
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1820
 * HTML output can be filtered with 'the_date'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1821
 * Date string output can be filtered with 'get_the_date'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1823
 * @since 0.71
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1824
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1825
 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1826
 * @param string $before Optional. Output before the date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1827
 * @param string $after Optional. Output after the date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1828
 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1829
 * @return string|null Null if displaying, string if retrieving.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1830
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
function the_date( $d = '', $before = '', $after = '', $echo = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1832
	global $currentday, $previousday;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1833
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1834
	if ( $currentday != $previousday ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1835
		$the_date = $before . get_the_date( $d ) . $after;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1836
		$previousday = $currentday;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1837
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1838
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1839
		 * Filter the date a post was published for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1840
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1841
		 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1842
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1843
		 * @param string $the_date The formatted date string.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1844
		 * @param string $d        PHP date format. Defaults to 'date_format' option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1845
		 *                         if not specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1846
		 * @param string $before   HTML output before the date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1847
		 * @param string $after    HTML output after the date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1848
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1849
		$the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1851
		if ( $echo )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1852
			echo $the_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1853
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1854
			return $the_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1855
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1856
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1857
	return null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1858
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1860
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1861
 * Retrieve the date on which the post was written.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1862
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1863
 * Unlike the_date() this function will always return the date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1864
 * Modify output with 'get_the_date' filter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1866
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1867
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1868
 * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1869
 * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1870
 * @return false|string Date the current post was written. False on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1871
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1872
function get_the_date( $d = '', $post = null ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1873
	$post = get_post( $post );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1874
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1875
	if ( ! $post ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1876
		return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1877
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1878
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1879
	if ( '' == $d ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1880
		$the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1881
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1882
		$the_date = mysql2date( $d, $post->post_date );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1883
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1884
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1885
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1886
	 * Filter the date a post was published.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1887
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1888
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1889
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1890
	 * @param string      $the_date The formatted date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1891
	 * @param string      $d        PHP date format. Defaults to 'date_format' option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1892
	 *                              if not specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1893
	 * @param int|WP_Post $post     The post object or ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1894
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1895
	return apply_filters( 'get_the_date', $the_date, $d, $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1896
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1897
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1898
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1899
 * Display the date on which the post was last modified.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1900
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1901
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1902
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
 * @param string $before Optional. Output before the date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
 * @param string $after Optional. Output after the date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1907
 * @return string|null Null if displaying, string if retrieving.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1908
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1909
function the_modified_date($d = '', $before='', $after='', $echo = true) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1910
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1911
	$the_modified_date = $before . get_the_modified_date($d) . $after;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1912
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1913
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1914
	 * Filter the date a post was last modified for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1915
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1916
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1917
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1918
	 * @param string $the_modified_date The last modified date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1919
	 * @param string $d                 PHP date format. Defaults to 'date_format' option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1920
	 *                                  if not specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1921
	 * @param string $before            HTML output before the date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1922
	 * @param string $after             HTML output after the date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1923
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1924
	$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1925
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1926
	if ( $echo )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1927
		echo $the_modified_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1928
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1929
		return $the_modified_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1930
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1931
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1932
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1933
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
 * Retrieve the date on which the post was last modified.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1935
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1936
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1937
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1938
 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1940
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
function get_the_modified_date($d = '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1942
	if ( '' == $d )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1943
		$the_time = get_post_modified_time(get_option('date_format'), null, null, true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1944
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
		$the_time = get_post_modified_time($d, null, null, true);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1946
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1947
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1948
	 * Filter the date a post was last modified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1949
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1950
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1951
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1952
	 * @param string $the_time The formatted date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1953
	 * @param string $d        PHP date format. Defaults to value specified in
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1954
	 *                         'date_format' option.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1955
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1956
	return apply_filters( 'get_the_modified_date', $the_time, $d );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1957
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1958
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1959
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1960
 * Display the time at which the post was written.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1961
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1963
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1964
 * @param string $d Either 'G', 'U', or php date format.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1965
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1966
function the_time( $d = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1967
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1968
	 * Filter the time a post was written for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1969
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1970
	 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1971
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1972
	 * @param string $get_the_time The formatted time.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1973
	 * @param string $d            The time format. Accepts 'G', 'U',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1974
	 *                             or php date format.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1975
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1976
	echo apply_filters( 'the_time', get_the_time( $d ), $d );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1977
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1978
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1979
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1980
 * Retrieve the time at which the post was written.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1981
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1982
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1983
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1984
 * @param string      $d    Optional. Format to use for retrieving the time the post
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1985
 *                          was written. Either 'G', 'U', or php date format defaults
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1986
 *                          to the value specified in the time_format option. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1987
 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1988
 * @return false|string Formatted date string or Unix timestamp. False on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1989
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1990
function get_the_time( $d = '', $post = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1991
	$post = get_post($post);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1993
	if ( ! $post ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1994
		return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1995
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1996
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1997
	if ( '' == $d )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1998
		$the_time = get_post_time(get_option('time_format'), false, $post, true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1999
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2000
		$the_time = get_post_time($d, false, $post, true);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2001
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2002
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2003
	 * Filter the time a post was written.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2004
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2005
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2006
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2007
	 * @param string      $the_time The formatted time.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2008
	 * @param string      $d        Format to use for retrieving the time the post was written.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2009
	 *                              Accepts 'G', 'U', or php date format value specified
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2010
	 *                              in 'time_format' option. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2011
	 * @param int|WP_Post $post     WP_Post object or ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2012
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2013
	return apply_filters( 'get_the_time', $the_time, $d, $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2014
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2015
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2016
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2017
 * Retrieve the time at which the post was written.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2018
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2019
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2020
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2021
 * @param string      $d         Optional. Format to use for retrieving the time the post
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2022
 *                               was written. Either 'G', 'U', or php date format. Default 'U'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2023
 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2024
 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2025
 * @param bool        $translate Whether to translate the time string. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2026
 * @return false|string|int Formatted date string or Unix timestamp. False on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2027
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2028
function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2029
	$post = get_post($post);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2030
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2031
	if ( ! $post ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2032
		return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2033
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2034
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2035
	if ( $gmt )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2036
		$time = $post->post_date_gmt;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2037
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2038
		$time = $post->post_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2039
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2040
	$time = mysql2date($d, $time, $translate);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2041
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2042
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2043
	 * Filter the localized time a post was written.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2044
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2045
	 * @since 2.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2046
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2047
	 * @param string $time The formatted time.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2048
	 * @param string $d    Format to use for retrieving the time the post was written.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2049
	 *                     Accepts 'G', 'U', or php date format. Default 'U'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2050
	 * @param bool   $gmt  Whether to retrieve the GMT time. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2051
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2052
	return apply_filters( 'get_post_time', $time, $d, $gmt );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2053
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2054
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2055
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2056
 * Display the time at which the post was last modified.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2057
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2058
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2059
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2060
 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2061
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2062
function the_modified_time($d = '') {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2063
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2064
	 * Filter the localized time a post was last modified, for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2065
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2066
	 * @since 2.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2067
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2068
	 * @param string $get_the_modified_time The formatted time.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2069
	 * @param string $d                     The time format. Accepts 'G', 'U',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2070
	 *                                      or php date format. Defaults to value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2071
	 *                                      specified in 'time_format' option.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2072
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2073
	echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2074
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2075
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2076
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2077
 * Retrieve the time at which the post was last modified.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2078
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2079
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2080
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2081
 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2082
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2083
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2084
function get_the_modified_time($d = '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2085
	if ( '' == $d )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2086
		$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2087
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2088
		$the_time = get_post_modified_time($d, null, null, true);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2089
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2090
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2091
	 * Filter the localized time a post was last modified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2092
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2093
	 * @since 2.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2094
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2095
	 * @param string $the_time The formatted time.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2096
	 * @param string $d        Format to use for retrieving the time the post was
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2097
	 *                         written. Accepts 'G', 'U', or php date format. Defaults
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2098
	 *                         to value specified in 'time_format' option.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2099
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2100
	return apply_filters( 'get_the_modified_time', $the_time, $d );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2101
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2102
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2103
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2104
 * Retrieve the time at which the post was last modified.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2105
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2106
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2107
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2108
 * @param string      $d         Optional. Format to use for retrieving the time the post
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2109
 *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2110
 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2111
 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2112
 * @param bool        $translate Whether to translate the time string. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2113
 * @return false|string Formatted date string or Unix timestamp. False on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2114
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2115
function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2116
	$post = get_post($post);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2117
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2118
	if ( ! $post ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2119
		return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2120
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2121
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2122
	if ( $gmt )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2123
		$time = $post->post_modified_gmt;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2124
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2125
		$time = $post->post_modified;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2126
	$time = mysql2date($d, $time, $translate);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2128
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2129
	 * Filter the localized time a post was last modified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2130
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2131
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2132
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2133
	 * @param string $time The formatted time.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2134
	 * @param string $d    The date format. Accepts 'G', 'U', or php date format. Default 'U'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2135
	 * @param bool   $gmt  Whether to return the GMT time. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2136
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2137
	return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2138
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2139
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2140
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2141
 * Display the weekday on which the post was written.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2142
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2143
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2144
 * @uses $wp_locale
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2145
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2146
function the_weekday() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2147
	global $wp_locale;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2148
	$the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2149
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2150
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2151
	 * Filter the weekday on which the post was written, for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2152
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2153
	 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2154
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2155
	 * @param string $the_weekday
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2156
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2157
	$the_weekday = apply_filters( 'the_weekday', $the_weekday );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2158
	echo $the_weekday;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2159
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2160
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2161
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2162
 * Display the weekday on which the post was written.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2163
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2164
 * Will only output the weekday if the current post's weekday is different from
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2165
 * the previous one output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2166
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2167
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2168
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2169
 * @param string $before Optional Output before the date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2170
 * @param string $after Optional Output after the date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2171
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2172
function the_weekday_date($before='',$after='') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2173
	global $wp_locale, $currentday, $previousweekday;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2174
	$the_weekday_date = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2175
	if ( $currentday != $previousweekday ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2176
		$the_weekday_date .= $before;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2177
		$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2178
		$the_weekday_date .= $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2179
		$previousweekday = $currentday;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2180
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2181
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2182
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2183
	 * Filter the localized date on which the post was written, for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2184
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2185
	 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2186
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2187
	 * @param string $the_weekday_date
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2188
	 * @param string $before           The HTML to output before the date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2189
	 * @param string $after            The HTML to output after the date.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2190
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2191
	$the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2192
	echo $the_weekday_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2193
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2194
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2195
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2196
 * Fire the wp_head action
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2197
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2198
 * @since 1.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2199
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2200
function wp_head() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2201
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2202
	 * Print scripts or data in the head tag on the front end.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2203
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2204
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2205
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2206
	do_action( 'wp_head' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2207
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2208
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2209
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2210
 * Fire the wp_footer action
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2211
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2212
 * @since 1.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2213
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2214
function wp_footer() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2215
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2216
	 * Print scripts or data before the closing body tag on the front end.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2217
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2218
	 * @since 1.5.1
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2219
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2220
	do_action( 'wp_footer' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2221
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2222
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2223
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2224
 * Display the links to the general feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2225
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2226
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2227
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2228
 * @param array $args Optional arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2229
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2230
function feed_links( $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2231
	if ( !current_theme_supports('automatic-feed-links') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2232
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2233
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2234
	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2235
		/* translators: Separator between blog name and feed type in feed links */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2236
		'separator'	=> _x('&raquo;', 'feed link'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2237
		/* translators: 1: blog title, 2: separator (raquo) */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2238
		'feedtitle'	=> __('%1$s %2$s Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2239
		/* translators: 1: blog title, 2: separator (raquo) */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2240
		'comstitle'	=> __('%1$s %2$s Comments Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2241
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2242
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2243
	$args = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2244
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2245
	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2246
	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2247
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2248
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2249
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2250
 * Display the links to the extra feeds such as category feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2251
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2252
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2253
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2254
 * @param array $args Optional arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2255
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2256
function feed_links_extra( $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2257
	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2258
		/* translators: Separator between blog name and feed type in feed links */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2259
		'separator'   => _x('&raquo;', 'feed link'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2260
		/* translators: 1: blog name, 2: separator(raquo), 3: post title */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2261
		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2262
		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2263
		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2264
		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2265
		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2266
		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2267
		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2268
		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2269
		'searchtitle' => __('%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2270
		/* translators: 1: blog name, 2: separator(raquo), 3: post type name */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2271
		'posttypetitle' => __('%1$s %2$s %3$s Feed'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2272
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2273
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2274
	$args = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2275
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2276
	if ( is_singular() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2277
		$id = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2278
		$post = get_post( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2279
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2280
		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2281
			$title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2282
			$href = get_post_comments_feed_link( $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2283
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2284
	} elseif ( is_post_type_archive() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2285
		$post_type = get_query_var( 'post_type' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2286
		if ( is_array( $post_type ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2287
			$post_type = reset( $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2288
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2289
		$post_type_obj = get_post_type_object( $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2290
		$title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2291
		$href = get_post_type_archive_feed_link( $post_type_obj->name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2292
	} elseif ( is_category() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2293
		$term = get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2294
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2295
		if ( $term ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2296
			$title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2297
			$href = get_category_feed_link( $term->term_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2298
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2299
	} elseif ( is_tag() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2300
		$term = get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2301
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2302
		if ( $term ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2303
			$title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2304
			$href = get_tag_feed_link( $term->term_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2305
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2306
	} elseif ( is_author() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2307
		$author_id = intval( get_query_var('author') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2308
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2309
		$title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2310
		$href = get_author_feed_link( $author_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2311
	} elseif ( is_search() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2312
		$title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2313
		$href = get_search_feed_link();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2314
	} elseif ( is_post_type_archive() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2315
		$title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2316
		$post_type_obj = get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2317
		if ( $post_type_obj )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2318
			$href = get_post_type_archive_feed_link( $post_type_obj->name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2319
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2320
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2321
	if ( isset($title) && isset($href) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2322
		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2323
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2324
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2325
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2326
 * Display the link to the Really Simple Discovery service endpoint.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2327
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2328
 * @link http://archipelago.phrasewise.com/rsd
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2329
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2330
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2331
function rsd_link() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2332
	echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2333
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2334
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2335
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2336
 * Display the link to the Windows Live Writer manifest file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2337
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2338
 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2339
 * @since 2.3.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2340
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2341
function wlwmanifest_link() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2342
	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2343
		includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2344
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2345
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2346
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2347
 * Display a noindex meta tag if required by the blog configuration.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2348
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2349
 * If a blog is marked as not being public then the noindex meta tag will be
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2350
 * output to tell web robots not to index the page content. Add this to the wp_head action.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2351
 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2352
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2353
 * @see wp_no_robots
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2354
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2355
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2356
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2357
function noindex() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2358
	// If the blog is not public, tell robots to go away.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2359
	if ( '0' == get_option('blog_public') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2360
		wp_no_robots();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2361
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2362
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2363
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2364
 * Display a noindex meta tag.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2365
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2366
 * Outputs a noindex meta tag that tells web robots not to index the page content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2367
 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2368
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2369
 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2370
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2371
function wp_no_robots() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2372
	echo "<meta name='robots' content='noindex,follow' />\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2373
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2374
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2375
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2376
 * Whether the user should have a WYSIWIG editor.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2377
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2378
 * Checks that the user requires a WYSIWIG editor and that the editor is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2379
 * supported in the users browser.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2382
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2383
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2384
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2385
function user_can_richedit() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2386
	global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2387
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2388
	if ( !isset($wp_rich_edit) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2389
		$wp_rich_edit = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2390
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2391
		if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2392
			if ( $is_safari ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2393
				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2394
			} elseif ( $is_gecko || $is_chrome || $is_IE || ( $is_opera && !wp_is_mobile() ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2395
				$wp_rich_edit = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2396
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2397
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2398
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2399
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2400
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2401
	 * Filter whether the user can access the rich (Visual) editor.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2402
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2403
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2404
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2405
	 * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2406
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2407
	return apply_filters( 'user_can_richedit', $wp_rich_edit );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2408
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2409
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2410
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2411
 * Find out which editor should be displayed by default.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2412
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2413
 * Works out which of the two editors to display as the current editor for a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2414
 * user. The 'html' setting is for the "Text" editor tab.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2415
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2416
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2417
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2418
 * @return string Either 'tinymce', or 'html', or 'test'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2419
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2420
function wp_default_editor() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2421
	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2422
	if ( wp_get_current_user() ) { // look for cookie
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2423
		$ed = get_user_setting('editor', 'tinymce');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2424
		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2425
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2426
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2427
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2428
	 * Filter which editor should be displayed by default.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2429
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2430
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2431
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2432
	 * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2433
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2434
	return apply_filters( 'wp_default_editor', $r );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2435
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2436
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2437
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2438
 * Renders an editor.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2439
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2440
 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2441
 * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2442
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2443
 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2444
 * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2445
 * On the post edit screen several actions can be used to include additional editors
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2446
 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2447
 * See https://core.trac.wordpress.org/ticket/19173 for more information.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2448
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2449
 * @see wp-includes/class-wp-editor.php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2450
 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2451
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2452
 * @param string $content Initial content for the editor.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2453
 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2454
 * @param array $settings See _WP_Editors::editor().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2455
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2456
function wp_editor( $content, $editor_id, $settings = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2457
	if ( ! class_exists( '_WP_Editors' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2458
		require( ABSPATH . WPINC . '/class-wp-editor.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2459
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2460
	_WP_Editors::editor($content, $editor_id, $settings);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2461
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2462
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2463
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2464
 * Retrieve the contents of the search WordPress query variable.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2465
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2466
 * The search query string is passed through {@link esc_attr()}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2467
 * to ensure that it is safe for placing in an html attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2468
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2469
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2470
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2471
 * @param bool $escaped Whether the result is escaped. Default true.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2472
 * 	Only use when you are later escaping it. Do not use unescaped.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2473
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2474
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2475
function get_search_query( $escaped = true ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2476
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2477
	 * Filter the contents of the search query variable.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2478
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2479
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2480
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2481
	 * @param mixed $search Contents of the search query variable.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2482
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2483
	$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2484
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2485
	if ( $escaped )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2486
		$query = esc_attr( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2487
	return $query;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2488
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2489
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2490
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2491
 * Display the contents of the search query variable.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2492
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2493
 * The search query string is passed through {@link esc_attr()}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2494
 * to ensure that it is safe for placing in an html attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2495
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2496
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2497
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2498
function the_search_query() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2499
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2500
	 * Filter the contents of the search query variable for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2501
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2502
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2503
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2504
	 * @param mixed $search Contents of the search query variable.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2505
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2506
	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2507
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2508
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2509
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2510
 * Display the language attributes for the html tag.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2511
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2512
 * Builds up a set of html attributes containing the text direction and language
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2513
 * information for the page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2514
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2515
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2516
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2517
 * @param string $doctype The type of html document (xhtml|html).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2518
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2519
function language_attributes($doctype = 'html') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2520
	$attributes = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2521
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2522
	if ( function_exists( 'is_rtl' ) && is_rtl() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2523
		$attributes[] = 'dir="rtl"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2524
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2525
	if ( $lang = get_bloginfo('language') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2526
		if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2527
			$attributes[] = "lang=\"$lang\"";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2528
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2529
		if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2530
			$attributes[] = "xml:lang=\"$lang\"";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2531
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2532
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2533
	$output = implode(' ', $attributes);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2534
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2535
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2536
	 * Filter the language attributes for display in the html tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2537
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2538
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2539
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2540
	 * @param string $output A space-separated list of language attributes.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2541
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2542
	echo apply_filters( 'language_attributes', $output );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2543
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2544
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2545
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2546
 * Retrieve paginated link for archive post pages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2547
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2548
 * Technically, the function can be used to create paginated link list for any
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2549
 * area. The 'base' argument is used to reference the url, which will be used to
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2550
 * create the paginated links. The 'format' argument is then used for replacing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2551
 * the page number. It is however, most likely and by default, to be used on the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2552
 * archive post pages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2553
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2554
 * The 'type' argument controls format of the returned value. The default is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2555
 * 'plain', which is just a string with the links separated by a newline
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2556
 * character. The other possible values are either 'array' or 'list'. The
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2557
 * 'array' value will return an array of the paginated link list to offer full
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2558
 * control of display. The 'list' value will place all of the paginated links in
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2559
 * an unordered HTML list.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2560
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2561
 * The 'total' argument is the total amount of pages and is an integer. The
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2562
 * 'current' argument is the current page number and is also an integer.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2563
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2564
 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2565
 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2566
 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2567
 * and the '%#%' is also required. The '%#%' will be replaced with the page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2568
 * number.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2569
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2570
 * You can include the previous and next links in the list by setting the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2571
 * 'prev_next' argument to true, which it is by default. You can set the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2572
 * previous text, by using the 'prev_text' argument. You can set the next text
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2573
 * by setting the 'next_text' argument.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2574
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2575
 * If the 'show_all' argument is set to true, then it will show all of the pages
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2576
 * instead of a short list of the pages near the current page. By default, the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2577
 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2578
 * arguments. The 'end_size' argument is how many numbers on either the start
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2579
 * and the end list edges, by default is 1. The 'mid_size' argument is how many
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2580
 * numbers to either side of current page, but not including current page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2581
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2582
 * It is possible to add query vars to the link by using the 'add_args' argument
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2583
 * and see {@link add_query_arg()} for more information.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2584
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2585
 * The 'before_page_number' and 'after_page_number' arguments allow users to
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2586
 * augment the links themselves. Typically this might be to add context to the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2587
 * numbered links so that screen reader users understand what the links are for.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2588
 * The text strings are added before and after the page number - within the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2589
 * anchor tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2590
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2591
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2592
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2593
 * @param string|array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2594
 *     Optional. Array or string of arguments for generating paginated links for archives.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2595
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2596
 *     @type string $base               Base of the paginated url. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2597
 *     @type string $format             Format for the pagination structure. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2598
 *     @type int    $total              The total amount of pages. Default is the value WP_Query's
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2599
 *                                      `max_num_pages` or 1.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2600
 *     @type int    $current            The current page number. Default is 'paged' query var or 1.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2601
 *     @type bool   $show_all           Whether to show all pages. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2602
 *     @type int    $end_size           How many numbers on either the start and the end list edges.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2603
 *                                      Default 1.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2604
 *     @type int    $mid_size           How many numbers to either side of the current pages. Default 2.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2605
 *     @type bool   $prev_next          Whether to include the previous and next links in the list. Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2606
 *     @type bool   $prev_text          The previous page text. Default '« Previous'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2607
 *     @type bool   $next_text          The next page text. Default '« Previous'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2608
 *     @type string $type               Controls format of the returned value. Possible values are 'plain',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2609
 *                                      'array' and 'list'. Default is 'plain'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2610
 *     @type array  $add_args           An array of query args to add. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2611
 *     @type string $add_fragment       A string to append to each link. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2612
 *     @type string $before_page_number A string to appear before the page number. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2613
 *     @type string $after_page_number  A string to append after the page number. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2614
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2615
 * @return array|string String of page links or array of page links.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2616
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2617
function paginate_links( $args = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2618
	global $wp_query, $wp_rewrite;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2619
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2620
	// Setting up default values based on the current URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2621
	$pagenum_link = html_entity_decode( get_pagenum_link() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2622
	$url_parts    = explode( '?', $pagenum_link );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2623
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2624
	// Get max pages and current page out of the current query, if available.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2625
	$total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2626
	$current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2627
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2628
	// Append the format placeholder to the base URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2629
	$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2630
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2631
	// URL base depends on permalink settings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2632
	$format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2633
	$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2634
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2635
	$defaults = array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2636
		'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2637
		'format' => $format, // ?page=%#% : %#% is replaced by the page number
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2638
		'total' => $total,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2639
		'current' => $current,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2640
		'show_all' => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2641
		'prev_next' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2642
		'prev_text' => __('&laquo; Previous'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2643
		'next_text' => __('Next &raquo;'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2644
		'end_size' => 1,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2645
		'mid_size' => 2,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2646
		'type' => 'plain',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2647
		'add_args' => array(), // array of query args to add
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2648
		'add_fragment' => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2649
		'before_page_number' => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2650
		'after_page_number' => ''
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2651
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2652
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2653
	$args = wp_parse_args( $args, $defaults );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2654
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2655
	if ( ! is_array( $args['add_args'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2656
		$args['add_args'] = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2657
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2658
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2659
	// Merge additional query vars found in the original URL into 'add_args' array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2660
	if ( isset( $url_parts[1] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2661
		// Find the format argument.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2662
		$format_query = parse_url( str_replace( '%_%', $args['format'], $args['base'] ), PHP_URL_QUERY );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2663
		wp_parse_str( $format_query, $format_arg );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2664
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2665
		// Remove the format argument from the array of query arguments, to avoid overwriting custom format.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2666
		wp_parse_str( remove_query_arg( array_keys( $format_arg ), $url_parts[1] ), $query_args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2667
		$args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $query_args ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2668
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2669
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2670
	// Who knows what else people pass in $args
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2671
	$total = (int) $args['total'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2672
	if ( $total < 2 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2673
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2674
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2675
	$current  = (int) $args['current'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2676
	$end_size = (int) $args['end_size']; // Out of bounds?  Make it the default.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2677
	if ( $end_size < 1 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2678
		$end_size = 1;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2679
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2680
	$mid_size = (int) $args['mid_size'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2681
	if ( $mid_size < 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2682
		$mid_size = 2;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2683
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2684
	$add_args = $args['add_args'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2685
	$r = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2686
	$page_links = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2687
	$dots = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2688
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2689
	if ( $args['prev_next'] && $current && 1 < $current ) :
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2690
		$link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2691
		$link = str_replace( '%#%', $current - 1, $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2692
		if ( $add_args )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2693
			$link = add_query_arg( $add_args, $link );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2694
		$link .= $args['add_fragment'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2695
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2696
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2697
		 * Filter the paginated links for the given archive pages.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2698
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2699
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2700
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2701
		 * @param string $link The paginated link URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2702
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2703
		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2704
	endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2705
	for ( $n = 1; $n <= $total; $n++ ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2706
		if ( $n == $current ) :
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2707
			$page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2708
			$dots = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2709
		else :
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2710
			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2711
				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2712
				$link = str_replace( '%#%', $n, $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2713
				if ( $add_args )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2714
					$link = add_query_arg( $add_args, $link );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2715
				$link .= $args['add_fragment'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2716
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2717
				/** This filter is documented in wp-includes/general-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2718
				$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</a>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2719
				$dots = true;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2720
			elseif ( $dots && ! $args['show_all'] ) :
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2721
				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2722
				$dots = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2723
			endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2724
		endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2725
	endfor;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2726
	if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2727
		$link = str_replace( '%_%', $args['format'], $args['base'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2728
		$link = str_replace( '%#%', $current + 1, $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2729
		if ( $add_args )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2730
			$link = add_query_arg( $add_args, $link );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2731
		$link .= $args['add_fragment'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2732
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2733
		/** This filter is documented in wp-includes/general-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2734
		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2735
	endif;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2736
	switch ( $args['type'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2737
		case 'array' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2738
			return $page_links;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2739
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2740
		case 'list' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2741
			$r .= "<ul class='page-numbers'>\n\t<li>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2742
			$r .= join("</li>\n\t<li>", $page_links);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2743
			$r .= "</li>\n</ul>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2744
			break;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2745
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2746
		default :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2747
			$r = join("\n", $page_links);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2748
			break;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2749
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2750
	return $r;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2751
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2752
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2753
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2754
 * Registers an admin colour scheme css file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2755
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2756
 * Allows a plugin to register a new admin colour scheme. For example:
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2757
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2758
 *     wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2759
 *         '#07273E', '#14568A', '#D54E21', '#2683AE'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2760
 *     ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2761
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2762
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2763
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2764
 * @todo Properly document optional arguments as such
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2765
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2766
 * @param string $key The unique key for this theme.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2767
 * @param string $name The name of the theme.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2768
 * @param string $url The url of the css file containing the colour scheme.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2769
 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2770
 * @param array $icons Optional An array of CSS color definitions used to color any SVG icons
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2771
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2772
function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2773
	global $_wp_admin_css_colors;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2774
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2775
	if ( !isset($_wp_admin_css_colors) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2776
		$_wp_admin_css_colors = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2777
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2778
	$_wp_admin_css_colors[$key] = (object) array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2779
		'name' => $name,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2780
		'url' => $url,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2781
		'colors' => $colors,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2782
		'icon_colors' => $icons,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2783
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2784
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2785
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2786
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2787
 * Registers the default Admin color schemes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2788
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2789
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2790
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2791
function register_admin_color_schemes() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2792
	$suffix = is_rtl() ? '-rtl' : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2793
	$suffix .= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2794
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2795
	wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2796
		false,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2797
		array( '#222', '#333', '#0073aa', '#00a0d2' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2798
		array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2799
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2800
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2801
	// Other color schemes are not available when running out of src
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2802
	if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2803
		return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2804
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2805
	wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2806
		admin_url( "css/colors/light/colors$suffix.css" ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2807
		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2808
		array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2809
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2810
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2811
	wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2812
		admin_url( "css/colors/blue/colors$suffix.css" ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2813
		array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2814
		array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2815
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2816
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2817
	wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2818
		admin_url( "css/colors/midnight/colors$suffix.css" ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2819
		array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2820
		array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2821
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2822
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2823
	wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2824
		admin_url( "css/colors/sunrise/colors$suffix.css" ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2825
		array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2826
		array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2827
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2828
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2829
	wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2830
		admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2831
		array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2832
		array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2833
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2834
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2835
	wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2836
		admin_url( "css/colors/ocean/colors$suffix.css" ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2837
		array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2838
		array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2839
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2840
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2841
	wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2842
		admin_url( "css/colors/coffee/colors$suffix.css" ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2843
		array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2844
		array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2845
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2846
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2847
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2848
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2849
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2850
 * Display the URL of a WordPress admin CSS file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2851
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2852
 * @see WP_Styles::_css_href and its style_loader_src filter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2853
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2854
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2855
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2856
 * @param string $file file relative to wp-admin/ without its ".css" extension.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2857
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2858
function wp_admin_css_uri( $file = 'wp-admin' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2859
	if ( defined('WP_INSTALLING') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2860
		$_file = "./$file.css";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2861
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2862
		$_file = admin_url("$file.css");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2863
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2864
	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2865
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2866
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2867
	 * Filter the URI of a WordPress admin CSS file.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2868
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2869
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2870
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2871
	 * @param string $_file Relative path to the file with query arguments attached.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2872
	 * @param string $file  Relative path to the file, minus its ".css" extension.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2873
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2874
	return apply_filters( 'wp_admin_css_uri', $_file, $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2875
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2876
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2877
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2878
 * Enqueues or directly prints a stylesheet link to the specified CSS file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2879
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2880
 * "Intelligently" decides to enqueue or to print the CSS file. If the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2881
 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2882
 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2883
 * be printed. Printing may be forced by passing true as the $force_echo
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2884
 * (second) parameter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2885
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2886
 * For backward compatibility with WordPress 2.3 calling method: If the $file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2887
 * (first) parameter does not correspond to a registered CSS file, we assume
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2888
 * $file is a file relative to wp-admin/ without its ".css" extension. A
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2889
 * stylesheet link to that generated URL is printed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2890
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2891
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2892
 * @uses $wp_styles WordPress Styles Object
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2893
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2894
 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2895
 * 	 to wp-admin/. Defaults to 'wp-admin'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2896
 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2897
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2898
function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2899
	global $wp_styles;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2900
	if ( ! ( $wp_styles instanceof WP_Styles ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2901
		$wp_styles = new WP_Styles();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2902
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2903
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2904
	// For backward compatibility
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2905
	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2906
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2907
	if ( $wp_styles->query( $handle ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2908
		if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2909
			wp_print_styles( $handle );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2910
		else // Add to style queue
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2911
			wp_enqueue_style( $handle );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2912
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2913
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2914
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2915
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2916
	 * Filter the stylesheet link to the specified CSS file.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2917
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2918
	 * If the site is set to display right-to-left, the RTL stylesheet link
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2919
	 * will be used instead.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2920
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2921
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2922
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2923
	 * @param string $file Style handle name or filename (without ".css" extension)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2924
	 *                     relative to wp-admin/. Defaults to 'wp-admin'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2925
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2926
	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2927
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2928
	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2929
		/** This filter is documented in wp-includes/general-template.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2930
		echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2931
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2932
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2933
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2934
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2935
 * Enqueues the default ThickBox js and css.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2936
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2937
 * If any of the settings need to be changed, this can be done with another js
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2938
 * file similar to media-upload.js. That file should
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2939
 * require array('thickbox') to ensure it is loaded after.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2940
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2941
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2942
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2943
function add_thickbox() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2944
	wp_enqueue_script( 'thickbox' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2945
	wp_enqueue_style( 'thickbox' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2946
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2947
	if ( is_network_admin() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2948
		add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2949
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2950
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2951
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2952
 * Display the XHTML generator that is generated on the wp_head hook.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2953
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2954
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2955
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2956
function wp_generator() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2957
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2958
	 * Filter the output of the XHTML generator tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2959
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2960
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2961
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2962
	 * @param string $generator_type The XHTML generator.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2963
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2964
	the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2965
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2966
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2967
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2968
 * Display the generator XML or Comment for RSS, ATOM, etc.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2969
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2970
 * Returns the correct generator type for the requested output format. Allows
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2971
 * for a plugin to filter generators overall the the_generator filter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2972
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2973
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2974
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2975
 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2976
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2977
function the_generator( $type ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2978
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2979
	 * Filter the output of the XHTML generator tag for display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2980
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2981
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2982
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2983
	 * @param string $generator_type The generator output.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2984
	 * @param string $type           The type of generator to output. Accepts 'html',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2985
	 *                               'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2986
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2987
	echo apply_filters( 'the_generator', get_the_generator($type), $type ) . "\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2988
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2989
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2990
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2991
 * Creates the generator XML or Comment for RSS, ATOM, etc.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2992
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2993
 * Returns the correct generator type for the requested output format. Allows
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2994
 * for a plugin to filter generators on an individual basis using the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2995
 * 'get_the_generator_{$type}' filter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2996
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2997
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2998
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2999
 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3000
 * @return string The HTML content for the generator.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3001
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3002
function get_the_generator( $type = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3003
	if ( empty( $type ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3004
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3005
		$current_filter = current_filter();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3006
		if ( empty( $current_filter ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3007
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3008
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3009
		switch ( $current_filter ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3010
			case 'rss2_head' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3011
			case 'commentsrss2_head' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3012
				$type = 'rss2';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3013
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3014
			case 'rss_head' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3015
			case 'opml_head' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3016
				$type = 'comment';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3017
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3018
			case 'rdf_header' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3019
				$type = 'rdf';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3020
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3021
			case 'atom_head' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3022
			case 'comments_atom_head' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3023
			case 'app_head' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3024
				$type = 'atom';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3025
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3026
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3027
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3028
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3029
	switch ( $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3030
		case 'html':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3031
			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3032
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3033
		case 'xhtml':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3034
			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3035
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3036
		case 'atom':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3037
			$gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3038
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3039
		case 'rss2':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3040
			$gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3041
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3042
		case 'rdf':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3043
			$gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3044
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3045
		case 'comment':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3046
			$gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3047
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3048
		case 'export':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3049
			$gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3050
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3051
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3052
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3053
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3054
	 * Filter the HTML for the retrieved generator type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3055
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3056
	 * The dynamic portion of the hook name, `$type`, refers to the generator type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3057
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3058
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3059
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3060
	 * @param string $gen  The HTML markup output to {@see wp_head()}.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3061
	 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3062
	 *                     'rss2', 'rdf', 'comment', 'export'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3063
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3064
	return apply_filters( "get_the_generator_{$type}", $gen, $type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3065
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3066
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3067
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3068
 * Outputs the html checked attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3069
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3070
 * Compares the first two arguments and if identical marks as checked
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3071
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3072
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3073
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3074
 * @param mixed $checked One of the values to compare
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3075
 * @param mixed $current (true) The other value to compare if not just true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3076
 * @param bool $echo Whether to echo or just return the string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3077
 * @return string html attribute or empty string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3078
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3079
function checked( $checked, $current = true, $echo = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3080
	return __checked_selected_helper( $checked, $current, $echo, 'checked' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3081
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3082
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3083
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3084
 * Outputs the html selected attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3085
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3086
 * Compares the first two arguments and if identical marks as selected
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3087
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3088
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3089
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3090
 * @param mixed $selected One of the values to compare
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3091
 * @param mixed $current (true) The other value to compare if not just true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3092
 * @param bool $echo Whether to echo or just return the string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3093
 * @return string html attribute or empty string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3094
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3095
function selected( $selected, $current = true, $echo = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3096
	return __checked_selected_helper( $selected, $current, $echo, 'selected' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3097
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3098
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3099
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3100
 * Outputs the html disabled attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3101
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3102
 * Compares the first two arguments and if identical marks as disabled
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3103
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3104
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3105
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3106
 * @param mixed $disabled One of the values to compare
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3107
 * @param mixed $current (true) The other value to compare if not just true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3108
 * @param bool $echo Whether to echo or just return the string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3109
 * @return string html attribute or empty string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3110
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3111
function disabled( $disabled, $current = true, $echo = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3112
	return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3113
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3115
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3116
 * Private helper function for checked, selected, and disabled.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3117
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3118
 * Compares the first two arguments and if identical marks as $type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3119
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3120
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3121
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3122
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3123
 * @param mixed $helper One of the values to compare
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3124
 * @param mixed $current (true) The other value to compare if not just true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3125
 * @param bool $echo Whether to echo or just return the string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3126
 * @param string $type The type of checked|selected|disabled we are doing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3127
 * @return string html attribute or empty string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3128
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3129
function __checked_selected_helper( $helper, $current, $echo, $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3130
	if ( (string) $helper === (string) $current )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3131
		$result = " $type='$type'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3132
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3133
		$result = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3134
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3135
	if ( $echo )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3136
		echo $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3137
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3138
	return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3139
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3140
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3141
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3142
 * Default settings for heartbeat
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3143
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3144
 * Outputs the nonce used in the heartbeat XHR
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3145
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3146
 * @since 3.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3147
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3148
 * @param array $settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3149
 * @return array $settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3150
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3151
function wp_heartbeat_settings( $settings ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3152
	if ( ! is_admin() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3153
		$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3154
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3155
	if ( is_user_logged_in() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3156
		$settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3157
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3158
	return $settings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3159
}