Skip to content

Commit 63867e9

Browse files
authored
Merge pull request #123 from Codeinwp/development
Removed footer banner upsell Fixed series settings issue Fixed issue with comas being used in numbers
2 parents f23b052 + c3be35c commit 63867e9

File tree

16 files changed

+144
-105
lines changed

16 files changed

+144
-105
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,43 @@ public function __construct( Visualizer_Plugin $plugin ) {
7272
* @access private
7373
* @return array The associated array of chart types with localized names.
7474
*/
75-
public static function _getChartTypesLocalized() {
75+
public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false ) {
7676
$types = array(
77-
'all' => esc_html__( 'All', 'visualizer' ),
78-
'pie' => esc_html__( 'Pie', 'visualizer' ),
79-
'line' => esc_html__( 'Line', 'visualizer' ),
80-
'area' => esc_html__( 'Area', 'visualizer' ),
81-
'geo' => esc_html__( 'Geo', 'visualizer' ),
82-
'bar' => esc_html__( 'Bar', 'visualizer' ),
83-
'column' => esc_html__( 'Column', 'visualizer' ),
84-
'gauge' => esc_html__( 'Gauge', 'visualizer' ),
85-
'scatter' => esc_html__( 'Scatter', 'visualizer' ),
86-
'candlestick' => esc_html__( 'Candlestick', 'visualizer' ),
77+
'pie' => array( 'name' => esc_html__( 'Pie', 'visualizer' ), 'enabled' => true ),
78+
'line' => array( 'name' => esc_html__( 'Line', 'visualizer' ), 'enabled' => true ),
79+
'area' => array( 'name' => esc_html__( 'Area', 'visualizer' ), 'enabled' => true ),
80+
'geo' => array( 'name' => esc_html__( 'Geo', 'visualizer' ), 'enabled' => true ),
81+
'bar' => array( 'name' => esc_html__( 'Bar', 'visualizer' ), 'enabled' => true ),
82+
'column' => array( 'name' => esc_html__( 'Column', 'visualizer' ), 'enabled' => true ),
83+
'gauge' => array( 'name' => esc_html__( 'Gauge', 'visualizer' ), 'enabled' => true ),
84+
'scatter' => array( 'name' => esc_html__( 'Scatter', 'visualizer' ), 'enabled' => true ),
85+
'candlestick' => array( 'name' => esc_html__( 'Candlestick', 'visualizer' ), 'enabled' => true ),
86+
// pro types
87+
'table' => array( 'name' => esc_html__( 'Table', 'visualizer' ), 'enabled' => false ),
88+
'timeline' => array( 'name' => esc_html__( 'Timeline', 'visualizer' ), 'enabled' => false ),
89+
'combo' => array( 'name' => esc_html__( 'Combo', 'visualizer' ), 'enabled' => false ),
8790
);
8891

8992
$types = apply_filters( 'visualizer_pro_chart_types', $types );
9093

94+
if ( $enabledOnly ) {
95+
$filtered = array();
96+
foreach ( $types as $type => $array ) {
97+
if ( ! $array['enabled'] ) { continue;
98+
}
99+
$filtered[ $type ] = $array;
100+
}
101+
$types = $filtered;
102+
}
103+
104+
if ( $get2Darray ) {
105+
$doubleD = array();
106+
foreach ( $types as $type => $array ) {
107+
$doubleD[ $type ] = $array['name'];
108+
}
109+
$types = $doubleD;
110+
}
111+
91112
return $types;
92113
}
93114

@@ -140,7 +161,8 @@ public function setupMediaViewStrings( $strings ) {
140161
'create' => esc_html__( 'Create New', 'visualizer' ),
141162
),
142163
'library' => array(
143-
'filters' => self::_getChartTypesLocalized(),
164+
'filters' => self::_getChartTypesLocalized( true, true ),
165+
'types' => array_keys( self::_getChartTypesLocalized( true, true ) ),
144166
),
145167
'nonce' => wp_create_nonce(),
146168
'buildurl' => add_query_arg( 'action', Visualizer_Plugin::ACTION_CREATE_CHART, admin_url( 'admin-ajax.php' ) ),

classes/Visualizer/Module/Chart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private function _handleTypesPage() {
300300

301301
$render = new Visualizer_Render_Page_Types();
302302
$render->type = get_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
303-
$render->types = Visualizer_Plugin::getChartTypes();
303+
$render->types = Visualizer_Module_Admin::_getChartTypesLocalized();
304304
$render->chart = $this->_chart;
305305

306306
wp_enqueue_style( 'visualizer-frame' );

classes/Visualizer/Plugin.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class Visualizer_Plugin {
3030

3131
const NAME = 'visualizer';
32-
const VERSION = '1.7.2';
32+
const VERSION = '1.7.5';
3333

3434
// custom post types
3535
const CPT_VISUALIZER = 'visualizer';
@@ -165,7 +165,6 @@ public function setModule( $class ) {
165165
*/
166166
public static function getChartTypes() {
167167
$array = array_keys( Visualizer_Module_Admin::_getChartTypesLocalized() );
168-
unset( $array[0] ); // all
169168
return $array;
170169
}
171170

classes/Visualizer/Render/Library.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,19 @@ private function _renderLibrary() {
9898
// Added by Ash/Upwork
9999
echo '<div id="visualizer-types" class="visualizer-clearfix">';
100100
echo '<ul>';
101-
foreach ( $this->types as $type => $label ) {
101+
foreach ( $this->types as $type => $array ) {
102+
$label = $array['name'];
103+
$link = '<a class="page-numbers" href="' . esc_url( add_query_arg( array( 'type' => $type, 'vpage' => false ) ) ) . '">';
104+
if ( ! $array['enabled'] ) {
105+
$link = "<a class='pro-upsell page-numbers' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
106+
}
102107
echo '<li class="visualizer-list-item">';
103108
if ( $type == $this->type ) {
104109
echo '<a class="page-numbers current" href="', esc_url( add_query_arg( 'vpage', false ) ), '">';
105110
echo $label;
106111
echo '</a>';
107112
} else {
108-
echo '<a class="page-numbers" href="', esc_url( add_query_arg( array( 'type' => $type, 'vpage' => false ) ) ), '">';
113+
echo $link;
109114
echo $label;
110115
echo '</a>';
111116
}

classes/Visualizer/Render/Page/Types.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,21 @@ protected function _toHTML() {
5353
*/
5454
protected function _renderContent() {
5555
echo '<div id="type-picker">';
56-
foreach ( $this->types as $type ) {
56+
foreach ( $this->types as $type => $array ) {
5757
echo '<div class="type-box type-box-', $type, '">';
58+
if ( ! $array['enabled'] ) {
59+
echo "<a class='pro-upsell' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
60+
echo "<span class='visualizder-pro-label'>" . __( 'PREMIUM', 'visualizer' ) . '</span>';
61+
}
5862
echo '<label class="type-label', $type == $this->type ? ' type-label-selected' : '', '">';
63+
echo '<span>' . $array['name'] . '</span>';
64+
if ( $array['enabled'] ) {
5965
echo '<input type="radio" class="type-radio" name="type" value="', $type, '"', checked( $type, $this->type, false ), '>';
66+
}
6067
echo '</label>';
68+
if ( ! $array['enabled'] ) {
69+
echo '</a>';
70+
}
6171
echo '</div>';
6272
}
6373
echo '</div>';
@@ -82,11 +92,6 @@ protected function _renderSidebar() {}
8292
protected function _renderToolbar() {
8393
if ( defined( 'Visualizer_Pro' ) ) {
8494
global $Visualizer_Pro;
85-
} else {
86-
echo "<a class='pro-upsell' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
87-
echo "<span class='dashicons dashicons-plus-alt'></span>";
88-
echo esc_html( 'Three Additional Chart Types Available in the Pro Version ( Table, Timeline and Combo Chart ) ', 'visualizer' );
89-
echo '</a>';
9095
}
9196
echo '<input type="submit" class="button button-primary button-large push-right" value="', esc_attr__( 'Next', 'visualizer' ), '">';
9297
}

classes/Visualizer/Render/Sidebar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ protected function _renderFormatField( $index = 0 ) {
526526
esc_html__( 'Number Format', 'visualizer' ),
527527
'series[' . $index . '][format]',
528528
isset( $this->series[ $index ]['format'] ) ? $this->series[ $index ]['format'] : '',
529-
sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU pattern set%1$s. Use something like #,### to get 1,234 as output, or $# to add dollar sign before digits. Pay attention that if you use &#37; percentage format then your values will be multiplied by 100.', 'visualizer' ), '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">', '</a>' ),
529+
sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU pattern set%2$s. Use something like #,### to get 1,234 as output, or $# to add dollar sign before digits. Pay attention that if you use &#37; percentage format then your values will be multiplied by 100.', 'visualizer' ), '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">', '</a>' ),
530530
'#,###.##'
531531
);
532532
break;
@@ -537,7 +537,7 @@ protected function _renderFormatField( $index = 0 ) {
537537
esc_html__( 'Date Format', 'visualizer' ),
538538
'series[' . $index . '][format]',
539539
isset( $this->series[ $index ]['format'] ) ? $this->series[ $index ]['format'] : '',
540-
sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU date and time format%1$s.', 'visualizer' ), '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">', '</a>' ),
540+
sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU date and time format%2$s.', 'visualizer' ), '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">', '</a>' ),
541541
'eeee, dd LLLL yyyy'
542542
);
543543
break;

classes/Visualizer/Source.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,20 @@ public function getRawData() {
118118
*/
119119
protected function _normalizeData( $data ) {
120120
// normalize values
121-
// print_r($data);
121+
// error_log(print_r($data,true));
122122
foreach ( $this->_series as $i => $series ) {
123123
// if no value exists for the seires, then add null
124124
if ( ! isset( $data[ $i ] ) ) {
125125
$data[ $i ] = null;
126126
}
127127

128-
if ( is_null( $data[ $i ] ) && ! is_numeric( $data[ $i ] ) ) {
128+
if ( is_null( $data[ $i ] ) ) {
129129
continue;
130130
}
131131

132132
switch ( $series['type'] ) {
133133
case 'number':
134-
$data[ $i ] = ( is_numeric( $data[ $i ] ) ) ? floatval( $data[ $i ] ) : null;
134+
$data[ $i ] = ( is_numeric( $data[ $i ] ) ) ? floatval( $data[ $i ] ) : (is_numeric( str_replace( ',', '', $data[ $i ] ) ) ? floatval( str_replace( ',', '', $data[ $i ] ) ) : null);
135135
break;
136136
case 'boolean':
137137
$data[ $i ] = ! empty( $data[ $i ] ) ? filter_validate( $data[ $i ], FILTER_VALIDATE_BOOLEAN ) : null;
@@ -149,6 +149,7 @@ protected function _normalizeData( $data ) {
149149
break;
150150
}
151151
}
152+
// error_log(print_r($data,true));
152153
return $data;
153154
}
154155

css/frame.css

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,35 @@ div.group-content .group-description {
336336
/******************************** TYPE PICKER ******************************/
337337
/******************************************************************************/
338338

339+
.type-box span {
340+
display: block;
341+
position: absolute;
342+
right: 0;
343+
bottom: -6px;
344+
width: 100%;
345+
padding: 4px 0;
346+
border-top: 1px dashed #ddd;
347+
border-bottom: 1px dashed #ddd;
348+
background: #e0e0e0;
349+
background-color: #efefef;
350+
-webkit-box-shadow: 0 0 8px #ddd;
351+
box-shadow: 0 0 8px #ddd;
352+
font-weight: bold;
353+
text-align: center;
354+
}
355+
356+
.type-box .pro-upsell {
357+
color: #c55555;
358+
}
359+
339360
#type-picker {
340361
width: 952px;
341362
margin: 50px auto;
342363
}
343364

344365
.type-box {
345366
float: left;
367+
position: relative;
346368
margin: 0 20px 20px 0;
347369
border: 1px dashed #ddd;
348370
background-color: #efefef;
@@ -354,10 +376,22 @@ div.group-content .group-description {
354376
margin-right: 0;
355377
}
356378

379+
.type-box .pro-upsell .visualizder-pro-label {
380+
display: inline;
381+
position: absolute;
382+
top: 0;
383+
width: 74px;
384+
height: 10px;
385+
height: 17px;
386+
border: none;
387+
color: #fff;
388+
background: #c55555;
389+
}
390+
357391
.type-label {
358392
display: block;
359393
width: 270px;
360-
height: 195px;
394+
height: 205px;
361395
padding: 15px;
362396
border: 1px solid #e0e0e0;
363397
background-color: white;
@@ -367,7 +401,7 @@ div.group-content .group-description {
367401
}
368402

369403
.type-label-selected,
370-
.type-label:hover {
404+
.type-box > .type-label:hover {
371405
background-image: url(../images/chart_types.png);
372406
}
373407

@@ -419,50 +453,6 @@ div.group-content .group-description {
419453
background-position: -597px -670px;
420454
}
421455

422-
a.pro-upsell {
423-
display: -webkit-box;
424-
display: -webkit-flex;
425-
display: -ms-flexbox;
426-
display: flex;
427-
position: relative;
428-
top: 10px;
429-
height: 20px;
430-
margin: 0;
431-
padding: 10px 20px;
432-
border: 1px solid #2c80d6;
433-
border-radius: 50px;
434-
background-color: #4285f4;
435-
-webkit-box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
436-
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
437-
text-decoration: none;
438-
-webkit-transition: all 0.5s ease-in;
439-
transition: all 0.5s ease-in;
440-
441-
-webkit-align-items: center;
442-
align-items: center;
443-
-webkit-box-align: center;
444-
-ms-flex-align: center;
445-
}
446-
447-
a.pro-upsell:hover {
448-
background-color: #5a95f5;
449-
-webkit-box-shadow: 0 5px 11px 0 rgba(0, 0, 0, 0.18), 0 4px 15px 0 rgba(0, 0, 0, 0.15);
450-
box-shadow: 0 5px 11px 0 rgba(0, 0, 0, 0.18), 0 4px 15px 0 rgba(0, 0, 0, 0.15);
451-
}
452-
453-
a.pro-upsell span {
454-
display: inline-block;
455-
margin-right: 10px;
456-
color: #fff;
457-
}
458-
459-
a.pro-upsell {
460-
display: inline;
461-
color: #fff;
462-
font-size: 13px;
463-
font-weight: bold;
464-
}
465-
466456
/******************************************************************************/
467457
/******************************** OTHER STYLES ******************************/
468458
/******************************************************************************/

css/media.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Version: 1.7.2
2+
Version: 1.7.5
33
*/
44
#visualizer-library-view {
55
padding: 30px 10px 10px 30px;

images/available_pro.png

-3 Bytes
Loading

0 commit comments

Comments
 (0)