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

248 lines 7.5 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.7.11';
32
33 // custom post types
34 const CPT_VISUALIZER = 'visualizer';
35
36 // custom meta fields
37 const CF_CHART_IMAGE = 'visualizer-chart-image';
38 const CF_CHART_TYPE = 'visualizer-chart-type';
39 const CF_SOURCE = 'visualizer-source';
40 const CF_SERIES = 'visualizer-series';
41 const CF_DEFAULT_DATA = 'visualizer-default-data';
42 const CF_SETTINGS = 'visualizer-settings';
43 const CF_CHART_LIBRARY = 'visualizer-chart-library';
44 const CF_ERROR = 'visualizer-error';
45 const CF_REMOTE_DB_PARAMS = 'visualizer-remote-db-params';
46
47 const CF_SOURCE_FILTER = 'visualizer-source-filter';
48 const CF_FILTER_CONFIG = 'visualizer-filter-config';
49 const CF_EDITABLE_TABLE = 'visualizer-editable-table';
50
51 // custom actions
52 const ACTION_GET_CHARTS = 'visualizer-get-charts';
53 const ACTION_CREATE_CHART = 'visualizer-create-chart';
54 const ACTION_EDIT_CHART = 'visualizer-edit-chart';
55 const ACTION_CLONE_CHART = 'visualizer-clone-chart';
56 const ACTION_DELETE_CHART = 'visualizer-delete-chart';
57 const ACTION_UPLOAD_DATA = 'visualizer-upload-data';
58 const ACTION_EXPORT_DATA = 'visualizer-export-data';
59
60 /**
61 *Action used for fetching specific users/roles for permissions.
62 */
63 const ACTION_FETCH_PERMISSIONS_DATA = 'visualizer-fetch-permissions-data';
64
65 /**
66 *Action used for fetching db import data.
67 */
68 const ACTION_FETCH_DB_DATA = 'visualizer-fetch-db-data';
69 const ACTION_SAVE_DB_QUERY = 'visualizer-save-db-query';
70
71 const ACTION_JSON_GET_ROOTS = 'visualizer-json-get-roots';
72 const ACTION_JSON_GET_DATA = 'visualizer-json-get-data';
73 const ACTION_JSON_SET_DATA = 'visualizer-json-set-data';
74 const ACTION_JSON_SET_SCHEDULE = 'visualizer-json-set-schedule';
75 const CF_JSON_URL = 'visualizer-json-url';
76 const CF_JSON_ROOT = 'visualizer-json-root';
77 const CF_JSON_SCHEDULE = 'visualizer-json-schedule';
78 const CF_JSON_PAGING = 'visualizer-json-paging';
79 const CF_JSON_HEADERS = 'visualizer-json-headers';
80 const CF_EDITOR = 'visualizer-editor';
81
82 const ACTION_SAVE_FILTER_QUERY = 'visualizer-save-filter-query';
83
84 // custom filters
85 const FILTER_CHART_WRAPPER_CLASS = 'visualizer-chart-wrapper-class';
86 const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series';
87 const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data';
88 const FILTER_GET_CHART_SETTINGS = 'visualizer-get-chart-settings';
89 const FILTER_UNDO_REVISIONS = 'visualizer-undo-revisions';
90 const FILTER_HANDLE_REVISIONS = 'visualizer-handle-revisions';
91 const FILTER_GET_CHART_DATA_AS = 'visualizer-get-chart-data-as';
92 const FILTER_HANDLE_CACHE_EXPIRATION_TIME = 'visualizer-handle-expiration-time';
93 const FILTER_CHART_TITLE = 'the_title';
94
95 const CF_DB_SCHEDULE = 'visualizer-db-schedule';
96 const CF_DB_QUERY = 'visualizer-db-query';
97
98 const CF_CHART_URL = 'visualizer-chart-url';
99 const CF_CHART_SCHEDULE = 'visualizer-chart-schedule';
100 // Added by Ash/Upwork
101 const PRO_TEASER_URL = 'https://themeisle.com/plugins/visualizer-charts-and-graphs/upgrade/#pricing';
102 const PRO_TEASER_TITLE = 'Check PRO version ';
103
104 const CF_CHART_CACHE = 'visualizer-chart-cache';
105
106 /**
107 * Name of the option for WordPress DB.
108 */
109 const WP_DB_NAME = 'WordPress DB';
110
111 // Added by Ash/Upwork
112 /**
113 * Singletone instance of the plugin.
114 *
115 * @since 1.0.0
116 *
117 * @access private
118 * @var Visualizer_Plugin
119 */
120 private static $_instance = null;
121
122 /**
123 * The array of registered modules.
124 *
125 * @since 1.0.0
126 *
127 * @access private
128 * @var array
129 */
130 private $_modules = array();
131
132 /**
133 * Returns the date queries supported in the library date filter.
134 */
135 public static function getSupportedDateFilter() {
136 return apply_filters( 'visualizer_filter_by_date', array( '' => __( 'All dates', 'visualizer' ), 'yesterday' => __( 'Yesterday', 'visualizer' ), 'last week' => __( 'Last Week', 'visualizer' ), 'last month' => __( 'Last Month', 'visualizer' ), 'last year' => __( 'Last Year', 'visualizer' ) ) );
137 }
138
139 /**
140 * Private constructor.
141 *
142 * @since 1.0.0
143 *
144 * @access private
145 */
146 private function __construct() {
147 if ( VISUALIZER_DEBUG ) {
148 add_action( 'themeisle_log_event', array( $this, 'themeisle_log_event_debug' ), 10, 5 );
149 }
150 }
151
152 /**
153 * Returns singletone instance of the plugin.
154 *
155 * @since 1.0.0
156 *
157 * @static
158 * @access public
159 * @return Visualizer_Plugin
160 */
161 public static function instance() {
162 if ( is_null( self::$_instance ) ) {
163 self::$_instance = new Visualizer_Plugin();
164 }
165
166 return self::$_instance;
167 }
168
169 /**
170 * Returns chart types.
171 *
172 * @since 1.0.0
173 *
174 * @static
175 * @access public
176 * @return array
177 */
178 public static function getChartTypes() {
179 $array = array_keys( Visualizer_Module_Admin::_getChartTypesLocalized() );
180
181 return $array;
182 }
183
184 /**
185 * Returns a module if it was registered before. Otherwise NULL.
186 *
187 * @since 1.0.0
188 *
189 * @access public
190 *
191 * @param string $name The name of the module to return.
192 *
193 * @return Visualizer_Module|null Returns a module if it was registered or NULL.
194 */
195 public function getModule( $name ) {
196 return isset( $this->_modules[ $name ] ) ? $this->_modules[ $name ] : null;
197 }
198
199 /**
200 * Determines whether the module has been registered or not.
201 *
202 * @since 1.0.0
203 *
204 * @access public
205 *
206 * @param string $name The name of a module to check.
207 *
208 * @return boolean TRUE if the module has been registered. Otherwise FALSE.
209 */
210 public function hasModule( $name ) {
211 return isset( $this->_modules[ $name ] );
212 }
213
214 /**
215 * Register new module in the plugin.
216 *
217 * @since 1.0.0
218 *
219 * @access public
220 *
221 * @param string $class The name of the module to use in the plugin.
222 */
223 public function setModule( $class ) {
224 $this->_modules[ $class ] = new $class( $this );
225 }
226
227 /**
228 * Private clone method.
229 *
230 * @since 1.0.0
231 *
232 * @access private
233 */
234 private function __clone() {
235 }
236
237 /**
238 * For local testing, overrides the 'themeisle_log_event' hook and redirects to error.log.
239 */
240 final function themeisle_log_event_debug( $name, $message, $type, $file, $line ) {
241 if ( Visualizer_Plugin::NAME !== $name ) {
242 return;
243 }
244 error_log( sprintf( '%s (%s): %s in %s:%s', $name, $type, $message, $file, $line ) );
245 }
246
247 }
248