| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Visualizer: Charts and Graphs |
| 4 |
Plugin URI: https://github.com/codeinwp/visualizer |
| 5 |
Description: A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages. The plugin uses Google Visualization API to render charts, which supports cross-browser compatibility (adopting VML for older IE versions) and cross-platform portability to iOS and new Android releases. |
| 6 |
Version: 1.4.2.3 |
| 7 |
Author: Themeisle |
| 8 |
Author URI: http://themeisle.com |
| 9 |
Donate link: http://flattr.com/thing/2574985/WordPress-Visualizer |
| 10 |
License: GPL v2.0 or later |
| 11 |
License URI: http://www.opensource.org/licenses/gpl-license.php |
| 12 |
*/ |
| 13 |
|
| 14 |
|
| 15 |
// prevent direct access to the plugin folder |
| 16 |
if ( !defined( 'ABSPATH' ) ) { |
| 17 |
header( 'HTTP/1.0 404 Not Found', true, 404 ); |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
// don't load the plugin, if it has been already loaded |
| 22 |
if ( class_exists( 'Visualizer_Plugin', false ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Automatically loads classes for the plugin. Checks a namespace and loads only |
| 28 |
* approved classes. |
| 29 |
* |
| 30 |
* @since 1.0.0 |
| 31 |
* |
| 32 |
* @param string $class The class name to autoload. |
| 33 |
* @return boolean Returns TRUE if the class is located. Otherwise FALSE. |
| 34 |
*/ |
| 35 |
function visualizer_autoloader( $class ) { |
| 36 |
$namespaces = array( 'Visualizer' ); |
| 37 |
foreach ( $namespaces as $namespace ) { |
| 38 |
if ( substr( $class, 0, strlen( $namespace ) ) == $namespace ) { |
| 39 |
$filename = dirname( __FILE__ ) . str_replace( '_', DIRECTORY_SEPARATOR, "_classes_{$class}.php" ); |
| 40 |
if ( is_readable( $filename ) ) { |
| 41 |
require $filename; |
| 42 |
return true; |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
return false; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Instantiates the plugin and setup all modules. |
| 52 |
* |
| 53 |
* @since 1.0.0 |
| 54 |
*/ |
| 55 |
function visualizer_launch() { |
| 56 |
// setup environment |
| 57 |
define( 'VISUALIZER_BASEFILE', __FILE__ ); |
| 58 |
define( 'VISUALIZER_ABSURL', plugins_url( '/', __FILE__ ) ); |
| 59 |
define( 'VISUALIZER_ABSPATH', dirname( __FILE__ ) ); |
| 60 |
|
| 61 |
if ( !defined( 'VISUALIZER_CSV_DELIMITER' ) ) { |
| 62 |
define( 'VISUALIZER_CSV_DELIMITER', ',' ); |
| 63 |
} |
| 64 |
|
| 65 |
if ( !defined( 'VISUALIZER_CSV_ENCLOSURE' ) ) { |
| 66 |
define( 'VISUALIZER_CSV_ENCLOSURE', '"' ); |
| 67 |
} |
| 68 |
|
| 69 |
// don't load the plugin if cron job is running or doing autosave |
| 70 |
$doing_autosave = defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE; |
| 71 |
$doing_cron = defined( 'DOING_CRON' ) && DOING_CRON; |
| 72 |
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
| 73 |
if ( $doing_autosave || $doing_cron ) { |
| 74 |
return; |
| 75 |
} |
| 76 |
|
| 77 |
// instantiate the plugin |
| 78 |
$plugin = Visualizer_Plugin::instance(); |
| 79 |
|
| 80 |
// set general modules |
| 81 |
$plugin->setModule( Visualizer_Module_Setup::NAME ); |
| 82 |
$plugin->setModule( Visualizer_Module_Sources::NAME ); |
| 83 |
|
| 84 |
if ( $doing_ajax ) { |
| 85 |
// set ajax modules |
| 86 |
$plugin->setModule( Visualizer_Module_Chart::NAME ); |
| 87 |
} else { |
| 88 |
if ( is_admin() ) { |
| 89 |
// set admin modules |
| 90 |
$plugin->setModule( Visualizer_Module_Admin::NAME ); |
| 91 |
} else { |
| 92 |
// set frontend modules |
| 93 |
$plugin->setModule( Visualizer_Module_Frontend::NAME ); |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
// register autoloader function |
| 99 |
spl_autoload_register( 'visualizer_autoloader' ); |
| 100 |
|
| 101 |
// launch the plugin |
| 102 |
visualizer_launch(); |