Edit File by line
/home/barbar84/public_h.../wp-admin/includes
File: nav-menu.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Core Navigation Menu API
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Nav_Menus
[5] Fix | Delete
* @since 3.0.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/** Walker_Nav_Menu_Edit class */
[9] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php';
[10] Fix | Delete
[11] Fix | Delete
/** Walker_Nav_Menu_Checklist class */
[12] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-checklist.php';
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Prints the appropriate response to a menu quick search.
[16] Fix | Delete
*
[17] Fix | Delete
* @since 3.0.0
[18] Fix | Delete
*
[19] Fix | Delete
* @param array $request The unsanitized request values.
[20] Fix | Delete
*/
[21] Fix | Delete
function _wp_ajax_menu_quick_search( $request = array() ) {
[22] Fix | Delete
$args = array();
[23] Fix | Delete
$type = isset( $request['type'] ) ? $request['type'] : '';
[24] Fix | Delete
$object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
[25] Fix | Delete
$query = isset( $request['q'] ) ? $request['q'] : '';
[26] Fix | Delete
$response_format = isset( $request['response-format'] ) ? $request['response-format'] : '';
[27] Fix | Delete
[28] Fix | Delete
if ( ! $response_format || ! in_array( $response_format, array( 'json', 'markup' ), true ) ) {
[29] Fix | Delete
$response_format = 'json';
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
if ( 'markup' === $response_format ) {
[33] Fix | Delete
$args['walker'] = new Walker_Nav_Menu_Checklist;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
if ( 'get-post-item' === $type ) {
[37] Fix | Delete
if ( post_type_exists( $object_type ) ) {
[38] Fix | Delete
if ( isset( $request['ID'] ) ) {
[39] Fix | Delete
$object_id = (int) $request['ID'];
[40] Fix | Delete
if ( 'markup' === $response_format ) {
[41] Fix | Delete
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
[42] Fix | Delete
} elseif ( 'json' === $response_format ) {
[43] Fix | Delete
echo wp_json_encode(
[44] Fix | Delete
array(
[45] Fix | Delete
'ID' => $object_id,
[46] Fix | Delete
'post_title' => get_the_title( $object_id ),
[47] Fix | Delete
'post_type' => get_post_type( $object_id ),
[48] Fix | Delete
)
[49] Fix | Delete
);
[50] Fix | Delete
echo "\n";
[51] Fix | Delete
}
[52] Fix | Delete
}
[53] Fix | Delete
} elseif ( taxonomy_exists( $object_type ) ) {
[54] Fix | Delete
if ( isset( $request['ID'] ) ) {
[55] Fix | Delete
$object_id = (int) $request['ID'];
[56] Fix | Delete
if ( 'markup' === $response_format ) {
[57] Fix | Delete
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
[58] Fix | Delete
} elseif ( 'json' === $response_format ) {
[59] Fix | Delete
$post_obj = get_term( $object_id, $object_type );
[60] Fix | Delete
echo wp_json_encode(
[61] Fix | Delete
array(
[62] Fix | Delete
'ID' => $object_id,
[63] Fix | Delete
'post_title' => $post_obj->name,
[64] Fix | Delete
'post_type' => $object_type,
[65] Fix | Delete
)
[66] Fix | Delete
);
[67] Fix | Delete
echo "\n";
[68] Fix | Delete
}
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
} elseif ( preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) ) {
[72] Fix | Delete
if ( 'posttype' === $matches[1] && get_post_type_object( $matches[2] ) ) {
[73] Fix | Delete
$post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) );
[74] Fix | Delete
$args = array_merge(
[75] Fix | Delete
$args,
[76] Fix | Delete
array(
[77] Fix | Delete
'no_found_rows' => true,
[78] Fix | Delete
'update_post_meta_cache' => false,
[79] Fix | Delete
'update_post_term_cache' => false,
[80] Fix | Delete
'posts_per_page' => 10,
[81] Fix | Delete
'post_type' => $matches[2],
[82] Fix | Delete
's' => $query,
[83] Fix | Delete
)
[84] Fix | Delete
);
[85] Fix | Delete
if ( isset( $post_type_obj->_default_query ) ) {
[86] Fix | Delete
$args = array_merge( $args, (array) $post_type_obj->_default_query );
[87] Fix | Delete
}
[88] Fix | Delete
$search_results_query = new WP_Query( $args );
[89] Fix | Delete
if ( ! $search_results_query->have_posts() ) {
[90] Fix | Delete
return;
[91] Fix | Delete
}
[92] Fix | Delete
while ( $search_results_query->have_posts() ) {
[93] Fix | Delete
$post = $search_results_query->next_post();
[94] Fix | Delete
if ( 'markup' === $response_format ) {
[95] Fix | Delete
$var_by_ref = $post->ID;
[96] Fix | Delete
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
[97] Fix | Delete
} elseif ( 'json' === $response_format ) {
[98] Fix | Delete
echo wp_json_encode(
[99] Fix | Delete
array(
[100] Fix | Delete
'ID' => $post->ID,
[101] Fix | Delete
'post_title' => get_the_title( $post->ID ),
[102] Fix | Delete
'post_type' => $matches[2],
[103] Fix | Delete
)
[104] Fix | Delete
);
[105] Fix | Delete
echo "\n";
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
} elseif ( 'taxonomy' === $matches[1] ) {
[109] Fix | Delete
$terms = get_terms(
[110] Fix | Delete
array(
[111] Fix | Delete
'taxonomy' => $matches[2],
[112] Fix | Delete
'name__like' => $query,
[113] Fix | Delete
'number' => 10,
[114] Fix | Delete
'hide_empty' => false,
[115] Fix | Delete
)
[116] Fix | Delete
);
[117] Fix | Delete
if ( empty( $terms ) || is_wp_error( $terms ) ) {
[118] Fix | Delete
return;
[119] Fix | Delete
}
[120] Fix | Delete
foreach ( (array) $terms as $term ) {
[121] Fix | Delete
if ( 'markup' === $response_format ) {
[122] Fix | Delete
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
[123] Fix | Delete
} elseif ( 'json' === $response_format ) {
[124] Fix | Delete
echo wp_json_encode(
[125] Fix | Delete
array(
[126] Fix | Delete
'ID' => $term->term_id,
[127] Fix | Delete
'post_title' => $term->name,
[128] Fix | Delete
'post_type' => $matches[2],
[129] Fix | Delete
)
[130] Fix | Delete
);
[131] Fix | Delete
echo "\n";
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Register nav menu meta boxes and advanced menu items.
[140] Fix | Delete
*
[141] Fix | Delete
* @since 3.0.0
[142] Fix | Delete
*/
[143] Fix | Delete
function wp_nav_menu_setup() {
[144] Fix | Delete
// Register meta boxes.
[145] Fix | Delete
wp_nav_menu_post_type_meta_boxes();
[146] Fix | Delete
add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
[147] Fix | Delete
wp_nav_menu_taxonomy_meta_boxes();
[148] Fix | Delete
[149] Fix | Delete
// Register advanced menu items (columns).
[150] Fix | Delete
add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
[151] Fix | Delete
[152] Fix | Delete
// If first time editing, disable advanced items by default.
[153] Fix | Delete
if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
[154] Fix | Delete
$user = wp_get_current_user();
[155] Fix | Delete
update_user_option(
[156] Fix | Delete
$user->ID,
[157] Fix | Delete
'managenav-menuscolumnshidden',
[158] Fix | Delete
array(
[159] Fix | Delete
0 => 'link-target',
[160] Fix | Delete
1 => 'css-classes',
[161] Fix | Delete
2 => 'xfn',
[162] Fix | Delete
3 => 'description',
[163] Fix | Delete
4 => 'title-attribute',
[164] Fix | Delete
),
[165] Fix | Delete
true
[166] Fix | Delete
);
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
/**
[171] Fix | Delete
* Limit the amount of meta boxes to pages, posts, links, and categories for first time users.
[172] Fix | Delete
*
[173] Fix | Delete
* @since 3.0.0
[174] Fix | Delete
*
[175] Fix | Delete
* @global array $wp_meta_boxes
[176] Fix | Delete
*/
[177] Fix | Delete
function wp_initial_nav_menu_meta_boxes() {
[178] Fix | Delete
global $wp_meta_boxes;
[179] Fix | Delete
[180] Fix | Delete
if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array( $wp_meta_boxes ) ) {
[181] Fix | Delete
return;
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
[185] Fix | Delete
$hidden_meta_boxes = array();
[186] Fix | Delete
[187] Fix | Delete
foreach ( array_keys( $wp_meta_boxes['nav-menus'] ) as $context ) {
[188] Fix | Delete
foreach ( array_keys( $wp_meta_boxes['nav-menus'][ $context ] ) as $priority ) {
[189] Fix | Delete
foreach ( $wp_meta_boxes['nav-menus'][ $context ][ $priority ] as $box ) {
[190] Fix | Delete
if ( in_array( $box['id'], $initial_meta_boxes, true ) ) {
[191] Fix | Delete
unset( $box['id'] );
[192] Fix | Delete
} else {
[193] Fix | Delete
$hidden_meta_boxes[] = $box['id'];
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
}
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
$user = wp_get_current_user();
[200] Fix | Delete
update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
/**
[204] Fix | Delete
* Creates meta boxes for any post type menu item..
[205] Fix | Delete
*
[206] Fix | Delete
* @since 3.0.0
[207] Fix | Delete
*/
[208] Fix | Delete
function wp_nav_menu_post_type_meta_boxes() {
[209] Fix | Delete
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
[210] Fix | Delete
[211] Fix | Delete
if ( ! $post_types ) {
[212] Fix | Delete
return;
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
foreach ( $post_types as $post_type ) {
[216] Fix | Delete
/**
[217] Fix | Delete
* Filters whether a menu items meta box will be added for the current
[218] Fix | Delete
* object type.
[219] Fix | Delete
*
[220] Fix | Delete
* If a falsey value is returned instead of an object, the menu items
[221] Fix | Delete
* meta box for the current meta box object will not be added.
[222] Fix | Delete
*
[223] Fix | Delete
* @since 3.0.0
[224] Fix | Delete
*
[225] Fix | Delete
* @param WP_Post_Type|false $post_type The current object to add a menu items
[226] Fix | Delete
* meta box for.
[227] Fix | Delete
*/
[228] Fix | Delete
$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
[229] Fix | Delete
if ( $post_type ) {
[230] Fix | Delete
$id = $post_type->name;
[231] Fix | Delete
// Give pages a higher priority.
[232] Fix | Delete
$priority = ( 'page' === $post_type->name ? 'core' : 'default' );
[233] Fix | Delete
add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
[234] Fix | Delete
}
[235] Fix | Delete
}
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
/**
[239] Fix | Delete
* Creates meta boxes for any taxonomy menu item.
[240] Fix | Delete
*
[241] Fix | Delete
* @since 3.0.0
[242] Fix | Delete
*/
[243] Fix | Delete
function wp_nav_menu_taxonomy_meta_boxes() {
[244] Fix | Delete
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
[245] Fix | Delete
[246] Fix | Delete
if ( ! $taxonomies ) {
[247] Fix | Delete
return;
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
foreach ( $taxonomies as $tax ) {
[251] Fix | Delete
/** This filter is documented in wp-admin/includes/nav-menu.php */
[252] Fix | Delete
$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
[253] Fix | Delete
if ( $tax ) {
[254] Fix | Delete
$id = $tax->name;
[255] Fix | Delete
add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
[256] Fix | Delete
}
[257] Fix | Delete
}
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
/**
[261] Fix | Delete
* Check whether to disable the Menu Locations meta box submit button and inputs.
[262] Fix | Delete
*
[263] Fix | Delete
* @since 3.6.0
[264] Fix | Delete
* @since 5.3.1 The `$echo` parameter was added.
[265] Fix | Delete
*
[266] Fix | Delete
* @global bool $one_theme_location_no_menus to determine if no menus exist
[267] Fix | Delete
*
[268] Fix | Delete
* @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu.
[269] Fix | Delete
* @param bool $echo Whether to echo or just return the string.
[270] Fix | Delete
* @return string|false Disabled attribute if at least one menu exists, false if not.
[271] Fix | Delete
*/
[272] Fix | Delete
function wp_nav_menu_disabled_check( $nav_menu_selected_id, $echo = true ) {
[273] Fix | Delete
global $one_theme_location_no_menus;
[274] Fix | Delete
[275] Fix | Delete
if ( $one_theme_location_no_menus ) {
[276] Fix | Delete
return false;
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
return disabled( $nav_menu_selected_id, 0, $echo );
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
/**
[283] Fix | Delete
* Displays a meta box for the custom links menu item.
[284] Fix | Delete
*
[285] Fix | Delete
* @since 3.0.0
[286] Fix | Delete
*
[287] Fix | Delete
* @global int $_nav_menu_placeholder
[288] Fix | Delete
* @global int|string $nav_menu_selected_id
[289] Fix | Delete
*/
[290] Fix | Delete
function wp_nav_menu_item_link_meta_box() {
[291] Fix | Delete
global $_nav_menu_placeholder, $nav_menu_selected_id;
[292] Fix | Delete
[293] Fix | Delete
$_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
[294] Fix | Delete
[295] Fix | Delete
?>
[296] Fix | Delete
<div class="customlinkdiv" id="customlinkdiv">
[297] Fix | Delete
<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
[298] Fix | Delete
<p id="menu-item-url-wrap" class="wp-clearfix">
[299] Fix | Delete
<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
[300] Fix | Delete
<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="code menu-item-textbox form-required" placeholder="https://" />
[301] Fix | Delete
</p>
[302] Fix | Delete
[303] Fix | Delete
<p id="menu-item-name-wrap" class="wp-clearfix">
[304] Fix | Delete
<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
[305] Fix | Delete
<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="regular-text menu-item-textbox" />
[306] Fix | Delete
</p>
[307] Fix | Delete
[308] Fix | Delete
<p class="button-controls wp-clearfix">
[309] Fix | Delete
<span class="add-to-menu">
[310] Fix | Delete
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
[311] Fix | Delete
<span class="spinner"></span>
[312] Fix | Delete
</span>
[313] Fix | Delete
</p>
[314] Fix | Delete
[315] Fix | Delete
</div><!-- /.customlinkdiv -->
[316] Fix | Delete
<?php
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
/**
[320] Fix | Delete
* Displays a meta box for a post type menu item.
[321] Fix | Delete
*
[322] Fix | Delete
* @since 3.0.0
[323] Fix | Delete
*
[324] Fix | Delete
* @global int $_nav_menu_placeholder
[325] Fix | Delete
* @global int|string $nav_menu_selected_id
[326] Fix | Delete
*
[327] Fix | Delete
* @param string $object Not used.
[328] Fix | Delete
* @param array $box {
[329] Fix | Delete
* Post type menu item meta box arguments.
[330] Fix | Delete
*
[331] Fix | Delete
* @type string $id Meta box 'id' attribute.
[332] Fix | Delete
* @type string $title Meta box title.
[333] Fix | Delete
* @type callable $callback Meta box display callback.
[334] Fix | Delete
* @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box).
[335] Fix | Delete
* }
[336] Fix | Delete
*/
[337] Fix | Delete
function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
[338] Fix | Delete
global $_nav_menu_placeholder, $nav_menu_selected_id;
[339] Fix | Delete
[340] Fix | Delete
$post_type_name = $box['args']->name;
[341] Fix | Delete
$post_type = get_post_type_object( $post_type_name );
[342] Fix | Delete
$tab_name = $post_type_name . '-tab';
[343] Fix | Delete
[344] Fix | Delete
// Paginate browsing for large numbers of post objects.
[345] Fix | Delete
$per_page = 50;
[346] Fix | Delete
$pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
[347] Fix | Delete
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
[348] Fix | Delete
[349] Fix | Delete
$args = array(
[350] Fix | Delete
'offset' => $offset,
[351] Fix | Delete
'order' => 'ASC',
[352] Fix | Delete
'orderby' => 'title',
[353] Fix | Delete
'posts_per_page' => $per_page,
[354] Fix | Delete
'post_type' => $post_type_name,
[355] Fix | Delete
'suppress_filters' => true,
[356] Fix | Delete
'update_post_term_cache' => false,
[357] Fix | Delete
'update_post_meta_cache' => false,
[358] Fix | Delete
);
[359] Fix | Delete
[360] Fix | Delete
if ( isset( $box['args']->_default_query ) ) {
[361] Fix | Delete
$args = array_merge( $args, (array) $box['args']->_default_query );
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
/*
[365] Fix | Delete
* If we're dealing with pages, let's prioritize the Front Page,
[366] Fix | Delete
* Posts Page and Privacy Policy Page at the top of the list.
[367] Fix | Delete
*/
[368] Fix | Delete
$important_pages = array();
[369] Fix | Delete
if ( 'page' === $post_type_name ) {
[370] Fix | Delete
$suppress_page_ids = array();
[371] Fix | Delete
[372] Fix | Delete
// Insert Front Page or custom Home link.
[373] Fix | Delete
$front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;
[374] Fix | Delete
[375] Fix | Delete
$front_page_obj = null;
[376] Fix | Delete
if ( ! empty( $front_page ) ) {
[377] Fix | Delete
$front_page_obj = get_post( $front_page );
[378] Fix | Delete
$front_page_obj->front_or_home = true;
[379] Fix | Delete
[380] Fix | Delete
$important_pages[] = $front_page_obj;
[381] Fix | Delete
$suppress_page_ids[] = $front_page_obj->ID;
[382] Fix | Delete
} else {
[383] Fix | Delete
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;
[384] Fix | Delete
$front_page_obj = (object) array(
[385] Fix | Delete
'front_or_home' => true,
[386] Fix | Delete
'ID' => 0,
[387] Fix | Delete
'object_id' => $_nav_menu_placeholder,
[388] Fix | Delete
'post_content' => '',
[389] Fix | Delete
'post_excerpt' => '',
[390] Fix | Delete
'post_parent' => '',
[391] Fix | Delete
'post_title' => _x( 'Home', 'nav menu home label' ),
[392] Fix | Delete
'post_type' => 'nav_menu_item',
[393] Fix | Delete
'type' => 'custom',
[394] Fix | Delete
'url' => home_url( '/' ),
[395] Fix | Delete
);
[396] Fix | Delete
[397] Fix | Delete
$important_pages[] = $front_page_obj;
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
// Insert Posts Page.
[401] Fix | Delete
$posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0;
[402] Fix | Delete
[403] Fix | Delete
if ( ! empty( $posts_page ) ) {
[404] Fix | Delete
$posts_page_obj = get_post( $posts_page );
[405] Fix | Delete
$posts_page_obj->posts_page = true;
[406] Fix | Delete
[407] Fix | Delete
$important_pages[] = $posts_page_obj;
[408] Fix | Delete
$suppress_page_ids[] = $posts_page_obj->ID;
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
// Insert Privacy Policy Page.
[412] Fix | Delete
$privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
[413] Fix | Delete
[414] Fix | Delete
if ( ! empty( $privacy_policy_page_id ) ) {
[415] Fix | Delete
$privacy_policy_page = get_post( $privacy_policy_page_id );
[416] Fix | Delete
if ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ) {
[417] Fix | Delete
$privacy_policy_page->privacy_policy_page = true;
[418] Fix | Delete
[419] Fix | Delete
$important_pages[] = $privacy_policy_page;
[420] Fix | Delete
$suppress_page_ids[] = $privacy_policy_page->ID;
[421] Fix | Delete
}
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
// Add suppression array to arguments for WP_Query.
[425] Fix | Delete
if ( ! empty( $suppress_page_ids ) ) {
[426] Fix | Delete
$args['post__not_in'] = $suppress_page_ids;
[427] Fix | Delete
}
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
// @todo Transient caching of these results with proper invalidation on updating of a post of this type.
[431] Fix | Delete
$get_posts = new WP_Query;
[432] Fix | Delete
$posts = $get_posts->query( $args );
[433] Fix | Delete
[434] Fix | Delete
// Only suppress and insert when more than just suppression pages available.
[435] Fix | Delete
if ( ! $get_posts->post_count ) {
[436] Fix | Delete
if ( ! empty( $suppress_page_ids ) ) {
[437] Fix | Delete
unset( $args['post__not_in'] );
[438] Fix | Delete
$get_posts = new WP_Query;
[439] Fix | Delete
$posts = $get_posts->query( $args );
[440] Fix | Delete
} else {
[441] Fix | Delete
echo '<p>' . __( 'No items.' ) . '</p>';
[442] Fix | Delete
return;
[443] Fix | Delete
}
[444] Fix | Delete
} elseif ( ! empty( $important_pages ) ) {
[445] Fix | Delete
$posts = array_merge( $important_pages, $posts );
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
$num_pages = $get_posts->max_num_pages;
[449] Fix | Delete
[450] Fix | Delete
$page_links = paginate_links(
[451] Fix | Delete
array(
[452] Fix | Delete
'base' => add_query_arg(
[453] Fix | Delete
array(
[454] Fix | Delete
$tab_name => 'all',
[455] Fix | Delete
'paged' => '%#%',
[456] Fix | Delete
'item-type' => 'post_type',
[457] Fix | Delete
'item-object' => $post_type_name,
[458] Fix | Delete
)
[459] Fix | Delete
),
[460] Fix | Delete
'format' => '',
[461] Fix | Delete
'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '&laquo;' ) . '</span>',
[462] Fix | Delete
'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '&raquo;' ) . '</span>',
[463] Fix | Delete
'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ',
[464] Fix | Delete
'total' => $num_pages,
[465] Fix | Delete
'current' => $pagenum,
[466] Fix | Delete
)
[467] Fix | Delete
);
[468] Fix | Delete
[469] Fix | Delete
$db_fields = false;
[470] Fix | Delete
if ( is_post_type_hierarchical( $post_type_name ) ) {
[471] Fix | Delete
$db_fields = array(
[472] Fix | Delete
'parent' => 'post_parent',
[473] Fix | Delete
'id' => 'ID',
[474] Fix | Delete
);
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
[478] Fix | Delete
[479] Fix | Delete
$current_tab = 'most-recent';
[480] Fix | Delete
[481] Fix | Delete
if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'search' ), true ) ) {
[482] Fix | Delete
$current_tab = $_REQUEST[ $tab_name ];
[483] Fix | Delete
}
[484] Fix | Delete
[485] Fix | Delete
if ( ! empty( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) {
[486] Fix | Delete
$current_tab = 'search';
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
$removed_args = array(
[490] Fix | Delete
'action',
[491] Fix | Delete
'customlink-tab',
[492] Fix | Delete
'edit-menu-item',
[493] Fix | Delete
'menu-item',
[494] Fix | Delete
'page-tab',
[495] Fix | Delete
'_wpnonce',
[496] Fix | Delete
);
[497] Fix | Delete
[498] Fix | Delete
$most_recent_url = '';
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function