Make WordPress Core


Ignore:
Timestamp:
05/18/2010 10:08:49 PM (15 years ago)
Author:
markjaquith
Message:

Add nonce protection for setting/removing featured post image. fixes #13438

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r14693 r14730  
    12871287    $calling_post_id = 0;
    12881288    if ( isset( $_GET['post_id'] ) )
    1289         $calling_post_id = $_GET['post_id'];
     1289        $calling_post_id = absint( $_GET['post_id'] );
    12901290    elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set
    12911291        $calling_post_id = $post->post_parent;
    1292     if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id )
    1293         $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>";
     1292    if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
     1293        $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" );
     1294        $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>";
     1295    }
    12941296
    12951297    if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) )
Note: See TracChangeset for help on using the changeset viewer.