# css-javascript-toolbox/12.0.5/models/block-templates.php

CSS &amp; JavaScript Toolbox, version 12.0.5. 57 lines.

- Page: https://pluginprobe.com/plugins/css-javascript-toolbox/12.0.5/code/models/block-templates.php
- Raw: https://pluginprobe.com/plugins/css-javascript-toolbox/12.0.5/raw/models/block-templates.php
- Modified: 2025-10-06T13:35:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/css-javascript-toolbox/12.0.5/code/models/block-templates.php#L10-L20`.

```php
<?php
/**
* 
*/

// Disllow direct access.
defined('ABSPATH') or die('Access denied');

/**
* 
*/
class CJTBlockTemplatesModel extends CJTHookableClass {

    
    /**
    * put your comment there...
    * 
    * @param mixed $blockId
    */
    public static function getLinkedTemplatesCount($blockId) {
        
        global $wpdb;
        
        $query = "  SELECT count(*)
                    FROM {$wpdb->prefix}cjtoolbox_block_templates
                    WHERE blockId = %d;";
                    
        $query = $wpdb->prepare($query, $blockId);
        
        $count = $wpdb->get_var($query);
        
        return $count;
    }
    
	/**
	* Check weather a template is linked to specific block.
	* 
	* Check database block_templates table for record with the given ids.
	* 
	* @param Integer Block Id.
	* @param Integer Template Id.
	* @return boolean TRUE if linked, FALSE if not.
	*/
	public function isLinked($blockId, $templateId)	{
		// Try to load block template table with the requested Ids.
		$tableBlockTemplate = CJTxTable::getInstance('block-template');
		$tableBlockTemplate->set('blockId', $blockId)
																			 ->set('templateId', $templateId)
																			 ->load(array('blockId', 'templateId'));
		// Return TRUE if the blockId and the TemplateId returned from the load process!
		return ($tableBlockTemplate->get('blockId') && $tableBlockTemplate->get('templateId'));
	}

} // End class.

// Hookable!
CJTBlockTemplatesModel::define('CJTBlockTemplatesModel');
```
