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/clone/wp-inclu...
File: post.php
clean_comment_cache( array_keys( $statuses ) );
[4000] Fix | Delete
[4001] Fix | Delete
delete_post_meta( $post_id, '_wp_trash_meta_comments_status' );
[4002] Fix | Delete
[4003] Fix | Delete
/**
[4004] Fix | Delete
* Fires after comments are restored for a post from the Trash.
[4005] Fix | Delete
*
[4006] Fix | Delete
* @since 2.9.0
[4007] Fix | Delete
*
[4008] Fix | Delete
* @param int $post_id Post ID.
[4009] Fix | Delete
*/
[4010] Fix | Delete
do_action( 'untrashed_post_comments', $post_id );
[4011] Fix | Delete
}
[4012] Fix | Delete
[4013] Fix | Delete
/**
[4014] Fix | Delete
* Retrieves the list of categories for a post.
[4015] Fix | Delete
*
[4016] Fix | Delete
* Compatibility layer for themes and plugins. Also an easy layer of abstraction
[4017] Fix | Delete
* away from the complexity of the taxonomy layer.
[4018] Fix | Delete
*
[4019] Fix | Delete
* @since 2.1.0
[4020] Fix | Delete
*
[4021] Fix | Delete
* @see wp_get_object_terms()
[4022] Fix | Delete
*
[4023] Fix | Delete
* @param int $post_id Optional. The Post ID. Does not default to the ID of the
[4024] Fix | Delete
* global $post. Default 0.
[4025] Fix | Delete
* @param array $args Optional. Category query parameters. Default empty array.
[4026] Fix | Delete
* See WP_Term_Query::__construct() for supported arguments.
[4027] Fix | Delete
* @return array|WP_Error List of categories. If the `$fields` argument passed via `$args` is 'all' or
[4028] Fix | Delete
* 'all_with_object_id', an array of WP_Term objects will be returned. If `$fields`
[4029] Fix | Delete
* is 'ids', an array of category IDs. If `$fields` is 'names', an array of category names.
[4030] Fix | Delete
* WP_Error object if 'category' taxonomy doesn't exist.
[4031] Fix | Delete
*/
[4032] Fix | Delete
function wp_get_post_categories( $post_id = 0, $args = array() ) {
[4033] Fix | Delete
$post_id = (int) $post_id;
[4034] Fix | Delete
[4035] Fix | Delete
$defaults = array( 'fields' => 'ids' );
[4036] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[4037] Fix | Delete
[4038] Fix | Delete
$cats = wp_get_object_terms( $post_id, 'category', $args );
[4039] Fix | Delete
return $cats;
[4040] Fix | Delete
}
[4041] Fix | Delete
[4042] Fix | Delete
/**
[4043] Fix | Delete
* Retrieves the tags for a post.
[4044] Fix | Delete
*
[4045] Fix | Delete
* There is only one default for this function, called 'fields' and by default
[4046] Fix | Delete
* is set to 'all'. There are other defaults that can be overridden in
[4047] Fix | Delete
* wp_get_object_terms().
[4048] Fix | Delete
*
[4049] Fix | Delete
* @since 2.3.0
[4050] Fix | Delete
*
[4051] Fix | Delete
* @param int $post_id Optional. The Post ID. Does not default to the ID of the
[4052] Fix | Delete
* global $post. Default 0.
[4053] Fix | Delete
* @param array $args Optional. Tag query parameters. Default empty array.
[4054] Fix | Delete
* See WP_Term_Query::__construct() for supported arguments.
[4055] Fix | Delete
* @return array|WP_Error Array of WP_Term objects on success or empty array if no tags were found.
[4056] Fix | Delete
* WP_Error object if 'post_tag' taxonomy doesn't exist.
[4057] Fix | Delete
*/
[4058] Fix | Delete
function wp_get_post_tags( $post_id = 0, $args = array() ) {
[4059] Fix | Delete
return wp_get_post_terms( $post_id, 'post_tag', $args );
[4060] Fix | Delete
}
[4061] Fix | Delete
[4062] Fix | Delete
/**
[4063] Fix | Delete
* Retrieves the terms for a post.
[4064] Fix | Delete
*
[4065] Fix | Delete
* @since 2.8.0
[4066] Fix | Delete
*
[4067] Fix | Delete
* @param int $post_id Optional. The Post ID. Does not default to the ID of the
[4068] Fix | Delete
* global $post. Default 0.
[4069] Fix | Delete
* @param string|string[] $taxonomy Optional. The taxonomy slug or array of slugs for which
[4070] Fix | Delete
* to retrieve terms. Default 'post_tag'.
[4071] Fix | Delete
* @param array $args {
[4072] Fix | Delete
* Optional. Term query parameters. See WP_Term_Query::__construct() for supported arguments.
[4073] Fix | Delete
*
[4074] Fix | Delete
* @type string $fields Term fields to retrieve. Default 'all'.
[4075] Fix | Delete
* }
[4076] Fix | Delete
* @return array|WP_Error Array of WP_Term objects on success or empty array if no terms were found.
[4077] Fix | Delete
* WP_Error object if `$taxonomy` doesn't exist.
[4078] Fix | Delete
*/
[4079] Fix | Delete
function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
[4080] Fix | Delete
$post_id = (int) $post_id;
[4081] Fix | Delete
[4082] Fix | Delete
$defaults = array( 'fields' => 'all' );
[4083] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[4084] Fix | Delete
[4085] Fix | Delete
$tags = wp_get_object_terms( $post_id, $taxonomy, $args );
[4086] Fix | Delete
[4087] Fix | Delete
return $tags;
[4088] Fix | Delete
}
[4089] Fix | Delete
[4090] Fix | Delete
/**
[4091] Fix | Delete
* Retrieves a number of recent posts.
[4092] Fix | Delete
*
[4093] Fix | Delete
* @since 1.0.0
[4094] Fix | Delete
*
[4095] Fix | Delete
* @see get_posts()
[4096] Fix | Delete
*
[4097] Fix | Delete
* @param array $args Optional. Arguments to retrieve posts. Default empty array.
[4098] Fix | Delete
* @param string $output Optional. The required return type. One of OBJECT or ARRAY_A, which
[4099] Fix | Delete
* correspond to a WP_Post object or an associative array, respectively.
[4100] Fix | Delete
* Default ARRAY_A.
[4101] Fix | Delete
* @return array|false Array of recent posts, where the type of each element is determined
[4102] Fix | Delete
* by the `$output` parameter. Empty array on failure.
[4103] Fix | Delete
*/
[4104] Fix | Delete
function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
[4105] Fix | Delete
[4106] Fix | Delete
if ( is_numeric( $args ) ) {
[4107] Fix | Delete
_deprecated_argument( __FUNCTION__, '3.1.0', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
[4108] Fix | Delete
$args = array( 'numberposts' => absint( $args ) );
[4109] Fix | Delete
}
[4110] Fix | Delete
[4111] Fix | Delete
// Set default arguments.
[4112] Fix | Delete
$defaults = array(
[4113] Fix | Delete
'numberposts' => 10,
[4114] Fix | Delete
'offset' => 0,
[4115] Fix | Delete
'category' => 0,
[4116] Fix | Delete
'orderby' => 'post_date',
[4117] Fix | Delete
'order' => 'DESC',
[4118] Fix | Delete
'include' => '',
[4119] Fix | Delete
'exclude' => '',
[4120] Fix | Delete
'meta_key' => '',
[4121] Fix | Delete
'meta_value' => '',
[4122] Fix | Delete
'post_type' => 'post',
[4123] Fix | Delete
'post_status' => 'draft, publish, future, pending, private',
[4124] Fix | Delete
'suppress_filters' => true,
[4125] Fix | Delete
);
[4126] Fix | Delete
[4127] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[4128] Fix | Delete
[4129] Fix | Delete
$results = get_posts( $parsed_args );
[4130] Fix | Delete
[4131] Fix | Delete
// Backward compatibility. Prior to 3.1 expected posts to be returned in array.
[4132] Fix | Delete
if ( ARRAY_A === $output ) {
[4133] Fix | Delete
foreach ( $results as $key => $result ) {
[4134] Fix | Delete
$results[ $key ] = get_object_vars( $result );
[4135] Fix | Delete
}
[4136] Fix | Delete
return $results ? $results : array();
[4137] Fix | Delete
}
[4138] Fix | Delete
[4139] Fix | Delete
return $results ? $results : false;
[4140] Fix | Delete
}
[4141] Fix | Delete
[4142] Fix | Delete
/**
[4143] Fix | Delete
* Inserts or update a post.
[4144] Fix | Delete
*
[4145] Fix | Delete
* If the $postarr parameter has 'ID' set to a value, then post will be updated.
[4146] Fix | Delete
*
[4147] Fix | Delete
* You can set the post date manually, by setting the values for 'post_date'
[4148] Fix | Delete
* and 'post_date_gmt' keys. You can close the comments or open the comments by
[4149] Fix | Delete
* setting the value for 'comment_status' key.
[4150] Fix | Delete
*
[4151] Fix | Delete
* @since 1.0.0
[4152] Fix | Delete
* @since 2.6.0 Added the `$wp_error` parameter to allow a WP_Error to be returned on failure.
[4153] Fix | Delete
* @since 4.2.0 Support was added for encoding emoji in the post title, content, and excerpt.
[4154] Fix | Delete
* @since 4.4.0 A 'meta_input' array can now be passed to `$postarr` to add post meta data.
[4155] Fix | Delete
* @since 5.6.0 Added the `$fire_after_hooks` parameter.
[4156] Fix | Delete
*
[4157] Fix | Delete
* @see sanitize_post()
[4158] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[4159] Fix | Delete
*
[4160] Fix | Delete
* @param array $postarr {
[4161] Fix | Delete
* An array of elements that make up a post to update or insert.
[4162] Fix | Delete
*
[4163] Fix | Delete
* @type int $ID The post ID. If equal to something other than 0,
[4164] Fix | Delete
* the post with that ID will be updated. Default 0.
[4165] Fix | Delete
* @type int $post_author The ID of the user who added the post. Default is
[4166] Fix | Delete
* the current user ID.
[4167] Fix | Delete
* @type string $post_date The date of the post. Default is the current time.
[4168] Fix | Delete
* @type string $post_date_gmt The date of the post in the GMT timezone. Default is
[4169] Fix | Delete
* the value of `$post_date`.
[4170] Fix | Delete
* @type string $post_content The post content. Default empty.
[4171] Fix | Delete
* @type string $post_content_filtered The filtered post content. Default empty.
[4172] Fix | Delete
* @type string $post_title The post title. Default empty.
[4173] Fix | Delete
* @type string $post_excerpt The post excerpt. Default empty.
[4174] Fix | Delete
* @type string $post_status The post status. Default 'draft'.
[4175] Fix | Delete
* @type string $post_type The post type. Default 'post'.
[4176] Fix | Delete
* @type string $comment_status Whether the post can accept comments. Accepts 'open' or 'closed'.
[4177] Fix | Delete
* Default is the value of 'default_comment_status' option.
[4178] Fix | Delete
* @type string $ping_status Whether the post can accept pings. Accepts 'open' or 'closed'.
[4179] Fix | Delete
* Default is the value of 'default_ping_status' option.
[4180] Fix | Delete
* @type string $post_password The password to access the post. Default empty.
[4181] Fix | Delete
* @type string $post_name The post name. Default is the sanitized post title
[4182] Fix | Delete
* when creating a new post.
[4183] Fix | Delete
* @type string $to_ping Space or carriage return-separated list of URLs to ping.
[4184] Fix | Delete
* Default empty.
[4185] Fix | Delete
* @type string $pinged Space or carriage return-separated list of URLs that have
[4186] Fix | Delete
* been pinged. Default empty.
[4187] Fix | Delete
* @type int $post_parent Set this for the post it belongs to, if any. Default 0.
[4188] Fix | Delete
* @type int $menu_order The order the post should be displayed in. Default 0.
[4189] Fix | Delete
* @type string $post_mime_type The mime type of the post. Default empty.
[4190] Fix | Delete
* @type string $guid Global Unique ID for referencing the post. Default empty.
[4191] Fix | Delete
* @type int $import_id The post ID to be used when inserting a new post.
[4192] Fix | Delete
* If specified, must not match any existing post ID. Default 0.
[4193] Fix | Delete
* @type int[] $post_category Array of category IDs.
[4194] Fix | Delete
* Defaults to value of the 'default_category' option.
[4195] Fix | Delete
* @type array $tags_input Array of tag names, slugs, or IDs. Default empty.
[4196] Fix | Delete
* @type array $tax_input An array of taxonomy terms keyed by their taxonomy name.
[4197] Fix | Delete
* If the taxonomy is hierarchical, the term list needs to be
[4198] Fix | Delete
* either an array of term IDs or a comma-separated string of IDs.
[4199] Fix | Delete
* If the taxonomy is non-hierarchical, the term list can be an array
[4200] Fix | Delete
* that contains term names or slugs, or a comma-separated string
[4201] Fix | Delete
* of names or slugs. This is because, in hierarchical taxonomy,
[4202] Fix | Delete
* child terms can have the same names with different parent terms,
[4203] Fix | Delete
* so the only way to connect them is using ID. Default empty.
[4204] Fix | Delete
* @type array $meta_input Array of post meta values keyed by their post meta key. Default empty.
[4205] Fix | Delete
* @type string $page_template Page template to use.
[4206] Fix | Delete
* }
[4207] Fix | Delete
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
[4208] Fix | Delete
* @param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.
[4209] Fix | Delete
* @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
[4210] Fix | Delete
*/
[4211] Fix | Delete
function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) {
[4212] Fix | Delete
global $wpdb;
[4213] Fix | Delete
[4214] Fix | Delete
// Capture original pre-sanitized array for passing into filters.
[4215] Fix | Delete
$unsanitized_postarr = $postarr;
[4216] Fix | Delete
[4217] Fix | Delete
$user_id = get_current_user_id();
[4218] Fix | Delete
[4219] Fix | Delete
$defaults = array(
[4220] Fix | Delete
'post_author' => $user_id,
[4221] Fix | Delete
'post_content' => '',
[4222] Fix | Delete
'post_content_filtered' => '',
[4223] Fix | Delete
'post_title' => '',
[4224] Fix | Delete
'post_excerpt' => '',
[4225] Fix | Delete
'post_status' => 'draft',
[4226] Fix | Delete
'post_type' => 'post',
[4227] Fix | Delete
'comment_status' => '',
[4228] Fix | Delete
'ping_status' => '',
[4229] Fix | Delete
'post_password' => '',
[4230] Fix | Delete
'to_ping' => '',
[4231] Fix | Delete
'pinged' => '',
[4232] Fix | Delete
'post_parent' => 0,
[4233] Fix | Delete
'menu_order' => 0,
[4234] Fix | Delete
'guid' => '',
[4235] Fix | Delete
'import_id' => 0,
[4236] Fix | Delete
'context' => '',
[4237] Fix | Delete
'post_date' => '',
[4238] Fix | Delete
'post_date_gmt' => '',
[4239] Fix | Delete
);
[4240] Fix | Delete
[4241] Fix | Delete
$postarr = wp_parse_args( $postarr, $defaults );
[4242] Fix | Delete
[4243] Fix | Delete
unset( $postarr['filter'] );
[4244] Fix | Delete
[4245] Fix | Delete
$postarr = sanitize_post( $postarr, 'db' );
[4246] Fix | Delete
[4247] Fix | Delete
// Are we updating or creating?
[4248] Fix | Delete
$post_id = 0;
[4249] Fix | Delete
$update = false;
[4250] Fix | Delete
$guid = $postarr['guid'];
[4251] Fix | Delete
[4252] Fix | Delete
if ( ! empty( $postarr['ID'] ) ) {
[4253] Fix | Delete
$update = true;
[4254] Fix | Delete
[4255] Fix | Delete
// Get the post ID and GUID.
[4256] Fix | Delete
$post_id = $postarr['ID'];
[4257] Fix | Delete
$post_before = get_post( $post_id );
[4258] Fix | Delete
[4259] Fix | Delete
if ( is_null( $post_before ) ) {
[4260] Fix | Delete
if ( $wp_error ) {
[4261] Fix | Delete
return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
[4262] Fix | Delete
}
[4263] Fix | Delete
return 0;
[4264] Fix | Delete
}
[4265] Fix | Delete
[4266] Fix | Delete
$guid = get_post_field( 'guid', $post_id );
[4267] Fix | Delete
$previous_status = get_post_field( 'post_status', $post_id );
[4268] Fix | Delete
} else {
[4269] Fix | Delete
$previous_status = 'new';
[4270] Fix | Delete
$post_before = null;
[4271] Fix | Delete
}
[4272] Fix | Delete
[4273] Fix | Delete
$post_type = empty( $postarr['post_type'] ) ? 'post' : $postarr['post_type'];
[4274] Fix | Delete
[4275] Fix | Delete
$post_title = $postarr['post_title'];
[4276] Fix | Delete
$post_content = $postarr['post_content'];
[4277] Fix | Delete
$post_excerpt = $postarr['post_excerpt'];
[4278] Fix | Delete
[4279] Fix | Delete
if ( isset( $postarr['post_name'] ) ) {
[4280] Fix | Delete
$post_name = $postarr['post_name'];
[4281] Fix | Delete
} elseif ( $update ) {
[4282] Fix | Delete
// For an update, don't modify the post_name if it wasn't supplied as an argument.
[4283] Fix | Delete
$post_name = $post_before->post_name;
[4284] Fix | Delete
}
[4285] Fix | Delete
[4286] Fix | Delete
$maybe_empty = 'attachment' !== $post_type
[4287] Fix | Delete
&& ! $post_content && ! $post_title && ! $post_excerpt
[4288] Fix | Delete
&& post_type_supports( $post_type, 'editor' )
[4289] Fix | Delete
&& post_type_supports( $post_type, 'title' )
[4290] Fix | Delete
&& post_type_supports( $post_type, 'excerpt' );
[4291] Fix | Delete
[4292] Fix | Delete
/**
[4293] Fix | Delete
* Filters whether the post should be considered "empty".
[4294] Fix | Delete
*
[4295] Fix | Delete
* The post is considered "empty" if both:
[4296] Fix | Delete
* 1. The post type supports the title, editor, and excerpt fields
[4297] Fix | Delete
* 2. The title, editor, and excerpt fields are all empty
[4298] Fix | Delete
*
[4299] Fix | Delete
* Returning a truthy value from the filter will effectively short-circuit
[4300] Fix | Delete
* the new post being inserted and return 0. If $wp_error is true, a WP_Error
[4301] Fix | Delete
* will be returned instead.
[4302] Fix | Delete
*
[4303] Fix | Delete
* @since 3.3.0
[4304] Fix | Delete
*
[4305] Fix | Delete
* @param bool $maybe_empty Whether the post should be considered "empty".
[4306] Fix | Delete
* @param array $postarr Array of post data.
[4307] Fix | Delete
*/
[4308] Fix | Delete
if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {
[4309] Fix | Delete
if ( $wp_error ) {
[4310] Fix | Delete
return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) );
[4311] Fix | Delete
} else {
[4312] Fix | Delete
return 0;
[4313] Fix | Delete
}
[4314] Fix | Delete
}
[4315] Fix | Delete
[4316] Fix | Delete
$post_status = empty( $postarr['post_status'] ) ? 'draft' : $postarr['post_status'];
[4317] Fix | Delete
[4318] Fix | Delete
if ( 'attachment' === $post_type && ! in_array( $post_status, array( 'inherit', 'private', 'trash', 'auto-draft' ), true ) ) {
[4319] Fix | Delete
$post_status = 'inherit';
[4320] Fix | Delete
}
[4321] Fix | Delete
[4322] Fix | Delete
if ( ! empty( $postarr['post_category'] ) ) {
[4323] Fix | Delete
// Filter out empty terms.
[4324] Fix | Delete
$post_category = array_filter( $postarr['post_category'] );
[4325] Fix | Delete
} elseif ( $update && ! isset( $postarr['post_category'] ) ) {
[4326] Fix | Delete
$post_category = $post_before->post_category;
[4327] Fix | Delete
}
[4328] Fix | Delete
[4329] Fix | Delete
// Make sure we set a valid category.
[4330] Fix | Delete
if ( empty( $post_category ) || 0 === count( $post_category ) || ! is_array( $post_category ) ) {
[4331] Fix | Delete
// 'post' requires at least one category.
[4332] Fix | Delete
if ( 'post' === $post_type && 'auto-draft' !== $post_status ) {
[4333] Fix | Delete
$post_category = array( get_option( 'default_category' ) );
[4334] Fix | Delete
} else {
[4335] Fix | Delete
$post_category = array();
[4336] Fix | Delete
}
[4337] Fix | Delete
}
[4338] Fix | Delete
[4339] Fix | Delete
/*
[4340] Fix | Delete
* Don't allow contributors to set the post slug for pending review posts.
[4341] Fix | Delete
*
[4342] Fix | Delete
* For new posts check the primitive capability, for updates check the meta capability.
[4343] Fix | Delete
*/
[4344] Fix | Delete
if ( 'pending' === $post_status ) {
[4345] Fix | Delete
$post_type_object = get_post_type_object( $post_type );
[4346] Fix | Delete
[4347] Fix | Delete
if ( ! $update && $post_type_object && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
[4348] Fix | Delete
$post_name = '';
[4349] Fix | Delete
} elseif ( $update && ! current_user_can( 'publish_post', $post_id ) ) {
[4350] Fix | Delete
$post_name = '';
[4351] Fix | Delete
}
[4352] Fix | Delete
}
[4353] Fix | Delete
[4354] Fix | Delete
/*
[4355] Fix | Delete
* Create a valid post name. Drafts and pending posts are allowed to have
[4356] Fix | Delete
* an empty post name.
[4357] Fix | Delete
*/
[4358] Fix | Delete
if ( empty( $post_name ) ) {
[4359] Fix | Delete
if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true ) ) {
[4360] Fix | Delete
$post_name = sanitize_title( $post_title );
[4361] Fix | Delete
} else {
[4362] Fix | Delete
$post_name = '';
[4363] Fix | Delete
}
[4364] Fix | Delete
} else {
[4365] Fix | Delete
// On updates, we need to check to see if it's using the old, fixed sanitization context.
[4366] Fix | Delete
$check_name = sanitize_title( $post_name, '', 'old-save' );
[4367] Fix | Delete
[4368] Fix | Delete
if ( $update
[4369] Fix | Delete
&& strtolower( urlencode( $post_name ) ) === $check_name
[4370] Fix | Delete
&& get_post_field( 'post_name', $post_id ) === $check_name
[4371] Fix | Delete
) {
[4372] Fix | Delete
$post_name = $check_name;
[4373] Fix | Delete
} else { // New post, or slug has changed.
[4374] Fix | Delete
$post_name = sanitize_title( $post_name );
[4375] Fix | Delete
}
[4376] Fix | Delete
}
[4377] Fix | Delete
[4378] Fix | Delete
/*
[4379] Fix | Delete
* Resolve the post date from any provided post date or post date GMT strings;
[4380] Fix | Delete
* if none are provided, the date will be set to now.
[4381] Fix | Delete
*/
[4382] Fix | Delete
$post_date = wp_resolve_post_date( $postarr['post_date'], $postarr['post_date_gmt'] );
[4383] Fix | Delete
[4384] Fix | Delete
if ( ! $post_date ) {
[4385] Fix | Delete
if ( $wp_error ) {
[4386] Fix | Delete
return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
[4387] Fix | Delete
} else {
[4388] Fix | Delete
return 0;
[4389] Fix | Delete
}
[4390] Fix | Delete
}
[4391] Fix | Delete
[4392] Fix | Delete
if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' === $postarr['post_date_gmt'] ) {
[4393] Fix | Delete
if ( ! in_array( $post_status, get_post_stati( array( 'date_floating' => true ) ), true ) ) {
[4394] Fix | Delete
$post_date_gmt = get_gmt_from_date( $post_date );
[4395] Fix | Delete
} else {
[4396] Fix | Delete
$post_date_gmt = '0000-00-00 00:00:00';
[4397] Fix | Delete
}
[4398] Fix | Delete
} else {
[4399] Fix | Delete
$post_date_gmt = $postarr['post_date_gmt'];
[4400] Fix | Delete
}
[4401] Fix | Delete
[4402] Fix | Delete
if ( $update || '0000-00-00 00:00:00' === $post_date ) {
[4403] Fix | Delete
$post_modified = current_time( 'mysql' );
[4404] Fix | Delete
$post_modified_gmt = current_time( 'mysql', 1 );
[4405] Fix | Delete
} else {
[4406] Fix | Delete
$post_modified = $post_date;
[4407] Fix | Delete
$post_modified_gmt = $post_date_gmt;
[4408] Fix | Delete
}
[4409] Fix | Delete
[4410] Fix | Delete
if ( 'attachment' !== $post_type ) {
[4411] Fix | Delete
$now = gmdate( 'Y-m-d H:i:s' );
[4412] Fix | Delete
[4413] Fix | Delete
if ( 'publish' === $post_status ) {
[4414] Fix | Delete
if ( strtotime( $post_date_gmt ) - strtotime( $now ) >= MINUTE_IN_SECONDS ) {
[4415] Fix | Delete
$post_status = 'future';
[4416] Fix | Delete
}
[4417] Fix | Delete
} elseif ( 'future' === $post_status ) {
[4418] Fix | Delete
if ( strtotime( $post_date_gmt ) - strtotime( $now ) < MINUTE_IN_SECONDS ) {
[4419] Fix | Delete
$post_status = 'publish';
[4420] Fix | Delete
}
[4421] Fix | Delete
}
[4422] Fix | Delete
}
[4423] Fix | Delete
[4424] Fix | Delete
// Comment status.
[4425] Fix | Delete
if ( empty( $postarr['comment_status'] ) ) {
[4426] Fix | Delete
if ( $update ) {
[4427] Fix | Delete
$comment_status = 'closed';
[4428] Fix | Delete
} else {
[4429] Fix | Delete
$comment_status = get_default_comment_status( $post_type );
[4430] Fix | Delete
}
[4431] Fix | Delete
} else {
[4432] Fix | Delete
$comment_status = $postarr['comment_status'];
[4433] Fix | Delete
}
[4434] Fix | Delete
[4435] Fix | Delete
// These variables are needed by compact() later.
[4436] Fix | Delete
$post_content_filtered = $postarr['post_content_filtered'];
[4437] Fix | Delete
$post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
[4438] Fix | Delete
$ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
[4439] Fix | Delete
$to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
[4440] Fix | Delete
$pinged = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';
[4441] Fix | Delete
$import_id = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0;
[4442] Fix | Delete
[4443] Fix | Delete
/*
[4444] Fix | Delete
* The 'wp_insert_post_parent' filter expects all variables to be present.
[4445] Fix | Delete
* Previously, these variables would have already been extracted
[4446] Fix | Delete
*/
[4447] Fix | Delete
if ( isset( $postarr['menu_order'] ) ) {
[4448] Fix | Delete
$menu_order = (int) $postarr['menu_order'];
[4449] Fix | Delete
} else {
[4450] Fix | Delete
$menu_order = 0;
[4451] Fix | Delete
}
[4452] Fix | Delete
[4453] Fix | Delete
$post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : '';
[4454] Fix | Delete
if ( 'private' === $post_status ) {
[4455] Fix | Delete
$post_password = '';
[4456] Fix | Delete
}
[4457] Fix | Delete
[4458] Fix | Delete
if ( isset( $postarr['post_parent'] ) ) {
[4459] Fix | Delete
$post_parent = (int) $postarr['post_parent'];
[4460] Fix | Delete
} else {
[4461] Fix | Delete
$post_parent = 0;
[4462] Fix | Delete
}
[4463] Fix | Delete
[4464] Fix | Delete
$new_postarr = array_merge(
[4465] Fix | Delete
array(
[4466] Fix | Delete
'ID' => $post_id,
[4467] Fix | Delete
),
[4468] Fix | Delete
compact( array_diff( array_keys( $defaults ), array( 'context', 'filter' ) ) )
[4469] Fix | Delete
);
[4470] Fix | Delete
[4471] Fix | Delete
/**
[4472] Fix | Delete
* Filters the post parent -- used to check for and prevent hierarchy loops.
[4473] Fix | Delete
*
[4474] Fix | Delete
* @since 3.1.0
[4475] Fix | Delete
*
[4476] Fix | Delete
* @param int $post_parent Post parent ID.
[4477] Fix | Delete
* @param int $post_id Post ID.
[4478] Fix | Delete
* @param array $new_postarr Array of parsed post data.
[4479] Fix | Delete
* @param array $postarr Array of sanitized, but otherwise unmodified post data.
[4480] Fix | Delete
*/
[4481] Fix | Delete
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_id, $new_postarr, $postarr );
[4482] Fix | Delete
[4483] Fix | Delete
/*
[4484] Fix | Delete
* If the post is being untrashed and it has a desired slug stored in post meta,
[4485] Fix | Delete
* reassign it.
[4486] Fix | Delete
*/
[4487] Fix | Delete
if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
[4488] Fix | Delete
$desired_post_slug = get_post_meta( $post_id, '_wp_desired_post_slug', true );
[4489] Fix | Delete
[4490] Fix | Delete
if ( $desired_post_slug ) {
[4491] Fix | Delete
delete_post_meta( $post_id, '_wp_desired_post_slug' );
[4492] Fix | Delete
$post_name = $desired_post_slug;
[4493] Fix | Delete
}
[4494] Fix | Delete
}
[4495] Fix | Delete
[4496] Fix | Delete
// If a trashed post has the desired slug, change it and let this post have it.
[4497] Fix | Delete
if ( 'trash' !== $post_status && $post_name ) {
[4498] Fix | Delete
/**
[4499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function