| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// No direct access. |
| 7 |
defined('ABSPATH') or die('Access denied'); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTTinymceShortcodesView extends CJTView { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @param mixed $info |
| 18 |
* @return CJTTinymceShortcodesView |
| 19 |
*/ |
| 20 |
public function __construct($info) { |
| 21 |
// Initialize parent! |
| 22 |
parent::__construct($info); |
| 23 |
// Register TinyMCE Plugin with Wordpress! |
| 24 |
add_filter('mce_external_plugins', array($this, 'registerPlugin'), 1, 11); |
| 25 |
// Add TinyMCE button for adding shortcode! |
| 26 |
add_filter('mce_buttons', array($this, 'addButton')); |
| 27 |
// Enqueue dependencies scripts. |
| 28 |
self::enqueueScripts(); |
| 29 |
self::enqueueStyles(); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* put your comment there... |
| 34 |
* |
| 35 |
* @param mixed $buttons |
| 36 |
*/ |
| 37 |
public function addButton($buttons) { |
| 38 |
// Add Blocks Shortcode button! |
| 39 |
array_push($buttons, 'separator', 'CJTBlockShortcode'); |
| 40 |
return $buttons; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* put your comment there... |
| 45 |
* |
| 46 |
* @param mixed $tpl |
| 47 |
*/ |
| 48 |
public function display($tpl = null) { |
| 49 |
// Output view! |
| 50 |
echo $this->getTemplate($tpl); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* put your comment there... |
| 55 |
* |
| 56 |
*/ |
| 57 |
public function enqueueScripts() { |
| 58 |
// Please thos scripts below should be already loaded |
| 59 |
// by the metabox views If the tinymce is loaded inside the editbox |
| 60 |
// IN OTHER CASES!!! what is the other cases! we load it! |
| 61 |
self::useScripts(__CLASS__, |
| 62 |
'thickbox', |
| 63 |
'framework:js:ajax:{CJT-}cjt-server' |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* put your comment there... |
| 69 |
* |
| 70 |
*/ |
| 71 |
public function enqueueStyles() { |
| 72 |
self::useStyles(__CLASS__, 'thickbox'); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* put your comment there... |
| 77 |
* |
| 78 |
* @param mixed $plugins |
| 79 |
*/ |
| 80 |
public function registerPlugin($plugins) { |
| 81 |
// Register shortcode TinyMCE button Plugin. |
| 82 |
$plugins['CJTShortcodes'] = $this->getURI('plugins/shortcode/shortcode.js'); |
| 83 |
return $plugins; |
| 84 |
} |
| 85 |
|
| 86 |
} // End class. |
| 87 |
|