' . esc_html__( 'Notifications', 'affiliates' ) . ''; $section_links = ''; foreach( self::$sections as $sec => $sec_data ) { $section_links .= sprintf( '%s', $section == $sec ? 'active nav-tab-active' : '', esc_url( add_query_arg( 'section', $sec, admin_url( 'admin.php?page=affiliates-admin-notifications' ) ) ), $sec_data ); } echo ''; echo '

' . esc_html( $section_title ) . '

'; switch ( $section ) { case 'administrator' : self::administrator_registration_section(); break; case 'affiliates' : default : self::affiliates_registration_section(); break; } affiliates_footer(); } /** * Settings sections. * * @return array */ public static function init_sections() { self::$sections = apply_filters( 'affiliates_notifications_sections', array( 'affiliates' => __( 'Affiliates', 'affiliates' ), 'administrator' => __( 'Administrator', 'affiliates' ) ) ); } /** * Display the Affiliates - Registration notifications section. */ public static function affiliates_registration_section () { if ( !current_user_can( AFFILIATES_ADMINISTER_OPTIONS ) ) { wp_die( esc_html__( 'Access denied.', 'affiliates' ) ); } $notifications = get_option( 'affiliates_notifications', null ); if ( $notifications === null ) { add_option( 'affiliates_notifications', array(), '', 'no' ); } if ( isset( $_POST['submit'] ) ) { if ( affiliates_verify_post_nonce( self::NONCE, self::NOTIFICATIONS ) ) { $notifications[Affiliates_Notifications::REGISTRATION_ENABLED] = !empty( $_POST[Affiliates_Notifications::REGISTRATION_ENABLED] ); update_option( 'affiliates_notifications', $notifications ); } } $registration_enabled = isset( $notifications[Affiliates_Notifications::REGISTRATION_ENABLED] ) ? $notifications[Affiliates_Notifications::REGISTRATION_ENABLED] : Affiliates_Notifications::REGISTRATION_ENABLED_DEFAULT; echo '
'; echo '
'; echo '
'; echo '
'; // Affiliate registration notifications echo '

' . esc_html__( 'Registration notifications', 'affiliates' ) . '

'; echo '

'; echo ''; echo '

'; echo '

'; echo esc_html__( 'Send new affiliates an email when their user account is created.', 'affiliates' ); echo ' '; echo esc_html__( 'This should normally be enabled, so that new affiliates receive their username and password to be able to log in and access their account.', 'affiliates' ); echo '

'; echo '

'; echo wp_nonce_field( self::NOTIFICATIONS, self::NONCE, true, false ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ''; echo '

'; echo '
'; echo '
'; echo '
'; // .manage echo '
'; // .notifications } /** * Display the Administrator - Registration notifications section. */ public static function administrator_registration_section () { if ( !current_user_can( AFFILIATES_ADMINISTER_OPTIONS ) ) { wp_die( esc_html__( 'Access denied.', 'affiliates' ) ); } if ( isset( $_POST['submit'] ) ) { if ( affiliates_verify_post_nonce( self::NONCE, self::NOTIFICATIONS ) ) { // admin registration enabled delete_option( 'aff_notify_admin' ); add_option( 'aff_notify_admin', !empty( $_POST[Affiliates_Notifications::REGISTRATION_NOTIFY_ADMIN] ), '', 'no' ); } } $notify_admin = get_option( 'aff_notify_admin', true ); echo '
'; echo '
'; echo '
'; echo '
'; // Administrator registration notifications echo '

' . esc_html__( 'Registration notifications', 'affiliates' ) . '

'; echo '

'; echo ''; echo '

'; echo '

'; echo esc_html__( 'Send the administrator an email when a new affiliate user account is created.', 'affiliates' ); echo ' '; echo esc_html__( 'This should normally be enabled, especially when the status for new affiliates is pending approval by the administrator.', 'affiliates' ); echo '

'; echo '

'; echo wp_nonce_field( self::NOTIFICATIONS, self::NONCE, true, false ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ''; echo '

'; echo '
'; echo '
'; echo '
'; // .manage echo '
'; // .notifications } /** * Adds help tabs. */ public static function load_page() { } }