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: ajax-actions.php
if ( ! current_user_can( 'upload_files' ) ) {
[3000] Fix | Delete
wp_send_json_error();
[3001] Fix | Delete
}
[3002] Fix | Delete
[3003] Fix | Delete
$attachment = wp_prepare_attachment_for_js( $id );
[3004] Fix | Delete
if ( ! $attachment ) {
[3005] Fix | Delete
wp_send_json_error();
[3006] Fix | Delete
}
[3007] Fix | Delete
[3008] Fix | Delete
wp_send_json_success( $attachment );
[3009] Fix | Delete
}
[3010] Fix | Delete
[3011] Fix | Delete
/**
[3012] Fix | Delete
* Handles querying attachments via AJAX.
[3013] Fix | Delete
*
[3014] Fix | Delete
* @since 3.5.0
[3015] Fix | Delete
*/
[3016] Fix | Delete
function wp_ajax_query_attachments() {
[3017] Fix | Delete
if ( ! current_user_can( 'upload_files' ) ) {
[3018] Fix | Delete
wp_send_json_error();
[3019] Fix | Delete
}
[3020] Fix | Delete
[3021] Fix | Delete
$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
[3022] Fix | Delete
$keys = array(
[3023] Fix | Delete
's',
[3024] Fix | Delete
'order',
[3025] Fix | Delete
'orderby',
[3026] Fix | Delete
'posts_per_page',
[3027] Fix | Delete
'paged',
[3028] Fix | Delete
'post_mime_type',
[3029] Fix | Delete
'post_parent',
[3030] Fix | Delete
'author',
[3031] Fix | Delete
'post__in',
[3032] Fix | Delete
'post__not_in',
[3033] Fix | Delete
'year',
[3034] Fix | Delete
'monthnum',
[3035] Fix | Delete
);
[3036] Fix | Delete
[3037] Fix | Delete
foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {
[3038] Fix | Delete
if ( $t->query_var && isset( $query[ $t->query_var ] ) ) {
[3039] Fix | Delete
$keys[] = $t->query_var;
[3040] Fix | Delete
}
[3041] Fix | Delete
}
[3042] Fix | Delete
[3043] Fix | Delete
$query = array_intersect_key( $query, array_flip( $keys ) );
[3044] Fix | Delete
$query['post_type'] = 'attachment';
[3045] Fix | Delete
[3046] Fix | Delete
if (
[3047] Fix | Delete
MEDIA_TRASH &&
[3048] Fix | Delete
! empty( $_REQUEST['query']['post_status'] ) &&
[3049] Fix | Delete
'trash' === $_REQUEST['query']['post_status']
[3050] Fix | Delete
) {
[3051] Fix | Delete
$query['post_status'] = 'trash';
[3052] Fix | Delete
} else {
[3053] Fix | Delete
$query['post_status'] = 'inherit';
[3054] Fix | Delete
}
[3055] Fix | Delete
[3056] Fix | Delete
if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) {
[3057] Fix | Delete
$query['post_status'] .= ',private';
[3058] Fix | Delete
}
[3059] Fix | Delete
[3060] Fix | Delete
// Filter query clauses to include filenames.
[3061] Fix | Delete
if ( isset( $query['s'] ) ) {
[3062] Fix | Delete
add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
[3063] Fix | Delete
}
[3064] Fix | Delete
[3065] Fix | Delete
/**
[3066] Fix | Delete
* Filters the arguments passed to WP_Query during an Ajax
[3067] Fix | Delete
* call for querying attachments.
[3068] Fix | Delete
*
[3069] Fix | Delete
* @since 3.7.0
[3070] Fix | Delete
*
[3071] Fix | Delete
* @see WP_Query::parse_query()
[3072] Fix | Delete
*
[3073] Fix | Delete
* @param array $query An array of query variables.
[3074] Fix | Delete
*/
[3075] Fix | Delete
$query = apply_filters( 'ajax_query_attachments_args', $query );
[3076] Fix | Delete
$attachments_query = new WP_Query( $query );
[3077] Fix | Delete
update_post_parent_caches( $attachments_query->posts );
[3078] Fix | Delete
[3079] Fix | Delete
$posts = array_map( 'wp_prepare_attachment_for_js', $attachments_query->posts );
[3080] Fix | Delete
$posts = array_filter( $posts );
[3081] Fix | Delete
$total_posts = $attachments_query->found_posts;
[3082] Fix | Delete
[3083] Fix | Delete
if ( $total_posts < 1 ) {
[3084] Fix | Delete
// Out-of-bounds, run the query again without LIMIT for total count.
[3085] Fix | Delete
unset( $query['paged'] );
[3086] Fix | Delete
[3087] Fix | Delete
$count_query = new WP_Query();
[3088] Fix | Delete
$count_query->query( $query );
[3089] Fix | Delete
$total_posts = $count_query->found_posts;
[3090] Fix | Delete
}
[3091] Fix | Delete
[3092] Fix | Delete
$posts_per_page = (int) $attachments_query->get( 'posts_per_page' );
[3093] Fix | Delete
[3094] Fix | Delete
$max_pages = $posts_per_page ? (int) ceil( $total_posts / $posts_per_page ) : 0;
[3095] Fix | Delete
[3096] Fix | Delete
header( 'X-WP-Total: ' . (int) $total_posts );
[3097] Fix | Delete
header( 'X-WP-TotalPages: ' . $max_pages );
[3098] Fix | Delete
[3099] Fix | Delete
wp_send_json_success( $posts );
[3100] Fix | Delete
}
[3101] Fix | Delete
[3102] Fix | Delete
/**
[3103] Fix | Delete
* Handles updating attachment attributes via AJAX.
[3104] Fix | Delete
*
[3105] Fix | Delete
* @since 3.5.0
[3106] Fix | Delete
*/
[3107] Fix | Delete
function wp_ajax_save_attachment() {
[3108] Fix | Delete
if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) {
[3109] Fix | Delete
wp_send_json_error();
[3110] Fix | Delete
}
[3111] Fix | Delete
[3112] Fix | Delete
$id = absint( $_REQUEST['id'] );
[3113] Fix | Delete
if ( ! $id ) {
[3114] Fix | Delete
wp_send_json_error();
[3115] Fix | Delete
}
[3116] Fix | Delete
[3117] Fix | Delete
check_ajax_referer( 'update-post_' . $id, 'nonce' );
[3118] Fix | Delete
[3119] Fix | Delete
if ( ! current_user_can( 'edit_post', $id ) ) {
[3120] Fix | Delete
wp_send_json_error();
[3121] Fix | Delete
}
[3122] Fix | Delete
[3123] Fix | Delete
$changes = $_REQUEST['changes'];
[3124] Fix | Delete
$post = get_post( $id, ARRAY_A );
[3125] Fix | Delete
[3126] Fix | Delete
if ( 'attachment' !== $post['post_type'] ) {
[3127] Fix | Delete
wp_send_json_error();
[3128] Fix | Delete
}
[3129] Fix | Delete
[3130] Fix | Delete
if ( isset( $changes['parent'] ) ) {
[3131] Fix | Delete
$post['post_parent'] = $changes['parent'];
[3132] Fix | Delete
}
[3133] Fix | Delete
[3134] Fix | Delete
if ( isset( $changes['title'] ) ) {
[3135] Fix | Delete
$post['post_title'] = $changes['title'];
[3136] Fix | Delete
}
[3137] Fix | Delete
[3138] Fix | Delete
if ( isset( $changes['caption'] ) ) {
[3139] Fix | Delete
$post['post_excerpt'] = $changes['caption'];
[3140] Fix | Delete
}
[3141] Fix | Delete
[3142] Fix | Delete
if ( isset( $changes['description'] ) ) {
[3143] Fix | Delete
$post['post_content'] = $changes['description'];
[3144] Fix | Delete
}
[3145] Fix | Delete
[3146] Fix | Delete
if ( MEDIA_TRASH && isset( $changes['status'] ) ) {
[3147] Fix | Delete
$post['post_status'] = $changes['status'];
[3148] Fix | Delete
}
[3149] Fix | Delete
[3150] Fix | Delete
if ( isset( $changes['alt'] ) ) {
[3151] Fix | Delete
$alt = wp_unslash( $changes['alt'] );
[3152] Fix | Delete
if ( get_post_meta( $id, '_wp_attachment_image_alt', true ) !== $alt ) {
[3153] Fix | Delete
$alt = wp_strip_all_tags( $alt, true );
[3154] Fix | Delete
update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
[3155] Fix | Delete
}
[3156] Fix | Delete
}
[3157] Fix | Delete
[3158] Fix | Delete
if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
[3159] Fix | Delete
$changed = false;
[3160] Fix | Delete
$id3data = wp_get_attachment_metadata( $post['ID'] );
[3161] Fix | Delete
[3162] Fix | Delete
if ( ! is_array( $id3data ) ) {
[3163] Fix | Delete
$changed = true;
[3164] Fix | Delete
$id3data = array();
[3165] Fix | Delete
}
[3166] Fix | Delete
[3167] Fix | Delete
foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) {
[3168] Fix | Delete
if ( isset( $changes[ $key ] ) ) {
[3169] Fix | Delete
$changed = true;
[3170] Fix | Delete
$id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) );
[3171] Fix | Delete
}
[3172] Fix | Delete
}
[3173] Fix | Delete
[3174] Fix | Delete
if ( $changed ) {
[3175] Fix | Delete
wp_update_attachment_metadata( $id, $id3data );
[3176] Fix | Delete
}
[3177] Fix | Delete
}
[3178] Fix | Delete
[3179] Fix | Delete
if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) {
[3180] Fix | Delete
wp_delete_post( $id );
[3181] Fix | Delete
} else {
[3182] Fix | Delete
wp_update_post( $post );
[3183] Fix | Delete
}
[3184] Fix | Delete
[3185] Fix | Delete
wp_send_json_success();
[3186] Fix | Delete
}
[3187] Fix | Delete
[3188] Fix | Delete
/**
[3189] Fix | Delete
* Handles saving backward compatible attachment attributes via AJAX.
[3190] Fix | Delete
*
[3191] Fix | Delete
* @since 3.5.0
[3192] Fix | Delete
*/
[3193] Fix | Delete
function wp_ajax_save_attachment_compat() {
[3194] Fix | Delete
if ( ! isset( $_REQUEST['id'] ) ) {
[3195] Fix | Delete
wp_send_json_error();
[3196] Fix | Delete
}
[3197] Fix | Delete
[3198] Fix | Delete
$id = absint( $_REQUEST['id'] );
[3199] Fix | Delete
if ( ! $id ) {
[3200] Fix | Delete
wp_send_json_error();
[3201] Fix | Delete
}
[3202] Fix | Delete
[3203] Fix | Delete
if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) {
[3204] Fix | Delete
wp_send_json_error();
[3205] Fix | Delete
}
[3206] Fix | Delete
[3207] Fix | Delete
$attachment_data = $_REQUEST['attachments'][ $id ];
[3208] Fix | Delete
[3209] Fix | Delete
check_ajax_referer( 'update-post_' . $id, 'nonce' );
[3210] Fix | Delete
[3211] Fix | Delete
if ( ! current_user_can( 'edit_post', $id ) ) {
[3212] Fix | Delete
wp_send_json_error();
[3213] Fix | Delete
}
[3214] Fix | Delete
[3215] Fix | Delete
$post = get_post( $id, ARRAY_A );
[3216] Fix | Delete
[3217] Fix | Delete
if ( 'attachment' !== $post['post_type'] ) {
[3218] Fix | Delete
wp_send_json_error();
[3219] Fix | Delete
}
[3220] Fix | Delete
[3221] Fix | Delete
/** This filter is documented in wp-admin/includes/media.php */
[3222] Fix | Delete
$post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
[3223] Fix | Delete
[3224] Fix | Delete
if ( isset( $post['errors'] ) ) {
[3225] Fix | Delete
$errors = $post['errors']; // @todo return me and display me!
[3226] Fix | Delete
unset( $post['errors'] );
[3227] Fix | Delete
}
[3228] Fix | Delete
[3229] Fix | Delete
wp_update_post( $post );
[3230] Fix | Delete
[3231] Fix | Delete
foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
[3232] Fix | Delete
if ( isset( $attachment_data[ $taxonomy ] ) ) {
[3233] Fix | Delete
wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
[3234] Fix | Delete
}
[3235] Fix | Delete
}
[3236] Fix | Delete
[3237] Fix | Delete
$attachment = wp_prepare_attachment_for_js( $id );
[3238] Fix | Delete
[3239] Fix | Delete
if ( ! $attachment ) {
[3240] Fix | Delete
wp_send_json_error();
[3241] Fix | Delete
}
[3242] Fix | Delete
[3243] Fix | Delete
wp_send_json_success( $attachment );
[3244] Fix | Delete
}
[3245] Fix | Delete
[3246] Fix | Delete
/**
[3247] Fix | Delete
* Handles saving the attachment order via AJAX.
[3248] Fix | Delete
*
[3249] Fix | Delete
* @since 3.5.0
[3250] Fix | Delete
*/
[3251] Fix | Delete
function wp_ajax_save_attachment_order() {
[3252] Fix | Delete
if ( ! isset( $_REQUEST['post_id'] ) ) {
[3253] Fix | Delete
wp_send_json_error();
[3254] Fix | Delete
}
[3255] Fix | Delete
[3256] Fix | Delete
$post_id = absint( $_REQUEST['post_id'] );
[3257] Fix | Delete
if ( ! $post_id ) {
[3258] Fix | Delete
wp_send_json_error();
[3259] Fix | Delete
}
[3260] Fix | Delete
[3261] Fix | Delete
if ( empty( $_REQUEST['attachments'] ) ) {
[3262] Fix | Delete
wp_send_json_error();
[3263] Fix | Delete
}
[3264] Fix | Delete
[3265] Fix | Delete
check_ajax_referer( 'update-post_' . $post_id, 'nonce' );
[3266] Fix | Delete
[3267] Fix | Delete
$attachments = $_REQUEST['attachments'];
[3268] Fix | Delete
[3269] Fix | Delete
if ( ! current_user_can( 'edit_post', $post_id ) ) {
[3270] Fix | Delete
wp_send_json_error();
[3271] Fix | Delete
}
[3272] Fix | Delete
[3273] Fix | Delete
foreach ( $attachments as $attachment_id => $menu_order ) {
[3274] Fix | Delete
if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
[3275] Fix | Delete
continue;
[3276] Fix | Delete
}
[3277] Fix | Delete
[3278] Fix | Delete
$attachment = get_post( $attachment_id );
[3279] Fix | Delete
[3280] Fix | Delete
if ( ! $attachment ) {
[3281] Fix | Delete
continue;
[3282] Fix | Delete
}
[3283] Fix | Delete
[3284] Fix | Delete
if ( 'attachment' !== $attachment->post_type ) {
[3285] Fix | Delete
continue;
[3286] Fix | Delete
}
[3287] Fix | Delete
[3288] Fix | Delete
wp_update_post(
[3289] Fix | Delete
array(
[3290] Fix | Delete
'ID' => $attachment_id,
[3291] Fix | Delete
'menu_order' => $menu_order,
[3292] Fix | Delete
)
[3293] Fix | Delete
);
[3294] Fix | Delete
}
[3295] Fix | Delete
[3296] Fix | Delete
wp_send_json_success();
[3297] Fix | Delete
}
[3298] Fix | Delete
[3299] Fix | Delete
/**
[3300] Fix | Delete
* Handles sending an attachment to the editor via AJAX.
[3301] Fix | Delete
*
[3302] Fix | Delete
* Generates the HTML to send an attachment to the editor.
[3303] Fix | Delete
* Backward compatible with the {@see 'media_send_to_editor'} filter
[3304] Fix | Delete
* and the chain of filters that follow.
[3305] Fix | Delete
*
[3306] Fix | Delete
* @since 3.5.0
[3307] Fix | Delete
*/
[3308] Fix | Delete
function wp_ajax_send_attachment_to_editor() {
[3309] Fix | Delete
check_ajax_referer( 'media-send-to-editor', 'nonce' );
[3310] Fix | Delete
[3311] Fix | Delete
$attachment = wp_unslash( $_POST['attachment'] );
[3312] Fix | Delete
[3313] Fix | Delete
$id = (int) $attachment['id'];
[3314] Fix | Delete
[3315] Fix | Delete
$post = get_post( $id );
[3316] Fix | Delete
if ( ! $post ) {
[3317] Fix | Delete
wp_send_json_error();
[3318] Fix | Delete
}
[3319] Fix | Delete
[3320] Fix | Delete
if ( 'attachment' !== $post->post_type ) {
[3321] Fix | Delete
wp_send_json_error();
[3322] Fix | Delete
}
[3323] Fix | Delete
[3324] Fix | Delete
if ( current_user_can( 'edit_post', $id ) ) {
[3325] Fix | Delete
// If this attachment is unattached, attach it. Primarily a back compat thing.
[3326] Fix | Delete
$insert_into_post_id = (int) $_POST['post_id'];
[3327] Fix | Delete
[3328] Fix | Delete
if ( 0 === $post->post_parent && $insert_into_post_id ) {
[3329] Fix | Delete
wp_update_post(
[3330] Fix | Delete
array(
[3331] Fix | Delete
'ID' => $id,
[3332] Fix | Delete
'post_parent' => $insert_into_post_id,
[3333] Fix | Delete
)
[3334] Fix | Delete
);
[3335] Fix | Delete
}
[3336] Fix | Delete
}
[3337] Fix | Delete
[3338] Fix | Delete
$url = empty( $attachment['url'] ) ? '' : $attachment['url'];
[3339] Fix | Delete
$rel = ( str_contains( $url, 'attachment_id' ) || get_attachment_link( $id ) === $url );
[3340] Fix | Delete
[3341] Fix | Delete
remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
[3342] Fix | Delete
[3343] Fix | Delete
if ( str_starts_with( $post->post_mime_type, 'image' ) ) {
[3344] Fix | Delete
$align = isset( $attachment['align'] ) ? $attachment['align'] : 'none';
[3345] Fix | Delete
$size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
[3346] Fix | Delete
$alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
[3347] Fix | Delete
[3348] Fix | Delete
// No whitespace-only captions.
[3349] Fix | Delete
$caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
[3350] Fix | Delete
if ( '' === trim( $caption ) ) {
[3351] Fix | Delete
$caption = '';
[3352] Fix | Delete
}
[3353] Fix | Delete
[3354] Fix | Delete
$title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
[3355] Fix | Delete
$html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt );
[3356] Fix | Delete
} elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) {
[3357] Fix | Delete
$html = stripslashes_deep( $_POST['html'] );
[3358] Fix | Delete
} else {
[3359] Fix | Delete
$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
[3360] Fix | Delete
$rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized.
[3361] Fix | Delete
[3362] Fix | Delete
if ( ! empty( $url ) ) {
[3363] Fix | Delete
$html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
[3364] Fix | Delete
}
[3365] Fix | Delete
}
[3366] Fix | Delete
[3367] Fix | Delete
/** This filter is documented in wp-admin/includes/media.php */
[3368] Fix | Delete
$html = apply_filters( 'media_send_to_editor', $html, $id, $attachment );
[3369] Fix | Delete
[3370] Fix | Delete
wp_send_json_success( $html );
[3371] Fix | Delete
}
[3372] Fix | Delete
[3373] Fix | Delete
/**
[3374] Fix | Delete
* Handles sending a link to the editor via AJAX.
[3375] Fix | Delete
*
[3376] Fix | Delete
* Generates the HTML to send a non-image embed link to the editor.
[3377] Fix | Delete
*
[3378] Fix | Delete
* Backward compatible with the following filters:
[3379] Fix | Delete
* - file_send_to_editor_url
[3380] Fix | Delete
* - audio_send_to_editor_url
[3381] Fix | Delete
* - video_send_to_editor_url
[3382] Fix | Delete
*
[3383] Fix | Delete
* @since 3.5.0
[3384] Fix | Delete
*
[3385] Fix | Delete
* @global WP_Post $post Global post object.
[3386] Fix | Delete
* @global WP_Embed $wp_embed WordPress Embed object.
[3387] Fix | Delete
*/
[3388] Fix | Delete
function wp_ajax_send_link_to_editor() {
[3389] Fix | Delete
global $post, $wp_embed;
[3390] Fix | Delete
[3391] Fix | Delete
check_ajax_referer( 'media-send-to-editor', 'nonce' );
[3392] Fix | Delete
[3393] Fix | Delete
$src = wp_unslash( $_POST['src'] );
[3394] Fix | Delete
if ( ! $src ) {
[3395] Fix | Delete
wp_send_json_error();
[3396] Fix | Delete
}
[3397] Fix | Delete
[3398] Fix | Delete
if ( ! strpos( $src, '://' ) ) {
[3399] Fix | Delete
$src = 'http://' . $src;
[3400] Fix | Delete
}
[3401] Fix | Delete
[3402] Fix | Delete
$src = sanitize_url( $src );
[3403] Fix | Delete
if ( ! $src ) {
[3404] Fix | Delete
wp_send_json_error();
[3405] Fix | Delete
}
[3406] Fix | Delete
[3407] Fix | Delete
$link_text = trim( wp_unslash( $_POST['link_text'] ) );
[3408] Fix | Delete
if ( ! $link_text ) {
[3409] Fix | Delete
$link_text = wp_basename( $src );
[3410] Fix | Delete
}
[3411] Fix | Delete
[3412] Fix | Delete
$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
[3413] Fix | Delete
[3414] Fix | Delete
// Ping WordPress for an embed.
[3415] Fix | Delete
$check_embed = $wp_embed->run_shortcode( '[embed]' . $src . '[/embed]' );
[3416] Fix | Delete
[3417] Fix | Delete
// Fallback that WordPress creates when no oEmbed was found.
[3418] Fix | Delete
$fallback = $wp_embed->maybe_make_link( $src );
[3419] Fix | Delete
[3420] Fix | Delete
if ( $check_embed !== $fallback ) {
[3421] Fix | Delete
// TinyMCE view for [embed] will parse this.
[3422] Fix | Delete
$html = '[embed]' . $src . '[/embed]';
[3423] Fix | Delete
} elseif ( $link_text ) {
[3424] Fix | Delete
$html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>';
[3425] Fix | Delete
} else {
[3426] Fix | Delete
$html = '';
[3427] Fix | Delete
}
[3428] Fix | Delete
[3429] Fix | Delete
// Figure out what filter to run:
[3430] Fix | Delete
$type = 'file';
[3431] Fix | Delete
$ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src );
[3432] Fix | Delete
if ( $ext ) {
[3433] Fix | Delete
$ext_type = wp_ext2type( $ext );
[3434] Fix | Delete
if ( 'audio' === $ext_type || 'video' === $ext_type ) {
[3435] Fix | Delete
$type = $ext_type;
[3436] Fix | Delete
}
[3437] Fix | Delete
}
[3438] Fix | Delete
[3439] Fix | Delete
/** This filter is documented in wp-admin/includes/media.php */
[3440] Fix | Delete
$html = apply_filters( "{$type}_send_to_editor_url", $html, $src, $link_text );
[3441] Fix | Delete
[3442] Fix | Delete
wp_send_json_success( $html );
[3443] Fix | Delete
}
[3444] Fix | Delete
[3445] Fix | Delete
/**
[3446] Fix | Delete
* Handles the Heartbeat API via AJAX.
[3447] Fix | Delete
*
[3448] Fix | Delete
* Runs when the user is logged in.
[3449] Fix | Delete
*
[3450] Fix | Delete
* @since 3.6.0
[3451] Fix | Delete
*/
[3452] Fix | Delete
function wp_ajax_heartbeat() {
[3453] Fix | Delete
if ( empty( $_POST['_nonce'] ) ) {
[3454] Fix | Delete
wp_send_json_error();
[3455] Fix | Delete
}
[3456] Fix | Delete
[3457] Fix | Delete
$response = array();
[3458] Fix | Delete
$data = array();
[3459] Fix | Delete
$nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' );
[3460] Fix | Delete
[3461] Fix | Delete
// 'screen_id' is the same as $current_screen->id and the JS global 'pagenow'.
[3462] Fix | Delete
if ( ! empty( $_POST['screen_id'] ) ) {
[3463] Fix | Delete
$screen_id = sanitize_key( $_POST['screen_id'] );
[3464] Fix | Delete
} else {
[3465] Fix | Delete
$screen_id = 'front';
[3466] Fix | Delete
}
[3467] Fix | Delete
[3468] Fix | Delete
if ( ! empty( $_POST['data'] ) ) {
[3469] Fix | Delete
$data = wp_unslash( (array) $_POST['data'] );
[3470] Fix | Delete
}
[3471] Fix | Delete
[3472] Fix | Delete
if ( 1 !== $nonce_state ) {
[3473] Fix | Delete
/**
[3474] Fix | Delete
* Filters the nonces to send to the New/Edit Post screen.
[3475] Fix | Delete
*
[3476] Fix | Delete
* @since 4.3.0
[3477] Fix | Delete
*
[3478] Fix | Delete
* @param array $response The Heartbeat response.
[3479] Fix | Delete
* @param array $data The $_POST data sent.
[3480] Fix | Delete
* @param string $screen_id The screen ID.
[3481] Fix | Delete
*/
[3482] Fix | Delete
$response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id );
[3483] Fix | Delete
[3484] Fix | Delete
if ( false === $nonce_state ) {
[3485] Fix | Delete
// User is logged in but nonces have expired.
[3486] Fix | Delete
$response['nonces_expired'] = true;
[3487] Fix | Delete
wp_send_json( $response );
[3488] Fix | Delete
}
[3489] Fix | Delete
}
[3490] Fix | Delete
[3491] Fix | Delete
if ( ! empty( $data ) ) {
[3492] Fix | Delete
/**
[3493] Fix | Delete
* Filters the Heartbeat response received.
[3494] Fix | Delete
*
[3495] Fix | Delete
* @since 3.6.0
[3496] Fix | Delete
*
[3497] Fix | Delete
* @param array $response The Heartbeat response.
[3498] Fix | Delete
* @param array $data The $_POST data sent.
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function