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.../public_h.../wp-inclu...
File: comment.php
trackback( $tb_ping, $post_title, $excerpt, $post->ID );
[3000] Fix | Delete
$pinged[] = $tb_ping;
[3001] Fix | Delete
} else {
[3002] Fix | Delete
$wpdb->query(
[3003] Fix | Delete
$wpdb->prepare(
[3004] Fix | Delete
"UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s,
[3005] Fix | Delete
'')) WHERE ID = %d",
[3006] Fix | Delete
$tb_ping,
[3007] Fix | Delete
$post->ID
[3008] Fix | Delete
)
[3009] Fix | Delete
);
[3010] Fix | Delete
}
[3011] Fix | Delete
}
[3012] Fix | Delete
}
[3013] Fix | Delete
}
[3014] Fix | Delete
[3015] Fix | Delete
/**
[3016] Fix | Delete
* Sends pings to all of the ping site services.
[3017] Fix | Delete
*
[3018] Fix | Delete
* @since 1.2.0
[3019] Fix | Delete
*
[3020] Fix | Delete
* @param int $post_id Post ID.
[3021] Fix | Delete
* @return int Same post ID as provided.
[3022] Fix | Delete
*/
[3023] Fix | Delete
function generic_ping( $post_id = 0 ) {
[3024] Fix | Delete
$services = get_option( 'ping_sites' );
[3025] Fix | Delete
[3026] Fix | Delete
$services = explode( "\n", $services );
[3027] Fix | Delete
foreach ( (array) $services as $service ) {
[3028] Fix | Delete
$service = trim( $service );
[3029] Fix | Delete
if ( '' !== $service ) {
[3030] Fix | Delete
weblog_ping( $service );
[3031] Fix | Delete
}
[3032] Fix | Delete
}
[3033] Fix | Delete
[3034] Fix | Delete
return $post_id;
[3035] Fix | Delete
}
[3036] Fix | Delete
[3037] Fix | Delete
/**
[3038] Fix | Delete
* Pings back the links found in a post.
[3039] Fix | Delete
*
[3040] Fix | Delete
* @since 0.71
[3041] Fix | Delete
* @since 4.7.0 `$post` can be a WP_Post object.
[3042] Fix | Delete
*
[3043] Fix | Delete
* @param string $content Post content to check for links. If empty will retrieve from post.
[3044] Fix | Delete
* @param int|WP_Post $post Post ID or object.
[3045] Fix | Delete
*/
[3046] Fix | Delete
function pingback( $content, $post ) {
[3047] Fix | Delete
require_once ABSPATH . WPINC . '/class-IXR.php';
[3048] Fix | Delete
require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
[3049] Fix | Delete
[3050] Fix | Delete
// Original code by Mort (http://mort.mine.nu:8080).
[3051] Fix | Delete
$post_links = array();
[3052] Fix | Delete
[3053] Fix | Delete
$post = get_post( $post );
[3054] Fix | Delete
[3055] Fix | Delete
if ( ! $post ) {
[3056] Fix | Delete
return;
[3057] Fix | Delete
}
[3058] Fix | Delete
[3059] Fix | Delete
$pung = get_pung( $post );
[3060] Fix | Delete
[3061] Fix | Delete
if ( empty( $content ) ) {
[3062] Fix | Delete
$content = $post->post_content;
[3063] Fix | Delete
}
[3064] Fix | Delete
[3065] Fix | Delete
/*
[3066] Fix | Delete
* Step 1.
[3067] Fix | Delete
* Parsing the post, external links (if any) are stored in the $post_links array.
[3068] Fix | Delete
*/
[3069] Fix | Delete
$post_links_temp = wp_extract_urls( $content );
[3070] Fix | Delete
[3071] Fix | Delete
/*
[3072] Fix | Delete
* Step 2.
[3073] Fix | Delete
* Walking through the links array.
[3074] Fix | Delete
* First we get rid of links pointing to sites, not to specific files.
[3075] Fix | Delete
* Example:
[3076] Fix | Delete
* http://dummy-weblog.org
[3077] Fix | Delete
* http://dummy-weblog.org/
[3078] Fix | Delete
* http://dummy-weblog.org/post.php
[3079] Fix | Delete
* We don't wanna ping first and second types, even if they have a valid <link/>.
[3080] Fix | Delete
*/
[3081] Fix | Delete
foreach ( (array) $post_links_temp as $link_test ) {
[3082] Fix | Delete
// If we haven't pung it already and it isn't a link to itself.
[3083] Fix | Delete
if ( ! in_array( $link_test, $pung, true ) && ( url_to_postid( $link_test ) != $post->ID )
[3084] Fix | Delete
// Also, let's never ping local attachments.
[3085] Fix | Delete
&& ! is_local_attachment( $link_test )
[3086] Fix | Delete
) {
[3087] Fix | Delete
$test = parse_url( $link_test );
[3088] Fix | Delete
if ( $test ) {
[3089] Fix | Delete
if ( isset( $test['query'] ) ) {
[3090] Fix | Delete
$post_links[] = $link_test;
[3091] Fix | Delete
} elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) {
[3092] Fix | Delete
$post_links[] = $link_test;
[3093] Fix | Delete
}
[3094] Fix | Delete
}
[3095] Fix | Delete
}
[3096] Fix | Delete
}
[3097] Fix | Delete
[3098] Fix | Delete
$post_links = array_unique( $post_links );
[3099] Fix | Delete
[3100] Fix | Delete
/**
[3101] Fix | Delete
* Fires just before pinging back links found in a post.
[3102] Fix | Delete
*
[3103] Fix | Delete
* @since 2.0.0
[3104] Fix | Delete
*
[3105] Fix | Delete
* @param string[] $post_links Array of link URLs to be checked (passed by reference).
[3106] Fix | Delete
* @param string[] $pung Array of link URLs already pinged (passed by reference).
[3107] Fix | Delete
* @param int $post_id The post ID.
[3108] Fix | Delete
*/
[3109] Fix | Delete
do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post->ID ) );
[3110] Fix | Delete
[3111] Fix | Delete
foreach ( (array) $post_links as $pagelinkedto ) {
[3112] Fix | Delete
$pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
[3113] Fix | Delete
[3114] Fix | Delete
if ( $pingback_server_url ) {
[3115] Fix | Delete
if ( function_exists( 'set_time_limit' ) ) {
[3116] Fix | Delete
set_time_limit( 60 );
[3117] Fix | Delete
}
[3118] Fix | Delete
[3119] Fix | Delete
// Now, the RPC call.
[3120] Fix | Delete
$pagelinkedfrom = get_permalink( $post );
[3121] Fix | Delete
[3122] Fix | Delete
// Using a timeout of 3 seconds should be enough to cover slow servers.
[3123] Fix | Delete
$client = new WP_HTTP_IXR_Client( $pingback_server_url );
[3124] Fix | Delete
$client->timeout = 3;
[3125] Fix | Delete
/**
[3126] Fix | Delete
* Filters the user agent sent when pinging-back a URL.
[3127] Fix | Delete
*
[3128] Fix | Delete
* @since 2.9.0
[3129] Fix | Delete
*
[3130] Fix | Delete
* @param string $concat_useragent The user agent concatenated with ' -- WordPress/'
[3131] Fix | Delete
* and the WordPress version.
[3132] Fix | Delete
* @param string $useragent The useragent.
[3133] Fix | Delete
* @param string $pingback_server_url The server URL being linked to.
[3134] Fix | Delete
* @param string $pagelinkedto URL of page linked to.
[3135] Fix | Delete
* @param string $pagelinkedfrom URL of page linked from.
[3136] Fix | Delete
*/
[3137] Fix | Delete
$client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . get_bloginfo( 'version' ), $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom );
[3138] Fix | Delete
// When set to true, this outputs debug messages by itself.
[3139] Fix | Delete
$client->debug = false;
[3140] Fix | Delete
[3141] Fix | Delete
if ( $client->query( 'pingback.ping', $pagelinkedfrom, $pagelinkedto ) || ( isset( $client->error->code ) && 48 == $client->error->code ) ) { // Already registered.
[3142] Fix | Delete
add_ping( $post, $pagelinkedto );
[3143] Fix | Delete
}
[3144] Fix | Delete
}
[3145] Fix | Delete
}
[3146] Fix | Delete
}
[3147] Fix | Delete
[3148] Fix | Delete
/**
[3149] Fix | Delete
* Checks whether blog is public before returning sites.
[3150] Fix | Delete
*
[3151] Fix | Delete
* @since 2.1.0
[3152] Fix | Delete
*
[3153] Fix | Delete
* @param mixed $sites Will return if blog is public, will not return if not public.
[3154] Fix | Delete
* @return mixed Empty string if blog is not public, returns $sites, if site is public.
[3155] Fix | Delete
*/
[3156] Fix | Delete
function privacy_ping_filter( $sites ) {
[3157] Fix | Delete
if ( '0' != get_option( 'blog_public' ) ) {
[3158] Fix | Delete
return $sites;
[3159] Fix | Delete
} else {
[3160] Fix | Delete
return '';
[3161] Fix | Delete
}
[3162] Fix | Delete
}
[3163] Fix | Delete
[3164] Fix | Delete
/**
[3165] Fix | Delete
* Sends a Trackback.
[3166] Fix | Delete
*
[3167] Fix | Delete
* Updates database when sending trackback to prevent duplicates.
[3168] Fix | Delete
*
[3169] Fix | Delete
* @since 0.71
[3170] Fix | Delete
*
[3171] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3172] Fix | Delete
*
[3173] Fix | Delete
* @param string $trackback_url URL to send trackbacks.
[3174] Fix | Delete
* @param string $title Title of post.
[3175] Fix | Delete
* @param string $excerpt Excerpt of post.
[3176] Fix | Delete
* @param int $post_id Post ID.
[3177] Fix | Delete
* @return int|false|void Database query from update.
[3178] Fix | Delete
*/
[3179] Fix | Delete
function trackback( $trackback_url, $title, $excerpt, $post_id ) {
[3180] Fix | Delete
global $wpdb;
[3181] Fix | Delete
[3182] Fix | Delete
if ( empty( $trackback_url ) ) {
[3183] Fix | Delete
return;
[3184] Fix | Delete
}
[3185] Fix | Delete
[3186] Fix | Delete
$options = array();
[3187] Fix | Delete
$options['timeout'] = 10;
[3188] Fix | Delete
$options['body'] = array(
[3189] Fix | Delete
'title' => $title,
[3190] Fix | Delete
'url' => get_permalink( $post_id ),
[3191] Fix | Delete
'blog_name' => get_option( 'blogname' ),
[3192] Fix | Delete
'excerpt' => $excerpt,
[3193] Fix | Delete
);
[3194] Fix | Delete
[3195] Fix | Delete
$response = wp_safe_remote_post( $trackback_url, $options );
[3196] Fix | Delete
[3197] Fix | Delete
if ( is_wp_error( $response ) ) {
[3198] Fix | Delete
return;
[3199] Fix | Delete
}
[3200] Fix | Delete
[3201] Fix | Delete
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $post_id ) );
[3202] Fix | Delete
return $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $post_id ) );
[3203] Fix | Delete
}
[3204] Fix | Delete
[3205] Fix | Delete
/**
[3206] Fix | Delete
* Sends a pingback.
[3207] Fix | Delete
*
[3208] Fix | Delete
* @since 1.2.0
[3209] Fix | Delete
*
[3210] Fix | Delete
* @param string $server Host of blog to connect to.
[3211] Fix | Delete
* @param string $path Path to send the ping.
[3212] Fix | Delete
*/
[3213] Fix | Delete
function weblog_ping( $server = '', $path = '' ) {
[3214] Fix | Delete
require_once ABSPATH . WPINC . '/class-IXR.php';
[3215] Fix | Delete
require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
[3216] Fix | Delete
[3217] Fix | Delete
// Using a timeout of 3 seconds should be enough to cover slow servers.
[3218] Fix | Delete
$client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) );
[3219] Fix | Delete
$client->timeout = 3;
[3220] Fix | Delete
$client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' );
[3221] Fix | Delete
[3222] Fix | Delete
// When set to true, this outputs debug messages by itself.
[3223] Fix | Delete
$client->debug = false;
[3224] Fix | Delete
$home = trailingslashit( home_url() );
[3225] Fix | Delete
if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // Then try a normal ping.
[3226] Fix | Delete
$client->query( 'weblogUpdates.ping', get_option( 'blogname' ), $home );
[3227] Fix | Delete
}
[3228] Fix | Delete
}
[3229] Fix | Delete
[3230] Fix | Delete
/**
[3231] Fix | Delete
* Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI.
[3232] Fix | Delete
*
[3233] Fix | Delete
* @since 3.5.1
[3234] Fix | Delete
*
[3235] Fix | Delete
* @see wp_http_validate_url()
[3236] Fix | Delete
*
[3237] Fix | Delete
* @param string $source_uri
[3238] Fix | Delete
* @return string
[3239] Fix | Delete
*/
[3240] Fix | Delete
function pingback_ping_source_uri( $source_uri ) {
[3241] Fix | Delete
return (string) wp_http_validate_url( $source_uri );
[3242] Fix | Delete
}
[3243] Fix | Delete
[3244] Fix | Delete
/**
[3245] Fix | Delete
* Default filter attached to xmlrpc_pingback_error.
[3246] Fix | Delete
*
[3247] Fix | Delete
* Returns a generic pingback error code unless the error code is 48,
[3248] Fix | Delete
* which reports that the pingback is already registered.
[3249] Fix | Delete
*
[3250] Fix | Delete
* @since 3.5.1
[3251] Fix | Delete
*
[3252] Fix | Delete
* @link https://www.hixie.ch/specs/pingback/pingback#TOC3
[3253] Fix | Delete
*
[3254] Fix | Delete
* @param IXR_Error $ixr_error
[3255] Fix | Delete
* @return IXR_Error
[3256] Fix | Delete
*/
[3257] Fix | Delete
function xmlrpc_pingback_error( $ixr_error ) {
[3258] Fix | Delete
if ( 48 === $ixr_error->code ) {
[3259] Fix | Delete
return $ixr_error;
[3260] Fix | Delete
}
[3261] Fix | Delete
return new IXR_Error( 0, '' );
[3262] Fix | Delete
}
[3263] Fix | Delete
[3264] Fix | Delete
//
[3265] Fix | Delete
// Cache.
[3266] Fix | Delete
//
[3267] Fix | Delete
[3268] Fix | Delete
/**
[3269] Fix | Delete
* Removes a comment from the object cache.
[3270] Fix | Delete
*
[3271] Fix | Delete
* @since 2.3.0
[3272] Fix | Delete
*
[3273] Fix | Delete
* @param int|array $ids Comment ID or an array of comment IDs to remove from cache.
[3274] Fix | Delete
*/
[3275] Fix | Delete
function clean_comment_cache( $ids ) {
[3276] Fix | Delete
$comment_ids = (array) $ids;
[3277] Fix | Delete
wp_cache_delete_multiple( $comment_ids, 'comment' );
[3278] Fix | Delete
foreach ( $comment_ids as $id ) {
[3279] Fix | Delete
/**
[3280] Fix | Delete
* Fires immediately after a comment has been removed from the object cache.
[3281] Fix | Delete
*
[3282] Fix | Delete
* @since 4.5.0
[3283] Fix | Delete
*
[3284] Fix | Delete
* @param int $id Comment ID.
[3285] Fix | Delete
*/
[3286] Fix | Delete
do_action( 'clean_comment_cache', $id );
[3287] Fix | Delete
}
[3288] Fix | Delete
[3289] Fix | Delete
wp_cache_set_comments_last_changed();
[3290] Fix | Delete
}
[3291] Fix | Delete
[3292] Fix | Delete
/**
[3293] Fix | Delete
* Updates the comment cache of given comments.
[3294] Fix | Delete
*
[3295] Fix | Delete
* Will add the comments in $comments to the cache. If comment ID already exists
[3296] Fix | Delete
* in the comment cache then it will not be updated. The comment is added to the
[3297] Fix | Delete
* cache using the comment group with the key using the ID of the comments.
[3298] Fix | Delete
*
[3299] Fix | Delete
* @since 2.3.0
[3300] Fix | Delete
* @since 4.4.0 Introduced the `$update_meta_cache` parameter.
[3301] Fix | Delete
*
[3302] Fix | Delete
* @param WP_Comment[] $comments Array of comment objects
[3303] Fix | Delete
* @param bool $update_meta_cache Whether to update commentmeta cache. Default true.
[3304] Fix | Delete
*/
[3305] Fix | Delete
function update_comment_cache( $comments, $update_meta_cache = true ) {
[3306] Fix | Delete
$data = array();
[3307] Fix | Delete
foreach ( (array) $comments as $comment ) {
[3308] Fix | Delete
$data[ $comment->comment_ID ] = $comment;
[3309] Fix | Delete
}
[3310] Fix | Delete
wp_cache_add_multiple( $data, 'comment' );
[3311] Fix | Delete
[3312] Fix | Delete
if ( $update_meta_cache ) {
[3313] Fix | Delete
// Avoid `wp_list_pluck()` in case `$comments` is passed by reference.
[3314] Fix | Delete
$comment_ids = array();
[3315] Fix | Delete
foreach ( $comments as $comment ) {
[3316] Fix | Delete
$comment_ids[] = $comment->comment_ID;
[3317] Fix | Delete
}
[3318] Fix | Delete
update_meta_cache( 'comment', $comment_ids );
[3319] Fix | Delete
}
[3320] Fix | Delete
}
[3321] Fix | Delete
[3322] Fix | Delete
/**
[3323] Fix | Delete
* Adds any comments from the given IDs to the cache that do not already exist in cache.
[3324] Fix | Delete
*
[3325] Fix | Delete
* @since 4.4.0
[3326] Fix | Delete
* @since 6.1.0 This function is no longer marked as "private".
[3327] Fix | Delete
* @since 6.3.0 Use wp_lazyload_comment_meta() for lazy-loading of comment meta.
[3328] Fix | Delete
*
[3329] Fix | Delete
* @see update_comment_cache()
[3330] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3331] Fix | Delete
*
[3332] Fix | Delete
* @param int[] $comment_ids Array of comment IDs.
[3333] Fix | Delete
* @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true.
[3334] Fix | Delete
*/
[3335] Fix | Delete
function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) {
[3336] Fix | Delete
global $wpdb;
[3337] Fix | Delete
[3338] Fix | Delete
$non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' );
[3339] Fix | Delete
if ( ! empty( $non_cached_ids ) ) {
[3340] Fix | Delete
$fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) );
[3341] Fix | Delete
[3342] Fix | Delete
update_comment_cache( $fresh_comments, false );
[3343] Fix | Delete
}
[3344] Fix | Delete
[3345] Fix | Delete
if ( $update_meta_cache ) {
[3346] Fix | Delete
wp_lazyload_comment_meta( $comment_ids );
[3347] Fix | Delete
}
[3348] Fix | Delete
}
[3349] Fix | Delete
[3350] Fix | Delete
//
[3351] Fix | Delete
// Internal.
[3352] Fix | Delete
//
[3353] Fix | Delete
[3354] Fix | Delete
/**
[3355] Fix | Delete
* Closes comments on old posts on the fly, without any extra DB queries. Hooked to the_posts.
[3356] Fix | Delete
*
[3357] Fix | Delete
* @since 2.7.0
[3358] Fix | Delete
* @access private
[3359] Fix | Delete
*
[3360] Fix | Delete
* @param WP_Post $posts Post data object.
[3361] Fix | Delete
* @param WP_Query $query Query object.
[3362] Fix | Delete
* @return array
[3363] Fix | Delete
*/
[3364] Fix | Delete
function _close_comments_for_old_posts( $posts, $query ) {
[3365] Fix | Delete
if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) {
[3366] Fix | Delete
return $posts;
[3367] Fix | Delete
}
[3368] Fix | Delete
[3369] Fix | Delete
/**
[3370] Fix | Delete
* Filters the list of post types to automatically close comments for.
[3371] Fix | Delete
*
[3372] Fix | Delete
* @since 3.2.0
[3373] Fix | Delete
*
[3374] Fix | Delete
* @param string[] $post_types An array of post type names.
[3375] Fix | Delete
*/
[3376] Fix | Delete
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
[3377] Fix | Delete
if ( ! in_array( $posts[0]->post_type, $post_types, true ) ) {
[3378] Fix | Delete
return $posts;
[3379] Fix | Delete
}
[3380] Fix | Delete
[3381] Fix | Delete
$days_old = (int) get_option( 'close_comments_days_old' );
[3382] Fix | Delete
if ( ! $days_old ) {
[3383] Fix | Delete
return $posts;
[3384] Fix | Delete
}
[3385] Fix | Delete
[3386] Fix | Delete
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
[3387] Fix | Delete
$posts[0]->comment_status = 'closed';
[3388] Fix | Delete
$posts[0]->ping_status = 'closed';
[3389] Fix | Delete
}
[3390] Fix | Delete
[3391] Fix | Delete
return $posts;
[3392] Fix | Delete
}
[3393] Fix | Delete
[3394] Fix | Delete
/**
[3395] Fix | Delete
* Closes comments on an old post. Hooked to comments_open and pings_open.
[3396] Fix | Delete
*
[3397] Fix | Delete
* @since 2.7.0
[3398] Fix | Delete
* @access private
[3399] Fix | Delete
*
[3400] Fix | Delete
* @param bool $open Comments open or closed.
[3401] Fix | Delete
* @param int $post_id Post ID.
[3402] Fix | Delete
* @return bool $open
[3403] Fix | Delete
*/
[3404] Fix | Delete
function _close_comments_for_old_post( $open, $post_id ) {
[3405] Fix | Delete
if ( ! $open ) {
[3406] Fix | Delete
return $open;
[3407] Fix | Delete
}
[3408] Fix | Delete
[3409] Fix | Delete
if ( ! get_option( 'close_comments_for_old_posts' ) ) {
[3410] Fix | Delete
return $open;
[3411] Fix | Delete
}
[3412] Fix | Delete
[3413] Fix | Delete
$days_old = (int) get_option( 'close_comments_days_old' );
[3414] Fix | Delete
if ( ! $days_old ) {
[3415] Fix | Delete
return $open;
[3416] Fix | Delete
}
[3417] Fix | Delete
[3418] Fix | Delete
$post = get_post( $post_id );
[3419] Fix | Delete
[3420] Fix | Delete
/** This filter is documented in wp-includes/comment.php */
[3421] Fix | Delete
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
[3422] Fix | Delete
if ( ! in_array( $post->post_type, $post_types, true ) ) {
[3423] Fix | Delete
return $open;
[3424] Fix | Delete
}
[3425] Fix | Delete
[3426] Fix | Delete
// Undated drafts should not show up as comments closed.
[3427] Fix | Delete
if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
[3428] Fix | Delete
return $open;
[3429] Fix | Delete
}
[3430] Fix | Delete
[3431] Fix | Delete
if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
[3432] Fix | Delete
return false;
[3433] Fix | Delete
}
[3434] Fix | Delete
[3435] Fix | Delete
return $open;
[3436] Fix | Delete
}
[3437] Fix | Delete
[3438] Fix | Delete
/**
[3439] Fix | Delete
* Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form.
[3440] Fix | Delete
*
[3441] Fix | Delete
* This function expects unslashed data, as opposed to functions such as `wp_new_comment()` which
[3442] Fix | Delete
* expect slashed data.
[3443] Fix | Delete
*
[3444] Fix | Delete
* @since 4.4.0
[3445] Fix | Delete
*
[3446] Fix | Delete
* @param array $comment_data {
[3447] Fix | Delete
* Comment data.
[3448] Fix | Delete
*
[3449] Fix | Delete
* @type string|int $comment_post_ID The ID of the post that relates to the comment.
[3450] Fix | Delete
* @type string $author The name of the comment author.
[3451] Fix | Delete
* @type string $email The comment author email address.
[3452] Fix | Delete
* @type string $url The comment author URL.
[3453] Fix | Delete
* @type string $comment The content of the comment.
[3454] Fix | Delete
* @type string|int $comment_parent The ID of this comment's parent, if any. Default 0.
[3455] Fix | Delete
* @type string $_wp_unfiltered_html_comment The nonce value for allowing unfiltered HTML.
[3456] Fix | Delete
* }
[3457] Fix | Delete
* @return WP_Comment|WP_Error A WP_Comment object on success, a WP_Error object on failure.
[3458] Fix | Delete
*/
[3459] Fix | Delete
function wp_handle_comment_submission( $comment_data ) {
[3460] Fix | Delete
$comment_post_id = 0;
[3461] Fix | Delete
$comment_author = '';
[3462] Fix | Delete
$comment_author_email = '';
[3463] Fix | Delete
$comment_author_url = '';
[3464] Fix | Delete
$comment_content = '';
[3465] Fix | Delete
$comment_parent = 0;
[3466] Fix | Delete
$user_id = 0;
[3467] Fix | Delete
[3468] Fix | Delete
if ( isset( $comment_data['comment_post_ID'] ) ) {
[3469] Fix | Delete
$comment_post_id = (int) $comment_data['comment_post_ID'];
[3470] Fix | Delete
}
[3471] Fix | Delete
if ( isset( $comment_data['author'] ) && is_string( $comment_data['author'] ) ) {
[3472] Fix | Delete
$comment_author = trim( strip_tags( $comment_data['author'] ) );
[3473] Fix | Delete
}
[3474] Fix | Delete
if ( isset( $comment_data['email'] ) && is_string( $comment_data['email'] ) ) {
[3475] Fix | Delete
$comment_author_email = trim( $comment_data['email'] );
[3476] Fix | Delete
}
[3477] Fix | Delete
if ( isset( $comment_data['url'] ) && is_string( $comment_data['url'] ) ) {
[3478] Fix | Delete
$comment_author_url = trim( $comment_data['url'] );
[3479] Fix | Delete
}
[3480] Fix | Delete
if ( isset( $comment_data['comment'] ) && is_string( $comment_data['comment'] ) ) {
[3481] Fix | Delete
$comment_content = trim( $comment_data['comment'] );
[3482] Fix | Delete
}
[3483] Fix | Delete
if ( isset( $comment_data['comment_parent'] ) ) {
[3484] Fix | Delete
$comment_parent = absint( $comment_data['comment_parent'] );
[3485] Fix | Delete
$comment_parent_object = get_comment( $comment_parent );
[3486] Fix | Delete
[3487] Fix | Delete
if (
[3488] Fix | Delete
0 !== $comment_parent &&
[3489] Fix | Delete
(
[3490] Fix | Delete
! $comment_parent_object instanceof WP_Comment ||
[3491] Fix | Delete
0 === (int) $comment_parent_object->comment_approved
[3492] Fix | Delete
)
[3493] Fix | Delete
) {
[3494] Fix | Delete
/**
[3495] Fix | Delete
* Fires when a comment reply is attempted to an unapproved comment.
[3496] Fix | Delete
*
[3497] Fix | Delete
* @since 6.2.0
[3498] Fix | Delete
*
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function