hooks(); } return self::$instance; } private function __construct() {} /** @var Admin_Pages|null */ private ?Admin_Pages $admin_pages = null; private function hooks(): void { add_action( 'admin_menu', array( $this, 'register_menus' ) ); add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_init', array( $this, 'maybe_create_pages' ) ); add_action( 'admin_notices', array( $this, 'maybe_show_setup_notice' ) ); add_filter( 'plugin_action_links_' . ARSHID6SOCIAL_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) ); add_filter( 'set_screen_option_arshid6social_payouts_per_page', array( $this, 'save_monetization_per_page' ), 10, 3 ); add_filter( 'set_screen_option_arshid6social_tx_per_page', array( $this, 'save_monetization_per_page' ), 10, 3 ); add_filter( 'set-screen-option', array( $this, 'save_monetization_per_page_legacy' ), 10, 3 ); // Instantiate sub-admin classes. Admin_Settings::instance(); Admin_Members::instance(); Admin_Moderation::instance(); Admin_Notifications::instance(); Admin_Marketplace::instance(); Admin_Activity::instance(); Admin_Verification::instance(); Admin_Page_Icons::instance(); Admin_Ads::instance(); Sample_Data::instance(); $this->admin_pages = new Admin_Pages(); } /** * Registers the admin menu tree. */ public function register_menus(): void { add_menu_page( __( '6Arshid Social Community', '6arshid-social-community' ), __( '6Arshid Social', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-dashboard', array( $this, 'render_dashboard' ), 'dashicons-groups', 30 ); add_submenu_page( 'arshid6social-dashboard', __( 'Dashboard', '6arshid-social-community' ), __( 'Dashboard', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-dashboard', array( $this, 'render_dashboard' ) ); $activity_hook = add_submenu_page( 'arshid6social-dashboard', __( 'Activity Items', '6arshid-social-community' ), __( 'Activity Items', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-activity', array( Admin_Activity::instance(), 'render' ) ); if ( $activity_hook ) { add_action( 'load-' . $activity_hook, array( Admin_Activity::instance(), 'setup_screen_options' ) ); } $members_hook = add_submenu_page( 'arshid6social-dashboard', __( 'Members', '6arshid-social-community' ), __( 'Members', '6arshid-social-community' ), 'arshid6social_manage_members', 'arshid6social-members', array( Admin_Members::instance(), 'render' ) ); if ( $members_hook ) { add_action( 'load-' . $members_hook, array( Admin_Members::instance(), 'setup_screen_options' ) ); } $moderation_hook = add_submenu_page( 'arshid6social-dashboard', __( 'Reports & Moderation', '6arshid-social-community' ), __( 'Moderation', '6arshid-social-community' ), 'arshid6social_manage_reports', 'arshid6social-moderation', array( Admin_Moderation::instance(), 'render' ) ); if ( $moderation_hook ) { add_action( 'load-' . $moderation_hook, array( Admin_Moderation::instance(), 'setup_screen_options' ) ); } if ( get_option( 'arshid6social_verification_enabled', false ) ) { $verification_hook = add_submenu_page( 'arshid6social-dashboard', __( 'Verification Queue', '6arshid-social-community' ), __( 'Verification', '6arshid-social-community' ), 'arshid6social_manage_members', 'arshid6social-verification', array( Admin_Verification::instance(), 'render' ) ); if ( $verification_hook ) { add_action( 'load-' . $verification_hook, array( Admin_Verification::instance(), 'setup_screen_options' ) ); } } add_submenu_page( 'arshid6social-dashboard', __( 'Pages & Shortcodes', '6arshid-social-community' ), __( 'Pages & Shortcodes', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-pages', array( $this->admin_pages, 'render' ) ); add_submenu_page( 'arshid6social-dashboard', __( 'Notifications', '6arshid-social-community' ), __( 'Notifications', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-notifications', array( Admin_Notifications::instance(), 'render' ) ); $mkt_hook = add_submenu_page( 'arshid6social-dashboard', __( 'Products Archive', '6arshid-social-community' ), __( 'Products Archive', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-marketplace', array( Admin_Marketplace::instance(), 'render' ) ); if ( $mkt_hook ) { add_action( 'load-' . $mkt_hook, array( Admin_Marketplace::instance(), 'setup_screen_options' ) ); } add_submenu_page( 'arshid6social-dashboard', __( 'Ads Manager', '6arshid-social-community' ), __( 'Ads Manager', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-ads', array( Admin_Ads::instance(), 'render' ) ); $monetization_hook = add_submenu_page( 'arshid6social-dashboard', __( 'Monetization', '6arshid-social-community' ), __( 'Monetization', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-monetization', array( $this, 'render_monetization' ) ); if ( $monetization_hook ) { add_action( 'load-' . $monetization_hook, array( $this, 'setup_monetization_screen_options' ) ); } add_submenu_page( 'arshid6social-dashboard', __( 'Settings', '6arshid-social-community' ), __( 'Settings', '6arshid-social-community' ), 'arshid6social_manage_settings', 'arshid6social-settings', array( Admin_Settings::instance(), 'render' ) ); } /** * Registers all plugin settings with the Settings API. */ public function register_settings(): void { Admin_Settings::instance()->register(); } /** * Renders the dashboard overview page. */ public function render_dashboard(): void { if ( ! current_user_can( 'arshid6social_manage_settings' ) ) { wp_die( esc_html__( 'You do not have permission to access this page.', '6arshid-social-community' ) ); } $stats = $this->get_dashboard_stats(); echo '
'; } /** * Fetches quick stats for the dashboard overview. * * @return array%s %s
%s %s
' . esc_html__( 'Transactions table does not exist yet. Enable Monetization and save settings first.', '6arshid-social-community' ) . '
'; return; } // phpcs:disable WordPress.Security.NonceVerification.Recommended $search = isset( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : ''; $filter_type = isset( $_GET['txtype'] ) ? sanitize_key( $_GET['txtype'] ) : ''; $filter_status = isset( $_GET['txstatus'] ) ? sanitize_key( $_GET['txstatus'] ) : ''; $paged = max( 1, isset( $_GET['paged'] ) ? (int) $_GET['paged'] : 1 ); // phpcs:enable WordPress.Security.NonceVerification.Recommended $per_page = (int) get_user_option( 'arshid6social_tx_per_page' ); if ( $per_page < 1 ) { $per_page = 25; } $offset = ( $paged - 1 ) * $per_page; // Build WHERE clauses. $where_parts = array( '1=1' ); $where_vals = array(); if ( '' !== $search ) { $like = '%' . $wpdb->esc_like( $search ) . '%'; $where_parts[] = '( t.gateway_ref LIKE %s OR pu.user_login LIKE %s OR pu.user_email LIKE %s OR pu.display_name LIKE %s OR cu.user_login LIKE %s OR cu.user_email LIKE %s OR cu.display_name LIKE %s )'; array_push( $where_vals, $like, $like, $like, $like, $like, $like, $like ); } if ( '' !== $filter_type ) { $where_parts[] = 't.type = %s'; $where_vals[] = $filter_type; } if ( '' !== $filter_status ) { $where_parts[] = 't.status = %s'; $where_vals[] = $filter_status; } $where_sql = implode( ' AND ', $where_parts ); $join_sql = "LEFT JOIN {$wpdb->users} pu ON pu.ID = t.payer_id LEFT JOIN {$wpdb->users} cu ON cu.ID = t.creator_id"; // Count total matching rows. // phpcs:ignore WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared,PluginCheck.Security.DirectDB.UnescapedDBParameter $count_sql = "SELECT COUNT(*) FROM {$table} t {$join_sql} WHERE {$where_sql}"; $total = (int) ( empty( $where_vals ) ? $wpdb->get_var( $count_sql ) // phpcs:ignore PluginCheck.Security.DirectDB.UnescapedDBParameter,WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.NotPrepared : $wpdb->get_var( $wpdb->prepare( $count_sql, ...$where_vals ) ) ); // phpcs:ignore PluginCheck.Security.DirectDB.UnescapedDBParameter,WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.NotPrepared // Fetch page rows. // phpcs:ignore WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared,PluginCheck.Security.DirectDB.UnescapedDBParameter $rows_sql = "SELECT t.*, pu.display_name AS payer_name, pu.user_email AS payer_email, cu.display_name AS creator_name, cu.user_email AS creator_email FROM {$table} t {$join_sql} WHERE {$where_sql} ORDER BY t.id DESC LIMIT %d OFFSET %d"; $fetch_vals = array_merge( $where_vals, array( $per_page, $offset ) ); // phpcs:ignore PluginCheck.Security.DirectDB.UnescapedDBParameter,WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.NotPrepared $rows = $wpdb->get_results( $wpdb->prepare( $rows_sql, ...$fetch_vals ) ); $total_pages = (int) ceil( $total / $per_page ); $base_url = add_query_arg( array_filter( array( 'page' => 'arshid6social-monetization', 'tab' => 'transactions', 's' => $search ?: null, 'txtype' => $filter_type ?: null, 'txstatus' => $filter_status ?: null, ) ), admin_url( 'admin.php' ) ); $type_colors = array( 'subscription' => '#2563eb', 'ppv' => '#7c3aed', 'payout' => '#d97706', 'refund' => '#dc2626', ); $status_colors = array( 'completed' => '#16a34a', 'pending' => '#d97706', 'failed' => '#dc2626', 'refunded' => '#6b7280', ); ?>
| # | ||||||||
|---|---|---|---|---|---|---|---|---|
| id; ?> | type ); ?> |
payer_name ) : ?>
payer_name ); ?> payer_email ); ?> — |
creator_name ) : ?>
creator_name ); ?> creator_email ); ?> — |
amount, 2 ) . ' ' . strtoupper( $tx->currency ) ); ?> | platform_fee, 2 ) ); ?> | status ); ?> | gateway_ref ?: '—' ); ?> | created_at ) ) ); ?> |