Skip to content

Commit d644de0

Browse files
authored
Merge pull request #79 from Codeinwp/development
Added support for 3 more chart types Fixed issue with charts not saving
2 parents 9a2ceff + 41d0fb3 commit d644de0

File tree

16 files changed

+179
-88
lines changed

16 files changed

+179
-88
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ function visualizerAdminPointers( $p ) {
139139
* @access private
140140
* @return array The associated array of chart types with localized names.
141141
*/
142-
private static function _getChartTypesLocalized() {
143-
return array(
142+
public static function _getChartTypesLocalized() {
143+
$types = array(
144144
'all' => esc_html__( 'All', Visualizer_Plugin::NAME ),
145145
'pie' => esc_html__( 'Pie', Visualizer_Plugin::NAME ),
146146
'line' => esc_html__( 'Line', Visualizer_Plugin::NAME ),
@@ -150,8 +150,12 @@ private static function _getChartTypesLocalized() {
150150
'column' => esc_html__( 'Column', Visualizer_Plugin::NAME ),
151151
'gauge' => esc_html__( 'Gauge', Visualizer_Plugin::NAME ),
152152
'scatter' => esc_html__( 'Scatter', Visualizer_Plugin::NAME ),
153-
'candlestick' => esc_html__( 'Candelstick', Visualizer_Plugin::NAME ),
153+
'candlestick' => esc_html__( 'Candlestick', Visualizer_Plugin::NAME ),
154154
);
155+
156+
$types = apply_filters("visualizer_pro_chart_types", $types);
157+
158+
return $types;
155159
}
156160

157161
/**
@@ -169,7 +173,8 @@ public function enqueueMediaScripts() {
169173
if ( post_type_supports( $typenow, 'editor' ) ) {
170174
wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
171175

172-
wp_enqueue_script( 'visualizer-google-jsapi', '//www.google.com/jsapi', array( 'media-editor' ), null, true );
176+
wp_enqueue_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array( 'media-editor' ), null, true );
177+
wp_enqueue_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
173178
wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', array( 'visualizer-google-jsapi' ), Visualizer_Plugin::VERSION, true );
174179
wp_enqueue_script( 'visualizer-media-collection', VISUALIZER_ABSURL . 'js/media/collection.js', array( 'visualizer-media-model' ), Visualizer_Plugin::VERSION, true );
175180
wp_enqueue_script( 'visualizer-media-controller', VISUALIZER_ABSURL . 'js/media/controller.js', array( 'visualizer-media-collection' ), Visualizer_Plugin::VERSION, true );
@@ -249,8 +254,9 @@ public function enqueueLibraryScripts( $suffix ) {
249254

250255
wp_enqueue_media();
251256
wp_enqueue_script( 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array( 'jquery', 'media-views' ), Visualizer_Plugin::VERSION, true );
252-
wp_enqueue_script( 'google-jsapi', '//www.google.com/jsapi', array(), null, true );
253-
wp_enqueue_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'google-jsapi', 'visualizer-library' ), Visualizer_Plugin::VERSION, true );
257+
wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
258+
wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array('google-jsapi-new'), null, true );
259+
wp_enqueue_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'google-jsapi-old', 'visualizer-library' ), Visualizer_Plugin::VERSION, true );
254260
}
255261
if ( get_bloginfo( 'version' ) < '3.3' )
256262
return;

classes/Visualizer/Module/Chart.php

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,9 @@ public function renderChartPages() {
240240
wp_register_style( 'visualizer-frame', VISUALIZER_ABSURL . 'css/frame.css', array(), Visualizer_Plugin::VERSION );
241241

242242
wp_register_script( 'visualizer-frame', VISUALIZER_ABSURL . 'js/frame.js', array( 'jquery' ), Visualizer_Plugin::VERSION, true );
243-
wp_register_script( 'google-jsapi', '//www.google.com/jsapi', array(), null, true );
244-
wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'google-jsapi', 'visualizer-frame' ), Visualizer_Plugin::VERSION, true );
243+
wp_register_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
244+
wp_register_script( 'google-jsapi-old', '//www.google.com/jsapi', array('google-jsapi-new'), null, true );
245+
wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'google-jsapi-old', 'google-jsapi-new', 'visualizer-frame' ), Visualizer_Plugin::VERSION, true );
245246
wp_register_script( 'visualizer-preview', VISUALIZER_ABSURL . 'js/preview.js', array( 'wp-color-picker', 'visualizer-render' ), Visualizer_Plugin::VERSION, true );
246247

247248
// added by Ash/Upwork
@@ -350,68 +351,6 @@ private function _handleDataPage() {
350351
wp_iframe( array( $render, 'render') );
351352
}
352353

353-
/**
354-
* Handles chart settigns page.
355-
*
356-
* @since 1.0.0
357-
*
358-
* @access private
359-
*/
360-
private function _handleSettingsPage() {
361-
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ) ) ) {
362-
if ( $this->_chart->post_status == 'auto-draft' ) {
363-
$this->_chart->post_status = 'publish';
364-
wp_update_post( $this->_chart->to_array() );
365-
}
366-
367-
update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_SETTINGS, $_POST );
368-
369-
$render = new Visualizer_Render_Page_Send();
370-
$render->text = sprintf( '[visualizer id="%d"]', $this->_chart->ID );
371-
372-
wp_iframe( array( $render, 'render') );
373-
return;
374-
}
375-
376-
$data = $this->_getChartArray();
377-
378-
$sidebar = '';
379-
$sidebar_class = 'Visualizer_Render_Sidebar_Type_' . ucfirst( $data['type'] );
380-
if ( class_exists( $sidebar_class, true ) ) {
381-
$sidebar = new $sidebar_class( $data['settings'] );
382-
$sidebar->__series = $data['series'];
383-
$sidebar->__data = $data['data'];
384-
}
385-
386-
unset( $data['settings']['width'], $data['settings']['height'] );
387-
388-
wp_enqueue_style( 'wp-color-picker' );
389-
wp_enqueue_style( 'visualizer-frame' );
390-
391-
wp_enqueue_script( 'visualizer-preview' );
392-
wp_localize_script( 'visualizer-render', 'visualizer', array(
393-
'charts' => array(
394-
'canvas' => $data,
395-
),
396-
) );
397-
398-
$render = new Visualizer_Render_Page_Settings();
399-
400-
$render->sidebar = $sidebar;
401-
if ( filter_input( INPUT_GET, 'library', FILTER_VALIDATE_BOOLEAN ) ) {
402-
$render->button = filter_input( INPUT_GET, 'action' ) == Visualizer_Plugin::ACTION_EDIT_CHART
403-
? esc_html__( 'Save Chart', Visualizer_Plugin::NAME )
404-
: esc_html__( 'Create Chart', Visualizer_Plugin::NAME );
405-
} else {
406-
$render->button = esc_attr__( 'Insert Chart', Visualizer_Plugin::NAME );
407-
}
408-
409-
$this->_addAction( 'admin_head', 'renderFlattrScript' );
410-
411-
wp_iframe( array( $render, 'render') );
412-
}
413-
414-
415354
// changed by Ash/Upwork
416355
private function _handleDataAndSettingsPage(){
417356
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ) ) ) {
@@ -437,7 +376,13 @@ private function _handleDataAndSettingsPage(){
437376
$sidebar = new $sidebar_class( $data['settings'] );
438377
$sidebar->__series = $data['series'];
439378
$sidebar->__data = $data['data'];
440-
}
379+
} else {
380+
$sidebar = apply_filters("visualizer_pro_chart_type_sidebar", '', $data);
381+
if ($sidebar != '') {
382+
$sidebar->__series = $data['series'];
383+
$sidebar->__data = $data['data'];
384+
}
385+
}
441386

442387
unset( $data['settings']['width'], $data['settings']['height'] );
443388

classes/Visualizer/Module/Frontend.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ public function __construct( Visualizer_Plugin $plugin ) {
7777
* @access public
7878
*/
7979
public function enqueueScripts() {
80-
wp_register_script( 'visualizer-google-jsapi', '//www.google.com/jsapi', array(), null, true );
81-
wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'visualizer-google-jsapi', 'jquery' ), Visualizer_Plugin::VERSION, true );
80+
wp_register_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
81+
wp_register_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array('visualizer-google-jsapi-new'), null, true );
82+
wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'visualizer-google-jsapi-old', 'jquery' ), Visualizer_Plugin::VERSION, true );
8283
}
8384

8485
/**

classes/Visualizer/Plugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ public function setModule( $class ) {
166166
* @return array
167167
*/
168168
public static function getChartTypes() {
169-
return array( 'line', 'area', 'bar', 'column', 'pie', 'geo', 'scatter', 'candlestick', 'gauge' );
169+
$array = array_keys(Visualizer_Module_Admin::_getChartTypesLocalized());
170+
unset($array[0]); // all
171+
return $array;
170172
}
171173

172174
}

classes/Visualizer/Render/Page/Types.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ protected function _renderSidebar() {}
8080
*
8181
* @access protected
8282
*/
83-
protected function _renderToolbar() {
84-
echo '<input type="submit" class="button button-primary button-large push-right" value="', esc_attr__( 'Next', Visualizer_Plugin::NAME ), '">';
85-
}
86-
87-
}
83+
protected function _renderToolbar() {
84+
if( defined( 'Visualizer_Pro' ) ){
85+
global $Visualizer_Pro;
86+
}else{
87+
echo "<a class='pro-upsell' href='".Visualizer_Plugin::PRO_TEASER_URL."' target='_blank'>";
88+
echo "<span class='dashicons dashicons-plus-alt'></span>";
89+
echo esc_html( "Three Additional Chart Types Available in the Pro Version ( Table, Timeline and Combo Chart ) ", Visualizer_Plugin::NAME );
90+
echo "</a>";
91+
}
92+
echo '<input type="submit" class="button button-primary button-large push-right" value="', esc_attr__( 'Next', Visualizer_Plugin::NAME ), '">';
93+
}
94+
}

classes/Visualizer/Render/Sidebar.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,4 +545,13 @@ protected function _renderFormatField( $index = 0 ) {
545545
}
546546
}
547547

548+
protected static function _renderCheckboxItem( $title, $name, $value, $default, $desc ) {
549+
echo '<div class="section-item">';
550+
echo '<a class="more-info" href="javascript:;">[?]</a>';
551+
echo '<b>', $title, '</b>';
552+
echo '<input type="checkbox" class="control-check" value="', $default, '" name="', $name, '" ', ($value == $default ? "checked" : ""), '>';
553+
echo '<p class="section-description">', $desc, '</p>';
554+
echo '</div>';
555+
}
556+
548557
}

css/frame.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ div.group-content .group-description {
250250
width: 100%;
251251
}
252252

253+
.control-check {
254+
float: right;
255+
}
256+
.control-check::after {
257+
clear: both;
258+
}
259+
253260
.section-description ul {
254261
margin: 0 0 0 25px;
255262
list-style: circle;
@@ -303,6 +310,7 @@ div.group-content .group-description {
303310
z-index: 100;
304311
left: 0;
305312
right: 0;
313+
text-align: center;
306314
bottom: 0;
307315
border-top: 1px solid #DFDFDF;
308316
overflow: hidden;
@@ -314,10 +322,14 @@ div.group-content .group-description {
314322
float: right;
315323
}
316324

325+
.toolbar-div a{
326+
float:left;
327+
}
317328
.toolbar-div{
318329
display: inline-block;
319330
vertical-align: top;
320331
width: 30%;
332+
float:left;
321333
}
322334

323335
/******************************************************************************/
@@ -395,6 +407,54 @@ div.group-content .group-description {
395407
background-position: -600px -225px;
396408
}
397409

410+
.type-box-table .type-label {
411+
background-position: -301px -670px;
412+
}
413+
414+
.type-box-timeline .type-label {
415+
background-position: -2px -670px;
416+
}
417+
418+
.type-box-combo .type-label {
419+
background-position: -597px -670px;
420+
}
421+
422+
a.pro-upsell {
423+
margin: 0;
424+
display: flex;
425+
align-items: center;
426+
height: 20px;
427+
padding:10px 20px;
428+
border-radius: 50px;
429+
-moz-border-radius: 50px;
430+
-webkit-border-radius: 50px;
431+
background-color: #4285F4;
432+
text-decoration: none;
433+
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
434+
border: 1px solid #2c80d6;
435+
transition: all .5s ease-in;
436+
top: 10px;
437+
position: relative;
438+
}
439+
440+
a.pro-upsell:hover {
441+
background-color: #5a95f5;
442+
box-shadow: 0 5px 11px 0 rgba(0, 0, 0, 0.18), 0 4px 15px 0 rgba(0, 0, 0, 0.15);
443+
}
444+
445+
a.pro-upsell span {
446+
color: #fff;
447+
margin-right: 10px;
448+
display:inline-block;
449+
}
450+
451+
a.pro-upsell {
452+
font-weight: bold;
453+
font-size: 13px;
454+
color: #fff;
455+
display: inline;
456+
}
457+
398458
/******************************************************************************/
399459
/******************************** OTHER STYLES ******************************/
400460
/******************************************************************************/

images/chart_types.png

-58.2 KB
Loading

images/chart_types_g.png

30.4 KB
Loading

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Visualizer: Charts and Graphs
44
Plugin URI: https://themeisle.com/plugins/visualizer-charts-and-graphs/
55
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.5.5
6+
Version: 1.5.6
77
Author: Themeisle
88
Author URI: http://themeisle.com
99
License: GPL v2.0 or later

0 commit comments

Comments
 (0)