PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.3.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.3.4
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 3.3.4, at classes/Visualizer/Plugin.php

225 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // +----------------------------------------------------------------------+
3 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
4 // +----------------------------------------------------------------------+
5 // | This program is free software; you can redistribute it and/or modify |
6 // | it under the terms of the GNU General Public License, version 2, as |
7 // | published by the Free Software Foundation. |
8 // | |
9 // | This program is distributed in the hope that it will be useful, |
10 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 // | GNU General Public License for more details. |
13 // | |
14 // | You should have received a copy of the GNU General Public License |
15 // | along with this program; if not, write to the Free Software |
16 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
17 // | MA 02110-1301 USA |
18 // +----------------------------------------------------------------------+
19 // | Author: Eugene Manuilov <eugene@manuilov.org> |
20 // +----------------------------------------------------------------------+
21 /**
22 * The core plugin class.
23 *
24 * @category Visualizer
25 *
26 * @since 1.0.0
27 */
28 class Visualizer_Plugin {
29
30 const NAME = 'visualizer';
31 const VERSION = '3.3.4';
32
33 // custom post types
34 const CPT_VISUALIZER = 'visualizer';
35
36 // custom meta fields
37 const CF_CHART_TYPE = 'visualizer-chart-type';
38 const CF_SOURCE = 'visualizer-source';
39 const CF_SERIES = 'visualizer-series';
40 const CF_DEFAULT_DATA = 'visualizer-default-data';
41 const CF_SETTINGS = 'visualizer-settings';
42 const CF_CHART_LIBRARY = 'visualizer-chart-library';
43
44 const CF_SOURCE_FILTER = 'visualizer-source-filter';
45 const CF_FILTER_CONFIG = 'visualizer-filter-config';
46
47 // custom actions
48 const ACTION_GET_CHARTS = 'visualizer-get-charts';
49 const ACTION_CREATE_CHART = 'visualizer-create-chart';
50 const ACTION_EDIT_CHART = 'visualizer-edit-chart';
51 const ACTION_CLONE_CHART = 'visualizer-clone-chart';
52 const ACTION_DELETE_CHART = 'visualizer-delete-chart';
53 const ACTION_UPLOAD_DATA = 'visualizer-upload-data';
54 const ACTION_EXPORT_DATA = 'visualizer-export-data';
55
56 /**
57 *Action used for fetching specific users/roles for permissions.
58 */
59 const ACTION_FETCH_PERMISSIONS_DATA = 'visualizer-fetch-permissions-data';
60
61 /**
62 *Action used for fetching db import data.
63 */
64 const ACTION_FETCH_DB_DATA = 'visualizer-fetch-db-data';
65 const ACTION_SAVE_DB_QUERY = 'visualizer-save-db-query';
66
67 const ACTION_JSON_GET_ROOTS = 'visualizer-json-get-roots';
68 const ACTION_JSON_GET_DATA = 'visualizer-json-get-data';
69 const ACTION_JSON_SET_DATA = 'visualizer-json-set-data';
70 const ACTION_JSON_SET_SCHEDULE = 'visualizer-json-set-schedule';
71 const CF_JSON_URL = 'visualizer-json-url';
72 const CF_JSON_ROOT = 'visualizer-json-root';
73 const CF_JSON_SCHEDULE = 'visualizer-json-schedule';
74 const CF_JSON_PAGING = 'visualizer-json-paging';
75
76 const ACTION_SAVE_FILTER_QUERY = 'visualizer-save-filter-query';
77
78 // custom filters
79 const FILTER_CHART_WRAPPER_CLASS = 'visualizer-chart-wrapper-class';
80 const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series';
81 const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data';
82 const FILTER_GET_CHART_SETTINGS = 'visualizer-get-chart-settings';
83 const FILTER_UNDO_REVISIONS = 'visualizer-undo-revisions';
84 const FILTER_HANDLE_REVISIONS = 'visualizer-handle-revisions';
85 const FILTER_GET_CHART_DATA_AS = 'visualizer-get-chart-data-as';
86
87 const CF_DB_SCHEDULE = 'visualizer-db-schedule';
88 const CF_DB_QUERY = 'visualizer-db-query';
89
90 const CF_CHART_URL = 'visualizer-chart-url';
91 const CF_CHART_SCHEDULE = 'visualizer-chart-schedule';
92 // Added by Ash/Upwork
93 const PRO_TEASER_URL = 'https://themeisle.com/plugins/visualizer-charts-and-graphs/upgrade/#pricing';
94 const PRO_TEASER_TITLE = 'Check PRO version ';
95 // Added by Ash/Upwork
96 /**
97 * Singletone instance of the plugin.
98 *
99 * @since 1.0.0
100 *
101 * @access private
102 * @var Visualizer_Plugin
103 */
104 private static $_instance = null;
105
106 /**
107 * The array of registered modules.
108 *
109 * @since 1.0.0
110 *
111 * @access private
112 * @var array
113 */
114 private $_modules = array();
115
116 /**
117 * Private constructor.
118 *
119 * @since 1.0.0
120 *
121 * @access private
122 */
123 private function __construct() {
124 if ( VISUALIZER_DEBUG ) {
125 add_action( 'themeisle_log_event', array( $this, 'themeisle_log_event_debug' ), 10, 5 );
126 }
127 }
128
129 /**
130 * Returns singletone instance of the plugin.
131 *
132 * @since 1.0.0
133 *
134 * @static
135 * @access public
136 * @return Visualizer_Plugin
137 */
138 public static function instance() {
139 if ( is_null( self::$_instance ) ) {
140 self::$_instance = new Visualizer_Plugin();
141 }
142
143 return self::$_instance;
144 }
145
146 /**
147 * Returns chart types.
148 *
149 * @since 1.0.0
150 *
151 * @static
152 * @access public
153 * @return array
154 */
155 public static function getChartTypes() {
156 $array = array_keys( Visualizer_Module_Admin::_getChartTypesLocalized() );
157
158 return $array;
159 }
160
161 /**
162 * Returns a module if it was registered before. Otherwise NULL.
163 *
164 * @since 1.0.0
165 *
166 * @access public
167 *
168 * @param string $name The name of the module to return.
169 *
170 * @return Visualizer_Module|null Returns a module if it was registered or NULL.
171 */
172 public function getModule( $name ) {
173 return isset( $this->_modules[ $name ] ) ? $this->_modules[ $name ] : null;
174 }
175
176 /**
177 * Determines whether the module has been registered or not.
178 *
179 * @since 1.0.0
180 *
181 * @access public
182 *
183 * @param string $name The name of a module to check.
184 *
185 * @return boolean TRUE if the module has been registered. Otherwise FALSE.
186 */
187 public function hasModule( $name ) {
188 return isset( $this->_modules[ $name ] );
189 }
190
191 /**
192 * Register new module in the plugin.
193 *
194 * @since 1.0.0
195 *
196 * @access public
197 *
198 * @param string $class The name of the module to use in the plugin.
199 */
200 public function setModule( $class ) {
201 $this->_modules[ $class ] = new $class( $this );
202 }
203
204 /**
205 * Private clone method.
206 *
207 * @since 1.0.0
208 *
209 * @access private
210 */
211 private function __clone() {
212 }
213
214 /**
215 * For local testing, overrides the 'themeisle_log_event' hook and redirects to error.log.
216 */
217 final function themeisle_log_event_debug( $name, $message, $type, $file, $line ) {
218 if ( Visualizer_Plugin::NAME !== $name ) {
219 return;
220 }
221 error_log( sprintf( '%s (%s): %s in %s:%s', $name, $type, $message, $file, $line ) );
222 }
223
224 }
225