Created
March 30, 2012 06:20
-
-
Save jaredatch/2247508 to your computer and use it in GitHub Desktop.
bbPress TinyMCE Media Upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: bbPress TinyMCE Media Upload | |
Plugin URI: http://wordpress.org/extend/plugins/bbpress-tinymce-media-upload-for-administrators/ | |
Description: Enables the Media Upload button on the front-end TinyMCE editor for admin users. | |
Version: 1.0 | |
Author: Jared Atchison | |
Author URI: http://jaredatchison.com | |
*/ | |
/** | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* 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. | |
* | |
* @version 1.0 | |
* @author Jared Atchison | |
* @copyright Copyright (c) 2012, Jared Atchison | |
* @link http://jaredatchison.com | |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | |
*/ | |
/** | |
* Main bbPress TinyMCE Media Upload Class | |
*/ | |
class ja_bbp_tinymce_media_upload{ | |
/** | |
* @var One instance. Thank you, come again. | |
*/ | |
static $instance; | |
/** | |
* Start the engines | |
* | |
* @since 1.0 | |
*/ | |
function __construct() { | |
self::$instance =& $this; | |
// Add filters | |
add_filter( 'bbp_pre_the_content', array( $this, 'bbp_editor_args' ) ); | |
// Add actions | |
add_action( 'load-media-upload.php', array( $this, 'media_uploader_callback' ) ); | |
} | |
/** | |
* Add the media upload button if user has appropriate permissions | |
* | |
* @since 1.0 | |
*/ | |
function bbp_editor_args( $args ) { | |
if ( current_user_can( apply_filters( 'ja_bbp_tinymce_media_upload_capability', 'unfiltered_html' ) ) ) { | |
$args['media_buttons'] = true; | |
} | |
return $args; | |
} | |
/** | |
* Media uploader callback, trigger media tabs filter | |
* | |
* @since 1.0 | |
*/ | |
function media_uploader_callback() { | |
// debug | |
echo '<pre>' . print_r( $_GET, true ) . '</pre>'; | |
echo '<pre>' . print_r( $_REQUEST, true ) . '</pre>'; | |
echo '<pre>' . print_r( $_POST, true ) . '</pre>'; | |
add_filter( 'media_upload_tabs', array( $this, 'filter_tabs' ) ); | |
} | |
/** | |
* Filter tabs to remove 'Gallery' and 'Media Library' | |
* | |
* @since 1.0 | |
*/ | |
function filter_tabs( $tabs ){ | |
$tabs = array( | |
'type' => 'From Computer', | |
'type_url' => 'From URL' | |
); | |
return $tabs; | |
} | |
} | |
new ja_bbp_tinymce_media_upload(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment