PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
← All changes | includes/Admin/Menu.php +22 -77 2.3.3 → 2.4.1 View file →
@@ -11,52 +11,46 @@
11 11 exit;
12 12 }
13 13
14 14 /**
15 - * The Menu handler class
16 - *
15 + * Front-end legacy script loader.
16 + *
17 + * The backend half of this class enqueued the old PHP admin's scripts and styles
18 + * on the `better-payment-settings` / `-transactions` / `-analytics` pages. Those
19 + * pages no longer exist (the admin is React — see ReactAdmin), so only the
20 + * front-end enqueue remains: the user-dashboard templates still rely on
21 + * admin.min.js for their copy-to-clipboard buttons. The jQuery UI datepicker is
22 + * Pro's (analytics report); its scripts declare that dependency themselves.
23 + *
17 24 * @since 0.0.1
18 25 */
19 26 class Menu extends Controller{
20 27
21 - protected $pro_enabled;
22 -
23 28 /**
24 29 * Initialize the class
25 - *
30 + *
26 31 * @since 0.0.1
27 32 */
28 33 function __construct( ) {
29 -
34 +
30 35 }
31 36
32 - public function init($end = 'backend'){
33 - $this->pro_enabled = apply_filters('better_payment/pro_enabled', false);
34 -
35 - if('backend' === $end) {
36 - add_action('admin_enqueue_scripts', array($this, 'handle_scripts_and_styles'));
37 - }else if('frontend' === $end){
37 + /**
38 + * Register the front-end enqueue.
39 + *
40 + * @param string $end Only 'frontend' registers anything; the parameter is kept
41 + * for existing callers (Frontend passes it).
42 + * @since 0.0.1
43 + */
44 + public function init($end = 'frontend'){
45 + if('frontend' === $end){
38 46 add_action('wp_enqueue_scripts', array($this, 'handle_scripts_and_styles_frontend'));
39 47 }
40 48 }
41 49
42 - /**
43 - * Enqueue scripts and styles
44 - *
45 - * @since 0.0.1
46 - */
47 - public function handle_scripts_and_styles() {
48 - $menu_slugs = $this->better_payment_menu_slugs();
49 -
50 - if (!empty($_REQUEST['page']) && in_array($_REQUEST['page'], $menu_slugs)) {
51 - $this->enqueue_styles();
52 - $this->enqueue_scripts();
53 - }
54 - }
55 -
56 50 /**
57 51 * Enqueue scripts and styles
58 - *
52 + *
59 53 * @since 0.0.1
60 54 */
61 55 public function handle_scripts_and_styles_frontend() {
62 56 wp_enqueue_style('toastr-css');
@@ -64,55 +58,6 @@
64 58 wp_enqueue_script('toastr-js');
65 59 wp_enqueue_script('better-payment-script');
66 60 wp_enqueue_script('bp-admin-settings');
67 61 wp_enqueue_script('better-payment-common-script');
68 - wp_enqueue_script('better-payment-select2-script');
69 - wp_enqueue_script('jquery-ui-datepicker');
70 62 }
71 -
72 - /**
73 - * Enqueue scripts
74 - *
75 - * @since 0.0.1
76 - */
77 - public function enqueue_scripts() {
78 - wp_enqueue_script('bp-admin-settings');
79 - wp_enqueue_script('toastr-js-admin');
80 - wp_enqueue_script('sweetalert2-js');
81 - wp_enqueue_script('jquery-ui-datepicker');
82 - wp_enqueue_script('better-payment-common-script');
83 - }
84 -
85 - /**
86 - * Enqueue styles
87 - *
88 - * @since 0.0.1
89 - */
90 - public function enqueue_styles() {
91 - wp_enqueue_style('jquery-ui');
92 - wp_enqueue_style('better-payment-common-style');
93 - wp_enqueue_style('bp-settings-style');
94 - wp_enqueue_style('bp-icon-admin');
95 - wp_enqueue_style('toastr-css-admin');
96 - wp_enqueue_style('sweetalert2-css');
97 - wp_enqueue_style('better-payment-admin-style');
98 - }
99 -
100 - /**
101 - * Menu slugs
102 - *
103 - * @since 0.0.1
104 - */
105 - public function better_payment_menu_slugs() {
106 - $menu_slugs = array(
107 - 'better-payment-settings',
108 - 'better-payment-transactions',
109 - );
110 -
111 - if( ! $this->pro_enabled ){
112 - $menu_slugs[] = 'better-payment-analytics';
113 - }
114 -
115 - return apply_filters( 'better_payment/admin/get_page_menu_slug_list', $menu_slugs );
116 - }
117 -
118 -}
63 +}