' . __( '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 '

' . $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( __( 'Access denied.', 'affiliates' ) ); } $notifications = get_option( 'affiliates_notifications', null ); if ( $notifications === null ) { add_option( 'affiliates_notifications', array(), null, 'no' ); } if ( isset( $_POST['submit'] ) ) { if ( wp_verify_nonce( $_POST[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 '
' . '
' . // Affiliate registration notifications '

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

' . '

' . '' . '

' . '

' . __( 'Send new affiliates an email when their user account is created.', 'affiliates' ) . ' ' . __( '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' ) . '

' . '

' . wp_nonce_field( self::NOTIFICATIONS, self::NONCE, true, false ) . '' . '

' . '
' . '
' . '
'; // .manage echo '
'; // .notifications } /** * Display the Administrator - Registration notifications section. */ public static function administrator_registration_section () { if ( !current_user_can( AFFILIATES_ADMINISTER_OPTIONS ) ) { wp_die( __( 'Access denied.', 'affiliates' ) ); } if ( isset( $_POST['submit'] ) ) { if ( wp_verify_nonce( $_POST[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 '
' . '
' . // Administrator registration notifications '

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

' . '

' . '' . '

' . '

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

' . '

' . wp_nonce_field( self::NOTIFICATIONS, self::NONCE, true, false ) . '' . '

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