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

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