* @copyright Copyright (c) 2009 - 2018, Justin Tadlock * @link https://themehybrid.com/plugins/members * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ namespace Members\Admin; /** * Sets up and handles the plugin settings screen. * * @since 1.0.0 * @access public */ final class Settings_Page { /** * Admin page name/ID. * * @since 2.0.0 * @access public * @var string */ public $name = 'members-settings'; /** * Settings page name. * * @since 1.0.0 * @access public * @var string */ public $settings_page = ''; /** * Holds an array the settings page views. * * @since 2.0.0 * @access public * @var array */ public $views = array(); /** * Returns the instance. * * @since 1.0.0 * @access public * @return object */ public static function get_instance() { static $instance = null; if ( is_null( $instance ) ) { $instance = new self; $instance->includes(); $instance->setup_actions(); } return $instance; } /** * Constructor method. * * @since 1.0.0 * @access public * @return void */ private function __construct() {} /** * Loads settings files. * * @since 2.0.0 * @access private * @return void */ private function includes() { // Include the settings functions. require_once( members_plugin()->dir . 'admin/functions-settings.php' ); // Load settings view classes. require_once( members_plugin()->dir . 'admin/views/class-view.php' ); require_once( members_plugin()->dir . 'admin/views/class-view-general.php' ); require_once( members_plugin()->dir . 'admin/views/class-view-addons.php' ); } /** * Sets up initial actions. * * @since 2.0.0 * @access private * @return void */ private function setup_actions() { add_action( 'admin_menu', array( $this, 'admin_menu' ), 25 ); add_action( 'wp_ajax_mbrs_toggle_addon', array( $this, 'toggle_addon' ) ); } /** * AJAX call to toggle an addon off and on * * @return void */ public function toggle_addon() { if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'mbrs_toggle_addon' ) ) { die(); } $addon = ! empty( $_POST['addon'] ) ? sanitize_text_field( $_POST['addon'] ) : false; if ( false === $addon ) { wp_send_json_error( array( 'msg' => esc_html__( 'No add-on provided.', 'members' ) ) ); } // Grab the currently active add-ons $active_addons = get_option( 'members_active_addons', array() ); if ( ! in_array( $addon, $active_addons ) ) { // Activate the addon $active_addons[] = $addon; $response = array( 'status' => 'active', 'action_label' => esc_html__( 'Active', 'members' ), 'msg' => esc_html__( 'Add-on activated', 'members' ) ); // Run the add-on's activation hook members_plugin()->run_addon_activator( $addon ); } else { // Deactivate the addon $key = array_search( $addon, $active_addons ); unset( $active_addons[$key] ); $response = array( 'status' => 'inactive', 'action_label' => esc_html__( 'Activate', 'members' ), 'msg' => esc_html__( 'Add-on deactivated', 'members' ) ); } update_option( 'members_active_addons', $active_addons ); wp_send_json_success( $response ); } /** * Register a view. * * @since 2.0.0 * @access public * @param object $view * @return void */ public function register_view( $view ) { if ( ! $this->view_exists( $view->name ) ) $this->views[ $view->name ] = $view; } /** * Unregister a view. * * @since 2.0.0 * @access public * @param string $name * @return void */ public function unregister_view( $name ) { if ( $this->view_exists( $name ) ) unset( $this->view[ $name ] ); } /** * Get a view object * * @since 2.0.0 * @access public * @param string $name * @return object */ public function get_view( $name ) { return $this->view_exists( $name ) ? $this->views[ $name ] : false; } /** * Check if a view exists. * * @since 2.0.0 * @access public * @param string $name * @return bool */ public function view_exists( $name ) { return isset( $this->views[ $name ] ); } /** * Sets up custom admin menus. * * @since 1.0.0 * @access public * @return void */ public function admin_menu() { // Create the settings page. $this->settings_page = add_submenu_page( 'members', esc_html_x( 'Settings', 'admin screen', 'members' ), esc_html_x( 'Settings', 'admin screen', 'members' ), apply_filters( 'members_settings_capability', 'manage_options' ), 'members-settings', array( $this, 'settings_page' ) ); $this->addons_page = add_submenu_page( 'members', esc_html_x( 'Add-Ons', 'admin screen', 'members' ), _x( 'Add-Ons', 'admin screen', 'members' ), apply_filters( 'members_settings_capability', 'manage_options' ), 'members-settings&view=add-ons', array( $this, 'settings_page' ) ); if ( ! is_plugin_active( 'memberpress/memberpress.php' ) ) { $this->payments_page = add_submenu_page( 'members', esc_html_x( 'Payments', 'admin screen', 'members' ), esc_html_x( 'Payments', 'admin screen', 'members' ), apply_filters( 'members_settings_capability', 'manage_options' ), 'members-payments', array( $this, 'payments_page' ) ); } $this->about_page = add_submenu_page( 'members', esc_html_x( 'About Us', 'admin screen', 'members' ), esc_html_x( 'About Us', 'admin screen', 'members' ), apply_filters( 'members_settings_capability', 'manage_options' ), 'members-about', array( $this, 'about_page' ) ); if ( $this->settings_page ) { do_action( 'members_register_settings_views', $this ); uasort( $this->views, 'members_priority_sort' ); // Register setings. add_action( 'admin_init', array( $this, 'register_settings' ) ); // Page load callback. add_action( "load-{$this->settings_page}", array( $this, 'load' ) ); // Enqueue scripts/styles. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); } } /** * Runs on page load. * * @since 2.0.0 * @access public * @return void */ public function load() { // Print custom styles. add_action( 'admin_head', array( $this, 'print_styles' ) ); // Add help tabs for the current view. $view = $this->get_view( members_get_current_settings_view() ); if ( $view ) { $view->load(); $view->add_help_tabs(); } } /** * Print styles to the header. * * @since 2.0.0 * @access public * @return void */ public function print_styles() { ?> settings_page !== $hook_suffix ) return; $view = $this->get_view( members_get_current_settings_view() ); if ( $view ) $view->enqueue(); } /** * Registers the plugin settings. * * @since 1.0.0 * @access public * @return void */ function register_settings() { foreach ( $this->views as $view ) $view->register_settings(); } /** * Renders the settings page. * * @since 1.0.0 * @access public * @return void */ public function settings_page() { ?>
| Id | Transaction | Subscription | Status | Membership | Net | Tax | Total | Name | User | Gateway | Created On | Expires On |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 2 | 2 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 3 | 3 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 4 | 4 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 5 | 5 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 6 | 6 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 7 | 7 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 8 | 8 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 9 | 9 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never | |
| 10 | 10 | None | Your Membership | $20.00 | $0.00 | $20.00 | Your Customer | user | Payment Method | January 27, 2020 | Never |
Hello and welcome to Members by MemberPress, the simplest WordPress membership and role editor plugin. Our team here at MemberPress builds software that helps you to easily add powerful membership features to your website in minutes.
Over the years, we found that most WordPress membership plugins were bloated, buggy, slow, very hard to use and expensive. So, we started with a simple goal: build a WordPress membership plugin that’s both easy and powerful.
Our goal is to take the pain out of creating membership sites and make it easy.
Members is brought to you by the same team that’s behind the most powerful, full-featured membership plugin, MemberPress, the best Affiliate Program plugin, Affiliate Royale, and the best Affiliate Link Management plugin on the market, Pretty Links.
So, you can see that we know a thing or two about building great products that customers love.
MemberPress will help you build astounding WordPress membership sites, accept credit cards securely, control who sees your content and sell digital downloads... all without the difficult setup.
The easiest way to monetize your content. Are you tired of managing affiliate offers manually? Pretty Links helps you unlock more affiliate revenue from your existing content ... it’s like a surprise inheritance!
Affiliate Royale is a full-featured Affiliate Program plugin for WordPress. Use it to start an Affiliate Program for your products to dramatically increase traffic, attention and sales.