Advertisement
Guest User

Untitled

a guest
Jun 24th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. if ( ! defined( 'ABSPATH' ) )
  2.     die( "Can't load this file directly" );
  3.  
  4. class wppaGallery
  5. {
  6.     function __construct() {
  7.     add_action( 'admin_init', array( $this, 'action_admin_init' ) );
  8.     }
  9.      
  10.     function action_admin_init() {
  11.         // only hook up these filters if we're in the admin panel, and the current user has permission
  12.         // to edit posts and pages
  13.         if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
  14.             add_filter( 'mce_buttons', array( $this, 'filter_mce_button' ) );
  15.             add_filter( 'mce_external_plugins', array( $this, 'filter_mce_plugin' ) );
  16.         }
  17.     }
  18.      
  19.     function filter_mce_button( $buttons ) {
  20.         // add a separation before our button.
  21.         array_push( $buttons, '|', 'wppa_button' );
  22.         return $buttons;
  23.     }
  24.      
  25.     function filter_mce_plugin( $plugins ) {
  26.         // this plugin file will work the magic of our button
  27.         $plugins['wppa'] = plugin_dir_url( __FILE__ ) . 'wppa_plugin.js';
  28.         return $plugins;
  29.     }
  30.  
  31. }
  32.  
  33. $wppagallery = new wppaGallery();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement