PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.1.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.1.2
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Plugin.php

Plugin.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 1.1.2, at classes/Visualizer/Plugin.php

163 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // +----------------------------------------------------------------------+
4 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
5 // +----------------------------------------------------------------------+
6 // | This program is free software; you can redistribute it and/or modify |
7 // | it under the terms of the GNU General Public License, version 2, as |
8 // | published by the Free Software Foundation. |
9 // | |
10 // | This program is distributed in the hope that it will be useful, |
11 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 // | GNU General Public License for more details. |
14 // | |
15 // | You should have received a copy of the GNU General Public License |
16 // | along with this program; if not, write to the Free Software |
17 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18 // | MA 02110-1301 USA |
19 // +----------------------------------------------------------------------+
20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
21 // +----------------------------------------------------------------------+
22
23 /**
24 * The core plugin class.
25 *
26 * @category Visualizer
27 *
28 * @since 1.0.0
29 */
30 class Visualizer_Plugin {
31
32 const NAME = 'visualizer';
33 const VERSION = '1.1.2';
34
35 // custom post types
36 const CPT_VISUALIZER = 'visualizer';
37
38 // custom meta fields
39 const CF_CHART_TYPE = 'visualizer-chart-type';
40 const CF_SOURCE = 'visualizer-source';
41 const CF_SERIES = 'visualizer-series';
42 const CF_DEFAULT_DATA = 'visualizer-default-data';
43 const CF_SETTINGS = 'visualizer-settings';
44
45 // custom actions
46 const ACTION_GET_CHARTS = 'visualizer-get-charts';
47 const ACTION_CREATE_CHART = 'visualizer-create-chart';
48 const ACTION_EDIT_CHART = 'visualizer-edit-chart';
49 const ACTION_CLONE_CHART = 'visualizer-clone-chart';
50 const ACTION_DELETE_CHART = 'visualizer-delete-chart';
51 const ACTION_UPLOAD_DATA = 'visualizer-upload-data';
52
53 // custom filters
54 const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series';
55 const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data';
56
57 /**
58 * Singletone instance of the plugin.
59 *
60 * @since 1.0.0
61 *
62 * @access private
63 * @var Visualizer_Plugin
64 */
65 private static $_instance = null;
66
67 /**
68 * The array of registered modules.
69 *
70 * @since 1.0.0
71 *
72 * @access private
73 * @var array
74 */
75 private $_modules = array();
76
77 /**
78 * Private constructor.
79 *
80 * @since 1.0.0
81 *
82 * @access private
83 */
84 private function __construct() {}
85
86 /**
87 * Private clone method.
88 *
89 * @since 1.0.0
90 *
91 * @access private
92 */
93 private function __clone() {}
94
95 /**
96 * Returns singletone instance of the plugin.
97 *
98 * @since 1.0.0
99 *
100 * @static
101 * @access public
102 * @return Visualizer_Plugin
103 */
104 public static function instance() {
105 if ( is_null( self::$_instance ) ) {
106 self::$_instance = new Visualizer_Plugin();
107 }
108
109 return self::$_instance;
110 }
111
112 /**
113 * Returns a module if it was registered before. Otherwise NULL.
114 *
115 * @since 1.0.0
116 *
117 * @access public
118 * @param string $name The name of the module to return.
119 * @return Visualizer_Module|null Returns a module if it was registered or NULL.
120 */
121 public function getModule( $name ) {
122 return isset( $this->_modules[$name] ) ? $this->_modules[$name] : null;
123 }
124
125 /**
126 * Determines whether the module has been registered or not.
127 *
128 * @since 1.0.0
129 *
130 * @access public
131 * @param string $name The name of a module to check.
132 * @return boolean TRUE if the module has been registered. Otherwise FALSE.
133 */
134 public function hasModule( $name ) {
135 return isset( $this->_modules[$name] );
136 }
137
138 /**
139 * Register new module in the plugin.
140 *
141 * @since 1.0.0
142 *
143 * @access public
144 * @param string $module The name of the module to use in the plugin.
145 */
146 public function setModule( $class ) {
147 $this->_modules[$class] = new $class( $this );
148 }
149
150 /**
151 * Returns chart types.
152 *
153 * @since 1.0.0
154 *
155 * @static
156 * @access public
157 * @return array
158 */
159 public static function getChartTypes() {
160 return array( 'line', 'area', 'bar', 'column', 'pie', 'geo', 'scatter', 'candlestick', 'gauge' );
161 }
162
163 }