PluginProbe
CSS & JavaScript Toolbox / 7.2
CSS & JavaScript Toolbox v7.2
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
← All changes | controllers/metabox.php +20 -43 127.2 View file →
@@ -10,9 +10,9 @@
10 10 cssJSToolbox::import('framework:mvc:controller-ajax.inc.php');
11 11
12 12 /**
13 13 * Controll Block metabox actions.
14 -*
14 +*
15 15 * @version 6.0
16 16 * @package CJT
17 17 * @subpackage Controllers
18 18 * @author Ahmed Said
@@ -17,12 +17,12 @@
17 17 * @subpackage Controllers
18 18 * @author Ahmed Said
19 19 */
20 20 class CJTMetaboxController extends CJTAjaxController {
21 -
21 +
22 22 /**
23 23 * Initialize post controller.
24 - *
24 + *
25 25 * @return void
26 26 */
27 27 public function __construct($_unused_hasView = null, $request = null) {
28 28 // Initialize parent.
@@ -37,39 +37,16 @@
37 37 $this->registryAction('create');
38 38 $this->registryAction('delete');
39 39 }
40 40 else if ($this->model->doPost()) {
41 - $current_screen = get_current_screen();
42 41 // Add metabox.
43 - // Hiding metabox for Gutenberg editors.
44 - if ( ! $this->hasGutenberg() ) $this->showMetabox();
42 + $this->showMetabox();
45 43 }
46 44 }
47 -
45 +
48 46 /**
49 - * Check for Gutenberg editor.
50 - *
51 - * @return boolean
52 - */
53 - public function hasGutenberg() {
54 - if ( function_exists( 'is_gutenberg_page' ) &&
55 - is_gutenberg_page()
56 - ) {
57 - return true;
58 - }
59 - $current_screen = get_current_screen();
60 - if ( method_exists( $current_screen, 'is_block_editor' ) &&
61 - $current_screen->is_block_editor()
62 - ) {
63 - // Gutenberg page on 5+.
64 - return true;
65 - }
66 - return false;
67 - }
68 -
69 - /**
70 47 * Create block metabox for specific post object.
71 - *
48 + *
72 49 * @param integer Post id.
73 50 * @return array New block object consist of block id and new block metabox view content.
74 51 */
75 52 public function createAction() {
@@ -87,17 +64,17 @@
87 64 // Get metabox block view object.
88 65 $this->view = CJTView::create('blocks/metabox');
89 66 $this->view->setBlock(CJTModel::create('blocks')->getBlock($blockId, array('returnCodeFile' => true)));
90 67 $this->view->setSecurityToken($this->createSecurityToken());
91 - // Send JavaScript & CSS files needed for the metabox view to work.
68 + // Send Javascript & CSS files needed for the metabox view to work.
92 69 $this->response['references'] = self::getReferencesQueue();
93 70 $this->response['view'] = $this->view->setOption('customizeMetabox', true)->getTemplate('metabox');
94 71 }
95 72 }
96 -
73 +
97 74 /**
98 75 * put your comment there...
99 - *
76 + *
100 77 */
101 78 public function deleteAction() {
102 79 // Get input vars.
103 80 $metaboxBlockId = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
@@ -114,21 +91,21 @@
114 91 $block->name = cssJSToolbox::getText('CJT Block');
115 92 // Push vars into the view.
116 93 $this->view->setBlock($block);
117 94 $this->view->setSecurityToken($this->createSecurityToken());
118 - // Send JavaScript & CSS files needed for the metabox view to work.
95 + // Send Javascript & CSS files needed for the metabox view to work.
119 96 $this->response['references'] = self::getReferencesQueue();
120 97 // create-metabox view content.
121 98 $this->response['view'] = $this->view->setOption('customizeMetabox', true)->getTemplate('create');
122 99 }
123 -
100 +
124 101 /**
125 102 * put your comment there...
126 - *
103 + *
127 104 */
128 105 protected static function getReferencesQueue() {
129 106 $result = array();
130 - /**
107 + /**
131 108 Get all scripts needed to be loaded for block metabox to work.
132 109 --------------------------------------------------------------
133 110 * 1. Suppress the output we need the SRC URLs not the HTML tags.
134 111 * 2. Fire scripts & styles action so the view would enqueue all the files.
@@ -164,18 +141,18 @@
164 141 }
165 142 // Return references.
166 143 return $result;
167 144 }
168 -
145 +
169 146 /**
170 147 * Select which metabox to load.
171 - *
172 - * create-metabox view will be loaded if user doesnt
148 + *
149 + * create-metabox view will be loaded if user doesnt
173 150 * created a block for current post yet.
174 - *
151 + *
175 152 * metabox view will be loaded if there is a block
176 153 * already created for current post.
177 - *
154 + *
178 155 * Callback for add_meta_boxes action.
179 156 */
180 157 public function showMetabox() {
181 158 // Import blocks view.
@@ -182,9 +159,9 @@
182 159 CJTView::import('blocks/manager');
183 160 /// Get block id.
184 161 $metaboxId = $this->model->reservedMetaboxBlockId();
185 162 // User didn't create block for this post yet.
186 - // Show create-metabox view.
163 + // Show create-metabox view.
187 164 if (!$this->model->hasBlock()) {
188 165 // Set view template name.
189 166 $viewName = 'create-metabox';
190 167 // Create DUMMY block object.
@@ -210,6 +187,6 @@
210 187 $this->view->setSecurityToken($this->createSecurityToken());
211 188 // Add metabox.
212 189 add_meta_box($this->view->getMetaboxId(), $this->view->getMetaboxName(), array(&$this->view, 'display'), $this->model->getPost()->post_type, 'normal');
213 190 }
214 -
191 +
215 192 } // End class.