Skip to content

Commit 89a6d70

Browse files
authored
Merge pull request #157 from contactashish13/#46
schedule import #46
2 parents e90f6e0 + 0f00bbb commit 89a6d70

File tree

3 files changed

+57
-45
lines changed

3 files changed

+57
-45
lines changed

classes/Visualizer/Module/Sources.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct( Visualizer_Plugin $plugin ) {
5656
$this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_SERIES, 'filterChartSeries', 1, 2 );
5757
$this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_DATA, 'filterChartData', 1, 2 );
5858

59-
$this->_addFilter( 'visualizer_pro_upsell', 'addProUpsell', 10, 1 );
59+
$this->_addFilter( 'visualizer_pro_upsell', 'addProUpsell', 10, 2 );
6060
}
6161

6262
/**
@@ -129,25 +129,27 @@ public function filterChartData( $data, $chart_id ) {
129129
* Add the pro upsell html.
130130
*
131131
* @param string $old The previous html string.
132+
* @param string $feature What feature is this filter running for.
132133
*
133134
* @return string The new html code.
134135
*/
135-
public function addProUpsell( $old ) {
136-
if ( VISUALIZER_PRO ) {
136+
public function addProUpsell( $old, $feature = null ) {
137+
$return = '';
138+
if ( ! $feature || ($feature == 'schedule-chart' && ! apply_filters( 'visualizer_is_business', false )) ) {
139+
$return = '<div class="only-pro-content">';
140+
$return .= ' <div class="only-pro-container">';
141+
$return .= ' <div class="only-pro-inner">';
142+
$return .= ' <p>' . __( 'Enable this feature in PRO version!', 'visualizer' ) . '</p>';
143+
$return .= ' <a target="_blank" href="' . Visualizer_Plugin::PRO_TEASER_URL . '" title="' . __( 'Buy now', 'visualizer' ) . '">' . __( 'Buy now', 'visualizer' ) . '</a>';
144+
$return .= ' </div>';
145+
$return .= ' </div>';
146+
$return .= '</div>';
147+
}
148+
if ( ! $feature && defined( 'Visualizer_Pro' ) ) {
137149
remove_filter( 'visualizer_pro_upsell', 'addProUpsell', 10, 1 );
138-
return;
150+
$return = '';
139151
}
140-
$return = '<div class="only-pro-content">';
141-
$return .= ' <div class="only-pro-container">';
142-
$return .= ' <div class="only-pro-inner">';
143-
$return .= ' <p>' . __( 'Enable this feature in PRO version!', 'visualizer' ) . '</p>';
144-
$return .= ' <a target="_blank" href="' . Visualizer_Plugin::PRO_TEASER_URL . '" title="' . __( 'Buy now', 'visualizer' ) . '">' . __( 'Buy now', 'visualizer' ) . '</a>';
145-
$return .= ' </div>';
146-
$return .= ' </div>';
147-
$return .= '</div>';
148-
149152
return $return;
150-
151153
}
152154

153155
}

classes/Visualizer/Render/Page/Data.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function _renderSidebarContent() {
8888
</form>
8989
</div>
9090
</li>
91-
<li class="group">
91+
<li class="group visualizer-import-url">
9292
<h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
9393
<ul class="group-content">
9494
<li class="subsection">
@@ -111,33 +111,43 @@ class="visualizer-input">
111111
</form>
112112
</div>
113113
</li>
114-
<li class="subsection <?php echo apply_filters( 'visualizer_pro_upsell_class','only-pro-feature' ); ?>">
115-
<span class="section-title"><?php _e( 'Schedule Import', 'visualizer' ); ?><span
114+
<li class="subsection <?php echo apply_filters( 'visualizer_pro_upsell_class','only-pro-feature', 'schedule-chart' ); ?>">
115+
<span class="section-title visualizer-import-url-schedule"><?php _e( 'Schedule Import', 'visualizer' ); ?><span
116116
class="dashicons dashicons-lock"></span></span>
117117
<div class="section-items">
118118
<p class="group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p>
119119
<p class="group-description"> <?php _e( 'You can also synchronize with your Google Spreadsheet file, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
120120
<p class="group-description"> <?php _e( 'We will update the chart data based on your time interval preference by overwritting the current data with the one from the URL.', 'visualizer' ); ?></p>
121-
<form id="vz-schedule-import" action=" " method="post"
121+
<form id="vz-schedule-import" action="<?php echo $upload_link ?>" method="post"
122122
target="thehole" enctype="multipart/form-data">
123123
<div class="remote-file-section">
124-
<input type="url" id="vz-schedule-url" name="remote_data"
124+
<input type="url" id="vz-schedule-url" name="remote_data" value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true );?>"
125125
placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
126-
class="visualizer-input">
126+
class="visualizer-input visualizer-remote-url">
127127
<p class="group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p>
128-
<select name="vz-import-time" id="vz-import-time"
129-
class="visualizer-select">
130-
<option value="3600"><?php _e( 'Each hour', 'visualizer' ); ?></option>
131-
<option value="43200"><?php _e( 'Each 12 hours', 'visualizer' ); ?></option>
132-
<option value="86400"><?php _e( 'Each day', 'visualizer' ); ?></option>
133-
<option value="259200"><?php _e( 'Each 3 days', 'visualizer' ); ?></option>
128+
<select name="vz-import-time" id="vz-import-time" class="visualizer-select">
129+
<?php
130+
$hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
131+
$schedules = array(
132+
'1' => __( 'Each hour', 'visualizer' ),
133+
'12' => __( 'Each 12 hours', 'visualizer' ),
134+
'24' => __( 'Each day', 'visualizer' ),
135+
'36' => __( 'Each 3 days', 'visualizer' ),
136+
);
137+
foreach ( $schedules as $num => $name ) {
138+
$extra = $num == $hours ? 'selected' : '';
139+
?>
140+
<option value="<?php echo $num;?>" <?php echo $extra;?>><?php echo $name;?></option>
141+
<?php
142+
}
143+
?>
134144
</select>
135145
</div>
136146
<input type="button" id="vz-save-schedule" class="button button-primary"
137147
value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
138148

139149

140-
<?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
150+
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
141151
</form>
142152
</div>
143153
</li>

languages/visualizer.pot

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ msgstr ""
126126
msgid "CSV file is broken or invalid. Please, try again."
127127
msgstr ""
128128

129-
#: classes/Visualizer/Module/Sources.php:143
129+
#: classes/Visualizer/Module/Sources.php:142
130130
msgid "Enable this feature in PRO version!"
131131
msgstr ""
132132

133-
#: classes/Visualizer/Module/Sources.php:144
133+
#: classes/Visualizer/Module/Sources.php:143
134134
msgid "Buy now"
135135
msgstr ""
136136

@@ -289,67 +289,67 @@ msgstr ""
289289
msgid "How often do you want to check the url"
290290
msgstr ""
291291

292-
#: classes/Visualizer/Render/Page/Data.php:130
292+
#: classes/Visualizer/Render/Page/Data.php:132
293293
msgid "Each hour"
294294
msgstr ""
295295

296-
#: classes/Visualizer/Render/Page/Data.php:131
296+
#: classes/Visualizer/Render/Page/Data.php:133
297297
msgid "Each 12 hours"
298298
msgstr ""
299299

300-
#: classes/Visualizer/Render/Page/Data.php:132
300+
#: classes/Visualizer/Render/Page/Data.php:134
301301
msgid "Each day"
302302
msgstr ""
303303

304-
#: classes/Visualizer/Render/Page/Data.php:133
304+
#: classes/Visualizer/Render/Page/Data.php:135
305305
msgid "Each 3 days"
306306
msgstr ""
307307

308-
#: classes/Visualizer/Render/Page/Data.php:137
308+
#: classes/Visualizer/Render/Page/Data.php:147
309309
msgid "Save schedule"
310310
msgstr ""
311311

312-
#: classes/Visualizer/Render/Page/Data.php:148
312+
#: classes/Visualizer/Render/Page/Data.php:158
313313
msgid "Import from other chart"
314314
msgstr ""
315315

316-
#: classes/Visualizer/Render/Page/Data.php:152
316+
#: classes/Visualizer/Render/Page/Data.php:162
317317
msgid "You can import here data from your previously created charts"
318318
msgstr ""
319319

320-
#: classes/Visualizer/Render/Page/Data.php:180
320+
#: classes/Visualizer/Render/Page/Data.php:190
321321
msgid "Import Chart"
322322
msgstr ""
323323

324-
#: classes/Visualizer/Render/Page/Data.php:187
324+
#: classes/Visualizer/Render/Page/Data.php:197
325325
msgid "Edit current data"
326326
msgstr ""
327327

328-
#: classes/Visualizer/Render/Page/Data.php:195
328+
#: classes/Visualizer/Render/Page/Data.php:205
329329
msgid "You can manually edit the chart data using the spreadsheet like editor."
330330
msgstr ""
331331

332-
#: classes/Visualizer/Render/Page/Data.php:197
332+
#: classes/Visualizer/Render/Page/Data.php:207
333333
msgid "View Editor"
334334
msgstr ""
335335

336-
#: classes/Visualizer/Render/Page/Data.php:197
336+
#: classes/Visualizer/Render/Page/Data.php:207
337337
msgid "Show Chart"
338338
msgstr ""
339339

340-
#: classes/Visualizer/Render/Page/Data.php:207
340+
#: classes/Visualizer/Render/Page/Data.php:217
341341
msgid "Advanced Settings"
342342
msgstr ""
343343

344-
#: classes/Visualizer/Render/Page/Data.php:210
344+
#: classes/Visualizer/Render/Page/Data.php:220
345345
msgid "Chart Settings"
346346
msgstr ""
347347

348-
#: classes/Visualizer/Render/Page/Data.php:221
348+
#: classes/Visualizer/Render/Page/Data.php:231
349349
msgid "Rate our plugin"
350350
msgstr ""
351351

352-
#: classes/Visualizer/Render/Page/Data.php:240
352+
#: classes/Visualizer/Render/Page/Data.php:250
353353
#: classes/Visualizer/Render/Page/Settings.php:55
354354
msgid "Back"
355355
msgstr ""

0 commit comments

Comments
 (0)