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
if ( empty( $post_data ) ) {
[500] Fix | Delete
$post_data = &$_POST;
[501] Fix | Delete
}
[502] Fix | Delete
[503] Fix | Delete
if ( isset( $post_data['post_type'] ) ) {
[504] Fix | Delete
$ptype = get_post_type_object( $post_data['post_type'] );
[505] Fix | Delete
} else {
[506] Fix | Delete
$ptype = get_post_type_object( 'post' );
[507] Fix | Delete
}
[508] Fix | Delete
[509] Fix | Delete
if ( ! current_user_can( $ptype->cap->edit_posts ) ) {
[510] Fix | Delete
if ( 'page' === $ptype->name ) {
[511] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit pages.' ) );
[512] Fix | Delete
} else {
[513] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit posts.' ) );
[514] Fix | Delete
}
[515] Fix | Delete
}
[516] Fix | Delete
[517] Fix | Delete
if ( '-1' === $post_data['_status'] ) {
[518] Fix | Delete
$post_data['post_status'] = null;
[519] Fix | Delete
unset( $post_data['post_status'] );
[520] Fix | Delete
} else {
[521] Fix | Delete
$post_data['post_status'] = $post_data['_status'];
[522] Fix | Delete
}
[523] Fix | Delete
unset( $post_data['_status'] );
[524] Fix | Delete
[525] Fix | Delete
if ( ! empty( $post_data['post_status'] ) ) {
[526] Fix | Delete
$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
[527] Fix | Delete
[528] Fix | Delete
if ( 'inherit' === $post_data['post_status'] ) {
[529] Fix | Delete
unset( $post_data['post_status'] );
[530] Fix | Delete
}
[531] Fix | Delete
}
[532] Fix | Delete
[533] Fix | Delete
$post_ids = array_map( 'intval', (array) $post_data['post'] );
[534] Fix | Delete
[535] Fix | Delete
$reset = array(
[536] Fix | Delete
'post_author',
[537] Fix | Delete
'post_status',
[538] Fix | Delete
'post_password',
[539] Fix | Delete
'post_parent',
[540] Fix | Delete
'page_template',
[541] Fix | Delete
'comment_status',
[542] Fix | Delete
'ping_status',
[543] Fix | Delete
'keep_private',
[544] Fix | Delete
'tax_input',
[545] Fix | Delete
'post_category',
[546] Fix | Delete
'sticky',
[547] Fix | Delete
'post_format',
[548] Fix | Delete
);
[549] Fix | Delete
[550] Fix | Delete
foreach ( $reset as $field ) {
[551] Fix | Delete
if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || '-1' === $post_data[ $field ] ) ) {
[552] Fix | Delete
unset( $post_data[ $field ] );
[553] Fix | Delete
}
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
if ( isset( $post_data['post_category'] ) ) {
[557] Fix | Delete
if ( is_array( $post_data['post_category'] ) && ! empty( $post_data['post_category'] ) ) {
[558] Fix | Delete
$new_cats = array_map( 'absint', $post_data['post_category'] );
[559] Fix | Delete
} else {
[560] Fix | Delete
unset( $post_data['post_category'] );
[561] Fix | Delete
}
[562] Fix | Delete
}
[563] Fix | Delete
[564] Fix | Delete
$tax_input = array();
[565] Fix | Delete
if ( isset( $post_data['tax_input'] ) ) {
[566] Fix | Delete
foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
[567] Fix | Delete
if ( empty( $terms ) ) {
[568] Fix | Delete
continue;
[569] Fix | Delete
}
[570] Fix | Delete
[571] Fix | Delete
if ( is_taxonomy_hierarchical( $tax_name ) ) {
[572] Fix | Delete
$tax_input[ $tax_name ] = array_map( 'absint', $terms );
[573] Fix | Delete
} else {
[574] Fix | Delete
$comma = _x( ',', 'tag delimiter' );
[575] Fix | Delete
if ( ',' !== $comma ) {
[576] Fix | Delete
$terms = str_replace( $comma, ',', $terms );
[577] Fix | Delete
}
[578] Fix | Delete
$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
[579] Fix | Delete
}
[580] Fix | Delete
}
[581] Fix | Delete
}
[582] Fix | Delete
[583] Fix | Delete
if ( isset( $post_data['post_parent'] ) && (int) $post_data['post_parent'] ) {
[584] Fix | Delete
$parent = (int) $post_data['post_parent'];
[585] Fix | Delete
$pages = $wpdb->get_results( "SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'" );
[586] Fix | Delete
$children = array();
[587] Fix | Delete
[588] Fix | Delete
for ( $i = 0; $i < 50 && $parent > 0; $i++ ) {
[589] Fix | Delete
$children[] = $parent;
[590] Fix | Delete
[591] Fix | Delete
foreach ( $pages as $page ) {
[592] Fix | Delete
if ( (int) $page->ID === $parent ) {
[593] Fix | Delete
$parent = (int) $page->post_parent;
[594] Fix | Delete
break;
[595] Fix | Delete
}
[596] Fix | Delete
}
[597] Fix | Delete
}
[598] Fix | Delete
}
[599] Fix | Delete
[600] Fix | Delete
$updated = array();
[601] Fix | Delete
$skipped = array();
[602] Fix | Delete
$locked = array();
[603] Fix | Delete
$shared_post_data = $post_data;
[604] Fix | Delete
[605] Fix | Delete
foreach ( $post_ids as $post_id ) {
[606] Fix | Delete
// Start with fresh post data with each iteration.
[607] Fix | Delete
$post_data = $shared_post_data;
[608] Fix | Delete
[609] Fix | Delete
$post_type_object = get_post_type_object( get_post_type( $post_id ) );
[610] Fix | Delete
[611] Fix | Delete
if ( ! isset( $post_type_object )
[612] Fix | Delete
|| ( isset( $children ) && in_array( $post_id, $children, true ) )
[613] Fix | Delete
|| ! current_user_can( 'edit_post', $post_id )
[614] Fix | Delete
) {
[615] Fix | Delete
$skipped[] = $post_id;
[616] Fix | Delete
continue;
[617] Fix | Delete
}
[618] Fix | Delete
[619] Fix | Delete
if ( wp_check_post_lock( $post_id ) ) {
[620] Fix | Delete
$locked[] = $post_id;
[621] Fix | Delete
continue;
[622] Fix | Delete
}
[623] Fix | Delete
[624] Fix | Delete
$post = get_post( $post_id );
[625] Fix | Delete
$tax_names = get_object_taxonomies( $post );
[626] Fix | Delete
[627] Fix | Delete
foreach ( $tax_names as $tax_name ) {
[628] Fix | Delete
$taxonomy_obj = get_taxonomy( $tax_name );
[629] Fix | Delete
[630] Fix | Delete
if ( ! $taxonomy_obj->show_in_quick_edit ) {
[631] Fix | Delete
continue;
[632] Fix | Delete
}
[633] Fix | Delete
[634] Fix | Delete
if ( isset( $tax_input[ $tax_name ] ) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
[635] Fix | Delete
$new_terms = $tax_input[ $tax_name ];
[636] Fix | Delete
} else {
[637] Fix | Delete
$new_terms = array();
[638] Fix | Delete
}
[639] Fix | Delete
[640] Fix | Delete
if ( $taxonomy_obj->hierarchical ) {
[641] Fix | Delete
$current_terms = (array) wp_get_object_terms( $post_id, $tax_name, array( 'fields' => 'ids' ) );
[642] Fix | Delete
} else {
[643] Fix | Delete
$current_terms = (array) wp_get_object_terms( $post_id, $tax_name, array( 'fields' => 'names' ) );
[644] Fix | Delete
}
[645] Fix | Delete
[646] Fix | Delete
$post_data['tax_input'][ $tax_name ] = array_merge( $current_terms, $new_terms );
[647] Fix | Delete
}
[648] Fix | Delete
[649] Fix | Delete
if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) {
[650] Fix | Delete
$cats = (array) wp_get_post_categories( $post_id );
[651] Fix | Delete
[652] Fix | Delete
if (
[653] Fix | Delete
isset( $post_data['indeterminate_post_category'] )
[654] Fix | Delete
&& is_array( $post_data['indeterminate_post_category'] )
[655] Fix | Delete
) {
[656] Fix | Delete
$indeterminate_post_category = $post_data['indeterminate_post_category'];
[657] Fix | Delete
} else {
[658] Fix | Delete
$indeterminate_post_category = array();
[659] Fix | Delete
}
[660] Fix | Delete
[661] Fix | Delete
$indeterminate_cats = array_intersect( $cats, $indeterminate_post_category );
[662] Fix | Delete
$determinate_cats = array_diff( $new_cats, $indeterminate_post_category );
[663] Fix | Delete
$post_data['post_category'] = array_unique( array_merge( $indeterminate_cats, $determinate_cats ) );
[664] Fix | Delete
[665] Fix | Delete
unset( $post_data['tax_input']['category'] );
[666] Fix | Delete
}
[667] Fix | Delete
[668] Fix | Delete
$post_data['post_ID'] = $post_id;
[669] Fix | Delete
$post_data['post_type'] = $post->post_type;
[670] Fix | Delete
$post_data['post_mime_type'] = $post->post_mime_type;
[671] Fix | Delete
[672] Fix | Delete
foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) {
[673] Fix | Delete
if ( ! isset( $post_data[ $field ] ) ) {
[674] Fix | Delete
$post_data[ $field ] = $post->$field;
[675] Fix | Delete
}
[676] Fix | Delete
}
[677] Fix | Delete
[678] Fix | Delete
$post_data = _wp_translate_postdata( true, $post_data );
[679] Fix | Delete
if ( is_wp_error( $post_data ) ) {
[680] Fix | Delete
$skipped[] = $post_id;
[681] Fix | Delete
continue;
[682] Fix | Delete
}
[683] Fix | Delete
$post_data = _wp_get_allowed_postdata( $post_data );
[684] Fix | Delete
[685] Fix | Delete
if ( isset( $shared_post_data['post_format'] ) ) {
[686] Fix | Delete
set_post_format( $post_id, $shared_post_data['post_format'] );
[687] Fix | Delete
}
[688] Fix | Delete
[689] Fix | Delete
// Prevent wp_insert_post() from overwriting post format with the old data.
[690] Fix | Delete
unset( $post_data['tax_input']['post_format'] );
[691] Fix | Delete
[692] Fix | Delete
// Reset post date of scheduled post to be published.
[693] Fix | Delete
if (
[694] Fix | Delete
in_array( $post->post_status, array( 'future', 'draft' ), true ) &&
[695] Fix | Delete
'publish' === $post_data['post_status']
[696] Fix | Delete
) {
[697] Fix | Delete
$post_data['post_date'] = current_time( 'mysql' );
[698] Fix | Delete
$post_data['post_date_gmt'] = '';
[699] Fix | Delete
}
[700] Fix | Delete
[701] Fix | Delete
$post_id = wp_update_post( $post_data );
[702] Fix | Delete
update_post_meta( $post_id, '_edit_last', get_current_user_id() );
[703] Fix | Delete
$updated[] = $post_id;
[704] Fix | Delete
[705] Fix | Delete
if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
[706] Fix | Delete
if ( 'sticky' === $post_data['sticky'] ) {
[707] Fix | Delete
stick_post( $post_id );
[708] Fix | Delete
} else {
[709] Fix | Delete
unstick_post( $post_id );
[710] Fix | Delete
}
[711] Fix | Delete
}
[712] Fix | Delete
}
[713] Fix | Delete
[714] Fix | Delete
/**
[715] Fix | Delete
* Fires after processing the post data for bulk edit.
[716] Fix | Delete
*
[717] Fix | Delete
* @since 6.3.0
[718] Fix | Delete
*
[719] Fix | Delete
* @param int[] $updated An array of updated post IDs.
[720] Fix | Delete
* @param array $shared_post_data Associative array containing the post data.
[721] Fix | Delete
*/
[722] Fix | Delete
do_action( 'bulk_edit_posts', $updated, $shared_post_data );
[723] Fix | Delete
[724] Fix | Delete
return array(
[725] Fix | Delete
'updated' => $updated,
[726] Fix | Delete
'skipped' => $skipped,
[727] Fix | Delete
'locked' => $locked,
[728] Fix | Delete
);
[729] Fix | Delete
}
[730] Fix | Delete
[731] Fix | Delete
/**
[732] Fix | Delete
* Returns default post information to use when populating the "Write Post" form.
[733] Fix | Delete
*
[734] Fix | Delete
* @since 2.0.0
[735] Fix | Delete
*
[736] Fix | Delete
* @param string $post_type Optional. A post type string. Default 'post'.
[737] Fix | Delete
* @param bool $create_in_db Optional. Whether to insert the post into database. Default false.
[738] Fix | Delete
* @return WP_Post Post object containing all the default post data as attributes
[739] Fix | Delete
*/
[740] Fix | Delete
function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
[741] Fix | Delete
$post_title = '';
[742] Fix | Delete
if ( ! empty( $_REQUEST['post_title'] ) ) {
[743] Fix | Delete
$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ) );
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
$post_content = '';
[747] Fix | Delete
if ( ! empty( $_REQUEST['content'] ) ) {
[748] Fix | Delete
$post_content = esc_html( wp_unslash( $_REQUEST['content'] ) );
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
$post_excerpt = '';
[752] Fix | Delete
if ( ! empty( $_REQUEST['excerpt'] ) ) {
[753] Fix | Delete
$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ) );
[754] Fix | Delete
}
[755] Fix | Delete
[756] Fix | Delete
if ( $create_in_db ) {
[757] Fix | Delete
$post_id = wp_insert_post(
[758] Fix | Delete
array(
[759] Fix | Delete
'post_title' => __( 'Auto Draft' ),
[760] Fix | Delete
'post_type' => $post_type,
[761] Fix | Delete
'post_status' => 'auto-draft',
[762] Fix | Delete
),
[763] Fix | Delete
false,
[764] Fix | Delete
false
[765] Fix | Delete
);
[766] Fix | Delete
$post = get_post( $post_id );
[767] Fix | Delete
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
[768] Fix | Delete
set_post_format( $post, get_option( 'default_post_format' ) );
[769] Fix | Delete
}
[770] Fix | Delete
wp_after_insert_post( $post, false, null );
[771] Fix | Delete
[772] Fix | Delete
// Schedule auto-draft cleanup.
[773] Fix | Delete
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
[774] Fix | Delete
wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
[775] Fix | Delete
}
[776] Fix | Delete
} else {
[777] Fix | Delete
$post = new stdClass();
[778] Fix | Delete
$post->ID = 0;
[779] Fix | Delete
$post->post_author = '';
[780] Fix | Delete
$post->post_date = '';
[781] Fix | Delete
$post->post_date_gmt = '';
[782] Fix | Delete
$post->post_password = '';
[783] Fix | Delete
$post->post_name = '';
[784] Fix | Delete
$post->post_type = $post_type;
[785] Fix | Delete
$post->post_status = 'draft';
[786] Fix | Delete
$post->to_ping = '';
[787] Fix | Delete
$post->pinged = '';
[788] Fix | Delete
$post->comment_status = get_default_comment_status( $post_type );
[789] Fix | Delete
$post->ping_status = get_default_comment_status( $post_type, 'pingback' );
[790] Fix | Delete
$post->post_pingback = get_option( 'default_pingback_flag' );
[791] Fix | Delete
$post->post_category = get_option( 'default_category' );
[792] Fix | Delete
$post->page_template = 'default';
[793] Fix | Delete
$post->post_parent = 0;
[794] Fix | Delete
$post->menu_order = 0;
[795] Fix | Delete
$post = new WP_Post( $post );
[796] Fix | Delete
}
[797] Fix | Delete
[798] Fix | Delete
/**
[799] Fix | Delete
* Filters the default post content initially used in the "Write Post" form.
[800] Fix | Delete
*
[801] Fix | Delete
* @since 1.5.0
[802] Fix | Delete
*
[803] Fix | Delete
* @param string $post_content Default post content.
[804] Fix | Delete
* @param WP_Post $post Post object.
[805] Fix | Delete
*/
[806] Fix | Delete
$post->post_content = (string) apply_filters( 'default_content', $post_content, $post );
[807] Fix | Delete
[808] Fix | Delete
/**
[809] Fix | Delete
* Filters the default post title initially used in the "Write Post" form.
[810] Fix | Delete
*
[811] Fix | Delete
* @since 1.5.0
[812] Fix | Delete
*
[813] Fix | Delete
* @param string $post_title Default post title.
[814] Fix | Delete
* @param WP_Post $post Post object.
[815] Fix | Delete
*/
[816] Fix | Delete
$post->post_title = (string) apply_filters( 'default_title', $post_title, $post );
[817] Fix | Delete
[818] Fix | Delete
/**
[819] Fix | Delete
* Filters the default post excerpt initially used in the "Write Post" form.
[820] Fix | Delete
*
[821] Fix | Delete
* @since 1.5.0
[822] Fix | Delete
*
[823] Fix | Delete
* @param string $post_excerpt Default post excerpt.
[824] Fix | Delete
* @param WP_Post $post Post object.
[825] Fix | Delete
*/
[826] Fix | Delete
$post->post_excerpt = (string) apply_filters( 'default_excerpt', $post_excerpt, $post );
[827] Fix | Delete
[828] Fix | Delete
return $post;
[829] Fix | Delete
}
[830] Fix | Delete
[831] Fix | Delete
/**
[832] Fix | Delete
* Determines if a post exists based on title, content, date and type.
[833] Fix | Delete
*
[834] Fix | Delete
* @since 2.0.0
[835] Fix | Delete
* @since 5.2.0 Added the `$type` parameter.
[836] Fix | Delete
* @since 5.8.0 Added the `$status` parameter.
[837] Fix | Delete
*
[838] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[839] Fix | Delete
*
[840] Fix | Delete
* @param string $title Post title.
[841] Fix | Delete
* @param string $content Optional. Post content.
[842] Fix | Delete
* @param string $date Optional. Post date.
[843] Fix | Delete
* @param string $type Optional. Post type.
[844] Fix | Delete
* @param string $status Optional. Post status.
[845] Fix | Delete
* @return int Post ID if post exists, 0 otherwise.
[846] Fix | Delete
*/
[847] Fix | Delete
function post_exists( $title, $content = '', $date = '', $type = '', $status = '' ) {
[848] Fix | Delete
global $wpdb;
[849] Fix | Delete
[850] Fix | Delete
$post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
[851] Fix | Delete
$post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
[852] Fix | Delete
$post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
[853] Fix | Delete
$post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) );
[854] Fix | Delete
$post_status = wp_unslash( sanitize_post_field( 'post_status', $status, 0, 'db' ) );
[855] Fix | Delete
[856] Fix | Delete
$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
[857] Fix | Delete
$args = array();
[858] Fix | Delete
[859] Fix | Delete
if ( ! empty( $date ) ) {
[860] Fix | Delete
$query .= ' AND post_date = %s';
[861] Fix | Delete
$args[] = $post_date;
[862] Fix | Delete
}
[863] Fix | Delete
[864] Fix | Delete
if ( ! empty( $title ) ) {
[865] Fix | Delete
$query .= ' AND post_title = %s';
[866] Fix | Delete
$args[] = $post_title;
[867] Fix | Delete
}
[868] Fix | Delete
[869] Fix | Delete
if ( ! empty( $content ) ) {
[870] Fix | Delete
$query .= ' AND post_content = %s';
[871] Fix | Delete
$args[] = $post_content;
[872] Fix | Delete
}
[873] Fix | Delete
[874] Fix | Delete
if ( ! empty( $type ) ) {
[875] Fix | Delete
$query .= ' AND post_type = %s';
[876] Fix | Delete
$args[] = $post_type;
[877] Fix | Delete
}
[878] Fix | Delete
[879] Fix | Delete
if ( ! empty( $status ) ) {
[880] Fix | Delete
$query .= ' AND post_status = %s';
[881] Fix | Delete
$args[] = $post_status;
[882] Fix | Delete
}
[883] Fix | Delete
[884] Fix | Delete
if ( ! empty( $args ) ) {
[885] Fix | Delete
return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) );
[886] Fix | Delete
}
[887] Fix | Delete
[888] Fix | Delete
return 0;
[889] Fix | Delete
}
[890] Fix | Delete
[891] Fix | Delete
/**
[892] Fix | Delete
* Creates a new post from the "Write Post" form using `$_POST` information.
[893] Fix | Delete
*
[894] Fix | Delete
* @since 2.1.0
[895] Fix | Delete
*
[896] Fix | Delete
* @global WP_User $current_user
[897] Fix | Delete
*
[898] Fix | Delete
* @return int|WP_Error Post ID on success, WP_Error on failure.
[899] Fix | Delete
*/
[900] Fix | Delete
function wp_write_post() {
[901] Fix | Delete
if ( isset( $_POST['post_type'] ) ) {
[902] Fix | Delete
$ptype = get_post_type_object( $_POST['post_type'] );
[903] Fix | Delete
} else {
[904] Fix | Delete
$ptype = get_post_type_object( 'post' );
[905] Fix | Delete
}
[906] Fix | Delete
[907] Fix | Delete
if ( ! current_user_can( $ptype->cap->edit_posts ) ) {
[908] Fix | Delete
if ( 'page' === $ptype->name ) {
[909] Fix | Delete
return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) );
[910] Fix | Delete
} else {
[911] Fix | Delete
return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) );
[912] Fix | Delete
}
[913] Fix | Delete
}
[914] Fix | Delete
[915] Fix | Delete
$_POST['post_mime_type'] = '';
[916] Fix | Delete
[917] Fix | Delete
// Clear out any data in internal vars.
[918] Fix | Delete
unset( $_POST['filter'] );
[919] Fix | Delete
[920] Fix | Delete
// Edit, don't write, if we have a post ID.
[921] Fix | Delete
if ( isset( $_POST['post_ID'] ) ) {
[922] Fix | Delete
return edit_post();
[923] Fix | Delete
}
[924] Fix | Delete
[925] Fix | Delete
if ( isset( $_POST['visibility'] ) ) {
[926] Fix | Delete
switch ( $_POST['visibility'] ) {
[927] Fix | Delete
case 'public':
[928] Fix | Delete
$_POST['post_password'] = '';
[929] Fix | Delete
break;
[930] Fix | Delete
case 'password':
[931] Fix | Delete
unset( $_POST['sticky'] );
[932] Fix | Delete
break;
[933] Fix | Delete
case 'private':
[934] Fix | Delete
$_POST['post_status'] = 'private';
[935] Fix | Delete
$_POST['post_password'] = '';
[936] Fix | Delete
unset( $_POST['sticky'] );
[937] Fix | Delete
break;
[938] Fix | Delete
}
[939] Fix | Delete
}
[940] Fix | Delete
[941] Fix | Delete
$translated = _wp_translate_postdata( false );
[942] Fix | Delete
if ( is_wp_error( $translated ) ) {
[943] Fix | Delete
return $translated;
[944] Fix | Delete
}
[945] Fix | Delete
$translated = _wp_get_allowed_postdata( $translated );
[946] Fix | Delete
[947] Fix | Delete
// Create the post.
[948] Fix | Delete
$post_id = wp_insert_post( $translated );
[949] Fix | Delete
if ( is_wp_error( $post_id ) ) {
[950] Fix | Delete
return $post_id;
[951] Fix | Delete
}
[952] Fix | Delete
[953] Fix | Delete
if ( empty( $post_id ) ) {
[954] Fix | Delete
return 0;
[955] Fix | Delete
}
[956] Fix | Delete
[957] Fix | Delete
add_meta( $post_id );
[958] Fix | Delete
[959] Fix | Delete
add_post_meta( $post_id, '_edit_last', $GLOBALS['current_user']->ID );
[960] Fix | Delete
[961] Fix | Delete
// Now that we have an ID we can fix any attachment anchor hrefs.
[962] Fix | Delete
_fix_attachment_links( $post_id );
[963] Fix | Delete
[964] Fix | Delete
wp_set_post_lock( $post_id );
[965] Fix | Delete
[966] Fix | Delete
return $post_id;
[967] Fix | Delete
}
[968] Fix | Delete
[969] Fix | Delete
/**
[970] Fix | Delete
* Calls wp_write_post() and handles the errors.
[971] Fix | Delete
*
[972] Fix | Delete
* @since 2.0.0
[973] Fix | Delete
*
[974] Fix | Delete
* @return int|void Post ID on success, void on failure.
[975] Fix | Delete
*/
[976] Fix | Delete
function write_post() {
[977] Fix | Delete
$result = wp_write_post();
[978] Fix | Delete
if ( is_wp_error( $result ) ) {
[979] Fix | Delete
wp_die( $result->get_error_message() );
[980] Fix | Delete
} else {
[981] Fix | Delete
return $result;
[982] Fix | Delete
}
[983] Fix | Delete
}
[984] Fix | Delete
[985] Fix | Delete
//
[986] Fix | Delete
// Post Meta.
[987] Fix | Delete
//
[988] Fix | Delete
[989] Fix | Delete
/**
[990] Fix | Delete
* Adds post meta data defined in the `$_POST` superglobal for a post with given ID.
[991] Fix | Delete
*
[992] Fix | Delete
* @since 1.2.0
[993] Fix | Delete
*
[994] Fix | Delete
* @param int $post_id
[995] Fix | Delete
* @return int|bool
[996] Fix | Delete
*/
[997] Fix | Delete
function add_meta( $post_id ) {
[998] Fix | Delete
$post_id = (int) $post_id;
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function