| @@ -1,170 +1,172 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -// +----------------------------------------------------------------------+ | |
| 4 | -// | Copyright 2013 Madpixels (email : visualizer@madpixels.net) | | |
| 5 | -// +----------------------------------------------------------------------+ | |
| 6 | -// | This program is free software; you can redistribute it and/or modify | | |
| 7 | -// | it under the terms of the GNU General Public License, version 2, as | | |
| 8 | -// | published by the Free Software Foundation. | | |
| 9 | -// | | | |
| 10 | -// | This program is distributed in the hope that it will be useful, | | |
| 11 | -// | but WITHOUT ANY WARRANTY; without even the implied warranty of | | |
| 12 | -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | |
| 13 | -// | GNU General Public License for more details. | | |
| 14 | -// | | | |
| 15 | -// | You should have received a copy of the GNU General Public License | | |
| 16 | -// | along with this program; if not, write to the Free Software | | |
| 17 | -// | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, | | |
| 18 | -// | MA 02110-1301 USA | | |
| 19 | -// +----------------------------------------------------------------------+ | |
| 20 | -// | Author: Eugene Manuilov <eugene@manuilov.org> | | |
| 21 | -// +----------------------------------------------------------------------+ | |
| 22 | - | |
| 23 | -/** | |
| 24 | - * The core plugin class. | |
| 25 | - * | |
| 26 | - * @category Visualizer | |
| 27 | - * | |
| 28 | - * @since 1.0.0 | |
| 29 | - */ | |
| 30 | -class Visualizer_Plugin { | |
| 31 | - | |
| 32 | - const NAME = 'visualizer'; | |
| 33 | - const VERSION = '1.5.2'; | |
| 34 | - | |
| 35 | - // custom post types | |
| 36 | - const CPT_VISUALIZER = 'visualizer'; | |
| 37 | - | |
| 38 | - // custom meta fields | |
| 39 | - const CF_CHART_TYPE = 'visualizer-chart-type'; | |
| 40 | - const CF_SOURCE = 'visualizer-source'; | |
| 41 | - const CF_SERIES = 'visualizer-series'; | |
| 42 | - const CF_DEFAULT_DATA = 'visualizer-default-data'; | |
| 43 | - const CF_SETTINGS = 'visualizer-settings'; | |
| 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 | - | |
| 53 | - // custom filters | |
| 54 | - const FILTER_CHART_WRAPPER_CLASS = 'visualizer-chart-wrapper-class'; | |
| 55 | - const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series'; | |
| 56 | - const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data'; | |
| 57 | - const FILTER_GET_CHART_SETTINGS = 'visualizer-get-chart-settings'; | |
| 58 | - | |
| 59 | - // Added by Ash/Upwork | |
| 60 | - const PRO_TEASER_URL = "http://themeisle.com/plugins/visualizer-charts-and-graphs-pro-addon/"; | |
| 61 | - const PRO_TEASER_TITLE = "Check PRO version "; | |
| 62 | - // Added by Ash/Upwork | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * Singletone instance of the plugin. | |
| 66 | - * | |
| 67 | - * @since 1.0.0 | |
| 68 | - * | |
| 69 | - * @access private | |
| 70 | - * @var Visualizer_Plugin | |
| 71 | - */ | |
| 72 | - private static $_instance = null; | |
| 73 | - | |
| 74 | - /** | |
| 75 | - * The array of registered modules. | |
| 76 | - * | |
| 77 | - * @since 1.0.0 | |
| 78 | - * | |
| 79 | - * @access private | |
| 80 | - * @var array | |
| 81 | - */ | |
| 82 | - private $_modules = array(); | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * Private constructor. | |
| 86 | - * | |
| 87 | - * @since 1.0.0 | |
| 88 | - * | |
| 89 | - * @access private | |
| 90 | - */ | |
| 91 | - private function __construct() {} | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Private clone method. | |
| 95 | - * | |
| 96 | - * @since 1.0.0 | |
| 97 | - * | |
| 98 | - * @access private | |
| 99 | - */ | |
| 100 | - private function __clone() {} | |
| 101 | - | |
| 102 | - /** | |
| 103 | - * Returns singletone instance of the plugin. | |
| 104 | - * | |
| 105 | - * @since 1.0.0 | |
| 106 | - * | |
| 107 | - * @static | |
| 108 | - * @access public | |
| 109 | - * @return Visualizer_Plugin | |
| 110 | - */ | |
| 111 | - public static function instance() { | |
| 112 | - if ( is_null( self::$_instance ) ) { | |
| 113 | - self::$_instance = new Visualizer_Plugin(); | |
| 114 | - } | |
| 115 | - | |
| 116 | - return self::$_instance; | |
| 117 | - } | |
| 118 | - | |
| 119 | - /** | |
| 120 | - * Returns a module if it was registered before. Otherwise NULL. | |
| 121 | - * | |
| 122 | - * @since 1.0.0 | |
| 123 | - * | |
| 124 | - * @access public | |
| 125 | - * @param string $name The name of the module to return. | |
| 126 | - * @return Visualizer_Module|null Returns a module if it was registered or NULL. | |
| 127 | - */ | |
| 128 | - public function getModule( $name ) { | |
| 129 | - return isset( $this->_modules[$name] ) ? $this->_modules[$name] : null; | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * Determines whether the module has been registered or not. | |
| 134 | - * | |
| 135 | - * @since 1.0.0 | |
| 136 | - * | |
| 137 | - * @access public | |
| 138 | - * @param string $name The name of a module to check. | |
| 139 | - * @return boolean TRUE if the module has been registered. Otherwise FALSE. | |
| 140 | - */ | |
| 141 | - public function hasModule( $name ) { | |
| 142 | - return isset( $this->_modules[$name] ); | |
| 143 | - } | |
| 144 | - | |
| 145 | - /** | |
| 146 | - * Register new module in the plugin. | |
| 147 | - * | |
| 148 | - * @since 1.0.0 | |
| 149 | - * | |
| 150 | - * @access public | |
| 151 | - * @param string $module The name of the module to use in the plugin. | |
| 152 | - */ | |
| 153 | - public function setModule( $class ) { | |
| 154 | - $this->_modules[$class] = new $class( $this ); | |
| 155 | - } | |
| 156 | - | |
| 157 | - /** | |
| 158 | - * Returns chart types. | |
| 159 | - * | |
| 160 | - * @since 1.0.0 | |
| 161 | - * | |
| 162 | - * @static | |
| 163 | - * @access public | |
| 164 | - * @return array | |
| 165 | - */ | |
| 166 | - public static function getChartTypes() { | |
| 167 | - return array( 'line', 'area', 'bar', 'column', 'pie', 'geo', 'scatter', 'candlestick', 'gauge' ); | |
| 168 | - } | |
| 169 | - | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +// +----------------------------------------------------------------------+ | |
| 4 | +// | Copyright 2013 Madpixels (email : visualizer@madpixels.net) | | |
| 5 | +// +----------------------------------------------------------------------+ | |
| 6 | +// | This program is free software; you can redistribute it and/or modify | | |
| 7 | +// | it under the terms of the GNU General Public License, version 2, as | | |
| 8 | +// | published by the Free Software Foundation. | | |
| 9 | +// | | | |
| 10 | +// | This program is distributed in the hope that it will be useful, | | |
| 11 | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | | |
| 12 | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | |
| 13 | +// | GNU General Public License for more details. | | |
| 14 | +// | | | |
| 15 | +// | You should have received a copy of the GNU General Public License | | |
| 16 | +// | along with this program; if not, write to the Free Software | | |
| 17 | +// | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, | | |
| 18 | +// | MA 02110-1301 USA | | |
| 19 | +// +----------------------------------------------------------------------+ | |
| 20 | +// | Author: Eugene Manuilov <eugene@manuilov.org> | | |
| 21 | +// +----------------------------------------------------------------------+ | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * The core plugin class. | |
| 25 | + * | |
| 26 | + * @category Visualizer | |
| 27 | + * | |
| 28 | + * @since 1.0.0 | |
| 29 | + */ | |
| 30 | +class Visualizer_Plugin { | |
| 31 | + | |
| 32 | + const NAME = 'visualizer'; | |
| 33 | + const VERSION = '1.5.5'; | |
| 34 | + | |
| 35 | + // custom post types | |
| 36 | + const CPT_VISUALIZER = 'visualizer'; | |
| 37 | + | |
| 38 | + // custom meta fields | |
| 39 | + const CF_CHART_TYPE = 'visualizer-chart-type'; | |
| 40 | + const CF_SOURCE = 'visualizer-source'; | |
| 41 | + const CF_SERIES = 'visualizer-series'; | |
| 42 | + const CF_DEFAULT_DATA = 'visualizer-default-data'; | |
| 43 | + const CF_SETTINGS = 'visualizer-settings'; | |
| 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 | + // custom filters | |
| 56 | + const FILTER_CHART_WRAPPER_CLASS = 'visualizer-chart-wrapper-class'; | |
| 57 | + const FILTER_GET_CHART_SERIES = 'visualizer-get-chart-series'; | |
| 58 | + const FILTER_GET_CHART_DATA = 'visualizer-get-chart-data'; | |
| 59 | + const FILTER_GET_CHART_SETTINGS = 'visualizer-get-chart-settings'; | |
| 60 | + | |
| 61 | + // Added by Ash/Upwork | |
| 62 | + const PRO_TEASER_URL = "http://themeisle.com/plugins/visualizer-charts-and-graphs-pro-addon/"; | |
| 63 | + const PRO_TEASER_TITLE = "Check PRO version "; | |
| 64 | + // Added by Ash/Upwork | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Singletone instance of the plugin. | |
| 68 | + * | |
| 69 | + * @since 1.0.0 | |
| 70 | + * | |
| 71 | + * @access private | |
| 72 | + * @var Visualizer_Plugin | |
| 73 | + */ | |
| 74 | + private static $_instance = null; | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * The array of registered modules. | |
| 78 | + * | |
| 79 | + * @since 1.0.0 | |
| 80 | + * | |
| 81 | + * @access private | |
| 82 | + * @var array | |
| 83 | + */ | |
| 84 | + private $_modules = array(); | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * Private constructor. | |
| 88 | + * | |
| 89 | + * @since 1.0.0 | |
| 90 | + * | |
| 91 | + * @access private | |
| 92 | + */ | |
| 93 | + private function __construct() {} | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * Private clone method. | |
| 97 | + * | |
| 98 | + * @since 1.0.0 | |
| 99 | + * | |
| 100 | + * @access private | |
| 101 | + */ | |
| 102 | + private function __clone() {} | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Returns singletone instance of the plugin. | |
| 106 | + * | |
| 107 | + * @since 1.0.0 | |
| 108 | + * | |
| 109 | + * @static | |
| 110 | + * @access public | |
| 111 | + * @return Visualizer_Plugin | |
| 112 | + */ | |
| 113 | + public static function instance() { | |
| 114 | + if ( is_null( self::$_instance ) ) { | |
| 115 | + self::$_instance = new Visualizer_Plugin(); | |
| 116 | + } | |
| 117 | + | |
| 118 | + return self::$_instance; | |
| 119 | + } | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * Returns a module if it was registered before. Otherwise NULL. | |
| 123 | + * | |
| 124 | + * @since 1.0.0 | |
| 125 | + * | |
| 126 | + * @access public | |
| 127 | + * @param string $name The name of the module to return. | |
| 128 | + * @return Visualizer_Module|null Returns a module if it was registered or NULL. | |
| 129 | + */ | |
| 130 | + public function getModule( $name ) { | |
| 131 | + return isset( $this->_modules[$name] ) ? $this->_modules[$name] : null; | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * Determines whether the module has been registered or not. | |
| 136 | + * | |
| 137 | + * @since 1.0.0 | |
| 138 | + * | |
| 139 | + * @access public | |
| 140 | + * @param string $name The name of a module to check. | |
| 141 | + * @return boolean TRUE if the module has been registered. Otherwise FALSE. | |
| 142 | + */ | |
| 143 | + public function hasModule( $name ) { | |
| 144 | + return isset( $this->_modules[$name] ); | |
| 145 | + } | |
| 146 | + | |
| 147 | + /** | |
| 148 | + * Register new module in the plugin. | |
| 149 | + * | |
| 150 | + * @since 1.0.0 | |
| 151 | + * | |
| 152 | + * @access public | |
| 153 | + * @param string $module The name of the module to use in the plugin. | |
| 154 | + */ | |
| 155 | + public function setModule( $class ) { | |
| 156 | + $this->_modules[$class] = new $class( $this ); | |
| 157 | + } | |
| 158 | + | |
| 159 | + /** | |
| 160 | + * Returns chart types. | |
| 161 | + * | |
| 162 | + * @since 1.0.0 | |
| 163 | + * | |
| 164 | + * @static | |
| 165 | + * @access public | |
| 166 | + * @return array | |
| 167 | + */ | |
| 168 | + public static function getChartTypes() { | |
| 169 | + return array( 'line', 'area', 'bar', 'column', 'pie', 'geo', 'scatter', 'candlestick', 'gauge' ); | |
| 170 | + } | |
| 171 | + | |
| 170 | 172 | } |