| 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 |
* Base class for sidebar settigns of graph based charts. |
| 24 |
* |
| 25 |
* @category Visualizer |
| 26 |
* @package Render |
| 27 |
* @subpackage Sidebar |
| 28 |
* |
| 29 |
* @since 1.0.0 |
| 30 |
* @abstract |
| 31 |
*/ |
| 32 |
abstract class Visualizer_Render_Sidebar_Google extends Visualizer_Render_Sidebar { |
| 33 |
|
| 34 |
/** |
| 35 |
* The constructor. |
| 36 |
*/ |
| 37 |
public function __construct( $data = array() ) { |
| 38 |
$this->_library = 'google'; |
| 39 |
parent::__construct( $data ); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Registers additional hooks. |
| 44 |
* |
| 45 |
* @access protected |
| 46 |
*/ |
| 47 |
protected function hooks() { |
| 48 |
if ( $this->_library === 'google' ) { |
| 49 |
add_filter( 'visualizer_assets_render', array( $this, 'load_google_assets' ), 10, 2 ); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Loads the assets. |
| 55 |
*/ |
| 56 |
function load_google_assets( $deps, $is_frontend ) { |
| 57 |
wp_register_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true ); |
| 58 |
wp_register_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true ); |
| 59 |
wp_register_script( |
| 60 |
'visualizer-render-google-lib', |
| 61 |
VISUALIZER_ABSURL . 'js/render-google.js', |
| 62 |
array( |
| 63 |
'google-jsapi-old', |
| 64 |
), |
| 65 |
Visualizer_Plugin::VERSION, |
| 66 |
true |
| 67 |
); |
| 68 |
|
| 69 |
return array_merge( |
| 70 |
$deps, |
| 71 |
array( 'visualizer-render-google-lib' ) |
| 72 |
); |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Enqueue assets. |
| 78 |
*/ |
| 79 |
public static function enqueue_assets( $deps = array() ) { |
| 80 |
wp_enqueue_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true ); |
| 81 |
wp_enqueue_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true ); |
| 82 |
wp_enqueue_script( 'visualizer-render-google-lib', VISUALIZER_ABSURL . 'js/render-google.js', array_merge( $deps, array( 'visualizer-google-jsapi-old' ) ), Visualizer_Plugin::VERSION, true ); |
| 83 |
return 'visualizer-render-google-lib'; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
} |
| 88 |
|