PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / libraries / system / mce.php
vikappointments / libraries / system Last commit date
assets.php 1 month ago body.php 4 years ago builder.php 1 month ago cron.php 4 years ago feedback.php 4 years ago gutenberg.php 2 years ago install.php 1 month ago mce.php 4 years ago rssfeeds.php 5 months ago screen.php 4 years ago
mce.php
73 lines
1 <?php
2 /**
3 * @package VikAppointments - Libraries
4 * @subpackage system
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Class used to provide support for TinyMCE editor.
16 *
17 * @since 1.0
18 */
19 class VikAppointmentsTinyMCE
20 {
21 /**
22 * Adds a button to the array of buttons for TinyMCE
23 *
24 * @param array $buttons
25 *
26 * @return array
27 */
28 public static function addShortcodesButton($buttons)
29 {
30 $buttons[] = 'vap-shortcodes';
31
32 return $buttons;
33 }
34
35 /**
36 * Attaches the necessary scripts to handle the shortcode event
37 *
38 * @param array $plugin_array
39 *
40 * @return array
41 */
42 public static function registerShortcodesScript($plugin_array)
43 {
44 // get shortcode model
45 $model = JModel::getInstance('vikappointments', 'shortcodes', 'admin');
46
47 // obtain a categorized shortcodes list
48 $shortcodes = array();
49
50 foreach ($model->all() as $s)
51 {
52 $title = JText::translate($s->title);
53
54 if (!isset($shortcodes[$title]))
55 {
56 $shortcodes[$title] = array();
57 }
58
59 $shortcodes[$title][] = $s;
60 }
61
62 $document = JFactory::getDocument();
63
64 // register script to access JSON object
65 $document->addScriptDeclaration("var VIKAPPOINTMENTS_SHORTCODES = " . json_encode($shortcodes) . ";");
66 $document->addStyleSheet(VIKAPPOINTMENTS_CORE_MEDIA_URI . 'css/tinymce-shortcodes.css');
67
68 $plugin_array['vap-shortcodes'] = VIKAPPOINTMENTS_CORE_MEDIA_URI . 'js/tinymce-shortcodes.js';
69
70 return $plugin_array;
71 }
72 }
73