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

203 lines 5.7 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.0.10';
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
43 const CF_SOURCE_FILTER = 'visualizer-source-filter';
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 // Added by Ash/Upwork
53 const ACTION_EXPORT_DATA = 'visualizer-export-data';
54
55 /**
56 *Action used for fetching specific users/roles for permissions.
57 */
58 const ACTION_FETCH_PERMISSIONS_DATA = 'visualizer-fetch-permissions-data';
59
60 // custom filters
61 const FILTER_CHART_WRAPPER_CLASS = 'visualizer-chart-wrapper-class';
62 const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series';
63 const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data';
64 const FILTER_GET_CHART_SETTINGS = 'visualizer-get-chart-settings';
65 const FILTER_UNDO_REVISIONS = 'visualizer-undo-revisions';
66 const FILTER_HANDLE_REVISIONS = 'visualizer-handle-revisions';
67
68 const CF_CHART_URL = 'visualizer-chart-url';
69 const CF_CHART_SCHEDULE = 'visualizer-chart-schedule';
70 // Added by Ash/Upwork
71 const PRO_TEASER_URL = 'http://themeisle.com/plugins/visualizer-charts-and-graphs-pro-addon/';
72 const PRO_TEASER_TITLE = 'Check PRO version ';
73 // Added by Ash/Upwork
74 /**
75 * Singletone instance of the plugin.
76 *
77 * @since 1.0.0
78 *
79 * @access private
80 * @var Visualizer_Plugin
81 */
82 private static $_instance = null;
83
84 /**
85 * The array of registered modules.
86 *
87 * @since 1.0.0
88 *
89 * @access private
90 * @var array
91 */
92 private $_modules = array();
93
94 /**
95 * Private constructor.
96 *
97 * @since 1.0.0
98 *
99 * @access private
100 */
101 private function __construct() {
102 if ( VISUALIZER_DEBUG ) {
103 add_action( 'themeisle_log_event', array( $this, 'themeisle_log_event_debug' ), 10, 5 );
104 }
105 }
106
107 /**
108 * Returns singletone instance of the plugin.
109 *
110 * @since 1.0.0
111 *
112 * @static
113 * @access public
114 * @return Visualizer_Plugin
115 */
116 public static function instance() {
117 if ( is_null( self::$_instance ) ) {
118 self::$_instance = new Visualizer_Plugin();
119 }
120
121 return self::$_instance;
122 }
123
124 /**
125 * Returns chart types.
126 *
127 * @since 1.0.0
128 *
129 * @static
130 * @access public
131 * @return array
132 */
133 public static function getChartTypes() {
134 $array = array_keys( Visualizer_Module_Admin::_getChartTypesLocalized() );
135
136 return $array;
137 }
138
139 /**
140 * Returns a module if it was registered before. Otherwise NULL.
141 *
142 * @since 1.0.0
143 *
144 * @access public
145 *
146 * @param string $name The name of the module to return.
147 *
148 * @return Visualizer_Module|null Returns a module if it was registered or NULL.
149 */
150 public function getModule( $name ) {
151 return isset( $this->_modules[ $name ] ) ? $this->_modules[ $name ] : null;
152 }
153
154 /**
155 * Determines whether the module has been registered or not.
156 *
157 * @since 1.0.0
158 *
159 * @access public
160 *
161 * @param string $name The name of a module to check.
162 *
163 * @return boolean TRUE if the module has been registered. Otherwise FALSE.
164 */
165 public function hasModule( $name ) {
166 return isset( $this->_modules[ $name ] );
167 }
168
169 /**
170 * Register new module in the plugin.
171 *
172 * @since 1.0.0
173 *
174 * @access public
175 *
176 * @param string $class The name of the module to use in the plugin.
177 */
178 public function setModule( $class ) {
179 $this->_modules[ $class ] = new $class( $this );
180 }
181
182 /**
183 * Private clone method.
184 *
185 * @since 1.0.0
186 *
187 * @access private
188 */
189 private function __clone() {
190 }
191
192 /**
193 * For local testing, overrides the 'themeisle_log_event' hook and redirects to error.log.
194 */
195 final function themeisle_log_event_debug( $name, $message, $type, $file, $line ) {
196 if ( Visualizer_Plugin::NAME !== $name ) {
197 return;
198 }
199 error_log( sprintf( '%s (%s): %s in %s:%s', $name, $type, $message, $file, $line ) );
200 }
201
202 }
203