PluginProbe
CSS & JavaScript Toolbox / 8.0.3
CSS & JavaScript Toolbox v8.0.3
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 | models/blocks.php +15 -84 10.18.0.3 View file →
@@ -273,61 +273,8 @@
273 273
274 274 /**
275 275 * put your comment there...
276 276 *
277 - */
278 - public static function getCustomPostTypes()
279 - {
280 -
281 - static $postTypes = null;
282 -
283 - if ( $postTypes !== null )
284 - {
285 - return $postTypes;
286 - }
287 -
288 -
289 - $postTypes = array();
290 -
291 - // Create tabs for every custom post under the custom posts tab.
292 - // Get all registered custom posts.
293 - $customPosts = get_post_types( array( 'public' => 1, 'show_ui' => true, '_builtin' => false ), 'objects' );
294 -
295 - // Add tab for every custom post
296 - // Exclude 'Empty' Custom Post Types.
297 - foreach ( $customPosts as $typeName => $customPost )
298 - {
299 - // Check if has posts.
300 - $hasPosts = count( get_posts( array( 'post_type' => $typeName, 'offset' => 0, 'numberposts' => 1 ) ) );
301 -
302 - // Add only types with at least one post exists.
303 - if ( $hasPosts )
304 - {
305 - $postTypes[ $typeName ] = array
306 - (
307 - 'title' => $customPost->labels->name,
308 - 'renderer' => 'objects-list',
309 - 'type' => array
310 - (
311 - 'type' => $typeName,
312 - 'group' => 'posts',
313 - 'targetType' => 'post'
314 - )
315 -
316 - );
317 -
318 - }
319 -
320 - }
321 -
322 - do_action( CJTPluggableHelper::ACTION_BLOCK_CUSTOM_POST_TYPES, $postTypes );
323 -
324 - return $postTypes;
325 - }
326 -
327 - /**
328 - * put your comment there...
329 - *
330 277 * @param mixed $id
331 278 */
332 279 public function getInfo($id) {
333 280 // Info fields.
@@ -376,46 +323,30 @@
376 323 * put your comment there...
377 324 *
378 325 * @param mixed $block
379 326 */
380 - public function update( $block, $updatePins )
381 - {
382 -
383 - $block = ( array ) $block;
384 -
385 - $blocks = new CJTBlocksTable( $this->dbDriver );
386 - $pins = new CJTBlockPinsTable( $this->dbDriver );
387 -
327 + public function update($block, $updatePins) {
328 + // To be used by array_intersect_key.
329 + $block = (array) $block;
330 + // Create Tables objects.
331 + $blocks = new CJTBlocksTable($this->dbDriver);
332 + $pins = new CJTBlockPinsTable($this->dbDriver);
388 333 // Update block pins if requested.
389 - if ( $updatePins )
390 - {
334 + if ($updatePins) {
391 335 // Isolate block pins freom native block data.
392 - $pinsData = array_intersect_key( $block, array_flip( array_keys( CJTBlockModel::getCustomPins() ) ) );
393 -
394 - do_action( CJTPluggableHelper::FILTER_BLOCK_MODEL_PRE_UPDATE_BLOCK_PINS, $block, $pinsData );
395 -
396 - $pins->update( $block[ 'id' ], $pinsData );
397 -
336 + $pinsData = array_intersect_key($block, array_flip(array('pages', 'posts', 'categories')));
337 + $pins->update($block['id'], $pinsData);
398 338 }
399 -
400 339 // Update code file
401 - if ( isset( $block[ 'activeFileId' ] ) )
402 - {
403 -
404 - $codeFile = new CJTBlockFilesTable( $this->dbDriver );
405 -
406 - $codeFile->set( 'blockId', $block[ 'id' ] )
407 - ->set( 'id', $block[ 'activeFileId'] )
408 - ->set( 'code', $block[ 'code'] )
340 + if (isset($block['activeFileId'])) {
341 + $codeFile = new CJTBlockFilesTable($this->dbDriver);
342 + $codeFile->set('blockId', $block['id'])
343 + ->set('id', $block['activeFileId'])
344 + ->set('code', $block['code'])
409 345 ->save();
410 346 }
411 -
412 347 // Isolate block fields.
413 348 $blockData = array_intersect_key($block, $blocks->getFields());
414 -
415 - do_action( CJTPluggableHelper::FILTER_BLOCK_MODEL_PRE_UPDATE_BLOCK, $updatePins, $blockData );
416 -
417 - $blocks->update( $blockData );
418 -
349 + $blocks->update($blockData);
419 350 }
420 351
421 352 } // End class.