Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
Created September 9, 2016 15:08
Show Gist options
  • Save woodwardtw/cd09dec40403d6f30a5866a7434bcc83 to your computer and use it in GitHub Desktop.
Save woodwardtw/cd09dec40403d6f30a5866a7434bcc83 to your computer and use it in GitHub Desktop.
allows a chunk of iframe parameters via wp kses file . . . buyer beware etc.
<?php
/**
* Plugin Name: iframe allower
* Plugin URI: https://gist.github.com/woodwardtw/cd09dec40403d6f30a5866a7434bcc83
* Description: allows iframe embed
* Version: .7
* Author: Tom Woodward
* Author URI: http://bionicteaching.com
* License: GPL2
*/
/* 2015 Tom Woodward (email : bionicteaching@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
add_filter( 'wp_kses_allowed_html', 'esw_author_cap_filter',1,1 );
function esw_author_cap_filter( $allowedposttags ) {
//Here put your conditions, depending your context
if ( !current_user_can( 'publish_posts' ) )
return $allowedposttags;
// Here add tags and attributes you want to allow
$allowedposttags['iframe']=array(
'align' => true,
'width' => true,
'height' => true,
'frameborder' => true,
'name' => true,
'src' => true,
'id' => true,
'class' => true,
'style' => true,
'scrolling' => true,
'marginwidth' => true,
'marginheight' => true,
'allowfullscreen' => true,
'mozallowfullscreen' => true,
'webkitallowfullscreen' => true,
);
return $allowedposttags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment