page = 'member-payment-history'; $this->init_hooks(); } /** * Initialize hooks. * * @return void * @since 1.0.0 */ private function init_hooks() { add_action( 'admin_menu', array( $this, 'add_orders_menu' ), 70 ); add_action( 'in_admin_header', array( __CLASS__, 'hide_unrelated_notices' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) ); add_action( 'init', array( $this, 'add_payment_gateway_options' ) ); $this->includes(); } /** * Remove Notices. */ public static function hide_unrelated_notices() { if ( empty( $_REQUEST['page'] ) || 'member-payment-history' !== $_REQUEST['page'] ) { return; } global $wp_filter; foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $wp_notice ) { if ( ! empty( $wp_filter[ $wp_notice ]->callbacks ) && is_array( $wp_filter[ $wp_notice ]->callbacks ) ) { foreach ( $wp_filter[ $wp_notice ]->callbacks as $priority => $hooks ) { foreach ( $hooks as $name => $arr ) { // Remove all notices except user registration plugins notices. if ( ! strstr( $name, 'user_registration_' ) ) { unset( $wp_filter[ $wp_notice ]->callbacks[ $priority ][ $name ] ); } } } } } } public function add_orders_menu() { $orders_page = add_submenu_page( 'user-registration', __( 'Payment History', 'user-registration' ), // page title __( 'Payment History', 'user-registration' ), // menu title 'manage_user_registration', // Capability required to access $this->page, // Menu slug array( $this, 'render_payment_history_page', ), 5 ); add_action( 'load-' . $orders_page, array( $this, 'orders_initialization' ) ); } public function orders_initialization() { if ( isset( $_GET['page'] ) && $this->page === $_GET['page'] ) { $action_page = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; switch ( $action_page ) { case 'add_new_membership': break; default: global $orders_list_table; $orders_list_table = new OrdersListTable(); $orders_list_table->process_actions(); break; } } } /** * Enqueue scripts * * @since 1.0.0 */ public function enqueue_scripts() { if ( empty( $_GET['page'] ) || 'member-payment-history' !== $_GET['page'] ) { return; } $suffix = defined( 'SCRIPT_DEBUG' ) ? '' : '.min'; if ( ! wp_script_is( 'ur-snackbar', 'reqistered' ) ) { wp_register_script( 'ur-snackbar', UR()->plugin_url() . '/assets/js/ur-snackbar/ur-snackbar' . $suffix . '.js', array(), '1.0.0', true ); wp_enqueue_script( 'ur-snackbar' ); } wp_enqueue_script( 'sweetalert2' ); wp_register_script( 'payment-history', UR()->plugin_url() . '/assets/js/modules/membership/admin/payment-history' . $suffix . '.js', array( 'jquery' ), '1.0.0', true ); wp_enqueue_script( 'payment-history' ); $this->localize_scripts(); } /** * Enqueue Styles * * @return void */ public function enqueue_styles() { if ( empty( $_GET['page'] ) || 'member-payment-history' !== $_GET['page'] ) { return; } wp_register_style( 'payment-history-css', UR()->plugin_url() . '/assets/css/modules/payment-history/user-registration-payment-history.css', array(), UR_VERSION ); wp_register_style( 'ur-core-builder-style', UR()->plugin_url() . '/assets/css/admin.css', array(), UR_VERSION ); wp_enqueue_style( 'ur-core-builder-style' ); if ( ! wp_style_is( 'ur-snackbar', 'reqistered' ) ) { wp_register_style( 'ur-snackbar', UR()->plugin_url() . '/assets/css/ur-snackbar/ur-snackbar.css', array(), '1.0.0' ); } wp_enqueue_style( 'payment-history-css' ); wp_enqueue_style( 'sweetalert2' ); wp_enqueue_style( 'ur-snackbar' ); } /** * @return void */ public function render_payment_history_page() { $action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; switch ( $action ) { case 'add_new_payment': break; default: $this->render_payment_history_list(); break; } } /** * render_payment_history_list * * @return void */ public function render_payment_history_list() { global $orders_list_table; if ( ! $orders_list_table ) { return; } $enable_members_button = true; ?>