| 1 |
<?php |
| 2 |
/** |
| 3 |
* Responsible for the grid button in the classic editor. |
| 4 |
* |
| 5 |
* @link https://bootstrapped.ventures |
| 6 |
* @since 3.0.0 |
| 7 |
* |
| 8 |
* @package WP_Ultimate_Post_Grid |
| 9 |
* @subpackage WP_Ultimate_Post_Grid/includes/public |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Responsible for the grid button in the classic editor. |
| 14 |
* |
| 15 |
* @since 3.0.0 |
| 16 |
* @package WP_Ultimate_Post_Grid |
| 17 |
* @subpackage WP_Ultimate_Post_Grid/includes/public |
| 18 |
* @author Brecht Vandersmissen <brecht@bootstrapped.ventures> |
| 19 |
*/ |
| 20 |
class WPUPG_Button { |
| 21 |
|
| 22 |
/** |
| 23 |
* Register actions and filters. |
| 24 |
* |
| 25 |
* @since 3.0.0 |
| 26 |
*/ |
| 27 |
public static function init() { |
| 28 |
add_filter( 'mce_external_plugins', array( __CLASS__, 'add_button' ) ); |
| 29 |
add_filter( 'mce_buttons', array( __CLASS__, 'register_button' ) ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Add the button to the TinyMCE editor. |
| 34 |
* |
| 35 |
* @since 3.0.0 |
| 36 |
* @param mixed $plugin_array TinyMCE plugins. |
| 37 |
*/ |
| 38 |
public static function add_button( $plugin_array ) { |
| 39 |
$plugin_array['wp_ultimate_post_grid'] = WPUPG_URL . 'assets/js/other/tinymce-toolbar-icon.js'; |
| 40 |
return $plugin_array; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Register the button for the TinyMCE editor. |
| 45 |
* |
| 46 |
* @since 3.0.0 |
| 47 |
* @param mixed $buttons TinyMCE buttons. |
| 48 |
*/ |
| 49 |
public static function register_button( $buttons ) { |
| 50 |
array_push( $buttons, 'wp_ultimate_post_grid' ); |
| 51 |
return $buttons; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
WPUPG_Button::init(); |
| 56 |
|