| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | // +----------------------------------------------------------------------+ |
| 3 | 4 | // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) | |
| 4 | 5 | // +----------------------------------------------------------------------+ |
| 5 | 6 | // | This program is free software; you can redistribute it and/or modify | |
| @@ -17,8 +18,9 @@ | ||
| 17 | 18 | // | MA 02110-1301 USA | |
| 18 | 19 | // +----------------------------------------------------------------------+ |
| 19 | 20 | // | Author: Eugene Manuilov <eugene@manuilov.org> | |
| 20 | 21 | // +----------------------------------------------------------------------+ |
| 22 | + | |
| 21 | 23 | /** |
| 22 | 24 | * The core plugin class. |
| 23 | 25 | * |
| 24 | 26 | * @category Visualizer |
| @@ -26,93 +28,35 @@ | ||
| 26 | 28 | * @since 1.0.0 |
| 27 | 29 | */ |
| 28 | 30 | class Visualizer_Plugin { |
| 29 | 31 | |
| 30 | - const NAME = 'visualizer'; | |
| 31 | - const VERSION = '3.10.14'; | |
| 32 | + const NAME = 'visualizer'; | |
| 33 | + const VERSION = '1.4.2.2'; | |
| 32 | 34 | |
| 33 | 35 | // custom post types |
| 34 | 36 | const CPT_VISUALIZER = 'visualizer'; |
| 35 | 37 | |
| 36 | 38 | // 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'; | |
| 39 | + const CF_CHART_TYPE = 'visualizer-chart-type'; | |
| 40 | + const CF_SOURCE = 'visualizer-source'; | |
| 41 | + const CF_SERIES = 'visualizer-series'; | |
| 41 | 42 | 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'; | |
| 43 | + const CF_SETTINGS = 'visualizer-settings'; | |
| 46 | 44 | |
| 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 | 45 | // custom actions |
| 52 | - const ACTION_GET_CHARTS = 'visualizer-get-charts'; | |
| 46 | + const ACTION_GET_CHARTS = 'visualizer-get-charts'; | |
| 53 | 47 | const ACTION_CREATE_CHART = 'visualizer-create-chart'; |
| 54 | - const ACTION_EDIT_CHART = 'visualizer-edit-chart'; | |
| 55 | - const ACTION_CLONE_CHART = 'visualizer-clone-chart'; | |
| 48 | + const ACTION_EDIT_CHART = 'visualizer-edit-chart'; | |
| 49 | + const ACTION_CLONE_CHART = 'visualizer-clone-chart'; | |
| 56 | 50 | const ACTION_DELETE_CHART = 'visualizer-delete-chart'; |
| 57 | - const ACTION_UPLOAD_DATA = 'visualizer-upload-data'; | |
| 58 | - const ACTION_EXPORT_DATA = 'visualizer-export-data'; | |
| 51 | + const ACTION_UPLOAD_DATA = 'visualizer-upload-data'; | |
| 59 | 52 | |
| 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 | 53 | // custom filters |
| 85 | 54 | 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'; | |
| 55 | + const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series'; | |
| 56 | + const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data'; | |
| 94 | 57 | |
| 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/'; | |
| 102 | - const PRO_TEASER_TITLE = 'Check PRO version '; | |
| 103 | - | |
| 104 | - const CF_CHART_CACHE = 'visualizer-chart-cache'; | |
| 105 | - const CF_JSON_WOOCOMMERCE_SOURCE = 'visualizer-woocommerce-source'; | |
| 106 | - const CF_IS_WOOCOMMERCE_SOURCE = 'visualizer-is-woocommerce-source'; | |
| 107 | - | |
| 108 | 58 | /** |
| 109 | - * Name of the option for WordPress DB. | |
| 110 | - */ | |
| 111 | - const WP_DB_NAME = 'WordPress DB'; | |
| 112 | - | |
| 113 | - // Added by Ash/Upwork | |
| 114 | - /** | |
| 115 | 59 | * Singletone instance of the plugin. |
| 116 | 60 | * |
| 117 | 61 | * @since 1.0.0 |
| 118 | 62 | * |
| @@ -131,26 +75,24 @@ | ||
| 131 | 75 | */ |
| 132 | 76 | private $_modules = array(); |
| 133 | 77 | |
| 134 | 78 | /** |
| 135 | - * Returns the date queries supported in the library date filter. | |
| 79 | + * Private constructor. | |
| 80 | + * | |
| 81 | + * @since 1.0.0 | |
| 82 | + * | |
| 83 | + * @access private | |
| 136 | 84 | */ |
| 137 | - public static function getSupportedDateFilter() { | |
| 138 | - 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' ) ) ); | |
| 139 | - } | |
| 85 | + private function __construct() {} | |
| 140 | 86 | |
| 141 | 87 | /** |
| 142 | - * Private constructor. | |
| 88 | + * Private clone method. | |
| 143 | 89 | * |
| 144 | 90 | * @since 1.0.0 |
| 145 | 91 | * |
| 146 | 92 | * @access private |
| 147 | 93 | */ |
| 148 | - private function __construct() { | |
| 149 | - if ( VISUALIZER_DEBUG ) { | |
| 150 | - add_action( 'themeisle_log_event', array( $this, 'themeisle_log_event_debug' ), 10, 5 ); | |
| 151 | - } | |
| 152 | - } | |
| 94 | + private function __clone() {} | |
| 153 | 95 | |
| 154 | 96 | /** |
| 155 | 97 | * Returns singletone instance of the plugin. |
| 156 | 98 | * |
| @@ -168,35 +110,18 @@ | ||
| 168 | 110 | return self::$_instance; |
| 169 | 111 | } |
| 170 | 112 | |
| 171 | 113 | /** |
| 172 | - * Returns chart types. | |
| 173 | - * | |
| 174 | - * @since 1.0.0 | |
| 175 | - * | |
| 176 | - * @static | |
| 177 | - * @access public | |
| 178 | - * @return array | |
| 179 | - */ | |
| 180 | - public static function getChartTypes() { | |
| 181 | - $array = array_keys( Visualizer_Module_Admin::_getChartTypesLocalized() ); | |
| 182 | - | |
| 183 | - return $array; | |
| 184 | - } | |
| 185 | - | |
| 186 | - /** | |
| 187 | 114 | * Returns a module if it was registered before. Otherwise NULL. |
| 188 | 115 | * |
| 189 | 116 | * @since 1.0.0 |
| 190 | 117 | * |
| 191 | 118 | * @access public |
| 192 | - * | |
| 193 | 119 | * @param string $name The name of the module to return. |
| 194 | - * | |
| 195 | 120 | * @return Visualizer_Module|null Returns a module if it was registered or NULL. |
| 196 | 121 | */ |
| 197 | 122 | public function getModule( $name ) { |
| 198 | - return isset( $this->_modules[ $name ] ) ? $this->_modules[ $name ] : null; | |
| 123 | + return isset( $this->_modules[$name] ) ? $this->_modules[$name] : null; | |
| 199 | 124 | } |
| 200 | 125 | |
| 201 | 126 | /** |
| 202 | 127 | * Determines whether the module has been registered or not. |
| @@ -203,15 +128,13 @@ | ||
| 203 | 128 | * |
| 204 | 129 | * @since 1.0.0 |
| 205 | 130 | * |
| 206 | 131 | * @access public |
| 207 | - * | |
| 208 | 132 | * @param string $name The name of a module to check. |
| 209 | - * | |
| 210 | 133 | * @return boolean TRUE if the module has been registered. Otherwise FALSE. |
| 211 | 134 | */ |
| 212 | 135 | public function hasModule( $name ) { |
| 213 | - return isset( $this->_modules[ $name ] ); | |
| 136 | + return isset( $this->_modules[$name] ); | |
| 214 | 137 | } |
| 215 | 138 | |
| 216 | 139 | /** |
| 217 | 140 | * Register new module in the plugin. |
| @@ -218,32 +141,24 @@ | ||
| 218 | 141 | * |
| 219 | 142 | * @since 1.0.0 |
| 220 | 143 | * |
| 221 | 144 | * @access public |
| 222 | - * | |
| 223 | - * @param string $class The name of the module to use in the plugin. | |
| 145 | + * @param string $module The name of the module to use in the plugin. | |
| 224 | 146 | */ |
| 225 | 147 | public function setModule( $class ) { |
| 226 | - $this->_modules[ $class ] = new $class( $this ); | |
| 148 | + $this->_modules[$class] = new $class( $this ); | |
| 227 | 149 | } |
| 228 | 150 | |
| 229 | 151 | /** |
| 230 | - * Private clone method. | |
| 152 | + * Returns chart types. | |
| 231 | 153 | * |
| 232 | 154 | * @since 1.0.0 |
| 233 | 155 | * |
| 234 | - * @access private | |
| 156 | + * @static | |
| 157 | + * @access public | |
| 158 | + * @return array | |
| 235 | 159 | */ |
| 236 | - private function __clone() { | |
| 160 | + public static function getChartTypes() { | |
| 161 | + return array( 'line', 'area', 'bar', 'column', 'pie', 'geo', 'scatter', 'candlestick', 'gauge' ); | |
| 237 | 162 | } |
| 238 | 163 | |
| 239 | - /** | |
| 240 | - * For local testing, overrides the 'themeisle_log_event' hook and redirects to error.log. | |
| 241 | - */ | |
| 242 | - final function themeisle_log_event_debug( $name, $message, $type, $file, $line ) { | |
| 243 | - if ( Visualizer_Plugin::NAME !== $name ) { | |
| 244 | - return; | |
| 245 | - } | |
| 246 | - error_log( sprintf( '%s (%s): %s in %s:%s', $name, $type, $message, $file, $line ) ); | |
| 247 | - } | |
| 248 | - | |
| 249 | -} | |
| 164 | +} | |