| @@ -11,10 +11,17 @@ | ||
| 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 | |
| @@ -19,88 +26,38 @@ | ||
| 19 | 26 | class Menu extends Controller{ |
| 20 | 27 | |
| 21 | 28 | /** |
| 22 | 29 | * Initialize the class |
| 23 | - * | |
| 30 | + * | |
| 24 | 31 | * @since 0.0.1 |
| 25 | 32 | */ |
| 26 | 33 | function __construct( ) { |
| 27 | - | |
| 34 | + | |
| 28 | 35 | } |
| 29 | 36 | |
| 30 | - public function init($end = 'backend'){ | |
| 31 | - if('backend' === $end) { | |
| 32 | - add_action('admin_enqueue_scripts', array($this, 'handle_scripts_and_styles')); | |
| 33 | - }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){ | |
| 34 | 46 | add_action('wp_enqueue_scripts', array($this, 'handle_scripts_and_styles_frontend')); |
| 35 | 47 | } |
| 36 | 48 | } |
| 37 | 49 | |
| 38 | - /** | |
| 39 | - * Enqueue scripts and styles | |
| 40 | - * | |
| 41 | - * @since 0.0.1 | |
| 42 | - */ | |
| 43 | - public function handle_scripts_and_styles() { | |
| 44 | - $menu_slugs = $this->better_payment_menu_slugs(); | |
| 45 | - | |
| 46 | - if (!empty($_REQUEST['page']) && in_array($_REQUEST['page'], $menu_slugs)) { | |
| 47 | - $this->enqueue_styles(); | |
| 48 | - $this->enqueue_scripts(); | |
| 49 | - } | |
| 50 | - } | |
| 51 | - | |
| 52 | 50 | /** |
| 53 | 51 | * Enqueue scripts and styles |
| 54 | - * | |
| 52 | + * | |
| 55 | 53 | * @since 0.0.1 |
| 56 | 54 | */ |
| 57 | 55 | public function handle_scripts_and_styles_frontend() { |
| 58 | 56 | wp_enqueue_style('toastr-css'); |
| 59 | - | |
| 57 | + | |
| 60 | 58 | wp_enqueue_script('toastr-js'); |
| 61 | 59 | wp_enqueue_script('better-payment-script'); |
| 62 | 60 | wp_enqueue_script('bp-admin-settings'); |
| 63 | 61 | wp_enqueue_script('better-payment-common-script'); |
| 64 | - wp_enqueue_script('better-payment-select2-script'); | |
| 65 | - wp_enqueue_script( 'jquery-ui-datepicker' ); | |
| 66 | 62 | } |
| 67 | - | |
| 68 | - /** | |
| 69 | - * Enqueue scripts | |
| 70 | - * | |
| 71 | - * @since 0.0.1 | |
| 72 | - */ | |
| 73 | - public function enqueue_scripts() { | |
| 74 | - wp_enqueue_script( 'bp-admin-settings' ); | |
| 75 | - wp_enqueue_script( 'toastr-js-admin' ); | |
| 76 | - wp_enqueue_script( 'sweetalert2-js' ); | |
| 77 | - wp_enqueue_script( 'jquery-ui-datepicker' ); | |
| 78 | - wp_enqueue_script( 'better-payment-common-script' ); | |
| 79 | - do_action('better_payment/admin/after_enqueue_scripts'); | |
| 80 | - } | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * Enqueue styles | |
| 84 | - * | |
| 85 | - * @since 0.0.1 | |
| 86 | - */ | |
| 87 | - public function enqueue_styles() { | |
| 88 | - wp_enqueue_style( 'jquery-ui' ); | |
| 89 | - wp_enqueue_style( 'better-payment-common-style' ); | |
| 90 | - wp_enqueue_style( 'bp-settings-style' ); | |
| 91 | - wp_enqueue_style( 'bp-icon-admin' ); | |
| 92 | - wp_enqueue_style( 'toastr-css-admin' ); | |
| 93 | - wp_enqueue_style( 'sweetalert2-css' ); | |
| 94 | - wp_enqueue_style( 'better-payment-admin-style' ); | |
| 95 | - } | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * Menu slugs | |
| 99 | - * | |
| 100 | - * @since 0.0.1 | |
| 101 | - */ | |
| 102 | - public function better_payment_menu_slugs() { | |
| 103 | - return apply_filters( 'better_payment/admin/get_page_menu_slug_list', array( 'better-payment-settings', 'better-payment-transactions' ) ); | |
| 104 | - } | |
| 105 | - | |
| 106 | -} | |
| 63 | +} | |