-
Notifications
You must be signed in to change notification settings - Fork 71
/
pro-sites.php
5608 lines (4718 loc) · 216 KB
/
pro-sites.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Plugin Name: Pro Sites
* Plugin URI: https://premium.wpmudev.org/project/pro-sites/
* Description: The ultimate multisite site upgrade plugin, turn regular sites into multiple pro site subscription levels selling access to storage space, premium themes, premium plugins and much more! Author: WPMU DEV
* Version: 3.6.1
* Author: WPMUDEV
* Author URI: https://premium.wpmudev.org/
* Text Domain: psts
* Domain Path: /pro-sites-files/languages/
* Network: true
* WDP ID: 49
*
*
* Copyright 2007-2017 Incsub (http://incsub.com)
* Author - Aaron Edwards
* Contributors - Rheinard Korf, Jonathan Cowher, Carlos Vences, Andrew Billits, Umesh Kumar, Joel James
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
class ProSites {
var $version = '3.6.1';
var $location;
var $language;
var $plugin_dir = '';
var $plugin_url = '';
var $pro_sites = array();
var $level = array();
var $checkout_processed = false;
var $tcpdf = array(); //Array for PDF settings
//setup error var
var $errors = '';
public static $plugin_file = __FILE__;
function __construct() {
// Creates the class autoloader.
spl_autoload_register( array( $this, 'class_loader' ) );
//setup our variables
$this->init_vars();
//install plugin
register_activation_hook( __FILE__, array( $this, 'install' ) );
//load dashboard notice
global $wpmudev_notices;
$wpmudev_notices[] = array(
'id' => 49,
'name' => 'Pro Sites',
'screens' => array(
'toplevel_page_psts-network',
'pro-sites_page_psts-stats-network',
'pro-sites_page_psts-coupons-network',
'pro-sites_page_psts-levels-network',
'pro-sites_page_psts-modules-network',
'pro-sites_page_psts-plugins-network',
'pro-sites_page_psts-themes-network',
'pro-sites_page_psts-settings-network',
'pro-sites_page_psts-gateways-network',
'pro-sites_page_psts-pricing-settings-network',
),
);
if ( file_exists( $this->plugin_dir . 'dash-notice/wpmudev-dash-notification.php' ) ) {
include_once( $this->plugin_dir . 'dash-notice/wpmudev-dash-notification.php' );
}
// Set global cache group.
wp_cache_add_global_groups( array( 'psts', 'blog-details' ) );
// Force sessions to activate
add_action( 'init', array( 'ProSites_Helper_Session', 'attempt_force_sessions' ) );
//load plugins
require_once( $this->plugin_dir . 'plugins-loader.php' );
// Setup GDPR compliance.
require_once $this->plugin_dir . 'lib/psts-gdpr.php';
// TAX integration
if ( $this->get_setting( 'taxamo_status', false ) ) {
ProSites_Helper_Tax::init_tax();
}
// Other integrations
ProSites_Helper_Integration::init();
/**
* Temporary loading for modules
*
* @todo Improve this
*/
//add important filters
$modules = get_site_option( 'psts_settings' );
$modules = isset( $modules['modules_enabled'] ) ? $modules['modules_enabled'] : array();
foreach ( $modules as $module ) {
ProSites_PluginLoader::require_module( $module );
// Making sure that important filters are in place rather than loading too late
if( method_exists( $module, 'run_critical_tasks' ) && ( is_admin() || ! is_main_site( get_current_blog_id() ) ) ) {
call_user_func( array( $module, 'run_critical_tasks' ) );
}
}
/**
* Taxamo external module works only with PHP 5.3+.
*/
if ( defined( 'PHP_VERSION' ) && version_compare( PHP_VERSION, '5.3', '>=' ) ) {
ProSites_Module_Taxamo::init();
}
//localize
add_action( 'plugins_loaded', array( &$this, 'localization' ) );
//admin page stuff
add_action( 'network_admin_menu', array( &$this, 'plug_network_pages' ) );
add_action( 'admin_menu', array( &$this, 'plug_pages' ) );
add_action( 'admin_bar_menu', array( &$this, 'add_menu_admin_bar' ), 100 );
add_action( 'wp_head', array( &$this, 'add_menu_admin_bar_css' ) );
add_action( 'admin_head', array( &$this, 'add_menu_admin_bar_css' ) );
add_filter( 'wpmu_blogs_columns', array( &$this, 'add_column' ) );
add_action( 'manage_sites_custom_column', array( &$this, 'add_column_field' ), 1, 3 );
add_action( 'init', array( &$this, 'check' ) );
add_action( 'load-toplevel_page_psts-checkout', array( &$this, 'redirect_checkout' ) );
add_action( 'admin_init', array(
&$this,
'signup_redirect',
), 100 ); //delay to make sure it is last hook to admin_init
//trials
add_action( 'wpmu_new_blog', array( &$this, 'trial_extend' ) );
add_action( 'admin_notices', array( &$this, 'trial_notice' ), 2 );
add_action( 'pre_get_posts', array( &$this, 'checkout_page_load' ) );
// Change signup...
add_filter( 'register', array( &$this, 'prosites_signup_url' ) );
add_filter( 'psts_primary_checkout_table', array( 'ProSites_View_Front_Checkout', 'render_checkout_page' ), 10, 3 );
// Add Registration AJAX handler
ProSites_Model_Registration::add_ajax_hook();
add_filter( 'prosite_register_blog_pre_validation', array( 'ProSites_Model_Registration', 'cleanup_unused_user' ), 10, 3 );
// NBT support.
add_filter( 'nbt_signup_templates', array( 'ProSites_Model_Registration', 'filter_nbt_signup_templates' ) );
add_action( 'wp_enqueue_scripts', array( &$this, 'registration_page_styles' ) );
add_filter( 'update_welcome_email', array( 'ProSites_Helper_Registration', 'alter_welcome_for_existing_users' ), 10, 6 );
//handle signup pages
add_action('init','ProSites_Helper_ProSite::redirect_signup_page' );
add_filter( 'prosites_render_checkout_page_period', 'ProSites_View_Front_Gateway::select_current_period', 10, 2 );
add_filter( 'prosites_render_checkout_page_level', 'ProSites_View_Front_Gateway::select_current_level', 10, 2 );
// Dismissed signup prompt
if ( isset( $_GET['psts_dismiss'] ) ) {
update_option( 'psts_signed_up', 0 );
}
//Force Used Space Check in network if quota is enabled
add_action( 'psts_modules_save', array( $this, 'enable_network_used_space_check' ) );
add_action( 'psts_process_stats', array( &$this, 'process_stats' ) ); //cronjob hook
add_filter( 'blog_template_exclude_settings', array(
&$this,
'blog_template_settings',
) ); // exclude pro site setting from blog template copies
//Disable Blog Activation Email, as of Pay before blog creation
add_filter( 'wpmu_signup_blog_notification', array( $this, 'disable_user_activation_mail' ), 10 );
//Register styles
add_action( 'admin_enqueue_scripts', array( $this, 'register_psts_style' ) );
//Display the asterisk detail in sites screen
add_action( 'in_admin_footer', array( $this, 'psts_note' ) );
//update install script if necessary
if ( ( ! defined( 'PSTS_DISABLE_UPGRADE' ) || ( defined( 'PSTS_DISABLE_UPGRADE' ) && ! PSTS_DISABLE_UPGRADE ) ) && $this->get_setting( 'version' ) != $this->version ) {
$this->install();
}
// Hooking here until the models get reworked.
add_action( 'psts_extend', array( $this, 'send_extension_email' ), 10, 7 );
// New receipt
add_action( 'prosites_transaction_record', array( get_class(), 'send_receipt' ) );
//Check for manual signup, on blog activation
add_action('wpmu_activate_blog', array( $this, 'process_manual_signup'), 10, 5 );
//Checks if Allow multiple blog signup is disabled, hides the create new site link from dashboard
add_filter('default_site_option_registration', array($this, 'hide_create_new_site_link') );
add_filter('site_option_registration', array($this, 'hide_create_new_site_link') );
//Show message before checkout table
add_filter('prosites_inner_pricing_table_pre', array($this, 'signup_output') );
// Take action when a gateway changes
add_action( 'psts_extend', array( $this, 'cancel_on_gateway_change' ), 10, 6 );
// Delete blog
add_action( 'delete_blog', array( &$this, 'delete_blog' ) );
// Update password in email.
add_filter( 'update_welcome_email', array( 'ProSites_Helper_Registration', 'update_welcome_email' ), 10, 4 );
$this->setup_ajax_hooks();
$this->errors = new WP_Error();
}
//------------------------------------------------------------------------//
//---Functions------------------------------------------------------------//
//------------------------------------------------------------------------//
private function class_loader( $class ) {
do_action( 'prosites_class_loader_pre_processing', $this );
$basedir = dirname( __FILE__ );
$class = trim( $class );
$included_classes = array(
'^ProSites_Helper',
'^ProSites_View',
'^ProSites_Model',
'^ProSites_Gateway',
'^ProSites_Module',
);
/**
* @todo: Temporary until gateways are adopted into new structure
*/
$class_overrides = array(
'ProSites_Gateway_2Checkout' => 'gateways/gateway-2checkout.php',
'ProSites_Gateway_Manual' => 'gateways/gateway-manual.php',
'ProSites_Gateway_PayPalExpressPro' => 'gateways/gateway-paypal-express-pro.php',
'ProSites_Gateway_Stripe' => 'gateways/gateway-stripe.php',
);
$override_keys = array_keys( $class_overrides );
$pattern = '/' . implode( '|', $included_classes ) . '/';
if ( preg_match( $pattern, $class ) ) {
if( ! in_array( $class, $override_keys ) ) {
$filename = $basedir . '/pro-sites-files/lib/' . str_replace( '_', DIRECTORY_SEPARATOR, $class ) . '.php';
} else {
$filename = $basedir . '/pro-sites-files/' . $class_overrides[ $class ];
}
$filename = apply_filters( 'prosites_class_file_override', $filename );
if ( is_readable( $filename ) ) {
include_once $filename;
return true;
}
}
return false;
}
function localization() {
// Load up the localization file if we're using WordPress in a different language
// Place it in this plugin's "languages" folder and name it "psts-[value in wp-config].mo"
if ( $this->location == 'plugins' ) {
load_plugin_textdomain( 'psts', false, basename( dirname( __FILE__ ) ) . '/pro-sites-files/languages/' );
} else if ( $this->location == 'mu-plugins' ) {
load_muplugin_textdomain( 'psts', '/pro-sites-files/languages/' );
}
//setup language code for jquery datepicker translation
$temp_locales = explode( '_', get_locale() );
$this->language = ( $temp_locales[0] ) ? $temp_locales[0] : 'en';
}
function init_vars() {
//setup proper directories
if ( defined( 'WP_PLUGIN_URL' ) && defined( 'WP_PLUGIN_DIR' ) && file_exists( plugin_dir_path( __FILE__ ) . basename( __FILE__ ) ) ) {
$this->location = 'plugins';
$this->plugin_dir = plugin_dir_path( __FILE__ ) . 'pro-sites-files/';
$this->plugin_url = plugins_url( '/pro-sites-files/', __FILE__ );
} else if ( defined( 'WPMU_PLUGIN_URL' ) && defined( 'WPMU_PLUGIN_DIR' ) && file_exists( WPMU_PLUGIN_DIR . '/' . basename( __FILE__ ) ) ) {
$this->location = 'mu-plugins';
$this->plugin_dir = WPMU_PLUGIN_DIR . '/pro-sites-files/';
$this->plugin_url = WPMU_PLUGIN_URL . '/pro-sites-files/';
} else {
wp_die( __( 'There was an issue determining where Pro Sites is installed. Please reinstall.', 'psts' ) );
}
//Text Domain
define('PSTS_TEXT_DOMAIN', 'psts');
define('PSTS_PREFIX', 'psts');
//load data structures
require_once( $this->plugin_dir . 'data.php' );
}
private function setup_ajax_hooks() {
add_action( 'wp_ajax_apply_coupon_to_checkout', array( 'ProSites_Helper_Coupons', 'apply_coupon_to_checkout' ) );
// Adding _nopriv_ for future buy on register
add_action( 'wp_ajax_nopriv_apply_coupon_to_checkout', array( 'ProSites_Helper_Coupons', 'apply_coupon_to_checkout' ) );
add_action( 'wp_ajax_nopriv_create_prosite_blog', array( 'ProSites_Model_Registration', 'ajax_create_prosite_blog' ) );
add_action( 'wp_ajax_nopriv_check_prosite_blog', array( 'ProSites_Model_Registration', 'ajax_check_prosite_blog' ) );
}
public static function get_default_settings_array() {
return array(
'base_country' => 'US',
'currency' => 'USD',
'curr_symbol_position' => 1,
'curr_decimal' => 1,
'rebrand' => __( 'Pro Site', 'psts' ),
'lbl_signup' => __( 'Pro Upgrade', 'psts' ),
'lbl_curr' => __( 'Your Account', 'psts' ),
'gateways_enabled' => array(),
'modules_enabled' => array(),
'enabled_periods' => array( 1, 3, 12 ),
'send_receipts' => 1,
'hide_adminmenu' => 0,
'hide_adminbar' => 0,
'hide_adminbar_super' => 0,
'show_signup' => 1,
'show_signup_message' => 0,
'free_signup' => 0,
'multiple_signup' => 1,
'free_name' => __( 'Free', 'psts' ),
'free_msg' => __( 'No thank you, I will continue with a basic site for now', 'psts' ),
'trial_days' => get_site_option( "supporter_free_days" ),
'trial_message' => __( 'You have DAYS days left in your LEVEL free trial. Checkout now to prevent losing LEVEL features »', 'psts' ),
'cancel_message' => __( 'Your DAYS day trial begins once you click "Subscribe" below. We perform a $1 pre-authorization to ensure your credit card is valid, but we won\'t actually charge your card until the end of your trial. If you don\'t cancel by day DAYS, your card will be charged for the subscription amount shown above. You can cancel your subscription at any time.', 'psts' ),
'recurring_subscriptions' => 1,
'ga_ecommerce' => 'none',
'signup_message' => __( 'Signup for a Pro site', 'psts' ),
'feature_message' => __( 'Upgrade to LEVEL to access this feature »', 'psts' ),
'active_message' => __( 'Your Pro Site privileges will expire on: DATE<br />Unless you have canceled your subscription or your site was upgraded via the Bulk Upgrades tool, your Pro Site privileges will automatically be renewed.', 'psts' ),
'success_subject' => __( 'Thank you for becoming a Pro Site member!', 'psts' ),
'success_msg' => __( "Thank you for becoming a Pro Site member!\n\nWe have received your first subscription payment and you can now access all LEVEL features!\n\nSubscription payments should show on your credit card or bank statement as \"THIS COMPANY\". If you ever need to view, modify, upgrade, or cancel your Pro Site subscription you can do so here:\nCHECKOUTURL\n\nIf you ever have any billing questions please contact us:\nhttp://mysite.com/contact/\n\nThanks again for joining!", 'psts' ),
'canceled_subject' => __( 'Your Pro Site subscription has been canceled', 'psts' ),
'canceled_msg' => __( "Your Pro Site subscription has been canceled.\n\nYou should continue to have access until ENDDATE.\n\nWe are very sorry to see you go, but we are looking forward to you subscribing to our services again.\n\nYou can resubscribe at any time here:\nCHECKOUTURL\n\nThanks!", 'psts' ),
'receipt_subject' => __( 'Your Pro Site payment receipt', 'psts' ),
'receipt_msg' => __( "Your Pro Site subscription payment was successful!\n\nPAYMENTINFO\n\nSubscription payments should show on your credit card or bank statement as \"YOUR COMPANY\". If you ever need to view, modify, upgrade, or cancel your Pro Site subscription you can do so here:\nCHECKOUTURL\n\nIf you ever have any billing questions please contact us:\nhttp://mysite.com/contact/\n\nThanks again for being a valued member!", 'psts' ),
'expired_subject' => __( 'Your Pro Site status has expired', 'psts' ),
'expired_msg' => __( "Unfortunately the Pro status for your site SITENAME (SITEURL) has lapsed.\n\nYou can renew your Pro Site status here:\nCHECKOUTURL\n\nIf you're having billing problems please contact us for help:\nhttp://mysite.com/contact/\n\nLooking forward to having you back as a valued member!", 'psts' ),
'failed_subject' => __( 'Your Pro Site subscription payment failed', 'psts' ),
'failed_msg' => __( "It seems like there is a problem with your latest Pro Site subscription payment, sorry about that.\n\nPlease update your payment information or change your payment method as soon as possible to avoid a lapse in Pro Site features. If you're still having billing problems please contact us for help:\nhttp://mysite.com/contact/\n\nMany thanks again for being a member!", 'psts' ),
'extension_subject' => __( 'You have been given free Pro Site membership.', 'psts' ),
'extension_msg' => __( "We have given you Pro Site access. You will now be able to enjoy all the benefits of being a Pro Site member.\n\nThese benefits will be available to you until: ENDDATE.\n\nAfter this date your site will revert back to a standard site.\n\nYou can subscribe at any time from the link below:\nCHECKOUTURL\n\nThanks!", 'psts' ),
'revoked_subject' => __( 'Your permanent Pro Site status has changed.', 'psts' ),
'revoked_msg' => __( "Your permanent Pro Site status has been removed. You will continue to have all the benefits of your Pro Site membership until ENDDATE.\n\nAfter this date your site will revert back to a standard site.\n\nYou can subscribe at any time from the link below:\nCHECKOUTURL\n\nThanks!", 'psts' ),
'pypl_site' => 'US',
'pypl_currency' => 'USD',
'pypl_status' => 'test',
'pypl_enable_pro' => 0,
'stripe_ssl' => 0,
'stripe_debug' => 0,
'mp_name' => __( 'Manual Payment', 'psts' ),
'mp_show_form' => 0,
'mp_email' => get_site_option( "admin_email" ),
'pt_name' => __( 'Premium Themes', 'psts' ),
'pt_text' => __( 'Upgrade to LEVEL to activate this premium theme »', 'psts' ),
'ps_level' => 1,
'ps_email' => get_site_option( "admin_email" ),
'ps_name' => __( 'Premium Support', 'psts' ),
'ps_message' => __( 'You can send us a priority direct email support request here if you need help with your site.', 'psts' ),
'ps_notice' => __( 'To enable premium support, please upgrade to LEVEL »', 'psts' ),
'publishing_level' => 1,
'publishing_message_posts' => __( 'To enable publishing posts, please upgrade to LEVEL »', 'psts' ),
'publishing_message_pages' => __( 'To enable publishing pages, please upgrade to LEVEL »', 'psts' ),
'quota_message' => __( 'For SPACE of upload space, upgrade to LEVEL!', 'psts' ),
'quota_out_message' => __( 'You are out of upload space! Please upgrade to LEVEL to enable SPACE of storage space.', 'psts' ),
'xmlrpc_level' => 1,
'xmlrpc_message' => __( 'To enable XML-RPC remote publishing please upgrade to LEVEL »', 'psts' ),
'bp_notice' => __( 'Upgrade to LEVEL to access this feature »', 'psts' ),
'pp_name' => __( 'Premium Plugins', 'psts' ),
'ads_name' => __( 'Disable Ads', 'psts' ),
'ads_level' => 1,
'ads_enable_blogs' => 0,
'ads_count' => 3,
'ads_before_page' => 0,
'ads_after_page' => 0,
'ads_before_post' => 0,
'ads_after_post' => 0,
'ads_themes' => 0,
'bu_email' => get_site_option( "supporter_paypal_email" ),
'bu_status' => 'test',
'bu_payment_type' => 'recurring',
'bu_level' => 1,
'bu_credits_1' => 10,
'bu_option_msg' => __( 'Upgrade CREDITS sites to LEVEL for one year for only PRICE:', 'psts' ),
'bu_checkout_msg' => __( 'You can upgrade multiple sites at a lower cost by purchasing Pro Site credits below. After purchasing your credits just come back to this page, search for your sites via the tool at the bottom of the page, and upgrade them to Pro Site status. Each site is upgraded for one year.', 'psts' ),
'bu_payment_msg' => __( 'Depending on your payment method it may take just a few minutes (Credit Card or PayPal funds) or it may take several days (eCheck) for your Pro Site credits to become available.', 'psts' ),
'bu_name' => __( 'Bulk Upgrades', 'psts' ),
'bu_link_msg' => __( 'Purchase credits to upgrade multiple sites for one discounted price!', 'psts' ),
'ptb_front_disable' => 1,
'ptb_front_msg' => __( 'This site is temporarily disabled until payment is received. Please check back later.', 'psts' ),
'ptb_checkout_msg' => __( 'You must pay to enable your site.', 'psts' ),
'pq_level' => 1,
'pq_quotas' => array(
'post' => array( 'quota' => 'unlimited' ),
'page' => array( 'quota' => 'unlimited' ),
),
'uh_level' => 1,
'uh_message' => __( 'To enable the embedding html, please upgrade to LEVEL »', 'psts' ),
'co_pricing' => 'disabled',
'plans_table_enabled' => 'enabled',
'subsites_ssl' => is_ssl() ? 1 : 0,
);
}
function install() {
global $wpdb, $current_site;
//check if multisite is installed
if ( ! is_multisite() ) {
$this->trigger_install_error( __( 'WordPress multisite is required to run this plugin. <a target="_blank" href="http://codex.wordpress.org/Create_A_Network">Create a network</a>.', 'psts' ), E_USER_ERROR );
}
//rename tables if upgrading from old supporter
if ( get_site_option( "supporter_installed" ) == "yes" ) {
$wpdb->query( "RENAME TABLE `{$wpdb->base_prefix}supporters` TO `{$wpdb->base_prefix}pro_sites`" );
$wpdb->query( "RENAME TABLE `{$wpdb->base_prefix}supporter_signup_stats` TO `{$wpdb->base_prefix}pro_sites_signup_stats`" );
$wpdb->query( "RENAME TABLE `{$wpdb->base_prefix}supporter_daily_stats` TO `{$wpdb->base_prefix}pro_sites_daily_stats`" );
delete_site_option( "supporter_installed" );
}
if( ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', false );
}
$table1 = "CREATE TABLE {$wpdb->base_prefix}pro_sites (
blog_ID bigint(20) NOT NULL,
level int(3) NOT NULL DEFAULT 1,
expire bigint(20) NOT NULL,
gateway varchar(25) NULL DEFAULT '',
term varchar(25) NULL DEFAULT NULL,
amount varchar(10) NULL DEFAULT NULL,
is_recurring tinyint(1) NULL DEFAULT 1,
meta longtext NOT NULL,
identifier varchar(50) NULL,
PRIMARY KEY (blog_ID),
KEY ps_indexes (blog_ID,level,expire)
);";
$table2 = "CREATE TABLE {$wpdb->base_prefix}pro_sites_signup_stats (
action_ID bigint(20) unsigned NOT NULL auto_increment,
blog_ID bigint(20) NOT NULL,
action varchar(20) NOT NULL,
time_stamp DATE NOT NULL,
PRIMARY KEY (action_ID)
);";
$table3 = "CREATE TABLE {$wpdb->base_prefix}pro_sites_daily_stats (
id bigint(20) unsigned NOT NULL auto_increment,
date DATE NOT NULL,
supporter_count int(10) NOT NULL DEFAULT 0,
expired_count int(10) NOT NULL DEFAULT 0,
term_count_1 int(10) NOT NULL DEFAULT 0,
term_count_3 int(10) NOT NULL DEFAULT 0,
term_count_12 int(10) NOT NULL DEFAULT 0,
term_count_manual int(10) NOT NULL DEFAULT 0,
level_count_1 int(10) NOT NULL DEFAULT 0,
level_count_2 int(10) NOT NULL DEFAULT 0,
level_count_3 int(10) NOT NULL DEFAULT 0,
level_count_4 int(10) NOT NULL DEFAULT 0,
level_count_5 int(10) NOT NULL DEFAULT 0,
level_count_6 int(10) NOT NULL DEFAULT 0,
level_count_7 int(10) NOT NULL DEFAULT 0,
level_count_8 int(10) NOT NULL DEFAULT 0,
level_count_9 int(10) NOT NULL DEFAULT 0,
level_count_10 int(10) NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);";
$table4 = "CREATE TABLE {$wpdb->base_prefix}pro_sites_transactions (
id bigint(20) unsigned NOT NULL auto_increment,
transaction_id varchar(255) NOT NULL,
transaction_date DATE NOT NULL,
items longtext NOT NULL,
total decimal(13,4) NOT NULL DEFAULT 0,
sub_total decimal(13,4) NOT NULL DEFAULT 0,
tax_amount decimal(13,4) NOT NULL DEFAULT 0,
tax_percentage decimal(4,2) NOT NULL DEFAULT 0,
country varchar(3) NULL,
currency varchar(3) NULL,
meta longtext NULL,
PRIMARY KEY (id),
KEY ps_trans_indexes (id, transaction_id)
);";
//@todo: A Check needs to be in place to see if all the table exists or not
// If we get an error while creating table, plugin user should be aware of it.
if ( ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) || ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) && ! DO_NOT_UPGRADE_GLOBAL_TABLES ) ) {
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $table1 );
dbDelta( $table2 );
dbDelta( $table3 );
dbDelta( $table4 );
}
// add stats cron job action only to main site (or it may be running all the time!)
switch_to_blog( $current_site->blog_id );
if ( ! wp_next_scheduled( 'psts_process_stats' ) ) {
//get end of day
$time = strtotime( date( "Y-m-d 23:50:00" ) );
wp_schedule_event( $time, 'daily', 'psts_process_stats' );
}
restore_current_blog();
//our default settings
$default_settings = ProSites::get_default_settings_array();
$settings = wp_parse_args( ( array ) get_site_option( 'psts_settings' ), $default_settings );
update_site_option( 'psts_settings', $settings );
//default level
$default_levels = array(
1 => array(
'name' => __( 'Pro', 'psts' ),
'price_1' => get_site_option( "supporter_1_whole_cost" ) . '.' . get_site_option( "supporter_1_partial_cost" ),
'price_3' => get_site_option( "supporter_3_whole_cost" ) . '.' . get_site_option( "supporter_3_partial_cost" ),
'price_12' => get_site_option( "supporter_12_whole_cost" ) . '.' . get_site_option( "supporter_12_partial_cost" ),
),
);
if ( ! get_site_option( 'psts_levels' ) ) {
add_site_option( 'psts_levels', $default_levels );
}
//create a checkout page if not existing
add_action( 'init', array( &$this, 'create_checkout_page' ) );
//3.4.3.8 upgrade - fixes permanent upgrades that got truncated on 32 bit systems due to (int) casting
if ( version_compare( $this->get_setting( 'version' ), '3.4.3.7', '<=' ) ) {
$wpdb->query( "UPDATE {$wpdb->base_prefix}pro_sites SET expire = '9999999999' WHERE expire = '1410065407'" );
}
//3.5 upgrade - modify pro_sites table
if ( version_compare( $this->get_setting( 'version' ), '3.5', '<=' ) ) {
// Using dbDelta above, but add other code here.
//$wpdb->query( "ALTER TABLE {$wpdb->base_prefix}pro_sites ADD meta longtext NOT NULL" );
}
// If upgrading from a version lesser than or equal to 3.5.4 display options for Paypal pro, otherwise hide them
if ( $this->get_setting( 'version' ) && version_compare( $this->get_setting( 'version' ), '3.5.4', '<=' ) ) {
$this->update_setting( 'display_paypal_pro_option', true );
}
$this->update_setting( 'version', $this->version );
}
//an easy way to get to our settings array without undefined indexes
function get_setting( $key, $default = null ) {
$settings = get_site_option( 'psts_settings' );
$setting = isset( $settings[ $key ] ) ? $settings[ $key ] : $default;
$setting = !is_array( $setting ) ? trim( $setting ) : $setting;
/**
* Filter the specific setting, $key parameter value
*
* @param array $setting
* @param mixed $default , null The default value for $key setting if there is no value returned
*/
return apply_filters( "psts_setting_$key", $setting, $default );
}
//determine if a given level has a setup fee for a given blog id
function has_setup_fee( $blog_id, $level ) {
$setup_fee_amt = ProSites_Helper_Settings::setup_fee();
if( empty( $blog_id ) && 0 < $setup_fee_amt ) {
return true;
}
if ( 0 == $setup_fee_amt ) {
return false;
} //setup fee not set or is 0
if ( $this->get_level( $blog_id ) == 0 ) {
return true;
} //this is a free site. always apply setup fee.
if ( $this->get_level( $blog_id ) > $level ) {
return false;
} //customer is downgrading. don't apply setup fee
if ( ! self::is_trial( $blog_id ) && is_pro_site( $blog_id ) && ! $this->get_setting( 'apply_setup_fee_upgrade', false ) ) {
return false;
} //this is a pro site, not in trial, and admin doesn't want setup fees applied to upgrades
return true;
}
function update_setting( $key, $value ) {
$settings = get_site_option( 'psts_settings' );
$settings[ $key ] = $value;
return update_site_option( 'psts_settings', $settings );
}
function get_level_setting( $level, $key, $default = null ) {
$levels = ( array ) get_site_option( 'psts_levels' );
return isset( $levels[ $level ][ $key ] ) ? $levels[ $level ][ $key ] : $default;
}
function update_level_setting( $level, $key, $value ) {
$levels = ( array ) get_site_option( 'psts_levels' );
$levels[ $level ][ $key ] = $value;
return update_site_option( 'psts_levels', $levels );
}
/**
* Add trial days
*
* @param $blog_id
*/
function trial_extend( $blog_id ) {
$trial_days = $this->get_setting( 'trial_days' );
$free_signup = $this->get_setting( 'free_signup' );
$level = !empty( $_POST['level'] ) ? intval( $_POST['level'] ) : 1;
if( $free_signup ) {
return;
}elseif ( $trial_days > 0 ) {
$extend = $trial_days * 86400;
$this->extend( $blog_id, $extend, 'trial', $level );
}
}
function trial_notice() {
global $wpdb, $blog_id;
//get allowed roles for checkout
$checkout_roles = $this->get_setting( 'checkout_roles', array( 'administrator', 'editor' ) );
//check If user is allowed
$current_user_id = get_current_user_id();
$permission = $this->check_user_role( $current_user_id, $checkout_roles );
// Check if it is trialing.
$trialing = ProSites_Helper_Registration::is_trial( $blog_id );
if ( ! is_main_site() && $permission && $this->get_setting( 'trial_days' ) && $trialing ) {
$expire = $wpdb->get_var( $wpdb->prepare( "
SELECT expire
FROM {$wpdb->base_prefix}pro_sites
WHERE blog_ID = %d
AND expire >= %s
LIMIT 1", $blog_id, time()
) );
if ( $expire ) {
$days = round( ( $expire - time() ) / 86400 ); //calculate days left rounded
$notice = str_replace( 'LEVEL', $this->get_level_setting( $this->get_level($blog_id), 'name' ), $this->get_setting( 'trial_message' ) );
$notice = str_replace( 'DAYS', $days, $notice );
echo '
<div class="update-nag">
<a href="' . $this->checkout_url( $blog_id ) . '">' . $notice . '</a>
</div>';
}
}
}
function is_trial( $blog_id ) {
global $wpdb;
$trialing = ProSites_Helper_Registration::is_trial( $blog_id );
if( ! $trialing ) {
$trialing = empty( $blog_id ) ? false : $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = %d AND ( gateway = 'Trial' OR gateway = 'trial' ) AND expire >= %s LIMIT 1", $blog_id, time() ) );
}
return $trialing;
}
//run daily via wp_cron
function process_stats() {
global $wpdb;
$date = date( "Y-m-d", time() );
//don't process if already completed today (in case wp_cron goes nutzy)
$existing = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_daily_stats WHERE date = '" . $date . "'" );
if ( $existing ) {
return;
}
$active_pro_sites = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE expire > '" . time() . "'" );
$expired_pro_sites = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE expire <= '" . time() . "'" );
$term_1_pro_sites = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE term = 1 AND expire > '" . time() . "'" );
$term_3_pro_sites = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE term = 3 AND expire > '" . time() . "'" );
$term_12_pro_sites = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE term = 12 AND expire > '" . time() . "'" );
$term_manual_pro_sites = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE term NOT IN (1,3,12) AND expire > '" . time() . "'" );
//get level counts
$levels = get_site_option( 'psts_levels' );
$level_count = array();
for ( $i = 1; $i <= 10; $i ++ ) {
$level_count[ $i ] = 0;
} //prefill the array
if ( is_array( $levels ) && count( $levels ) > 1 ) {
foreach ( $levels as $level => $data ) {
//if last level include all previous ones greater than that level, in case a level was deleted
if ( count( $levels ) == $level ) {
$level_count[ $level ] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE level >= %d AND expire > %s", $level, time() ) );
} else {
$level_count[ $level ] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE level = %d AND expire > %s", $level, time() ) );
}
}
} else {
$level_count[1] = $active_pro_sites;
}
$wpdb->query( "INSERT INTO {$wpdb->base_prefix}pro_sites_daily_stats ( date, supporter_count, expired_count, term_count_1, term_count_3, term_count_12, term_count_manual, level_count_1, level_count_2, level_count_3, level_count_4, level_count_5, level_count_6, level_count_7, level_count_8, level_count_9, level_count_10 )
VALUES ( '$date', $active_pro_sites, $expired_pro_sites, $term_1_pro_sites, $term_3_pro_sites, $term_12_pro_sites, $term_manual_pro_sites, {$level_count[1]}, {$level_count[2]}, {$level_count[3]}, {$level_count[4]}, {$level_count[5]}, {$level_count[6]}, {$level_count[7]}, {$level_count[8]}, {$level_count[9]}, {$level_count[10]} )" );
}
/*
Used for stats, must be called by payment gateways
--------------------------------------------------
Parameters:
$blog_id = blog's id
$action = "signup", "cancel", "modify", "upgrade"
*/
function record_stat( $blog_id, $action ) {
global $wpdb;
//only record one stat action per blog per day
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_signup_stats WHERE blog_ID = %s AND action = %s AND time_stamp = %s", $blog_id, $action, date( 'Y-m-d' ) ) );
if ( ! $exists ) {
$wpdb->insert( "{$wpdb->base_prefix}pro_sites_signup_stats", array(
'blog_ID' => $blog_id,
'action' => $action,
'time_stamp' => date( 'Y-m-d' ),
), array( '%d', '%s', '%s' ) );
}
}
//returns html of a weekly summary
function weekly_summary() {
global $wpdb;
$img_base = $this->plugin_url . 'images/';
//count total
$current_total = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites WHERE expire > '" . time() . "'" );
$date = date( "Y-m-d", strtotime( "-1 week" ) );
$last_total = $wpdb->get_var( "SELECT supporter_count FROM {$wpdb->base_prefix}pro_sites_daily_stats WHERE date >= '$date' ORDER BY date ASC LIMIT 1" );
if ( $current_total > $last_total ) {
$active_diff = "<img src='{$img_base}green-up.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( $current_total - $last_total ) . "</span>";
} else if ( $current_total < $last_total ) {
$active_diff = "<img src='{$img_base}red-down.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( - ( $current_total - $last_total ) ) . "</span>";
} else {
$active_diff = "<span style='font-size: 18px; font-family: arial;'>" . __( 'no change', 'psts' ) . "</span>";
}
$text = sprintf( __( '%s active Pro Sites %s since last week', 'psts' ), "<p><span style='font-size: 24px; font-family: arial;'>" . number_format_i18n( $current_total ) . "</span><span style='color: rgb(85, 85, 85);'>", "</span>$active_diff<span style='color: rgb(85, 85, 85);'>" ) . "</span></p>";
//activity stats
$week_start = strtotime( "-1 week" );
$week_start_date = date( 'Y-m-d', $week_start );
$this_week['total_signups'] = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_signup_stats WHERE action = 'signup' AND time_stamp >= '$week_start_date'" );
$this_week['upgrades'] = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_signup_stats WHERE action = 'upgrade' AND time_stamp >= '$week_start_date'" );
$this_week['cancels'] = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_signup_stats WHERE action = 'cancel' AND time_stamp >= '$week_start_date'" );
$number_trial = count( ProSites_Helper_Registration::get_all_trial_blogs() );
$week_end = $week_start;
$week_start = strtotime( "-1 week", $week_start );
$week_start_date = date( 'Y-m-d', $week_start );
$week_end_date = date( 'Y-m-d', $week_end );
$last_week['total_signups'] = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_signup_stats WHERE action = 'signup' AND time_stamp >= '$week_start_date' AND time_stamp < '$week_end_date'" );
$last_week['upgrades'] = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_signup_stats WHERE action = 'upgrade' AND time_stamp >= '$week_start_date' AND time_stamp < '$week_end_date'" );
$last_week['cancels'] = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->base_prefix}pro_sites_signup_stats WHERE action = 'cancel' AND time_stamp >= '$week_start_date' AND time_stamp < '$week_end_date'" );
if ( $this_week['total_signups'] > $last_week['total_signups'] ) {
$diff = "<img src='{$img_base}green-up.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( $this_week['total_signups'] - $last_week['total_signups'] ) . "</span>";
} else if ( $this_week['total_signups'] < $last_week['total_signups'] ) {
$diff = "<img src='{$img_base}red-down.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( - ( $this_week['total_signups'] - $last_week['total_signups'] ) ) . "</span>";
} else {
$diff = "<span style='font-size: 18px; font-family: arial;'>" . __( 'no change', 'psts' ) . "</span>";
}
$text .= sprintf( __( '%s new signups this week %s compared to last week', 'psts' ), "\n<p><span style='font-size: 24px; font-family: arial;'>" . number_format_i18n( $this_week['total_signups'] ) . "</span><span style='color: rgb(85, 85, 85);'>", "</span>$diff<span style='color: rgb(85, 85, 85);'>" ) . "</span></p>";
if ( $this_week['upgrades'] > $last_week['upgrades'] ) {
$diff = "<img src='{$img_base}green-up.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( $this_week['upgrades'] - $last_week['upgrades'] ) . "</span>";
} else if ( $this_week['upgrades'] < $last_week['upgrades'] ) {
$diff = "<img src='{$img_base}red-down.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( - ( $this_week['upgrades'] - $last_week['upgrades'] ) ) . "</span>";
} else {
$diff = "<span style='font-size: 18px; font-family: arial;'>" . __( 'no change', 'psts' ) . "</span>";
}
$text .= sprintf( __( '%s upgrades this week %s compared to last week', 'psts' ), "\n<p><span style='font-size: 24px; font-family: arial;'>" . number_format_i18n( $this_week['upgrades'] ) . "</span><span style='color: rgb(85, 85, 85);'>", "</span>$diff<span style='color: rgb(85, 85, 85);'>" ) . "</span></p>";
if ( $this_week['cancels'] > $last_week['cancels'] ) {
$diff = "<img src='{$img_base}red-up.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( $this_week['cancels'] - $last_week['cancels'] ) . "</span>";
} else if ( $this_week['cancels'] < $last_week['cancels'] ) {
$diff = "<img src='{$img_base}green-down.gif'><span style='font-size: 18px; font-family: arial;'>" . number_format_i18n( - ( $this_week['cancels'] - $last_week['cancels'] ) ) . "</span>";
} else {
$diff = "<span style='font-size: 18px; font-family: arial;'>" . __( 'no change', 'psts' ) . "</span>";
}
$text .= sprintf( __( '%s cancelations this week %s compared to last week', 'psts' ), "\n<p><span style='font-size: 24px; font-family: arial;'>" . number_format_i18n( $this_week['cancels'] ) . "</span><span style='color: rgb(85, 85, 85);'>", "</span>$diff<span style='color: rgb(85, 85, 85);'>" ) . "</span></p>";
// Current active trials
$text .= sprintf( '<p>' . __( '%s active trials.', 'psts' ) . '</p>', "<span style='font-size: 24px; font-family: arial;'>" . number_format_i18n( $number_trial ) . "</span>" );
return $text;
}
function plug_network_pages() {
global $psts_plugin_loader;
//main page
$psts_main_page = add_menu_page( __( 'Pro Sites', 'psts' ), __( 'Pro Sites', 'psts' ), 'manage_network_options', 'psts', array(
&$this,
'admin_modify',
), 'dashicons-plus' );
$psts_manage_sites_page = add_submenu_page( 'psts', __( 'Manage Sites', 'psts' ), __( 'Manage Sites', 'psts' ), 'manage_network_options', 'psts', array(
&$this,
'admin_modify',
) );
do_action( 'psts_page_after_main' );
//stats page
$psts_stats_page = add_submenu_page( 'psts', __( 'Pro Sites Statistics', 'psts' ), __( 'Statistics', 'psts' ), 'manage_network_options', 'psts-stats', array(
&$this,
'admin_stats',
) );
do_action( 'psts_page_after_stats' );
//coupons page
// $psts_coupons_page_old = add_submenu_page( 'psts', __( 'Pro Sites Coupons', 'psts' ), __( 'Coupons', 'psts' ), 'manage_network_options', 'psts-coupons-old', array(
// &$this,
// 'admin_coupons'
// ) );
//ProSites_View_Coupons
$psts_coupons_page = add_submenu_page( 'psts', ProSites_View_Coupons::get_page_name(), ProSites_View_Coupons::get_menu_name(), 'manage_network_options', ProSites_View_Coupons::get_page_slug(), array(
'ProSites_View_Coupons',
'render_page',
) );
do_action( 'psts_page_after_coupons' );
//levels page
$psts_levels_page = add_submenu_page( 'psts', __( 'Pro Sites Levels', 'psts' ), __( 'Levels', 'psts' ), 'manage_network_options', 'psts-levels', array(
&$this,
'admin_levels',
) );
do_action( 'psts_page_after_levels' );
//modules page
$psts_modules_page = add_submenu_page( 'psts', __( 'Pro Sites Modules', 'psts' ), __( 'Modules', 'psts' ), 'manage_network_options', 'psts-modules', array(
&$this,
'admin_modules',
) );
do_action( 'psts_page_after_modules' );
$psts_gateways_page = add_submenu_page( 'psts', __( 'Pro Sites Gateways', 'psts' ), __( 'Payment Gateways', 'psts' ), 'manage_network_options', 'psts-gateways', array(
'ProSites_View_Gateways',
'render_page',
) );
do_action( 'psts_page_after_gateways' );
//ProSites_View_Settings
$psts_settings_page = add_submenu_page( 'psts', __( 'Pro Sites Settings', 'psts' ), __( 'Settings', 'psts' ), 'manage_network_options', 'psts-settings', array(
'ProSites_View_Settings',
'render_page',
) );
do_action( 'psts_page_after_settings' );
//ProSites_View_Settings
$psts_pricing_page = add_submenu_page( 'psts', ProSites_View_Pricing::get_page_name(), ProSites_View_Pricing::get_menu_name(), 'manage_network_options', ProSites_View_Pricing::get_page_slug(), array(
'ProSites_View_Pricing',
'render_page',
) );
do_action( 'psts_page_after_pricing_settings' );
//checkout page settings
// $psts_pricing_page_old = add_submenu_page( 'psts', __( 'Pro Sites Pricing Table', 'psts' ), __( 'Pricing Table', 'psts' ), 'manage_network_options', 'psts-pricing-table', array(
// &$this,
// 'pricing_table_settings'
// ) );
//register plugin style
add_action( 'admin_print_styles-' . $psts_main_page, array( &$this, 'load_psts_style' ) );
//Load style and js for cooupons only
add_action( 'admin_print_scripts-' . $psts_coupons_page, array( &$this, 'scripts_coupons' ) );
add_action( 'admin_print_styles-' . $psts_coupons_page, array( &$this, 'css_coupons' ) );
//Load Stats page js
add_action( 'admin_print_scripts-' . $psts_stats_page, array( &$this, 'scripts_stats' ) );
//Load pricing table style and scripts
add_action( 'admin_print_styles-' . $psts_pricing_page, array( &$this, 'css_pricing' ) );
//Add PSTS Style to settings page
add_action( 'admin_print_styles-' . $psts_settings_page, array( &$this, 'load_settings_style' ) );
// add_action( 'admin_print_styles-' . $psts_settings_page_old, array( &$this, 'load_settings_style' ) );
//Add PSTS Style to gateways page
add_action( 'admin_print_styles-' . $psts_gateways_page, array( &$this, 'load_settings_style' ) );
//Add PSTS Style to pricing page
add_action( 'admin_print_styles-' . $psts_pricing_page, array( &$this, 'load_levels_style' ) );
// Add Scripts for Levels page
add_action( 'admin_print_styles-' . $psts_levels_page, array( &$this, 'load_levels_style' ) );
do_action( 'psts_after_checkout_page_settings' );
}
function plug_pages() {
//get allowed roles for checkout
$checkout_roles = $this->get_setting( 'checkout_roles', array( 'administrator', 'editor' ) );
//check If user is allowed
$current_user_id = get_current_user_id();
$permission = $this->check_user_role( $current_user_id, $checkout_roles );
if ( ! is_main_site() && ! $this->get_setting( 'hide_adminmenu', 0 ) && $permission ) {
$label = is_pro_site( get_current_blog_id() ) ? $this->get_setting( 'lbl_curr' ) : $this->get_setting( 'lbl_signup' );
add_menu_page( $label, $label, 'edit_pages', 'psts-checkout', array(
&$this,
'checkout_redirect_page',
), 'dashicons-plus', 3.12 );
}
}
function add_menu_admin_bar_css() {
if ( is_main_site() || ! is_admin_bar_showing() || ! is_user_logged_in() || ! current_user_can( 'edit_pages' ) || $this->get_setting( 'hide_adminbar' ) ) {
return;
}
//styles the upgrade button
?>
<style type="text/css">#wpadminbar li#wp-admin-bar-pro-site {
float: right;
}
#wpadminbar li#wp-admin-bar-pro-site a {
padding-top: 3px !important;
height: 25px !important;
border-right: 1px solid #333 !important;
}
#wpadminbar li#wp-admin-bar-pro-site a span {
display: block;
color: #fff;
font-weight: bold;
font-size: 11px;
margin: 0px 1px 0px 1px;
padding: 0 30px !important;
border: 1px solid #409ed0 !important;
height: 18px !important;
line-height: 18px !important;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
background-image: -moz-linear-gradient(bottom, #3b85ad, #419ece) !important;
background-image: -ms-linear-gradient(bottom, #3b85ad, #419ece) !important;
background-image: -webkit-gradient(linear, left bottom, left top, from(#3b85ad), to(#419ece)) !important;
background-image: -webkit-linear-gradient(bottom, #419ece, #3b85ad) !important;
background-image: linear-gradient(bottom, #3b85ad, #419ece) !important;
}
#wpadminbar li#wp-admin-bar-pro-site a:hover span {
background-image: -moz-linear-gradient(bottom, #0B93C5, #3b85ad) !important;
background-image: -ms-linear-gradient(bottom, #0B93C5, #3b85ad) !important;
background-image: -webkit-gradient(linear, left bottom, left top, from(#0B93C5), to(#3b85ad)) !important;
background-image: -webkit-linear-gradient(bottom, #3b85ad, #0B93C5) !important;
background-image: linear-gradient(bottom, #0B93C5, #3b85ad) !important;