| @@ -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,62 +28,33 @@ | ||
| 26 | 28 | * @since 1.0.0 |
| 27 | 29 | */ |
| 28 | 30 | class Visualizer_Plugin { |
| 29 | 31 | |
| 30 | - const NAME = 'visualizer'; | |
| 31 | - const VERSION = '3.1.3'; | |
| 32 | + const NAME = 'visualizer'; | |
| 33 | + const VERSION = '1.1.4'; | |
| 32 | 34 | |
| 33 | 35 | // custom post types |
| 34 | 36 | const CPT_VISUALIZER = 'visualizer'; |
| 35 | 37 | |
| 36 | 38 | // custom meta fields |
| 37 | - const CF_CHART_TYPE = 'visualizer-chart-type'; | |
| 38 | - const CF_SOURCE = 'visualizer-source'; | |
| 39 | - 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'; | |
| 40 | 42 | const CF_DEFAULT_DATA = 'visualizer-default-data'; |
| 41 | - const CF_SETTINGS = 'visualizer-settings'; | |
| 43 | + const CF_SETTINGS = 'visualizer-settings'; | |
| 42 | 44 | |
| 43 | - const CF_SOURCE_FILTER = 'visualizer-source-filter'; | |
| 44 | - const CF_FILTER_CONFIG = 'visualizer-filter-config'; | |
| 45 | - | |
| 46 | 45 | // custom actions |
| 47 | - const ACTION_GET_CHARTS = 'visualizer-get-charts'; | |
| 46 | + const ACTION_GET_CHARTS = 'visualizer-get-charts'; | |
| 48 | 47 | const ACTION_CREATE_CHART = 'visualizer-create-chart'; |
| 49 | - const ACTION_EDIT_CHART = 'visualizer-edit-chart'; | |
| 50 | - const ACTION_CLONE_CHART = 'visualizer-clone-chart'; | |
| 48 | + const ACTION_EDIT_CHART = 'visualizer-edit-chart'; | |
| 49 | + const ACTION_CLONE_CHART = 'visualizer-clone-chart'; | |
| 51 | 50 | const ACTION_DELETE_CHART = 'visualizer-delete-chart'; |
| 52 | - const ACTION_UPLOAD_DATA = 'visualizer-upload-data'; | |
| 53 | - const ACTION_EXPORT_DATA = 'visualizer-export-data'; | |
| 51 | + const ACTION_UPLOAD_DATA = 'visualizer-upload-data'; | |
| 54 | 52 | |
| 55 | - /** | |
| 56 | - *Action used for fetching specific users/roles for permissions. | |
| 57 | - */ | |
| 58 | - const ACTION_FETCH_PERMISSIONS_DATA = 'visualizer-fetch-permissions-data'; | |
| 59 | - | |
| 60 | - /** | |
| 61 | - *Action used for fetching db import data. | |
| 62 | - */ | |
| 63 | - const ACTION_FETCH_DB_DATA = 'visualizer-fetch-db-data'; | |
| 64 | - const ACTION_SAVE_DB_QUERY = 'visualizer-save-db-query'; | |
| 65 | - const ACTION_SAVE_FILTER_QUERY = 'visualizer-save-filter-query'; | |
| 66 | - | |
| 67 | 53 | // custom filters |
| 68 | - const FILTER_CHART_WRAPPER_CLASS = 'visualizer-chart-wrapper-class'; | |
| 69 | 54 | const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series'; |
| 70 | - const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data'; | |
| 71 | - const FILTER_GET_CHART_SETTINGS = 'visualizer-get-chart-settings'; | |
| 72 | - const FILTER_UNDO_REVISIONS = 'visualizer-undo-revisions'; | |
| 73 | - const FILTER_HANDLE_REVISIONS = 'visualizer-handle-revisions'; | |
| 55 | + const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data'; | |
| 74 | 56 | |
| 75 | - const CF_DB_SCHEDULE = 'visualizer-db-schedule'; | |
| 76 | - const CF_DB_QUERY = 'visualizer-db-query'; | |
| 77 | - | |
| 78 | - const CF_CHART_URL = 'visualizer-chart-url'; | |
| 79 | - const CF_CHART_SCHEDULE = 'visualizer-chart-schedule'; | |
| 80 | - // Added by Ash/Upwork | |
| 81 | - const PRO_TEASER_URL = 'http://themeisle.com/plugins/visualizer-charts-and-graphs-pro-addon/'; | |
| 82 | - const PRO_TEASER_TITLE = 'Check PRO version '; | |
| 83 | - // Added by Ash/Upwork | |
| 84 | 57 | /** |
| 85 | 58 | * Singletone instance of the plugin. |
| 86 | 59 | * |
| 87 | 60 | * @since 1.0.0 |
| @@ -107,15 +80,20 @@ | ||
| 107 | 80 | * @since 1.0.0 |
| 108 | 81 | * |
| 109 | 82 | * @access private |
| 110 | 83 | */ |
| 111 | - private function __construct() { | |
| 112 | - if ( VISUALIZER_DEBUG ) { | |
| 113 | - add_action( 'themeisle_log_event', array( $this, 'themeisle_log_event_debug' ), 10, 5 ); | |
| 114 | - } | |
| 115 | - } | |
| 84 | + private function __construct() {} | |
| 116 | 85 | |
| 117 | 86 | /** |
| 87 | + * Private clone method. | |
| 88 | + * | |
| 89 | + * @since 1.0.0 | |
| 90 | + * | |
| 91 | + * @access private | |
| 92 | + */ | |
| 93 | + private function __clone() {} | |
| 94 | + | |
| 95 | + /** | |
| 118 | 96 | * Returns singletone instance of the plugin. |
| 119 | 97 | * |
| 120 | 98 | * @since 1.0.0 |
| 121 | 99 | * |
| @@ -131,35 +109,18 @@ | ||
| 131 | 109 | return self::$_instance; |
| 132 | 110 | } |
| 133 | 111 | |
| 134 | 112 | /** |
| 135 | - * Returns chart types. | |
| 136 | - * | |
| 137 | - * @since 1.0.0 | |
| 138 | - * | |
| 139 | - * @static | |
| 140 | - * @access public | |
| 141 | - * @return array | |
| 142 | - */ | |
| 143 | - public static function getChartTypes() { | |
| 144 | - $array = array_keys( Visualizer_Module_Admin::_getChartTypesLocalized() ); | |
| 145 | - | |
| 146 | - return $array; | |
| 147 | - } | |
| 148 | - | |
| 149 | - /** | |
| 150 | 113 | * Returns a module if it was registered before. Otherwise NULL. |
| 151 | 114 | * |
| 152 | 115 | * @since 1.0.0 |
| 153 | 116 | * |
| 154 | 117 | * @access public |
| 155 | - * | |
| 156 | 118 | * @param string $name The name of the module to return. |
| 157 | - * | |
| 158 | 119 | * @return Visualizer_Module|null Returns a module if it was registered or NULL. |
| 159 | 120 | */ |
| 160 | 121 | public function getModule( $name ) { |
| 161 | - return isset( $this->_modules[ $name ] ) ? $this->_modules[ $name ] : null; | |
| 122 | + return isset( $this->_modules[$name] ) ? $this->_modules[$name] : null; | |
| 162 | 123 | } |
| 163 | 124 | |
| 164 | 125 | /** |
| 165 | 126 | * Determines whether the module has been registered or not. |
| @@ -166,15 +127,13 @@ | ||
| 166 | 127 | * |
| 167 | 128 | * @since 1.0.0 |
| 168 | 129 | * |
| 169 | 130 | * @access public |
| 170 | - * | |
| 171 | 131 | * @param string $name The name of a module to check. |
| 172 | - * | |
| 173 | 132 | * @return boolean TRUE if the module has been registered. Otherwise FALSE. |
| 174 | 133 | */ |
| 175 | 134 | public function hasModule( $name ) { |
| 176 | - return isset( $this->_modules[ $name ] ); | |
| 135 | + return isset( $this->_modules[$name] ); | |
| 177 | 136 | } |
| 178 | 137 | |
| 179 | 138 | /** |
| 180 | 139 | * Register new module in the plugin. |
| @@ -181,32 +140,24 @@ | ||
| 181 | 140 | * |
| 182 | 141 | * @since 1.0.0 |
| 183 | 142 | * |
| 184 | 143 | * @access public |
| 185 | - * | |
| 186 | - * @param string $class The name of the module to use in the plugin. | |
| 144 | + * @param string $module The name of the module to use in the plugin. | |
| 187 | 145 | */ |
| 188 | 146 | public function setModule( $class ) { |
| 189 | - $this->_modules[ $class ] = new $class( $this ); | |
| 147 | + $this->_modules[$class] = new $class( $this ); | |
| 190 | 148 | } |
| 191 | 149 | |
| 192 | 150 | /** |
| 193 | - * Private clone method. | |
| 151 | + * Returns chart types. | |
| 194 | 152 | * |
| 195 | 153 | * @since 1.0.0 |
| 196 | 154 | * |
| 197 | - * @access private | |
| 155 | + * @static | |
| 156 | + * @access public | |
| 157 | + * @return array | |
| 198 | 158 | */ |
| 199 | - private function __clone() { | |
| 159 | + public static function getChartTypes() { | |
| 160 | + return array( 'line', 'area', 'bar', 'column', 'pie', 'geo', 'scatter', 'candlestick', 'gauge' ); | |
| 200 | 161 | } |
| 201 | 162 | |
| 202 | - /** | |
| 203 | - * For local testing, overrides the 'themeisle_log_event' hook and redirects to error.log. | |
| 204 | - */ | |
| 205 | - final function themeisle_log_event_debug( $name, $message, $type, $file, $line ) { | |
| 206 | - if ( Visualizer_Plugin::NAME !== $name ) { | |
| 207 | - return; | |
| 208 | - } | |
| 209 | - error_log( sprintf( '%s (%s): %s in %s:%s', $name, $type, $message, $file, $line ) ); | |
| 210 | - } | |
| 211 | - | |
| 212 | -} | |
| 163 | +} | |