Edit File by line

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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: post-template.php
$output .= ( 1 === $i ) ? ' ' : $parsed_args['separator'];
[1000] Fix | Delete
$output .= $link;
[1001] Fix | Delete
}
[1002] Fix | Delete
$output .= $parsed_args['after'];
[1003] Fix | Delete
} elseif ( $more ) {
[1004] Fix | Delete
$output .= $parsed_args['before'];
[1005] Fix | Delete
$prev = $page - 1;
[1006] Fix | Delete
if ( $prev > 0 ) {
[1007] Fix | Delete
$link = _wp_link_page( $prev ) . $parsed_args['link_before'] . $parsed_args['previouspagelink'] . $parsed_args['link_after'] . '</a>';
[1008] Fix | Delete
[1009] Fix | Delete
/** This filter is documented in wp-includes/post-template.php */
[1010] Fix | Delete
$output .= apply_filters( 'wp_link_pages_link', $link, $prev );
[1011] Fix | Delete
}
[1012] Fix | Delete
$next = $page + 1;
[1013] Fix | Delete
if ( $next <= $numpages ) {
[1014] Fix | Delete
if ( $prev ) {
[1015] Fix | Delete
$output .= $parsed_args['separator'];
[1016] Fix | Delete
}
[1017] Fix | Delete
$link = _wp_link_page( $next ) . $parsed_args['link_before'] . $parsed_args['nextpagelink'] . $parsed_args['link_after'] . '</a>';
[1018] Fix | Delete
[1019] Fix | Delete
/** This filter is documented in wp-includes/post-template.php */
[1020] Fix | Delete
$output .= apply_filters( 'wp_link_pages_link', $link, $next );
[1021] Fix | Delete
}
[1022] Fix | Delete
$output .= $parsed_args['after'];
[1023] Fix | Delete
}
[1024] Fix | Delete
}
[1025] Fix | Delete
[1026] Fix | Delete
/**
[1027] Fix | Delete
* Filters the HTML output of page links for paginated posts.
[1028] Fix | Delete
*
[1029] Fix | Delete
* @since 3.6.0
[1030] Fix | Delete
*
[1031] Fix | Delete
* @param string $output HTML output of paginated posts' page links.
[1032] Fix | Delete
* @param array|string $args An array or query string of arguments. See wp_link_pages()
[1033] Fix | Delete
* for information on accepted arguments.
[1034] Fix | Delete
*/
[1035] Fix | Delete
$html = apply_filters( 'wp_link_pages', $output, $args );
[1036] Fix | Delete
[1037] Fix | Delete
if ( $parsed_args['echo'] ) {
[1038] Fix | Delete
echo $html;
[1039] Fix | Delete
}
[1040] Fix | Delete
return $html;
[1041] Fix | Delete
}
[1042] Fix | Delete
[1043] Fix | Delete
/**
[1044] Fix | Delete
* Helper function for wp_link_pages().
[1045] Fix | Delete
*
[1046] Fix | Delete
* @since 3.1.0
[1047] Fix | Delete
* @access private
[1048] Fix | Delete
*
[1049] Fix | Delete
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
[1050] Fix | Delete
*
[1051] Fix | Delete
* @param int $i Page number.
[1052] Fix | Delete
* @return string Link.
[1053] Fix | Delete
*/
[1054] Fix | Delete
function _wp_link_page( $i ) {
[1055] Fix | Delete
global $wp_rewrite;
[1056] Fix | Delete
$post = get_post();
[1057] Fix | Delete
$query_args = array();
[1058] Fix | Delete
[1059] Fix | Delete
if ( 1 === $i ) {
[1060] Fix | Delete
$url = get_permalink();
[1061] Fix | Delete
} else {
[1062] Fix | Delete
if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) {
[1063] Fix | Delete
$url = add_query_arg( 'page', $i, get_permalink() );
[1064] Fix | Delete
} elseif ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID ) {
[1065] Fix | Delete
$url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
[1066] Fix | Delete
} else {
[1067] Fix | Delete
$url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' );
[1068] Fix | Delete
}
[1069] Fix | Delete
}
[1070] Fix | Delete
[1071] Fix | Delete
if ( is_preview() ) {
[1072] Fix | Delete
[1073] Fix | Delete
if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
[1074] Fix | Delete
$query_args['preview_id'] = wp_unslash( $_GET['preview_id'] );
[1075] Fix | Delete
$query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
[1076] Fix | Delete
}
[1077] Fix | Delete
[1078] Fix | Delete
$url = get_preview_post_link( $post, $query_args, $url );
[1079] Fix | Delete
}
[1080] Fix | Delete
[1081] Fix | Delete
return '<a href="' . esc_url( $url ) . '" class="post-page-numbers">';
[1082] Fix | Delete
}
[1083] Fix | Delete
[1084] Fix | Delete
//
[1085] Fix | Delete
// Post-meta: Custom per-post fields.
[1086] Fix | Delete
//
[1087] Fix | Delete
[1088] Fix | Delete
/**
[1089] Fix | Delete
* Retrieves post custom meta data field.
[1090] Fix | Delete
*
[1091] Fix | Delete
* @since 1.5.0
[1092] Fix | Delete
*
[1093] Fix | Delete
* @param string $key Meta data key name.
[1094] Fix | Delete
* @return array|string|false Array of values, or single value if only one element exists.
[1095] Fix | Delete
* False if the key does not exist.
[1096] Fix | Delete
*/
[1097] Fix | Delete
function post_custom( $key = '' ) {
[1098] Fix | Delete
$custom = get_post_custom();
[1099] Fix | Delete
[1100] Fix | Delete
if ( ! isset( $custom[ $key ] ) ) {
[1101] Fix | Delete
return false;
[1102] Fix | Delete
} elseif ( 1 === count( $custom[ $key ] ) ) {
[1103] Fix | Delete
return $custom[ $key ][0];
[1104] Fix | Delete
} else {
[1105] Fix | Delete
return $custom[ $key ];
[1106] Fix | Delete
}
[1107] Fix | Delete
}
[1108] Fix | Delete
[1109] Fix | Delete
/**
[1110] Fix | Delete
* Displays a list of post custom fields.
[1111] Fix | Delete
*
[1112] Fix | Delete
* @since 1.2.0
[1113] Fix | Delete
*
[1114] Fix | Delete
* @deprecated 6.0.2 Use get_post_meta() to retrieve post meta and render manually.
[1115] Fix | Delete
*/
[1116] Fix | Delete
function the_meta() {
[1117] Fix | Delete
_deprecated_function( __FUNCTION__, '6.0.2', 'get_post_meta()' );
[1118] Fix | Delete
$keys = get_post_custom_keys();
[1119] Fix | Delete
if ( $keys ) {
[1120] Fix | Delete
$li_html = '';
[1121] Fix | Delete
foreach ( (array) $keys as $key ) {
[1122] Fix | Delete
$keyt = trim( $key );
[1123] Fix | Delete
if ( is_protected_meta( $keyt, 'post' ) ) {
[1124] Fix | Delete
continue;
[1125] Fix | Delete
}
[1126] Fix | Delete
[1127] Fix | Delete
$values = array_map( 'trim', get_post_custom_values( $key ) );
[1128] Fix | Delete
$value = implode( ', ', $values );
[1129] Fix | Delete
[1130] Fix | Delete
$html = sprintf(
[1131] Fix | Delete
"<li><span class='post-meta-key'>%s</span> %s</li>\n",
[1132] Fix | Delete
/* translators: %s: Post custom field name. */
[1133] Fix | Delete
esc_html( sprintf( _x( '%s:', 'Post custom field name' ), $key ) ),
[1134] Fix | Delete
esc_html( $value )
[1135] Fix | Delete
);
[1136] Fix | Delete
[1137] Fix | Delete
/**
[1138] Fix | Delete
* Filters the HTML output of the li element in the post custom fields list.
[1139] Fix | Delete
*
[1140] Fix | Delete
* @since 2.2.0
[1141] Fix | Delete
*
[1142] Fix | Delete
* @param string $html The HTML output for the li element.
[1143] Fix | Delete
* @param string $key Meta key.
[1144] Fix | Delete
* @param string $value Meta value.
[1145] Fix | Delete
*/
[1146] Fix | Delete
$li_html .= apply_filters( 'the_meta_key', $html, $key, $value );
[1147] Fix | Delete
}
[1148] Fix | Delete
[1149] Fix | Delete
if ( $li_html ) {
[1150] Fix | Delete
echo "<ul class='post-meta'>\n{$li_html}</ul>\n";
[1151] Fix | Delete
}
[1152] Fix | Delete
}
[1153] Fix | Delete
}
[1154] Fix | Delete
[1155] Fix | Delete
//
[1156] Fix | Delete
// Pages.
[1157] Fix | Delete
//
[1158] Fix | Delete
[1159] Fix | Delete
/**
[1160] Fix | Delete
* Retrieves or displays a list of pages as a dropdown (select list).
[1161] Fix | Delete
*
[1162] Fix | Delete
* @since 2.1.0
[1163] Fix | Delete
* @since 4.2.0 The `$value_field` argument was added.
[1164] Fix | Delete
* @since 4.3.0 The `$class` argument was added.
[1165] Fix | Delete
*
[1166] Fix | Delete
* @see get_pages()
[1167] Fix | Delete
*
[1168] Fix | Delete
* @param array|string $args {
[1169] Fix | Delete
* Optional. Array or string of arguments to generate a page dropdown. See get_pages() for additional arguments.
[1170] Fix | Delete
*
[1171] Fix | Delete
* @type int $depth Maximum depth. Default 0.
[1172] Fix | Delete
* @type int $child_of Page ID to retrieve child pages of. Default 0.
[1173] Fix | Delete
* @type int|string $selected Value of the option that should be selected. Default 0.
[1174] Fix | Delete
* @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1,
[1175] Fix | Delete
* or their bool equivalents. Default 1.
[1176] Fix | Delete
* @type string $name Value for the 'name' attribute of the select element.
[1177] Fix | Delete
* Default 'page_id'.
[1178] Fix | Delete
* @type string $id Value for the 'id' attribute of the select element.
[1179] Fix | Delete
* @type string $class Value for the 'class' attribute of the select element. Default: none.
[1180] Fix | Delete
* Defaults to the value of `$name`.
[1181] Fix | Delete
* @type string $show_option_none Text to display for showing no pages. Default empty (does not display).
[1182] Fix | Delete
* @type string $show_option_no_change Text to display for "no change" option. Default empty (does not display).
[1183] Fix | Delete
* @type string $option_none_value Value to use when no page is selected. Default empty.
[1184] Fix | Delete
* @type string $value_field Post field used to populate the 'value' attribute of the option
[1185] Fix | Delete
* elements. Accepts any valid post field. Default 'ID'.
[1186] Fix | Delete
* }
[1187] Fix | Delete
* @return string HTML dropdown list of pages.
[1188] Fix | Delete
*/
[1189] Fix | Delete
function wp_dropdown_pages( $args = '' ) {
[1190] Fix | Delete
$defaults = array(
[1191] Fix | Delete
'depth' => 0,
[1192] Fix | Delete
'child_of' => 0,
[1193] Fix | Delete
'selected' => 0,
[1194] Fix | Delete
'echo' => 1,
[1195] Fix | Delete
'name' => 'page_id',
[1196] Fix | Delete
'id' => '',
[1197] Fix | Delete
'class' => '',
[1198] Fix | Delete
'show_option_none' => '',
[1199] Fix | Delete
'show_option_no_change' => '',
[1200] Fix | Delete
'option_none_value' => '',
[1201] Fix | Delete
'value_field' => 'ID',
[1202] Fix | Delete
);
[1203] Fix | Delete
[1204] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[1205] Fix | Delete
[1206] Fix | Delete
$pages = get_pages( $parsed_args );
[1207] Fix | Delete
$output = '';
[1208] Fix | Delete
// Back-compat with old system where both id and name were based on $name argument.
[1209] Fix | Delete
if ( empty( $parsed_args['id'] ) ) {
[1210] Fix | Delete
$parsed_args['id'] = $parsed_args['name'];
[1211] Fix | Delete
}
[1212] Fix | Delete
[1213] Fix | Delete
if ( ! empty( $pages ) ) {
[1214] Fix | Delete
$class = '';
[1215] Fix | Delete
if ( ! empty( $parsed_args['class'] ) ) {
[1216] Fix | Delete
$class = " class='" . esc_attr( $parsed_args['class'] ) . "'";
[1217] Fix | Delete
}
[1218] Fix | Delete
[1219] Fix | Delete
$output = "<select name='" . esc_attr( $parsed_args['name'] ) . "'" . $class . " id='" . esc_attr( $parsed_args['id'] ) . "'>\n";
[1220] Fix | Delete
if ( $parsed_args['show_option_no_change'] ) {
[1221] Fix | Delete
$output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
[1222] Fix | Delete
}
[1223] Fix | Delete
if ( $parsed_args['show_option_none'] ) {
[1224] Fix | Delete
$output .= "\t<option value=\"" . esc_attr( $parsed_args['option_none_value'] ) . '">' . $parsed_args['show_option_none'] . "</option>\n";
[1225] Fix | Delete
}
[1226] Fix | Delete
$output .= walk_page_dropdown_tree( $pages, $parsed_args['depth'], $parsed_args );
[1227] Fix | Delete
$output .= "</select>\n";
[1228] Fix | Delete
}
[1229] Fix | Delete
[1230] Fix | Delete
/**
[1231] Fix | Delete
* Filters the HTML output of a list of pages as a dropdown.
[1232] Fix | Delete
*
[1233] Fix | Delete
* @since 2.1.0
[1234] Fix | Delete
* @since 4.4.0 `$parsed_args` and `$pages` added as arguments.
[1235] Fix | Delete
*
[1236] Fix | Delete
* @param string $output HTML output for dropdown list of pages.
[1237] Fix | Delete
* @param array $parsed_args The parsed arguments array. See wp_dropdown_pages()
[1238] Fix | Delete
* for information on accepted arguments.
[1239] Fix | Delete
* @param WP_Post[] $pages Array of the page objects.
[1240] Fix | Delete
*/
[1241] Fix | Delete
$html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages );
[1242] Fix | Delete
[1243] Fix | Delete
if ( $parsed_args['echo'] ) {
[1244] Fix | Delete
echo $html;
[1245] Fix | Delete
}
[1246] Fix | Delete
[1247] Fix | Delete
return $html;
[1248] Fix | Delete
}
[1249] Fix | Delete
[1250] Fix | Delete
/**
[1251] Fix | Delete
* Retrieves or displays a list of pages (or hierarchical post type items) in list (li) format.
[1252] Fix | Delete
*
[1253] Fix | Delete
* @since 1.5.0
[1254] Fix | Delete
* @since 4.7.0 Added the `item_spacing` argument.
[1255] Fix | Delete
*
[1256] Fix | Delete
* @see get_pages()
[1257] Fix | Delete
*
[1258] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[1259] Fix | Delete
*
[1260] Fix | Delete
* @param array|string $args {
[1261] Fix | Delete
* Optional. Array or string of arguments to generate a list of pages. See get_pages() for additional arguments.
[1262] Fix | Delete
*
[1263] Fix | Delete
* @type int $child_of Display only the sub-pages of a single page by ID. Default 0 (all pages).
[1264] Fix | Delete
* @type string $authors Comma-separated list of author IDs. Default empty (all authors).
[1265] Fix | Delete
* @type string $date_format PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
[1266] Fix | Delete
* Default is the value of 'date_format' option.
[1267] Fix | Delete
* @type int $depth Number of levels in the hierarchy of pages to include in the generated list.
[1268] Fix | Delete
* Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
[1269] Fix | Delete
* the given n depth). Default 0.
[1270] Fix | Delete
* @type bool $echo Whether or not to echo the list of pages. Default true.
[1271] Fix | Delete
* @type string $exclude Comma-separated list of page IDs to exclude. Default empty.
[1272] Fix | Delete
* @type array $include Comma-separated list of page IDs to include. Default empty.
[1273] Fix | Delete
* @type string $link_after Text or HTML to follow the page link label. Default null.
[1274] Fix | Delete
* @type string $link_before Text or HTML to precede the page link label. Default null.
[1275] Fix | Delete
* @type string $post_type Post type to query for. Default 'page'.
[1276] Fix | Delete
* @type string|array $post_status Comma-separated list or array of post statuses to include. Default 'publish'.
[1277] Fix | Delete
* @type string $show_date Whether to display the page publish or modified date for each page. Accepts
[1278] Fix | Delete
* 'modified' or any other value. An empty value hides the date. Default empty.
[1279] Fix | Delete
* @type string $sort_column Comma-separated list of column names to sort the pages by. Accepts 'post_author',
[1280] Fix | Delete
* 'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
[1281] Fix | Delete
* 'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
[1282] Fix | Delete
* @type string $title_li List heading. Passing a null or empty value will result in no heading, and the list
[1283] Fix | Delete
* will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
[1284] Fix | Delete
* @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
[1285] Fix | Delete
* Default 'preserve'.
[1286] Fix | Delete
* @type Walker $walker Walker instance to use for listing pages. Default empty which results in a
[1287] Fix | Delete
* Walker_Page instance being used.
[1288] Fix | Delete
* }
[1289] Fix | Delete
* @return void|string Void if 'echo' argument is true, HTML list of pages if 'echo' is false.
[1290] Fix | Delete
*/
[1291] Fix | Delete
function wp_list_pages( $args = '' ) {
[1292] Fix | Delete
$defaults = array(
[1293] Fix | Delete
'depth' => 0,
[1294] Fix | Delete
'show_date' => '',
[1295] Fix | Delete
'date_format' => get_option( 'date_format' ),
[1296] Fix | Delete
'child_of' => 0,
[1297] Fix | Delete
'exclude' => '',
[1298] Fix | Delete
'title_li' => __( 'Pages' ),
[1299] Fix | Delete
'echo' => 1,
[1300] Fix | Delete
'authors' => '',
[1301] Fix | Delete
'sort_column' => 'menu_order, post_title',
[1302] Fix | Delete
'link_before' => '',
[1303] Fix | Delete
'link_after' => '',
[1304] Fix | Delete
'item_spacing' => 'preserve',
[1305] Fix | Delete
'walker' => '',
[1306] Fix | Delete
);
[1307] Fix | Delete
[1308] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[1309] Fix | Delete
[1310] Fix | Delete
if ( ! in_array( $parsed_args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
[1311] Fix | Delete
// Invalid value, fall back to default.
[1312] Fix | Delete
$parsed_args['item_spacing'] = $defaults['item_spacing'];
[1313] Fix | Delete
}
[1314] Fix | Delete
[1315] Fix | Delete
$output = '';
[1316] Fix | Delete
$current_page = 0;
[1317] Fix | Delete
[1318] Fix | Delete
// Sanitize, mostly to keep spaces out.
[1319] Fix | Delete
$parsed_args['exclude'] = preg_replace( '/[^0-9,]/', '', $parsed_args['exclude'] );
[1320] Fix | Delete
[1321] Fix | Delete
// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array).
[1322] Fix | Delete
$exclude_array = ( $parsed_args['exclude'] ) ? explode( ',', $parsed_args['exclude'] ) : array();
[1323] Fix | Delete
[1324] Fix | Delete
/**
[1325] Fix | Delete
* Filters the array of pages to exclude from the pages list.
[1326] Fix | Delete
*
[1327] Fix | Delete
* @since 2.1.0
[1328] Fix | Delete
*
[1329] Fix | Delete
* @param string[] $exclude_array An array of page IDs to exclude.
[1330] Fix | Delete
*/
[1331] Fix | Delete
$parsed_args['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
[1332] Fix | Delete
[1333] Fix | Delete
$parsed_args['hierarchical'] = 0;
[1334] Fix | Delete
[1335] Fix | Delete
// Query pages.
[1336] Fix | Delete
$pages = get_pages( $parsed_args );
[1337] Fix | Delete
[1338] Fix | Delete
if ( ! empty( $pages ) ) {
[1339] Fix | Delete
if ( $parsed_args['title_li'] ) {
[1340] Fix | Delete
$output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>';
[1341] Fix | Delete
}
[1342] Fix | Delete
global $wp_query;
[1343] Fix | Delete
if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
[1344] Fix | Delete
$current_page = get_queried_object_id();
[1345] Fix | Delete
} elseif ( is_singular() ) {
[1346] Fix | Delete
$queried_object = get_queried_object();
[1347] Fix | Delete
if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
[1348] Fix | Delete
$current_page = $queried_object->ID;
[1349] Fix | Delete
}
[1350] Fix | Delete
}
[1351] Fix | Delete
[1352] Fix | Delete
$output .= walk_page_tree( $pages, $parsed_args['depth'], $current_page, $parsed_args );
[1353] Fix | Delete
[1354] Fix | Delete
if ( $parsed_args['title_li'] ) {
[1355] Fix | Delete
$output .= '</ul></li>';
[1356] Fix | Delete
}
[1357] Fix | Delete
}
[1358] Fix | Delete
[1359] Fix | Delete
/**
[1360] Fix | Delete
* Filters the HTML output of the pages to list.
[1361] Fix | Delete
*
[1362] Fix | Delete
* @since 1.5.1
[1363] Fix | Delete
* @since 4.4.0 `$pages` added as arguments.
[1364] Fix | Delete
*
[1365] Fix | Delete
* @see wp_list_pages()
[1366] Fix | Delete
*
[1367] Fix | Delete
* @param string $output HTML output of the pages list.
[1368] Fix | Delete
* @param array $parsed_args An array of page-listing arguments. See wp_list_pages()
[1369] Fix | Delete
* for information on accepted arguments.
[1370] Fix | Delete
* @param WP_Post[] $pages Array of the page objects.
[1371] Fix | Delete
*/
[1372] Fix | Delete
$html = apply_filters( 'wp_list_pages', $output, $parsed_args, $pages );
[1373] Fix | Delete
[1374] Fix | Delete
if ( $parsed_args['echo'] ) {
[1375] Fix | Delete
echo $html;
[1376] Fix | Delete
} else {
[1377] Fix | Delete
return $html;
[1378] Fix | Delete
}
[1379] Fix | Delete
}
[1380] Fix | Delete
[1381] Fix | Delete
/**
[1382] Fix | Delete
* Displays or retrieves a list of pages with an optional home link.
[1383] Fix | Delete
*
[1384] Fix | Delete
* The arguments are listed below and part of the arguments are for wp_list_pages() function.
[1385] Fix | Delete
* Check that function for more info on those arguments.
[1386] Fix | Delete
*
[1387] Fix | Delete
* @since 2.7.0
[1388] Fix | Delete
* @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
[1389] Fix | Delete
* @since 4.7.0 Added the `item_spacing` argument.
[1390] Fix | Delete
*
[1391] Fix | Delete
* @param array|string $args {
[1392] Fix | Delete
* Optional. Array or string of arguments to generate a page menu. See wp_list_pages() for additional arguments.
[1393] Fix | Delete
*
[1394] Fix | Delete
* @type string $sort_column How to sort the list of pages. Accepts post column names.
[1395] Fix | Delete
* Default 'menu_order, post_title'.
[1396] Fix | Delete
* @type string $menu_id ID for the div containing the page list. Default is empty string.
[1397] Fix | Delete
* @type string $menu_class Class to use for the element containing the page list. Default 'menu'.
[1398] Fix | Delete
* @type string $container Element to use for the element containing the page list. Default 'div'.
[1399] Fix | Delete
* @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return).
[1400] Fix | Delete
* Default true.
[1401] Fix | Delete
* @type int|bool|string $show_home Whether to display the link to the home page. Can just enter the text
[1402] Fix | Delete
* you'd like shown for the home link. 1|true defaults to 'Home'.
[1403] Fix | Delete
* @type string $link_before The HTML or text to prepend to $show_home text. Default empty.
[1404] Fix | Delete
* @type string $link_after The HTML or text to append to $show_home text. Default empty.
[1405] Fix | Delete
* @type string $before The HTML or text to prepend to the menu. Default is '<ul>'.
[1406] Fix | Delete
* @type string $after The HTML or text to append to the menu. Default is '</ul>'.
[1407] Fix | Delete
* @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
[1408] Fix | Delete
* or 'discard'. Default 'discard'.
[1409] Fix | Delete
* @type Walker $walker Walker instance to use for listing pages. Default empty which results in a
[1410] Fix | Delete
* Walker_Page instance being used.
[1411] Fix | Delete
* }
[1412] Fix | Delete
* @return void|string Void if 'echo' argument is true, HTML menu if 'echo' is false.
[1413] Fix | Delete
*/
[1414] Fix | Delete
function wp_page_menu( $args = array() ) {
[1415] Fix | Delete
$defaults = array(
[1416] Fix | Delete
'sort_column' => 'menu_order, post_title',
[1417] Fix | Delete
'menu_id' => '',
[1418] Fix | Delete
'menu_class' => 'menu',
[1419] Fix | Delete
'container' => 'div',
[1420] Fix | Delete
'echo' => true,
[1421] Fix | Delete
'link_before' => '',
[1422] Fix | Delete
'link_after' => '',
[1423] Fix | Delete
'before' => '<ul>',
[1424] Fix | Delete
'after' => '</ul>',
[1425] Fix | Delete
'item_spacing' => 'discard',
[1426] Fix | Delete
'walker' => '',
[1427] Fix | Delete
);
[1428] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[1429] Fix | Delete
[1430] Fix | Delete
if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
[1431] Fix | Delete
// Invalid value, fall back to default.
[1432] Fix | Delete
$args['item_spacing'] = $defaults['item_spacing'];
[1433] Fix | Delete
}
[1434] Fix | Delete
[1435] Fix | Delete
if ( 'preserve' === $args['item_spacing'] ) {
[1436] Fix | Delete
$t = "\t";
[1437] Fix | Delete
$n = "\n";
[1438] Fix | Delete
} else {
[1439] Fix | Delete
$t = '';
[1440] Fix | Delete
$n = '';
[1441] Fix | Delete
}
[1442] Fix | Delete
[1443] Fix | Delete
/**
[1444] Fix | Delete
* Filters the arguments used to generate a page-based menu.
[1445] Fix | Delete
*
[1446] Fix | Delete
* @since 2.7.0
[1447] Fix | Delete
*
[1448] Fix | Delete
* @see wp_page_menu()
[1449] Fix | Delete
*
[1450] Fix | Delete
* @param array $args An array of page menu arguments. See wp_page_menu()
[1451] Fix | Delete
* for information on accepted arguments.
[1452] Fix | Delete
*/
[1453] Fix | Delete
$args = apply_filters( 'wp_page_menu_args', $args );
[1454] Fix | Delete
[1455] Fix | Delete
$menu = '';
[1456] Fix | Delete
[1457] Fix | Delete
$list_args = $args;
[1458] Fix | Delete
[1459] Fix | Delete
// Show Home in the menu.
[1460] Fix | Delete
if ( ! empty( $args['show_home'] ) ) {
[1461] Fix | Delete
if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) {
[1462] Fix | Delete
$text = __( 'Home' );
[1463] Fix | Delete
} else {
[1464] Fix | Delete
$text = $args['show_home'];
[1465] Fix | Delete
}
[1466] Fix | Delete
$class = '';
[1467] Fix | Delete
if ( is_front_page() && ! is_paged() ) {
[1468] Fix | Delete
$class = 'class="current_page_item"';
[1469] Fix | Delete
}
[1470] Fix | Delete
$menu .= '<li ' . $class . '><a href="' . esc_url( home_url( '/' ) ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
[1471] Fix | Delete
// If the front page is a page, add it to the exclude list.
[1472] Fix | Delete
if ( 'page' === get_option( 'show_on_front' ) ) {
[1473] Fix | Delete
if ( ! empty( $list_args['exclude'] ) ) {
[1474] Fix | Delete
$list_args['exclude'] .= ',';
[1475] Fix | Delete
} else {
[1476] Fix | Delete
$list_args['exclude'] = '';
[1477] Fix | Delete
}
[1478] Fix | Delete
$list_args['exclude'] .= get_option( 'page_on_front' );
[1479] Fix | Delete
}
[1480] Fix | Delete
}
[1481] Fix | Delete
[1482] Fix | Delete
$list_args['echo'] = false;
[1483] Fix | Delete
$list_args['title_li'] = '';
[1484] Fix | Delete
$menu .= wp_list_pages( $list_args );
[1485] Fix | Delete
[1486] Fix | Delete
$container = sanitize_text_field( $args['container'] );
[1487] Fix | Delete
[1488] Fix | Delete
// Fallback in case `wp_nav_menu()` was called without a container.
[1489] Fix | Delete
if ( empty( $container ) ) {
[1490] Fix | Delete
$container = 'div';
[1491] Fix | Delete
}
[1492] Fix | Delete
[1493] Fix | Delete
if ( $menu ) {
[1494] Fix | Delete
[1495] Fix | Delete
// wp_nav_menu() doesn't set before and after.
[1496] Fix | Delete
if ( isset( $args['fallback_cb'] ) &&
[1497] Fix | Delete
'wp_page_menu' === $args['fallback_cb'] &&
[1498] Fix | Delete
'ul' !== $container ) {
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function