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-admin/includes
File: post.php
do_action( 'wp_creating_autosave', get_post( $revision, ARRAY_A ), false );
[2000] Fix | Delete
}
[2001] Fix | Delete
[2002] Fix | Delete
return $revision;
[2003] Fix | Delete
}
[2004] Fix | Delete
[2005] Fix | Delete
/**
[2006] Fix | Delete
* Autosave the revisioned meta fields.
[2007] Fix | Delete
*
[2008] Fix | Delete
* Iterates through the revisioned meta fields and checks each to see if they are set,
[2009] Fix | Delete
* and have a changed value. If so, the meta value is saved and attached to the autosave.
[2010] Fix | Delete
*
[2011] Fix | Delete
* @since 6.4.0
[2012] Fix | Delete
*
[2013] Fix | Delete
* @param array $new_autosave The new post data being autosaved.
[2014] Fix | Delete
*/
[2015] Fix | Delete
function wp_autosave_post_revisioned_meta_fields( $new_autosave ) {
[2016] Fix | Delete
/*
[2017] Fix | Delete
* The post data arrives as either $_POST['data']['wp_autosave'] or the $_POST
[2018] Fix | Delete
* itself. This sets $posted_data to the correct variable.
[2019] Fix | Delete
*
[2020] Fix | Delete
* Ignoring sanitization to avoid altering meta. Ignoring the nonce check because
[2021] Fix | Delete
* this is hooked on inner core hooks where a valid nonce was already checked.
[2022] Fix | Delete
*/
[2023] Fix | Delete
$posted_data = isset( $_POST['data']['wp_autosave'] ) ? $_POST['data']['wp_autosave'] : $_POST;
[2024] Fix | Delete
[2025] Fix | Delete
$post_type = get_post_type( $new_autosave['post_parent'] );
[2026] Fix | Delete
[2027] Fix | Delete
/*
[2028] Fix | Delete
* Go thru the revisioned meta keys and save them as part of the autosave, if
[2029] Fix | Delete
* the meta key is part of the posted data, the meta value is not blank and
[2030] Fix | Delete
* the the meta value has changes from the last autosaved value.
[2031] Fix | Delete
*/
[2032] Fix | Delete
foreach ( wp_post_revision_meta_keys( $post_type ) as $meta_key ) {
[2033] Fix | Delete
[2034] Fix | Delete
if (
[2035] Fix | Delete
isset( $posted_data[ $meta_key ] ) &&
[2036] Fix | Delete
get_post_meta( $new_autosave['ID'], $meta_key, true ) !== wp_unslash( $posted_data[ $meta_key ] )
[2037] Fix | Delete
) {
[2038] Fix | Delete
/*
[2039] Fix | Delete
* Use the underlying delete_metadata() and add_metadata() functions
[2040] Fix | Delete
* vs delete_post_meta() and add_post_meta() to make sure we're working
[2041] Fix | Delete
* with the actual revision meta.
[2042] Fix | Delete
*/
[2043] Fix | Delete
delete_metadata( 'post', $new_autosave['ID'], $meta_key );
[2044] Fix | Delete
[2045] Fix | Delete
/*
[2046] Fix | Delete
* One last check to ensure meta value not empty().
[2047] Fix | Delete
*/
[2048] Fix | Delete
if ( ! empty( $posted_data[ $meta_key ] ) ) {
[2049] Fix | Delete
/*
[2050] Fix | Delete
* Add the revisions meta data to the autosave.
[2051] Fix | Delete
*/
[2052] Fix | Delete
add_metadata( 'post', $new_autosave['ID'], $meta_key, $posted_data[ $meta_key ] );
[2053] Fix | Delete
}
[2054] Fix | Delete
}
[2055] Fix | Delete
}
[2056] Fix | Delete
}
[2057] Fix | Delete
[2058] Fix | Delete
/**
[2059] Fix | Delete
* Saves a draft or manually autosaves for the purpose of showing a post preview.
[2060] Fix | Delete
*
[2061] Fix | Delete
* @since 2.7.0
[2062] Fix | Delete
*
[2063] Fix | Delete
* @return string URL to redirect to show the preview.
[2064] Fix | Delete
*/
[2065] Fix | Delete
function post_preview() {
[2066] Fix | Delete
[2067] Fix | Delete
$post_id = (int) $_POST['post_ID'];
[2068] Fix | Delete
$_POST['ID'] = $post_id;
[2069] Fix | Delete
[2070] Fix | Delete
$post = get_post( $post_id );
[2071] Fix | Delete
[2072] Fix | Delete
if ( ! $post ) {
[2073] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
[2074] Fix | Delete
}
[2075] Fix | Delete
[2076] Fix | Delete
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
[2077] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
[2078] Fix | Delete
}
[2079] Fix | Delete
[2080] Fix | Delete
$is_autosave = false;
[2081] Fix | Delete
[2082] Fix | Delete
if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() === (int) $post->post_author
[2083] Fix | Delete
&& ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status )
[2084] Fix | Delete
) {
[2085] Fix | Delete
$saved_post_id = edit_post();
[2086] Fix | Delete
} else {
[2087] Fix | Delete
$is_autosave = true;
[2088] Fix | Delete
[2089] Fix | Delete
if ( isset( $_POST['post_status'] ) && 'auto-draft' === $_POST['post_status'] ) {
[2090] Fix | Delete
$_POST['post_status'] = 'draft';
[2091] Fix | Delete
}
[2092] Fix | Delete
[2093] Fix | Delete
$saved_post_id = wp_create_post_autosave( $post->ID );
[2094] Fix | Delete
}
[2095] Fix | Delete
[2096] Fix | Delete
if ( is_wp_error( $saved_post_id ) ) {
[2097] Fix | Delete
wp_die( $saved_post_id->get_error_message() );
[2098] Fix | Delete
}
[2099] Fix | Delete
[2100] Fix | Delete
$query_args = array();
[2101] Fix | Delete
[2102] Fix | Delete
if ( $is_autosave && $saved_post_id ) {
[2103] Fix | Delete
$query_args['preview_id'] = $post->ID;
[2104] Fix | Delete
$query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID );
[2105] Fix | Delete
[2106] Fix | Delete
if ( isset( $_POST['post_format'] ) ) {
[2107] Fix | Delete
$query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
[2108] Fix | Delete
}
[2109] Fix | Delete
[2110] Fix | Delete
if ( isset( $_POST['_thumbnail_id'] ) ) {
[2111] Fix | Delete
$query_args['_thumbnail_id'] = ( (int) $_POST['_thumbnail_id'] <= 0 ) ? '-1' : (int) $_POST['_thumbnail_id'];
[2112] Fix | Delete
}
[2113] Fix | Delete
}
[2114] Fix | Delete
[2115] Fix | Delete
return get_preview_post_link( $post, $query_args );
[2116] Fix | Delete
}
[2117] Fix | Delete
[2118] Fix | Delete
/**
[2119] Fix | Delete
* Saves a post submitted with XHR.
[2120] Fix | Delete
*
[2121] Fix | Delete
* Intended for use with heartbeat and autosave.js
[2122] Fix | Delete
*
[2123] Fix | Delete
* @since 3.9.0
[2124] Fix | Delete
*
[2125] Fix | Delete
* @param array $post_data Associative array of the submitted post data.
[2126] Fix | Delete
* @return mixed The value 0 or WP_Error on failure. The saved post ID on success.
[2127] Fix | Delete
* The ID can be the draft post_id or the autosave revision post_id.
[2128] Fix | Delete
*/
[2129] Fix | Delete
function wp_autosave( $post_data ) {
[2130] Fix | Delete
// Back-compat.
[2131] Fix | Delete
if ( ! defined( 'DOING_AUTOSAVE' ) ) {
[2132] Fix | Delete
define( 'DOING_AUTOSAVE', true );
[2133] Fix | Delete
}
[2134] Fix | Delete
[2135] Fix | Delete
$post_id = (int) $post_data['post_id'];
[2136] Fix | Delete
$post_data['ID'] = $post_id;
[2137] Fix | Delete
$post_data['post_ID'] = $post_id;
[2138] Fix | Delete
[2139] Fix | Delete
if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) {
[2140] Fix | Delete
return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) );
[2141] Fix | Delete
}
[2142] Fix | Delete
[2143] Fix | Delete
$post = get_post( $post_id );
[2144] Fix | Delete
[2145] Fix | Delete
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
[2146] Fix | Delete
return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) );
[2147] Fix | Delete
}
[2148] Fix | Delete
[2149] Fix | Delete
if ( 'auto-draft' === $post->post_status ) {
[2150] Fix | Delete
$post_data['post_status'] = 'draft';
[2151] Fix | Delete
}
[2152] Fix | Delete
[2153] Fix | Delete
if ( 'page' !== $post_data['post_type'] && ! empty( $post_data['catslist'] ) ) {
[2154] Fix | Delete
$post_data['post_category'] = explode( ',', $post_data['catslist'] );
[2155] Fix | Delete
}
[2156] Fix | Delete
[2157] Fix | Delete
if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() === (int) $post->post_author
[2158] Fix | Delete
&& ( 'auto-draft' === $post->post_status || 'draft' === $post->post_status )
[2159] Fix | Delete
) {
[2160] Fix | Delete
// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked.
[2161] Fix | Delete
return edit_post( wp_slash( $post_data ) );
[2162] Fix | Delete
} else {
[2163] Fix | Delete
/*
[2164] Fix | Delete
* Non-drafts or other users' drafts are not overwritten.
[2165] Fix | Delete
* The autosave is stored in a special post revision for each user.
[2166] Fix | Delete
*/
[2167] Fix | Delete
return wp_create_post_autosave( wp_slash( $post_data ) );
[2168] Fix | Delete
}
[2169] Fix | Delete
}
[2170] Fix | Delete
[2171] Fix | Delete
/**
[2172] Fix | Delete
* Redirects to previous page.
[2173] Fix | Delete
*
[2174] Fix | Delete
* @since 2.7.0
[2175] Fix | Delete
*
[2176] Fix | Delete
* @param int $post_id Optional. Post ID.
[2177] Fix | Delete
*/
[2178] Fix | Delete
function redirect_post( $post_id = '' ) {
[2179] Fix | Delete
if ( isset( $_POST['save'] ) || isset( $_POST['publish'] ) ) {
[2180] Fix | Delete
$status = get_post_status( $post_id );
[2181] Fix | Delete
[2182] Fix | Delete
switch ( $status ) {
[2183] Fix | Delete
case 'pending':
[2184] Fix | Delete
$message = 8;
[2185] Fix | Delete
break;
[2186] Fix | Delete
case 'future':
[2187] Fix | Delete
$message = 9;
[2188] Fix | Delete
break;
[2189] Fix | Delete
case 'draft':
[2190] Fix | Delete
$message = 10;
[2191] Fix | Delete
break;
[2192] Fix | Delete
default:
[2193] Fix | Delete
$message = isset( $_POST['publish'] ) ? 6 : 1;
[2194] Fix | Delete
break;
[2195] Fix | Delete
}
[2196] Fix | Delete
[2197] Fix | Delete
$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
[2198] Fix | Delete
} elseif ( isset( $_POST['addmeta'] ) && $_POST['addmeta'] ) {
[2199] Fix | Delete
$location = add_query_arg( 'message', 2, wp_get_referer() );
[2200] Fix | Delete
$location = explode( '#', $location );
[2201] Fix | Delete
$location = $location[0] . '#postcustom';
[2202] Fix | Delete
} elseif ( isset( $_POST['deletemeta'] ) && $_POST['deletemeta'] ) {
[2203] Fix | Delete
$location = add_query_arg( 'message', 3, wp_get_referer() );
[2204] Fix | Delete
$location = explode( '#', $location );
[2205] Fix | Delete
$location = $location[0] . '#postcustom';
[2206] Fix | Delete
} else {
[2207] Fix | Delete
$location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
[2208] Fix | Delete
}
[2209] Fix | Delete
[2210] Fix | Delete
/**
[2211] Fix | Delete
* Filters the post redirect destination URL.
[2212] Fix | Delete
*
[2213] Fix | Delete
* @since 2.9.0
[2214] Fix | Delete
*
[2215] Fix | Delete
* @param string $location The destination URL.
[2216] Fix | Delete
* @param int $post_id The post ID.
[2217] Fix | Delete
*/
[2218] Fix | Delete
wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
[2219] Fix | Delete
exit;
[2220] Fix | Delete
}
[2221] Fix | Delete
[2222] Fix | Delete
/**
[2223] Fix | Delete
* Sanitizes POST values from a checkbox taxonomy metabox.
[2224] Fix | Delete
*
[2225] Fix | Delete
* @since 5.1.0
[2226] Fix | Delete
*
[2227] Fix | Delete
* @param string $taxonomy The taxonomy name.
[2228] Fix | Delete
* @param array $terms Raw term data from the 'tax_input' field.
[2229] Fix | Delete
* @return int[] Array of sanitized term IDs.
[2230] Fix | Delete
*/
[2231] Fix | Delete
function taxonomy_meta_box_sanitize_cb_checkboxes( $taxonomy, $terms ) {
[2232] Fix | Delete
return array_map( 'intval', $terms );
[2233] Fix | Delete
}
[2234] Fix | Delete
[2235] Fix | Delete
/**
[2236] Fix | Delete
* Sanitizes POST values from an input taxonomy metabox.
[2237] Fix | Delete
*
[2238] Fix | Delete
* @since 5.1.0
[2239] Fix | Delete
*
[2240] Fix | Delete
* @param string $taxonomy The taxonomy name.
[2241] Fix | Delete
* @param array|string $terms Raw term data from the 'tax_input' field.
[2242] Fix | Delete
* @return array
[2243] Fix | Delete
*/
[2244] Fix | Delete
function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
[2245] Fix | Delete
/*
[2246] Fix | Delete
* Assume that a 'tax_input' string is a comma-separated list of term names.
[2247] Fix | Delete
* Some languages may use a character other than a comma as a delimiter, so we standardize on
[2248] Fix | Delete
* commas before parsing the list.
[2249] Fix | Delete
*/
[2250] Fix | Delete
if ( ! is_array( $terms ) ) {
[2251] Fix | Delete
$comma = _x( ',', 'tag delimiter' );
[2252] Fix | Delete
if ( ',' !== $comma ) {
[2253] Fix | Delete
$terms = str_replace( $comma, ',', $terms );
[2254] Fix | Delete
}
[2255] Fix | Delete
$terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
[2256] Fix | Delete
}
[2257] Fix | Delete
[2258] Fix | Delete
$clean_terms = array();
[2259] Fix | Delete
foreach ( $terms as $term ) {
[2260] Fix | Delete
// Empty terms are invalid input.
[2261] Fix | Delete
if ( empty( $term ) ) {
[2262] Fix | Delete
continue;
[2263] Fix | Delete
}
[2264] Fix | Delete
[2265] Fix | Delete
$_term = get_terms(
[2266] Fix | Delete
array(
[2267] Fix | Delete
'taxonomy' => $taxonomy,
[2268] Fix | Delete
'name' => $term,
[2269] Fix | Delete
'fields' => 'ids',
[2270] Fix | Delete
'hide_empty' => false,
[2271] Fix | Delete
)
[2272] Fix | Delete
);
[2273] Fix | Delete
[2274] Fix | Delete
if ( ! empty( $_term ) ) {
[2275] Fix | Delete
$clean_terms[] = (int) $_term[0];
[2276] Fix | Delete
} else {
[2277] Fix | Delete
// No existing term was found, so pass the string. A new term will be created.
[2278] Fix | Delete
$clean_terms[] = $term;
[2279] Fix | Delete
}
[2280] Fix | Delete
}
[2281] Fix | Delete
[2282] Fix | Delete
return $clean_terms;
[2283] Fix | Delete
}
[2284] Fix | Delete
[2285] Fix | Delete
/**
[2286] Fix | Delete
* Prepares server-registered blocks for the block editor.
[2287] Fix | Delete
*
[2288] Fix | Delete
* Returns an associative array of registered block data keyed by block name. Data includes properties
[2289] Fix | Delete
* of a block relevant for client registration.
[2290] Fix | Delete
*
[2291] Fix | Delete
* @since 5.0.0
[2292] Fix | Delete
* @since 6.3.0 Added `selectors` field.
[2293] Fix | Delete
* @since 6.4.0 Added `block_hooks` field.
[2294] Fix | Delete
*
[2295] Fix | Delete
* @return array An associative array of registered block data.
[2296] Fix | Delete
*/
[2297] Fix | Delete
function get_block_editor_server_block_settings() {
[2298] Fix | Delete
$block_registry = WP_Block_Type_Registry::get_instance();
[2299] Fix | Delete
$blocks = array();
[2300] Fix | Delete
$fields_to_pick = array(
[2301] Fix | Delete
'api_version' => 'apiVersion',
[2302] Fix | Delete
'title' => 'title',
[2303] Fix | Delete
'description' => 'description',
[2304] Fix | Delete
'icon' => 'icon',
[2305] Fix | Delete
'attributes' => 'attributes',
[2306] Fix | Delete
'provides_context' => 'providesContext',
[2307] Fix | Delete
'uses_context' => 'usesContext',
[2308] Fix | Delete
'block_hooks' => 'blockHooks',
[2309] Fix | Delete
'selectors' => 'selectors',
[2310] Fix | Delete
'supports' => 'supports',
[2311] Fix | Delete
'category' => 'category',
[2312] Fix | Delete
'styles' => 'styles',
[2313] Fix | Delete
'textdomain' => 'textdomain',
[2314] Fix | Delete
'parent' => 'parent',
[2315] Fix | Delete
'ancestor' => 'ancestor',
[2316] Fix | Delete
'keywords' => 'keywords',
[2317] Fix | Delete
'example' => 'example',
[2318] Fix | Delete
'variations' => 'variations',
[2319] Fix | Delete
'allowed_blocks' => 'allowedBlocks',
[2320] Fix | Delete
);
[2321] Fix | Delete
[2322] Fix | Delete
foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
[2323] Fix | Delete
foreach ( $fields_to_pick as $field => $key ) {
[2324] Fix | Delete
if ( ! isset( $block_type->{ $field } ) ) {
[2325] Fix | Delete
continue;
[2326] Fix | Delete
}
[2327] Fix | Delete
[2328] Fix | Delete
if ( ! isset( $blocks[ $block_name ] ) ) {
[2329] Fix | Delete
$blocks[ $block_name ] = array();
[2330] Fix | Delete
}
[2331] Fix | Delete
[2332] Fix | Delete
$blocks[ $block_name ][ $key ] = $block_type->{ $field };
[2333] Fix | Delete
}
[2334] Fix | Delete
}
[2335] Fix | Delete
[2336] Fix | Delete
return $blocks;
[2337] Fix | Delete
}
[2338] Fix | Delete
[2339] Fix | Delete
/**
[2340] Fix | Delete
* Renders the meta boxes forms.
[2341] Fix | Delete
*
[2342] Fix | Delete
* @since 5.0.0
[2343] Fix | Delete
*
[2344] Fix | Delete
* @global WP_Post $post Global post object.
[2345] Fix | Delete
* @global WP_Screen $current_screen WordPress current screen object.
[2346] Fix | Delete
* @global array $wp_meta_boxes Global meta box state.
[2347] Fix | Delete
*/
[2348] Fix | Delete
function the_block_editor_meta_boxes() {
[2349] Fix | Delete
global $post, $current_screen, $wp_meta_boxes;
[2350] Fix | Delete
[2351] Fix | Delete
// Handle meta box state.
[2352] Fix | Delete
$_original_meta_boxes = $wp_meta_boxes;
[2353] Fix | Delete
[2354] Fix | Delete
/**
[2355] Fix | Delete
* Fires right before the meta boxes are rendered.
[2356] Fix | Delete
*
[2357] Fix | Delete
* This allows for the filtering of meta box data, that should already be
[2358] Fix | Delete
* present by this point. Do not use as a means of adding meta box data.
[2359] Fix | Delete
*
[2360] Fix | Delete
* @since 5.0.0
[2361] Fix | Delete
*
[2362] Fix | Delete
* @param array $wp_meta_boxes Global meta box state.
[2363] Fix | Delete
*/
[2364] Fix | Delete
$wp_meta_boxes = apply_filters( 'filter_block_editor_meta_boxes', $wp_meta_boxes );
[2365] Fix | Delete
$locations = array( 'side', 'normal', 'advanced' );
[2366] Fix | Delete
$priorities = array( 'high', 'sorted', 'core', 'default', 'low' );
[2367] Fix | Delete
[2368] Fix | Delete
// Render meta boxes.
[2369] Fix | Delete
?>
[2370] Fix | Delete
<form class="metabox-base-form">
[2371] Fix | Delete
<?php the_block_editor_meta_box_post_form_hidden_fields( $post ); ?>
[2372] Fix | Delete
</form>
[2373] Fix | Delete
<form id="toggle-custom-fields-form" method="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>">
[2374] Fix | Delete
<?php wp_nonce_field( 'toggle-custom-fields', 'toggle-custom-fields-nonce' ); ?>
[2375] Fix | Delete
<input type="hidden" name="action" value="toggle-custom-fields" />
[2376] Fix | Delete
</form>
[2377] Fix | Delete
<?php foreach ( $locations as $location ) : ?>
[2378] Fix | Delete
<form class="metabox-location-<?php echo esc_attr( $location ); ?>" onsubmit="return false;">
[2379] Fix | Delete
<div id="poststuff" class="sidebar-open">
[2380] Fix | Delete
<div id="postbox-container-2" class="postbox-container">
[2381] Fix | Delete
<?php
[2382] Fix | Delete
do_meta_boxes(
[2383] Fix | Delete
$current_screen,
[2384] Fix | Delete
$location,
[2385] Fix | Delete
$post
[2386] Fix | Delete
);
[2387] Fix | Delete
?>
[2388] Fix | Delete
</div>
[2389] Fix | Delete
</div>
[2390] Fix | Delete
</form>
[2391] Fix | Delete
<?php endforeach; ?>
[2392] Fix | Delete
<?php
[2393] Fix | Delete
[2394] Fix | Delete
$meta_boxes_per_location = array();
[2395] Fix | Delete
foreach ( $locations as $location ) {
[2396] Fix | Delete
$meta_boxes_per_location[ $location ] = array();
[2397] Fix | Delete
[2398] Fix | Delete
if ( ! isset( $wp_meta_boxes[ $current_screen->id ][ $location ] ) ) {
[2399] Fix | Delete
continue;
[2400] Fix | Delete
}
[2401] Fix | Delete
[2402] Fix | Delete
foreach ( $priorities as $priority ) {
[2403] Fix | Delete
if ( ! isset( $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ] ) ) {
[2404] Fix | Delete
continue;
[2405] Fix | Delete
}
[2406] Fix | Delete
[2407] Fix | Delete
$meta_boxes = (array) $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ];
[2408] Fix | Delete
foreach ( $meta_boxes as $meta_box ) {
[2409] Fix | Delete
if ( false === $meta_box || ! $meta_box['title'] ) {
[2410] Fix | Delete
continue;
[2411] Fix | Delete
}
[2412] Fix | Delete
[2413] Fix | Delete
// If a meta box is just here for back compat, don't show it in the block editor.
[2414] Fix | Delete
if ( isset( $meta_box['args']['__back_compat_meta_box'] ) && $meta_box['args']['__back_compat_meta_box'] ) {
[2415] Fix | Delete
continue;
[2416] Fix | Delete
}
[2417] Fix | Delete
[2418] Fix | Delete
$meta_boxes_per_location[ $location ][] = array(
[2419] Fix | Delete
'id' => $meta_box['id'],
[2420] Fix | Delete
'title' => $meta_box['title'],
[2421] Fix | Delete
);
[2422] Fix | Delete
}
[2423] Fix | Delete
}
[2424] Fix | Delete
}
[2425] Fix | Delete
[2426] Fix | Delete
/*
[2427] Fix | Delete
* Sadly we probably cannot add this data directly into editor settings.
[2428] Fix | Delete
*
[2429] Fix | Delete
* Some meta boxes need `admin_head` to fire for meta box registry.
[2430] Fix | Delete
* `admin_head` fires after `admin_enqueue_scripts`, which is where we create
[2431] Fix | Delete
* our editor instance.
[2432] Fix | Delete
*/
[2433] Fix | Delete
$script = 'window._wpLoadBlockEditor.then( function() {
[2434] Fix | Delete
wp.data.dispatch( \'core/edit-post\' ).setAvailableMetaBoxesPerLocation( ' . wp_json_encode( $meta_boxes_per_location ) . ' );
[2435] Fix | Delete
} );';
[2436] Fix | Delete
[2437] Fix | Delete
wp_add_inline_script( 'wp-edit-post', $script );
[2438] Fix | Delete
[2439] Fix | Delete
/*
[2440] Fix | Delete
* When `wp-edit-post` is output in the `<head>`, the inline script needs to be manually printed.
[2441] Fix | Delete
* Otherwise, meta boxes will not display because inline scripts for `wp-edit-post`
[2442] Fix | Delete
* will not be printed again after this point.
[2443] Fix | Delete
*/
[2444] Fix | Delete
if ( wp_script_is( 'wp-edit-post', 'done' ) ) {
[2445] Fix | Delete
printf( "<script type='text/javascript'>\n%s\n</script>\n", trim( $script ) );
[2446] Fix | Delete
}
[2447] Fix | Delete
[2448] Fix | Delete
/*
[2449] Fix | Delete
* If the 'postcustom' meta box is enabled, then we need to perform
[2450] Fix | Delete
* some extra initialization on it.
[2451] Fix | Delete
*/
[2452] Fix | Delete
$enable_custom_fields = (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true );
[2453] Fix | Delete
[2454] Fix | Delete
if ( $enable_custom_fields ) {
[2455] Fix | Delete
$script = "( function( $ ) {
[2456] Fix | Delete
if ( $('#postcustom').length ) {
[2457] Fix | Delete
$( '#the-list' ).wpList( {
[2458] Fix | Delete
addBefore: function( s ) {
[2459] Fix | Delete
s.data += '&post_id=$post->ID';
[2460] Fix | Delete
return s;
[2461] Fix | Delete
},
[2462] Fix | Delete
addAfter: function() {
[2463] Fix | Delete
$('table#list-table').show();
[2464] Fix | Delete
}
[2465] Fix | Delete
});
[2466] Fix | Delete
}
[2467] Fix | Delete
} )( jQuery );";
[2468] Fix | Delete
wp_enqueue_script( 'wp-lists' );
[2469] Fix | Delete
wp_add_inline_script( 'wp-lists', $script );
[2470] Fix | Delete
}
[2471] Fix | Delete
[2472] Fix | Delete
/*
[2473] Fix | Delete
* Refresh nonces used by the meta box loader.
[2474] Fix | Delete
*
[2475] Fix | Delete
* The logic is very similar to that provided by post.js for the classic editor.
[2476] Fix | Delete
*/
[2477] Fix | Delete
$script = "( function( $ ) {
[2478] Fix | Delete
var check, timeout;
[2479] Fix | Delete
[2480] Fix | Delete
function schedule() {
[2481] Fix | Delete
check = false;
[2482] Fix | Delete
window.clearTimeout( timeout );
[2483] Fix | Delete
timeout = window.setTimeout( function() { check = true; }, 300000 );
[2484] Fix | Delete
}
[2485] Fix | Delete
[2486] Fix | Delete
$( document ).on( 'heartbeat-send.wp-refresh-nonces', function( e, data ) {
[2487] Fix | Delete
var post_id, \$authCheck = $( '#wp-auth-check-wrap' );
[2488] Fix | Delete
[2489] Fix | Delete
if ( check || ( \$authCheck.length && ! \$authCheck.hasClass( 'hidden' ) ) ) {
[2490] Fix | Delete
if ( ( post_id = $( '#post_ID' ).val() ) && $( '#_wpnonce' ).val() ) {
[2491] Fix | Delete
data['wp-refresh-metabox-loader-nonces'] = {
[2492] Fix | Delete
post_id: post_id
[2493] Fix | Delete
};
[2494] Fix | Delete
}
[2495] Fix | Delete
}
[2496] Fix | Delete
}).on( 'heartbeat-tick.wp-refresh-nonces', function( e, data ) {
[2497] Fix | Delete
var nonces = data['wp-refresh-metabox-loader-nonces'];
[2498] Fix | Delete
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function