Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2014 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9b2c4a93a7f07b23d321 to your computer and use it in GitHub Desktop.
Save anonymous/9b2c4a93a7f07b23d321 to your computer and use it in GitHub Desktop.
additional tags
<?php
/*
Plugin Name: Additional Tags
Plugin URI: http://premium.wpmudev.org/project/additional-tags
Description: Allows additional tags (embed, iframe, etc) to be used when writing a post or page - so your users (and you) can actually use YouTube (and other) embed codes!
Author: Andrew Billits & Aaron Edwards
Version: 1.1.2
WDP ID: 37
*/
/*
Copyright 2007-2011 Incsub (http://incsub.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 - GPLv2) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
WARNING! This plugin is designed for advanced users who know what they are doing!
Allowing additional tags on a public site with untrusted blog users is a huge security risk!
A malicious user could redirect people to a virus, use your site for phishing attacks, or steal
login cookies, even the super admin one and bring down your entire install.
We can't be held responsible for any security problems you run into while using
this plugin.
INSTRUCTIONS: Add to, remove, or modify this array to allow additional tags and their associated attributes.
*/
$add_tags = array(
'iframe' => array(
'width' => array(),
'height' => array(),
'frameborder' => array(),
'src' => array(),
'scrolling' => array(),
'style' => array()
),
'object' => array(
'width' => array(),
'height' => array()
),
'param' => array(
'name' => array(),
'value' => array()
),
'embed' => array(
'src' => array(),
'type' => array(),
'wmode' => array(),
'width' => array(),
'height' => array(),
'name' => array(),
'id' => array(),
'bgcolor' => array(),
'flashVars' => array(),
'allowFullScreen' => array(),
'allowScriptAccess' => array(),
'seamlesstabbing' => array(),
'swLiveConnect' => array(),
'pluginspage' => array()
),
'script' => array(
'type' => array(),
'src' => array(),
'charset' => array()
),
'div' => array(
'class' => array(),
'id' => array(),
'style' => array()
),
'style' => array(
'type' => array()
)
);
//Change this to true if you want these additional tags to be allowed in comments. By default it will only affect posts/pages/text widgets
define('ALLOW_IN_COMMENTS', false);
/* DO NOT EDIT BELOW THIS LINE */
//------------------------------------------------------------------------//
//---Hook-----------------------------------------------------------------//
//------------------------------------------------------------------------//
add_action('plugins_loaded', 'additional_tags_localization');
add_action('wpmu_options', 'additional_tags_options');
add_action('update_wpmu_options', 'additional_tags_options_process');
add_action('plugins_loaded', 'additional_tags');
//------------------------------------------------------------------------//
//---Functions------------------------------------------------------------//
//------------------------------------------------------------------------//
function additional_tags_localization() {
// Load up the localization file if we're using WordPress in a different language
// Place it in this plugin's "languages" folder and name it "addtags-[value in wp-config].mo"
load_muplugin_textdomain( 'addtags' );
}
function additional_tags_options_process() {
$additional_tags = $_POST['additional_tags_supporter'];
if ( empty( $additional_tags ) ) {
$additional_tags = 0;
}
update_site_option( 'additional_tags_supporter' , $additional_tags );
}
function additional_tags() {
global $add_tags, $allowedposttags, $allowedtags;
//check supporter limit
if (function_exists('is_supporter')) {
if (get_site_option('additional_tags_supporter') && !is_supporter())
return;
}
//merge post tags
$allowedposttags = array_merge($allowedposttags, $add_tags);
if (defined('ALLOW_IN_COMMENTS') && ALLOW_IN_COMMENTS) {
//merge basic html (comments/etc)
$allowedtags = array_merge($allowedtags, $add_tags);
}
}
//------------------------------------------------------------------------//
//---Output Functions-----------------------------------------------------//
//------------------------------------------------------------------------//
function additional_tags_options() {
//only show is supporter is installed
if (!function_exists('is_supporter'))
return;
?>
<h3><?php _e('Additional Tags', 'addtags'); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Allow additional tags only on Supporter blogs', 'addtags'); ?></th>
<td>
<label><input type="checkbox" name="additional_tags_supporter" value="1"<?php checked(get_site_option('additional_tags_supporter')); ?> /> <?php _e('Supporters Only', 'addtags'); ?></label>
</td>
</tr>
</table>
<?php
}
//------------------------------------------------------------------------//
//---Page Output Functions------------------------------------------------//
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//---Support Functions----------------------------------------------------//
//------------------------------------------------------------------------//
///////////////////////////////////////////////////////////////////////////
/* -------------------- Update Notifications Notice -------------------- */
if ( !function_exists( 'wdp_un_check' ) ) {
add_action( 'admin_notices', 'wdp_un_check', 5 );
add_action( 'network_admin_notices', 'wdp_un_check', 5 );
function wdp_un_check() {
if ( !class_exists( 'WPMUDEV_Update_Notifications' ) && current_user_can( 'edit_users' ) )
echo '<div class="error fade"><p>' . __('Please install the latest version of <a href="http://premium.wpmudev.org/project/update-notifications/" title="Download Now &raquo;">our free Update Notifications plugin</a> which helps you stay up-to-date with the most stable, secure versions of WPMU DEV themes and plugins. <a href="http://premium.wpmudev.org/wpmu-dev/update-notifications-plugin-information/">More information &raquo;</a>', 'wpmudev') . '</a></p></div>';
}
}
/* --------------------------------------------------------------------- */
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment