GWP_bs3_panel_shortcode.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. class GWP_bs3_panel_shortcode{
  3. /**
  4. * $shortcode_tag
  5. * holds the name of the shortcode tag
  6. * @var string
  7. */
  8. public $shortcode_tag = 'librevideojs';
  9. /**
  10. * __construct
  11. * class constructor will set the needed filter and action hooks
  12. *
  13. * @param array $args
  14. */
  15. function __construct($args = array()){
  16. if (is_admin()){
  17. add_action('admin_head', array($this, 'admin_head'));
  18. add_action('admin_enqueue_scripts', array($this , 'admin_enqueue_scripts'));
  19. }
  20. }
  21. /**
  22. * admin_head
  23. * calls your functions into the correct filters
  24. * @return void
  25. */
  26. function admin_head() {
  27. // check user permissions
  28. if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
  29. return;
  30. }
  31. // check if WYSIWYG is enabled
  32. if ('true' == get_user_option('rich_editing')) {
  33. add_filter('mce_external_plugins', array($this ,'mce_external_plugins'));
  34. add_filter('mce_buttons', array($this, 'mce_buttons'));
  35. }
  36. }
  37. /**
  38. * mce_external_plugins
  39. * Adds our tinymce plugin
  40. * @param array $plugin_array
  41. * @return array
  42. */
  43. function mce_external_plugins($plugin_array) {
  44. $plugin_array[$this->shortcode_tag] = plugins_url('librevideojs/js/mce-button.js', __FILE__);
  45. return $plugin_array;
  46. }
  47. /**
  48. * mce_buttons
  49. * Adds our tinymce button
  50. * @param array $buttons
  51. * @return array
  52. */
  53. function mce_buttons($buttons) {
  54. array_push($buttons, $this->shortcode_tag);
  55. return $buttons;
  56. }
  57. /**
  58. * admin_enqueue_scripts
  59. * Used to enqueue custom styles
  60. * @return void
  61. */
  62. function admin_enqueue_scripts() {
  63. wp_enqueue_style('librevideojs_shortcode', plugins_url('librevideojs/css/mce-button.css', __FILE__));
  64. }
  65. }
  66. ?>