Skip to content

Instantly share code, notes, and snippets.

@leotsem
Forked from ocean90/plugin.php
Created November 15, 2013 16:07
Show Gist options
  • Select an option

  • Save leotsem/7486827 to your computer and use it in GitHub Desktop.

Select an option

Save leotsem/7486827 to your computer and use it in GitHub Desktop.

Revisions

  1. leotsem revised this gist Nov 15, 2013. 1 changed file with 1 addition and 9 deletions.
    10 changes: 1 addition & 9 deletions plugin.php
    Original file line number Diff line number Diff line change
    @@ -9,15 +9,7 @@
    * @return array
    */
    function send_no_xss_protection_header( $headers, $object ) {
    if (
    ! empty( $object->query_vars['preview'] ) &&
    ! empty( $object->query_vars['p'] ) &&
    wp_get_referer() &&
    wp_get_referer() == sprintf( admin_url( 'post.php?post=%d&action=edit' ), $object->query_vars['p'] )
    )
    $headers['X-XSS-Protection'] = 0;


    $headers['X-XSS-Protection'] = 0;
    return $headers;
    }
    add_filter( 'wp_headers', 'send_no_xss_protection_header', 10, 2 );
  2. @ocean90 ocean90 revised this gist Sep 5, 2012. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion plugin.php
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,15 @@
    * @return array
    */
    function send_no_xss_protection_header( $headers, $object ) {
    if ( ! empty( $object->query_vars['preview'] ) )
    if (
    ! empty( $object->query_vars['preview'] ) &&
    ! empty( $object->query_vars['p'] ) &&
    wp_get_referer() &&
    wp_get_referer() == sprintf( admin_url( 'post.php?post=%d&action=edit' ), $object->query_vars['p'] )
    )
    $headers['X-XSS-Protection'] = 0;


    return $headers;
    }
    add_filter( 'wp_headers', 'send_no_xss_protection_header', 10, 2 );
  3. @ocean90 ocean90 created this gist Sep 4, 2012.
    17 changes: 17 additions & 0 deletions plugin.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    /**
    * Add a X-XSS-Protection = 0 header for post previews to allow
    * Webkit browsers to render iframe and flash objects.
    * @see: http://core.trac.wordpress.org/ticket/20148
    *
    * @param $headers array Already added header items.
    * @param $object WP The query variables.
    *
    * @return array
    */
    function send_no_xss_protection_header( $headers, $object ) {
    if ( ! empty( $object->query_vars['preview'] ) )
    $headers['X-XSS-Protection'] = 0;

    return $headers;
    }
    add_filter( 'wp_headers', 'send_no_xss_protection_header', 10, 2 );