Responsive Pricing Table - Version 3.2.1

Version Description

  • SAFE UPDATE: No data loss for those upgrading from version 3.0 or higher
  • Allows automatic recovery of all pricing tables when switching to PRO version
Download this release

Release Info

Developer spwebguy
Plugin Icon 128x128 Responsive Pricing Table
Version 3.2.1
Comparing to
See all releases

Code changes from version 3.2 to 3.2.1

Files changed (2) hide show
  1. readme.txt +4 -0
  2. rpt.php +579 -563
readme.txt CHANGED
@@ -70,6 +70,10 @@ The free version of the Responsive Pricing Table plugin is **not limited** and d
70
 
71
 
72
  == Changelog ==
 
 
 
 
73
  = 3.2 =
74
  * SAFE UPDATE: No data loss for those upgrading from version 3.0 or higher
75
  * CSS bug fixes (icons/titles)
70
 
71
 
72
  == Changelog ==
73
+ = 3.2.1 =
74
+ * SAFE UPDATE: No data loss for those upgrading from version 3.0 or higher
75
+ * Allows automatic recovery of all pricing tables when switching to PRO version
76
+
77
  = 3.2 =
78
  * SAFE UPDATE: No data loss for those upgrading from version 3.0 or higher
79
  * CSS bug fixes (icons/titles)
rpt.php CHANGED
@@ -1,564 +1,580 @@
1
- <?php
2
- /**
3
- * Plugin Name: Responsive Pricing Table
4
- * Plugin URI: http://wpdarko.com/darko-tools/responsive-pricing-table/
5
- * Description: A responsive, easy and elegant way to present your offer to your visitors. Just create a new pricing table (custom type) and copy-paste the shortcode into your posts/pages. Find support and information on the <a href="http://wpdarko.com/darko-tools/responsive-pricing-table/">plugin's page</a>. This free version is NOT limited and does not contain any ad. Check out the <a href='http://wpdarko.com/darko-tools/responsive-pricing-table-pro/'>PRO version</a> for more great features.
6
- * Version: 3.2
7
- * Author: WP Darko
8
- * Author URI: http://wpdarko.com
9
- * License: GPL2
10
- */
11
-
12
- //adds stylesheet
13
- add_action( 'wp_enqueue_scripts', 'add_rpt_style' );
14
- function add_rpt_style() {
15
- wp_enqueue_style( 'rpt', plugins_url('css/rpt_custom_style.min.css', __FILE__));
16
- }
17
-
18
- add_action( 'init', 'create_rpt_pricing_table_type' );
19
-
20
- function create_rpt_pricing_table_type() {
21
- register_post_type( 'rpt_pricing_table',
22
- array(
23
- 'labels' => array(
24
- 'name' => 'Pricing Tables',
25
- 'singular_name' => 'Pricing Table'
26
- ),
27
- 'public' => true,
28
- 'has_archive' => false,
29
- 'hierarchical' => false,
30
- 'supports' => array( 'title' ),
31
- 'menu_icon' => 'dashicons-plus',
32
- )
33
- );
34
- }
35
-
36
- /*
37
- * Include and setup custom metaboxes and fields.
38
- * @category Responsive Pricing Table
39
- * @package Metaboxes
40
- */
41
-
42
- add_filter( 'dkrpt_meta_boxes', 'rpt_metaboxes' );
43
-
44
- /*
45
- * Define the metabox and field configurations.
46
- * @param array $meta_boxes
47
- * @return array
48
- */
49
- function rpt_metaboxes( array $meta_boxes ) {
50
-
51
- //hiding fields from custom fields list
52
- $prefix = '_rpt_';
53
-
54
- //price table single metabox (built with dkrpt)
55
- $meta_boxes['rpt_tables_group'] = array(
56
- 'id' => 'tables_group',
57
- 'title' => 'Create / Remove your plans',
58
- 'pages' => array( 'rpt_pricing_table', ),
59
- 'dkrpt_styles' => true,
60
- 'fields' => array(
61
- array(
62
- 'id' => $prefix . 'plan_group',
63
- 'type' => 'group',
64
- 'options' => array(
65
- 'group_title' => 'Plan {#}',
66
- 'add_button' => 'Add Plan',
67
- 'remove_button' => 'Remove Plan',
68
- 'sortable' => true,
69
- ),
70
- 'fields' => array(
71
- array(
72
- 'name' => 'Plan header',
73
- 'id' => $prefix . 'header_desc',
74
- 'type' => 'title',
75
- ),
76
- array(
77
- 'name' => 'Title',
78
- 'id' => $prefix . 'title',
79
- 'type' => 'text',
80
- ),
81
- array(
82
- 'name' => 'Recommended?',
83
- 'desc' => 'check this if it\'s a recommended plan',
84
- 'id' => $prefix . 'recommended',
85
- 'type' => 'checkbox',
86
- 'default' => false,
87
- ),
88
- array(
89
- 'name' => 'Subtitle',
90
- 'id' => $prefix . 'subtitle',
91
- 'type' => 'text',
92
- ),
93
- array(
94
- 'name' => 'Description',
95
- 'id' => $prefix . 'description',
96
- 'type' => 'text',
97
- ),
98
- array(
99
- 'name' => 'Price',
100
- 'id' => $prefix . 'price',
101
- 'type' => 'text',
102
- ),
103
- array(
104
- 'name' => 'Free?',
105
- 'desc' => 'check this if this plan is free',
106
- 'id' => $prefix . 'free',
107
- 'type' => 'checkbox',
108
- 'default' => false,
109
- ),
110
- array(
111
- 'name' => 'Recurrence',
112
- 'id' => $prefix . 'recurrence',
113
- 'type' => 'text',
114
- 'attributes' => array(
115
- 'placeholder' => 'eg. per month, one time fee',
116
- ),
117
- ),
118
- array(
119
- 'name' => 'Small icon',
120
- 'id' => $prefix . 'icon',
121
- 'type' => 'file',
122
- 'attributes' => array(
123
- 'placeholder' => 'recommended size: 30 x 30',
124
- ),
125
- ),
126
- array(
127
- 'name' => 'Plan features',
128
- 'desc' => '<div style="margin-top: 20px;line-height:24px; padding:10px; padding-left:30px; border-left:grey solid 4px;"><span style="font-style:normal; color:black;"><span style="color:black;"><strong>&#60;strong&#62;</strong></span> tags allowed for bold text.<br/><span style="color:#bbbbbb; font-size:12px;">eg. "&#60;strong&#62;5&#60;/strong&#62; products in the store".</span><br/>Use prefix "<span style="color:black;"><strong>-n</strong></span>" if the feature isn\'t available in this plan.<br/><span style="color:#bbbbbb; font-size:12px;">eg. "-n Custom domain name."</span></span></div>',
129
- 'id' => $prefix . 'features_desc',
130
- 'type' => 'title',
131
- ),
132
- array(
133
- 'name' => 'Features',
134
- 'id' => $prefix . 'features',
135
- 'type' => 'textarea',
136
- 'attributes' => array(
137
- 'placeholder' => 'one per line',
138
- ),
139
- ),
140
- array(
141
- 'name' => 'Plan button',
142
- 'id' => $prefix . 'plan_button_desc',
143
- 'type' => 'title',
144
- ),
145
- array(
146
- 'name' => 'Button text',
147
- 'id' => $prefix . 'btn_text',
148
- 'type' => 'text',
149
- 'attributes' => array(
150
- 'placeholder' => 'eg. Sign up, Buy',
151
- ),
152
- ),
153
- array(
154
- 'name' => 'Button link',
155
- 'id' => $prefix . 'btn_link',
156
- 'type' => 'text',
157
- 'attributes' => array(
158
- 'placeholder' => 'eg. http://anything.com',
159
- ),
160
- ),
161
- array(
162
- 'name' => 'Plan styling',
163
- 'id' => $prefix . 'styling_desc',
164
- 'type' => 'title',
165
- ),
166
- array(
167
- 'name' => 'Color',
168
- 'id' => $prefix . 'color',
169
- 'type' => 'colorpicker',
170
- 'default' => '#9fdb80',
171
- ),
172
- ),
173
- ),
174
- ),
175
- );
176
-
177
- //price table single metabox (built with dkrpt)
178
- $meta_boxes['rpt_settings_group'] = array(
179
- 'id' => $prefix . 'settings_group',
180
- 'title' => 'Pricing table settings',
181
- 'pages' => array( 'rpt_pricing_table', ),
182
- 'dkrpt_styles' => true,
183
- 'context' => 'side',
184
- 'fields' => array(
185
- array(
186
- 'name' => 'General settings',
187
- 'id' => $prefix . 'other_settings_desc',
188
- 'type' => 'title',
189
- ),
190
- array(
191
- 'name' => 'Change currency',
192
- 'id' => $prefix . 'currency',
193
- 'type' => 'text',
194
- 'default' => '$',
195
- ),
196
- array(
197
- 'name' => 'Links behavior',
198
- 'id' => $prefix . 'open_newwindow',
199
- 'type' => 'select',
200
- 'options' => array(
201
- 'currentwindow' => 'Open in current window',
202
- 'newwindow' => 'Open in new window/tab',
203
- ),
204
- 'default' => 'currentwindow',
205
- ),
206
- array(
207
- 'name' => 'Font sizes',
208
- 'id' => $prefix . 'font_sizes_desc',
209
- 'type' => 'title',
210
- ),
211
- array(
212
- 'name' => 'Title font size',
213
- 'id' => $prefix . 'title_fontsize',
214
- 'type' => 'select',
215
- 'options' => array(
216
- 'tiny' => 'Tiny',
217
- 'small' => 'Small',
218
- 'normal' => 'Normal',
219
- ),
220
- 'default' => 'normal',
221
- ),
222
- array(
223
- 'name' => 'Subtitle font size',
224
- 'id' => $prefix . 'subtitle_fontsize',
225
- 'type' => 'select',
226
- 'options' => array(
227
- 'tiny' => 'Tiny',
228
- 'small' => 'Small',
229
- 'normal' => 'Normal',
230
- ),
231
- 'default' => 'normal',
232
- ),
233
- array(
234
- 'name' => 'Description font size',
235
- 'id' => $prefix . 'description_fontsize',
236
- 'type' => 'select',
237
- 'options' => array(
238
- 'small' => 'Small',
239
- 'normal' => 'Normal',
240
- ),
241
- 'default' => 'normal',
242
- ),
243
- array(
244
- 'name' => 'Price font size',
245
- 'id' => $prefix . 'price_fontsize',
246
- 'type' => 'select',
247
- 'options' => array(
248
- 'tiny' => 'Tiny',
249
- 'small' => 'Small',
250
- 'normal' => 'Normal',
251
- ),
252
- 'default' => 'normal',
253
- ),
254
- array(
255
- 'name' => 'Recurrence font size',
256
- 'id' => $prefix . 'recurrence_fontsize',
257
- 'type' => 'select',
258
- 'options' => array(
259
- 'small' => 'Small',
260
- 'normal' => 'Normal',
261
- ),
262
- 'default' => 'normal',
263
- ),
264
- array(
265
- 'name' => 'Features font size',
266
- 'id' => $prefix . 'features_fontsize',
267
- 'type' => 'select',
268
- 'options' => array(
269
- 'small' => 'Small',
270
- 'normal' => 'Normal',
271
- ),
272
- 'default' => 'normal',
273
- ),
274
- array(
275
- 'name' => 'Button font size',
276
- 'id' => $prefix . 'button_fontsize',
277
- 'type' => 'select',
278
- 'options' => array(
279
- 'small' => 'Small',
280
- 'normal' => 'Normal',
281
- ),
282
- 'default' => 'normal',
283
- ),
284
- ),
285
- );
286
-
287
- return $meta_boxes;
288
- }
289
-
290
- add_action( 'init', 'rpt_initialize_dkrpt_meta_boxes', 9999 );
291
-
292
- //metabox class
293
- function rpt_initialize_dkrpt_meta_boxes() {
294
-
295
- if ( ! class_exists( 'dkrpt_Meta_Box' ) )
296
- require_once 'dkrpt/init.php';
297
- }
298
-
299
- //shortcode columns
300
- add_action( 'manage_rpt_pricing_table_posts_custom_column' , 'rpt_custom_columns', 10, 2 );
301
-
302
- function rpt_custom_columns( $column, $post_id ) {
303
- switch ( $column ) {
304
- case 'shortcode' :
305
- global $post;
306
- $slug = '' ;
307
- $slug = $post->post_name;
308
-
309
-
310
- $shortcode = '<span style="border: solid 3px lightgray; background:white; padding:7px; font-size:17px; line-height:40px;">[rpt name="'.$slug.'"]</strong>';
311
- echo $shortcode;
312
- break;
313
- }
314
- }
315
-
316
- function add_rpt_pricing_table_columns($columns) {
317
- return array_merge($columns,
318
- array('shortcode' => __('Shortcode'),
319
- ));
320
- }
321
- add_filter('manage_rpt_pricing_table_posts_columns' , 'add_rpt_pricing_table_columns');
322
-
323
- //rpt shortcode
324
- function rpt_sc($atts) {
325
- extract(shortcode_atts(array(
326
- "name" => ''
327
- ), $atts));
328
-
329
- $output = '';
330
-
331
- query_posts( array( 'post_type' => 'rpt_pricing_table', 'name' => $name, ) );
332
- if ( have_posts() ) : while ( have_posts() ) : the_post();
333
-
334
- global $post;
335
- $entries = get_post_meta( $post->ID, '_rpt_plan_group', true );
336
-
337
- $nb_entries = count($entries);;
338
-
339
- //get font sizes
340
- $title_fontsize = get_post_meta( $post->ID, '_rpt_title_fontsize', true );
341
- if ($title_fontsize == 'small') {
342
- $title_fs_class = ' rpt_sm_title';
343
- } else if ($title_fontsize == 'tiny') {
344
- $title_fs_class = ' rpt_xsm_title';
345
- } else {
346
- $title_fs_class = '';
347
- }
348
-
349
- $subtitle_fontsize = get_post_meta( $post->ID, '_rpt_subtitle_fontsize', true );
350
- if ($subtitle_fontsize == 'small') {
351
- $subtitle_fs_class = ' rpt_sm_subtitle';
352
- } else if ($subtitle_fontsize == 'tiny') {
353
- $subtitle_fs_class = ' rpt_xsm_subtitle';
354
- } else {
355
- $subtitle_fs_class = '';
356
- }
357
-
358
- $description_fontsize = get_post_meta( $post->ID, '_rpt_description_fontsize', true );
359
- if ($description_fontsize == 'small') {
360
- $description_fs_class = ' rpt_sm_description';
361
- } else {
362
- $description_fs_class = '';
363
- }
364
-
365
- $price_fontsize = get_post_meta( $post->ID, '_rpt_price_fontsize', true );
366
- if ($price_fontsize == 'small') {
367
- $price_fs_class = ' rpt_sm_price';
368
- } else if ($price_fontsize == 'tiny') {
369
- $price_fs_class = ' rpt_xsm_price';
370
- } else {
371
- $price_fs_class = '';
372
- }
373
-
374
- $recurrence_fontsize = get_post_meta( $post->ID, '_rpt_recurrence_fontsize', true );
375
- if ($recurrence_fontsize == 'small') {
376
- $recurrence_fs_class = ' rpt_sm_recurrence';
377
- } else {
378
- $recurrence_fs_class = '';
379
- }
380
-
381
- $features_fontsize = get_post_meta( $post->ID, '_rpt_features_fontsize', true );
382
- if ($features_fontsize == 'small') {
383
- $features_fs_class = ' rpt_sm_features';
384
- } else {
385
- $features_fs_class = '';
386
- }
387
-
388
- $button_fontsize = get_post_meta( $post->ID, '_rpt_button_fontsize', true );
389
- if ($button_fontsize == 'small') {
390
- $button_fs_class = ' rpt_sm_button';
391
- } else {
392
- $button_fs_class = '';
393
- }
394
-
395
- //opening rpt_pricr container
396
- $output .= '<div id="rpt_pricr" class="rpt_plans rpt_'.$nb_entries .'_plans rpt_style_basic">';
397
-
398
- //opening rpt_pricr inner
399
- $output .= '<div class="'. $title_fs_class . $subtitle_fs_class . $description_fs_class . $price_fs_class . $recurrence_fs_class . $features_fs_class. $button_fs_class .'">';
400
-
401
- foreach ($entries as $key => $plans) {
402
-
403
- if (!empty($plans['_rpt_recommended'])){
404
- $is_reco = $plans['_rpt_recommended'];
405
- //opening plan
406
- if ($is_reco == true ){
407
- $reco = '<img class="rpt_recommended" src="' . plugins_url('img/rpt_recommended.png', __FILE__) . '"/>';
408
- $reco_class = 'rpt_recommended_plan';
409
- } else if ($is_reco == false ) {
410
- $reco = '';
411
- $reco_class = '';
412
- }
413
- } else {
414
- $reco = '';
415
- $reco_class = '';
416
- }
417
-
418
- $output .= '<div class="rpt_plan rpt_plan_' . $key . ' ' . $reco_class . '">';
419
-
420
- //title
421
- if (!empty($plans['_rpt_title'])){
422
- $output .= '<div class="rpt_title rpt_title_' . $key . '">';
423
-
424
- if (!empty($plans['_rpt_icon'])){
425
- $output .= '<img height=30px width=30px src="' . $plans['_rpt_icon'] . '" class="rpt_icon rpt_icon_' . $key . '"/> ';
426
- }
427
-
428
- $output .= $plans['_rpt_title'];
429
- $output .= $reco . '</div>';
430
- }
431
-
432
- //head
433
- $output .= '<div class="rpt_head rpt_head_' . $key . '">';
434
-
435
- //recurrence
436
- if (!empty($plans['_rpt_recurrence'])){
437
- $output .= '<div class="rpt_recurrence rpt_recurrence_' . $key . '">' . $plans['_rpt_recurrence'] . '</div>';
438
- }
439
-
440
- //price
441
- if (!empty($plans['_rpt_price'])){
442
-
443
- $output .= '<div class="rpt_price rpt_price_' . $key . '">';
444
-
445
- if (!empty($plans['_rpt_free'])){
446
- if ($plans['_rpt_free'] == true ){
447
- $output .= __( 'Free' );
448
- } else {
449
- $output .= '<span class="rpt_currency">$</span>' . $plans['_rpt_price'];
450
- }
451
- } else {
452
-
453
- $currency = get_post_meta( $post->ID, '_rpt_currency', true );
454
-
455
- if (!empty($currency)){
456
- $output .= '<span class="rpt_currency">';
457
- $output .= $currency;
458
- $output .= '</span>';
459
- }
460
-
461
- $output .= $plans['_rpt_price'];
462
-
463
- }
464
-
465
- $output .= '</div>';
466
- }
467
-
468
- //subtitle
469
- if (!empty($plans['_rpt_subtitle'])){
470
- $output .= '<div style="color:' . $plans['_rpt_color'] . ';" class="rpt_subtitle rpt_subtitle_' . $key . '">' . $plans['_rpt_subtitle'] . '</div>';
471
- }
472
-
473
- //description
474
- if (!empty($plans['_rpt_description'])){
475
- $output .= '<div class="rpt_description rpt_description_' . $key . '">' . $plans['_rpt_description'] . '</div>';
476
- }
477
-
478
- //closing plan head
479
- $output .= '</div>';
480
-
481
-
482
- if (!empty($plans['_rpt_features'])){
483
-
484
- $output .= '<div class="rpt_features rpt_features_' . $key . '">';
485
-
486
- $string = $plans['_rpt_features'];
487
- $stringAr = explode("\n", $string);
488
- $stringAr = array_filter($stringAr, 'trim'); // remove any extra \r characters left behind
489
-
490
- $features = '';
491
-
492
- foreach ($stringAr as $feature) {
493
- $features[] .= strip_tags($feature,'<strong></strong>');
494
- }
495
-
496
- foreach ($features as $small_key => $feature){
497
- if (!empty($feature)){
498
-
499
- $check = substr($feature, 0, 2);
500
- if ($check == '-n') {
501
- $feature = substr($feature, 2);
502
- $check_color = '#bbbbbb';
503
- } else {
504
- $check_color = 'black';
505
- }
506
-
507
- $output .= '<div style="color:' . $check_color . ';" class="rpt_feature rpt_feature_' . $key . '-' . $small_key . '">';
508
- $output .= $feature;
509
- $output .= '</div>';
510
-
511
- }
512
- }
513
-
514
- $output .= '</div>';
515
- }
516
-
517
- if (!empty($plans['_rpt_btn_text'])){
518
- $btn_text = $plans['_rpt_btn_text'];
519
- if (!empty($plans['_rpt_btn_link'])){
520
- $btn_link = $plans['_rpt_btn_link'];
521
- } else { $btn_link = 'http://#'; }
522
- } else {
523
- $btn_text = 'Sign up';
524
- $btn_link = 'http://#';
525
- }
526
-
527
- //link option
528
- $newcurrentwindow = get_post_meta( $post->ID, '_rpt_open_newwindow', true );
529
- if ($newcurrentwindow == 'newwindow'){
530
- $link_behavior = 'target="_blank"';
531
- } else {
532
- $link_behavior = 'target="_self"';
533
- }
534
-
535
- //foot
536
- $output .= '<a '. $link_behavior .' href="' . $btn_link . '" style="background:' . $plans['_rpt_color'] . '" class="rpt_foot rpt_foot_' . $key . '">';
537
-
538
- //closing foot
539
- $output .= $btn_text;
540
-
541
- //closing foot
542
- $output .= '</a>';
543
-
544
- $output .= '</div>';
545
-
546
- }
547
-
548
- //closing rpt_inner
549
- $output .= '</div>';
550
-
551
- //closing rpt_container
552
- $output .= '</div>';
553
-
554
- $output .= '<div style="clear:both;"></div>';
555
-
556
-
557
- endwhile; endif; wp_reset_query();
558
-
559
- return $output;
560
-
561
- }
562
- add_shortcode("rpt", "rpt_sc");
563
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
  ?>
1
+ <?php
2
+ /**
3
+ * Plugin Name: Responsive Pricing Table
4
+ * Plugin URI: http://wpdarko.com/darko-tools/responsive-pricing-table/
5
+ * Description: A responsive, easy and elegant way to present your offer to your visitors. Just create a new pricing table (custom type) and copy-paste the shortcode into your posts/pages. Find support and information on the <a href="http://wpdarko.com/darko-tools/responsive-pricing-table/">plugin's page</a>. This free version is NOT limited and does not contain any ad. Check out the <a href='http://wpdarko.com/darko-tools/responsive-pricing-table-pro/'>PRO version</a> for more great features.
6
+ * Version: 3.2.1
7
+ * Author: WP Darko
8
+ * Author URI: http://wpdarko.com
9
+ * License: GPL2
10
+ */
11
+
12
+ function free_pro_check() {
13
+ if (is_plugin_active('responsive-pricing-table-pro/rpt_pro.php')) {
14
+
15
+ function my_admin_notice(){
16
+ echo '<div class="updated">
17
+ <p><strong>PRO</strong> version is activated.</p>
18
+ </div>';
19
+ }
20
+ add_action('admin_notices', 'my_admin_notice');
21
+
22
+ deactivate_plugins(__FILE__);
23
+ }
24
+ }
25
+
26
+ add_action( 'admin_init', 'free_pro_check' );
27
+
28
+ //adds stylesheet
29
+ add_action( 'wp_enqueue_scripts', 'add_rpt_style' );
30
+ function add_rpt_style() {
31
+ wp_enqueue_style( 'rpt', plugins_url('css/rpt_custom_style.min.css', __FILE__));
32
+ }
33
+
34
+ add_action( 'init', 'create_rpt_pricing_table_type' );
35
+
36
+ function create_rpt_pricing_table_type() {
37
+ register_post_type( 'rpt_pricing_table',
38
+ array(
39
+ 'labels' => array(
40
+ 'name' => 'Pricing Tables',
41
+ 'singular_name' => 'Pricing Table'
42
+ ),
43
+ 'public' => true,
44
+ 'has_archive' => false,
45
+ 'hierarchical' => false,
46
+ 'supports' => array( 'title' ),
47
+ 'menu_icon' => 'dashicons-plus',
48
+ )
49
+ );
50
+ }
51
+
52
+ /*
53
+ * Include and setup custom metaboxes and fields.
54
+ * @category Responsive Pricing Table
55
+ * @package Metaboxes
56
+ */
57
+
58
+ add_filter( 'dkrpt_meta_boxes', 'rpt_metaboxes' );
59
+
60
+ /*
61
+ * Define the metabox and field configurations.
62
+ * @param array $meta_boxes
63
+ * @return array
64
+ */
65
+ function rpt_metaboxes( array $meta_boxes ) {
66
+
67
+ //hiding fields from custom fields list
68
+ $prefix = '_rpt_';
69
+
70
+ //price table single metabox (built with dkrpt)
71
+ $meta_boxes['rpt_tables_group'] = array(
72
+ 'id' => 'tables_group',
73
+ 'title' => 'Create / Remove your plans',
74
+ 'pages' => array( 'rpt_pricing_table', ),
75
+ 'dkrpt_styles' => true,
76
+ 'fields' => array(
77
+ array(
78
+ 'id' => $prefix . 'plan_group',
79
+ 'type' => 'group',
80
+ 'options' => array(
81
+ 'group_title' => 'Plan {#}',
82
+ 'add_button' => 'Add Plan',
83
+ 'remove_button' => 'Remove Plan',
84
+ 'sortable' => true,
85
+ ),
86
+ 'fields' => array(
87
+ array(
88
+ 'name' => 'Plan header',
89
+ 'id' => $prefix . 'header_desc',
90
+ 'type' => 'title',
91
+ ),
92
+ array(
93
+ 'name' => 'Title',
94
+ 'id' => $prefix . 'title',
95
+ 'type' => 'text',
96
+ ),
97
+ array(
98
+ 'name' => 'Recommended?',
99
+ 'desc' => 'check this if it\'s a recommended plan',
100
+ 'id' => $prefix . 'recommended',
101
+ 'type' => 'checkbox',
102
+ 'default' => false,
103
+ ),
104
+ array(
105
+ 'name' => 'Subtitle',
106
+ 'id' => $prefix . 'subtitle',
107
+ 'type' => 'text',
108
+ ),
109
+ array(
110
+ 'name' => 'Description',
111
+ 'id' => $prefix . 'description',
112
+ 'type' => 'text',
113
+ ),
114
+ array(
115
+ 'name' => 'Price',
116
+ 'id' => $prefix . 'price',
117
+ 'type' => 'text',
118
+ ),
119
+ array(
120
+ 'name' => 'Free?',
121
+ 'desc' => 'check this if this plan is free',
122
+ 'id' => $prefix . 'free',
123
+ 'type' => 'checkbox',
124
+ 'default' => false,
125
+ ),
126
+ array(
127
+ 'name' => 'Recurrence',
128
+ 'id' => $prefix . 'recurrence',
129
+ 'type' => 'text',
130
+ 'attributes' => array(
131
+ 'placeholder' => 'eg. per month, one time fee',
132
+ ),
133
+ ),
134
+ array(
135
+ 'name' => 'Small icon',
136
+ 'id' => $prefix . 'icon',
137
+ 'type' => 'file',
138
+ 'attributes' => array(
139
+ 'placeholder' => 'recommended size: 30 x 30',
140
+ ),
141
+ ),
142
+ array(
143
+ 'name' => 'Plan features',
144
+ 'desc' => '<div style="margin-top: 20px;line-height:24px; padding:10px; padding-left:30px; border-left:grey solid 4px;"><span style="font-style:normal; color:black;"><span style="color:black;"><strong>&#60;strong&#62;</strong></span> tags allowed for bold text.<br/><span style="color:#bbbbbb; font-size:12px;">eg. "&#60;strong&#62;5&#60;/strong&#62; products in the store".</span><br/>Use prefix "<span style="color:black;"><strong>-n</strong></span>" if the feature isn\'t available in this plan.<br/><span style="color:#bbbbbb; font-size:12px;">eg. "-n Custom domain name."</span></span></div>',
145
+ 'id' => $prefix . 'features_desc',
146
+ 'type' => 'title',
147
+ ),
148
+ array(
149
+ 'name' => 'Features',
150
+ 'id' => $prefix . 'features',
151
+ 'type' => 'textarea',
152
+ 'attributes' => array(
153
+ 'placeholder' => 'one per line',
154
+ ),
155
+ ),
156
+ array(
157
+ 'name' => 'Plan button',
158
+ 'id' => $prefix . 'plan_button_desc',
159
+ 'type' => 'title',
160
+ ),
161
+ array(
162
+ 'name' => 'Button text',
163
+ 'id' => $prefix . 'btn_text',
164
+ 'type' => 'text',
165
+ 'attributes' => array(
166
+ 'placeholder' => 'eg. Sign up, Buy',
167
+ ),
168
+ ),
169
+ array(
170
+ 'name' => 'Button link',
171
+ 'id' => $prefix . 'btn_link',
172
+ 'type' => 'text',
173
+ 'attributes' => array(
174
+ 'placeholder' => 'eg. http://anything.com',
175
+ ),
176
+ ),
177
+ array(
178
+ 'name' => 'Plan styling',
179
+ 'id' => $prefix . 'styling_desc',
180
+ 'type' => 'title',
181
+ ),
182
+ array(
183
+ 'name' => 'Color',
184
+ 'id' => $prefix . 'color',
185
+ 'type' => 'colorpicker',
186
+ 'default' => '#9fdb80',
187
+ ),
188
+ ),
189
+ ),
190
+ ),
191
+ );
192
+
193
+ //price table single metabox (built with dkrpt)
194
+ $meta_boxes['rpt_settings_group'] = array(
195
+ 'id' => $prefix . 'settings_group',
196
+ 'title' => 'Pricing table settings',
197
+ 'pages' => array( 'rpt_pricing_table', ),
198
+ 'dkrpt_styles' => true,
199
+ 'context' => 'side',
200
+ 'fields' => array(
201
+ array(
202
+ 'name' => 'General settings',
203
+ 'id' => $prefix . 'other_settings_desc',
204
+ 'type' => 'title',
205
+ ),
206
+ array(
207
+ 'name' => 'Change currency',
208
+ 'id' => $prefix . 'currency',
209
+ 'type' => 'text',
210
+ 'default' => '$',
211
+ ),
212
+ array(
213
+ 'name' => 'Links behavior',
214
+ 'id' => $prefix . 'open_newwindow',
215
+ 'type' => 'select',
216
+ 'options' => array(
217
+ 'currentwindow' => 'Open in current window',
218
+ 'newwindow' => 'Open in new window/tab',
219
+ ),
220
+ 'default' => 'currentwindow',
221
+ ),
222
+ array(
223
+ 'name' => 'Font sizes',
224
+ 'id' => $prefix . 'font_sizes_desc',
225
+ 'type' => 'title',
226
+ ),
227
+ array(
228
+ 'name' => 'Title font size',
229
+ 'id' => $prefix . 'title_fontsize',
230
+ 'type' => 'select',
231
+ 'options' => array(
232
+ 'tiny' => 'Tiny',
233
+ 'small' => 'Small',
234
+ 'normal' => 'Normal',
235
+ ),
236
+ 'default' => 'normal',
237
+ ),
238
+ array(
239
+ 'name' => 'Subtitle font size',
240
+ 'id' => $prefix . 'subtitle_fontsize',
241
+ 'type' => 'select',
242
+ 'options' => array(
243
+ 'tiny' => 'Tiny',
244
+ 'small' => 'Small',
245
+ 'normal' => 'Normal',
246
+ ),
247
+ 'default' => 'normal',
248
+ ),
249
+ array(
250
+ 'name' => 'Description font size',
251
+ 'id' => $prefix . 'description_fontsize',
252
+ 'type' => 'select',
253
+ 'options' => array(
254
+ 'small' => 'Small',
255
+ 'normal' => 'Normal',
256
+ ),
257
+ 'default' => 'normal',
258
+ ),
259
+ array(
260
+ 'name' => 'Price font size',
261
+ 'id' => $prefix . 'price_fontsize',
262
+ 'type' => 'select',
263
+ 'options' => array(
264
+ 'tiny' => 'Tiny',
265
+ 'small' => 'Small',
266
+ 'normal' => 'Normal',
267
+ ),
268
+ 'default' => 'normal',
269
+ ),
270
+ array(
271
+ 'name' => 'Recurrence font size',
272
+ 'id' => $prefix . 'recurrence_fontsize',
273
+ 'type' => 'select',
274
+ 'options' => array(
275
+ 'small' => 'Small',
276
+ 'normal' => 'Normal',
277
+ ),
278
+ 'default' => 'normal',
279
+ ),
280
+ array(
281
+ 'name' => 'Features font size',
282
+ 'id' => $prefix . 'features_fontsize',
283
+ 'type' => 'select',
284
+ 'options' => array(
285
+ 'small' => 'Small',
286
+ 'normal' => 'Normal',
287
+ ),
288
+ 'default' => 'normal',
289
+ ),
290
+ array(
291
+ 'name' => 'Button font size',
292
+ 'id' => $prefix . 'button_fontsize',
293
+ 'type' => 'select',
294
+ 'options' => array(
295
+ 'small' => 'Small',
296
+ 'normal' => 'Normal',
297
+ ),
298
+ 'default' => 'normal',
299
+ ),
300
+ ),
301
+ );
302
+
303
+ return $meta_boxes;
304
+ }
305
+
306
+ add_action( 'init', 'rpt_initialize_dkrpt_meta_boxes', 9999 );
307
+
308
+ //metabox class
309
+ function rpt_initialize_dkrpt_meta_boxes() {
310
+
311
+ if ( ! class_exists( 'dkrpt_Meta_Box' ) )
312
+ require_once 'dkrpt/init.php';
313
+ }
314
+
315
+ //shortcode columns
316
+ add_action( 'manage_rpt_pricing_table_posts_custom_column' , 'rpt_custom_columns', 10, 2 );
317
+
318
+ function rpt_custom_columns( $column, $post_id ) {
319
+ switch ( $column ) {
320
+ case 'shortcode' :
321
+ global $post;
322
+ $slug = '' ;
323
+ $slug = $post->post_name;
324
+
325
+
326
+ $shortcode = '<span style="border: solid 3px lightgray; background:white; padding:7px; font-size:17px; line-height:40px;">[rpt name="'.$slug.'"]</strong>';
327
+ echo $shortcode;
328
+ break;
329
+ }
330
+ }
331
+
332
+ function add_rpt_pricing_table_columns($columns) {
333
+ return array_merge($columns,
334
+ array('shortcode' => __('Shortcode'),
335
+ ));
336
+ }
337
+ add_filter('manage_rpt_pricing_table_posts_columns' , 'add_rpt_pricing_table_columns');
338
+
339
+ //rpt shortcode
340
+ function rpt_sc($atts) {
341
+ extract(shortcode_atts(array(
342
+ "name" => ''
343
+ ), $atts));
344
+
345
+ $output = '';
346
+
347
+ query_posts( array( 'post_type' => 'rpt_pricing_table', 'name' => $name, ) );
348
+ if ( have_posts() ) : while ( have_posts() ) : the_post();
349
+
350
+ global $post;
351
+ $entries = get_post_meta( $post->ID, '_rpt_plan_group', true );
352
+
353
+ $nb_entries = count($entries);;
354
+
355
+ //get font sizes
356
+ $title_fontsize = get_post_meta( $post->ID, '_rpt_title_fontsize', true );
357
+ if ($title_fontsize == 'small') {
358
+ $title_fs_class = ' rpt_sm_title';
359
+ } else if ($title_fontsize == 'tiny') {
360
+ $title_fs_class = ' rpt_xsm_title';
361
+ } else {
362
+ $title_fs_class = '';
363
+ }
364
+
365
+ $subtitle_fontsize = get_post_meta( $post->ID, '_rpt_subtitle_fontsize', true );
366
+ if ($subtitle_fontsize == 'small') {
367
+ $subtitle_fs_class = ' rpt_sm_subtitle';
368
+ } else if ($subtitle_fontsize == 'tiny') {
369
+ $subtitle_fs_class = ' rpt_xsm_subtitle';
370
+ } else {
371
+ $subtitle_fs_class = '';
372
+ }
373
+
374
+ $description_fontsize = get_post_meta( $post->ID, '_rpt_description_fontsize', true );
375
+ if ($description_fontsize == 'small') {
376
+ $description_fs_class = ' rpt_sm_description';
377
+ } else {
378
+ $description_fs_class = '';
379
+ }
380
+
381
+ $price_fontsize = get_post_meta( $post->ID, '_rpt_price_fontsize', true );
382
+ if ($price_fontsize == 'small') {
383
+ $price_fs_class = ' rpt_sm_price';
384
+ } else if ($price_fontsize == 'tiny') {
385
+ $price_fs_class = ' rpt_xsm_price';
386
+ } else {
387
+ $price_fs_class = '';
388
+ }
389
+
390
+ $recurrence_fontsize = get_post_meta( $post->ID, '_rpt_recurrence_fontsize', true );
391
+ if ($recurrence_fontsize == 'small') {
392
+ $recurrence_fs_class = ' rpt_sm_recurrence';
393
+ } else {
394
+ $recurrence_fs_class = '';
395
+ }
396
+
397
+ $features_fontsize = get_post_meta( $post->ID, '_rpt_features_fontsize', true );
398
+ if ($features_fontsize == 'small') {
399
+ $features_fs_class = ' rpt_sm_features';
400
+ } else {
401
+ $features_fs_class = '';
402
+ }
403
+
404
+ $button_fontsize = get_post_meta( $post->ID, '_rpt_button_fontsize', true );
405
+ if ($button_fontsize == 'small') {
406
+ $button_fs_class = ' rpt_sm_button';
407
+ } else {
408
+ $button_fs_class = '';
409
+ }
410
+
411
+ //opening rpt_pricr container
412
+ $output .= '<div id="rpt_pricr" class="rpt_plans rpt_'.$nb_entries .'_plans rpt_style_basic">';
413
+
414
+ //opening rpt_pricr inner
415
+ $output .= '<div class="'. $title_fs_class . $subtitle_fs_class . $description_fs_class . $price_fs_class . $recurrence_fs_class . $features_fs_class. $button_fs_class .'">';
416
+
417
+ foreach ($entries as $key => $plans) {
418
+
419
+ if (!empty($plans['_rpt_recommended'])){
420
+ $is_reco = $plans['_rpt_recommended'];
421
+ //opening plan
422
+ if ($is_reco == true ){
423
+ $reco = '<img class="rpt_recommended" src="' . plugins_url('img/rpt_recommended.png', __FILE__) . '"/>';
424
+ $reco_class = 'rpt_recommended_plan';
425
+ } else if ($is_reco == false ) {
426
+ $reco = '';
427
+ $reco_class = '';
428
+ }
429
+ } else {
430
+ $reco = '';
431
+ $reco_class = '';
432
+ }
433
+
434
+ $output .= '<div class="rpt_plan rpt_plan_' . $key . ' ' . $reco_class . '">';
435
+
436
+ //title
437
+ if (!empty($plans['_rpt_title'])){
438
+ $output .= '<div class="rpt_title rpt_title_' . $key . '">';
439
+
440
+ if (!empty($plans['_rpt_icon'])){
441
+ $output .= '<img height=30px width=30px src="' . $plans['_rpt_icon'] . '" class="rpt_icon rpt_icon_' . $key . '"/> ';
442
+ }
443
+
444
+ $output .= $plans['_rpt_title'];
445
+ $output .= $reco . '</div>';
446
+ }
447
+
448
+ //head
449
+ $output .= '<div class="rpt_head rpt_head_' . $key . '">';
450
+
451
+ //recurrence
452
+ if (!empty($plans['_rpt_recurrence'])){
453
+ $output .= '<div class="rpt_recurrence rpt_recurrence_' . $key . '">' . $plans['_rpt_recurrence'] . '</div>';
454
+ }
455
+
456
+ //price
457
+ if (!empty($plans['_rpt_price'])){
458
+
459
+ $output .= '<div class="rpt_price rpt_price_' . $key . '">';
460
+
461
+ if (!empty($plans['_rpt_free'])){
462
+ if ($plans['_rpt_free'] == true ){
463
+ $output .= __( 'Free' );
464
+ } else {
465
+ $output .= '<span class="rpt_currency">$</span>' . $plans['_rpt_price'];
466
+ }
467
+ } else {
468
+
469
+ $currency = get_post_meta( $post->ID, '_rpt_currency', true );
470
+
471
+ if (!empty($currency)){
472
+ $output .= '<span class="rpt_currency">';
473
+ $output .= $currency;
474
+ $output .= '</span>';
475
+ }
476
+
477
+ $output .= $plans['_rpt_price'];
478
+
479
+ }
480
+
481
+ $output .= '</div>';
482
+ }
483
+
484
+ //subtitle
485
+ if (!empty($plans['_rpt_subtitle'])){
486
+ $output .= '<div style="color:' . $plans['_rpt_color'] . ';" class="rpt_subtitle rpt_subtitle_' . $key . '">' . $plans['_rpt_subtitle'] . '</div>';
487
+ }
488
+
489
+ //description
490
+ if (!empty($plans['_rpt_description'])){
491
+ $output .= '<div class="rpt_description rpt_description_' . $key . '">' . $plans['_rpt_description'] . '</div>';
492
+ }
493
+
494
+ //closing plan head
495
+ $output .= '</div>';
496
+
497
+
498
+ if (!empty($plans['_rpt_features'])){
499
+
500
+ $output .= '<div class="rpt_features rpt_features_' . $key . '">';
501
+
502
+ $string = $plans['_rpt_features'];
503
+ $stringAr = explode("\n", $string);
504
+ $stringAr = array_filter($stringAr, 'trim'); // remove any extra \r characters left behind
505
+
506
+ $features = '';
507
+
508
+ foreach ($stringAr as $feature) {
509
+ $features[] .= strip_tags($feature,'<strong></strong>');
510
+ }
511
+
512
+ foreach ($features as $small_key => $feature){
513
+ if (!empty($feature)){
514
+
515
+ $check = substr($feature, 0, 2);
516
+ if ($check == '-n') {
517
+ $feature = substr($feature, 2);
518
+ $check_color = '#bbbbbb';
519
+ } else {
520
+ $check_color = 'black';
521
+ }
522
+
523
+ $output .= '<div style="color:' . $check_color . ';" class="rpt_feature rpt_feature_' . $key . '-' . $small_key . '">';
524
+ $output .= $feature;
525
+ $output .= '</div>';
526
+
527
+ }
528
+ }
529
+
530
+ $output .= '</div>';
531
+ }
532
+
533
+ if (!empty($plans['_rpt_btn_text'])){
534
+ $btn_text = $plans['_rpt_btn_text'];
535
+ if (!empty($plans['_rpt_btn_link'])){
536
+ $btn_link = $plans['_rpt_btn_link'];
537
+ } else { $btn_link = 'http://#'; }
538
+ } else {
539
+ $btn_text = 'Sign up';
540
+ $btn_link = 'http://#';
541
+ }
542
+
543
+ //link option
544
+ $newcurrentwindow = get_post_meta( $post->ID, '_rpt_open_newwindow', true );
545
+ if ($newcurrentwindow == 'newwindow'){
546
+ $link_behavior = 'target="_blank"';
547
+ } else {
548
+ $link_behavior = 'target="_self"';
549
+ }
550
+
551
+ //foot
552
+ $output .= '<a '. $link_behavior .' href="' . $btn_link . '" style="background:' . $plans['_rpt_color'] . '" class="rpt_foot rpt_foot_' . $key . '">';
553
+
554
+ //closing foot
555
+ $output .= $btn_text;
556
+
557
+ //closing foot
558
+ $output .= '</a>';
559
+
560
+ $output .= '</div>';
561
+
562
+ }
563
+
564
+ //closing rpt_inner
565
+ $output .= '</div>';
566
+
567
+ //closing rpt_container
568
+ $output .= '</div>';
569
+
570
+ $output .= '<div style="clear:both;"></div>';
571
+
572
+
573
+ endwhile; endif; wp_reset_query();
574
+
575
+ return $output;
576
+
577
+ }
578
+ add_shortcode("rpt", "rpt_sc");
579
+
580
  ?>