PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.1.0
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.1.0
3.1.14 3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 123 releases
firebox / Inc / Core / Admin / Includes / Cpts / FireBox / TinyMCEButton.php

TinyMCEButton.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 1.1.0, at Inc/Core/Admin/Includes/Cpts/FireBox/TinyMCEButton.php

84 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 1.1.0 Free
5 *
6 * @author FirePlugins <[email protected]>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2022 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Admin\Includes\Cpts\FireBox;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class TinyMCEButton
20 {
21 public function __construct()
22 {
23 if (!$this->canRun())
24 {
25 return;
26 }
27
28 // Load wp.apiFetch function
29 wp_enqueue_script('wp-api-fetch');
30
31 // add button media
32 add_filter('mce_external_plugins', [$this, 'register_button_media']);
33
34 // register button
35 add_filter('mce_buttons', [$this, 'register_button']);
36 }
37
38 /**
39 * Registers Firebox to TinyMCE editor
40 *
41 * @param array $buttons
42 *
43 * @return array
44 */
45 public function register_button($buttons)
46 {
47 array_push($buttons, "|", "fireplugins_firebox");
48 return $buttons;
49 }
50
51 /**
52 * Adds button media files
53 *
54 * @param array $buttons
55 *
56 * @return array
57 */
58 public function register_button_media($buttons)
59 {
60 $buttons['fireplugins_firebox'] = FBOX_MEDIA_ADMIN_URL . 'js/fb_tinymce_button.js';
61 return $buttons;
62 }
63
64 /**
65 * Whether we can run
66 *
67 * @return boolean
68 */
69 private function canRun()
70 {
71 if (!current_user_can('manage_options') || !current_user_can('edit_posts') || !current_user_can('edit_pages'))
72 {
73 return false;
74 }
75
76 global $pagenow;
77 if (!in_array($pagenow, ['post.php', 'post-new.php']))
78 {
79 return false;
80 }
81
82 return true;
83 }
84 }