__( 'General', 'affiliates' ), 'registration' => __( 'Registration', 'affiliates' ), 'pages' => __( 'Pages', 'affiliates' ), 'referrals' => __( 'Referrals', 'affiliates' ), 'integrations' => __( 'Integrations', 'affiliates' ) ) ); } /** * Registers an admin_notices action. */ public static function admin_init() { wp_register_style( 'affiliates-admin-settings', AFFILIATES_PLUGIN_URL . 'css/affiliates_admin_settings.css' ); wp_register_script( 'affiliates-field-choice', AFFILIATES_PLUGIN_URL . 'js/affiliates-field-choice.js', array( 'jquery' ), AFFILIATES_CORE_VERSION, true ); wp_localize_script( 'affiliates-field-choice', 'affiliates_field_choice_l12n', array( 'remove' => __( 'Remove', 'affiliates' ) ) ); if ( current_user_can( AFFILIATES_ADMINISTER_OPTIONS ) ) { if ( isset( $_REQUEST['aff_setup_hide'] ) ) { if ( wp_verify_nonce( $_REQUEST['aff_setup_nonce'], 'aff_setup_hide' ) ) { add_option( 'aff_setup_hide', 'yes', '', 'no' ); } } if ( !get_option( 'aff_setup_hide' ) ) { add_action( 'admin_notices', array( __CLASS__, 'setup_notice' ) ); } } } /** * Prints setup notices. */ public static function setup_notice() { echo ''; echo '
'; // render the welcome header and a brief explanation echo '

'; echo sprintf( __( 'Welcome to %s', 'affiliates' ), ucwords( str_replace('-', ' ', AFFILIATES_PLUGIN_NAME ) ) ); echo '

'; echo '

'; echo __( 'Please review the following suggested steps to set up the affiliate system.', 'affiliates' ); echo ' '; echo __( 'This is intended as a guidance and you can safely hide this message when finished.', 'affiliates' ); echo ' '; echo sprintf( __( 'Use the Settings section to review or adjust the system anytime.', 'affiliates' ), admin_url( 'admin.php?page=affiliates-admin-settings' ) ); echo '

'; $buttons = apply_filters( 'affiliates_setup_buttons', array( 'general' => sprintf( '%s', add_query_arg( 'section', 'general', admin_url( 'admin.php?page=affiliates-admin-settings' ) ), __( 'Review General Settings', 'affiliates' ) ), 'registration' => sprintf ( '%s', add_query_arg( 'section', 'registration', admin_url( 'admin.php?page=affiliates-admin-settings' ) ), __( 'Enable Affiliate Registration', 'affiliates' ) ), 'pages' => sprintf ( '%s', add_query_arg( 'section', 'pages', admin_url( 'admin.php?page=affiliates-admin-settings' ) ), __( 'Create an Affiliate Area', 'affiliates' ) ), 'integrations' => sprintf ( '%s', add_query_arg( 'section', 'integrations', admin_url( 'admin.php?page=affiliates-admin-settings' ) ), __( 'Install an Integration', 'affiliates' ) ) ) ); // render the buttons echo '

'; echo implode( ' ', $buttons ); echo ' '; printf( '%s', wp_nonce_url( add_query_arg( 'aff_setup_hide', 'true', admin_url( 'admin.php?page=affiliates-admin-settings' ) ), 'aff_setup_hide', 'aff_setup_nonce' ), __( 'Hide this', 'affiliates' ) ); echo '

'; echo '
'; } /** * Settings admin section. */ public static function admin_settings() { global $wp, $wpdb, $affiliates_options, $wp_roles; if ( !current_user_can( AFFILIATES_ADMINISTER_OPTIONS ) ) { wp_die( __( 'Access denied.', 'affiliates' ) ); } wp_enqueue_style( 'affiliates-admin-settings' ); wp_enqueue_script( 'affiliates-field-choice' ); self::init_sections(); $section = isset( $_REQUEST['section'] ) ? $_REQUEST['section'] : null; if ( !key_exists( $section, self::$sections ) ) { $section = 'general'; } $section_title = self::$sections[$section]; echo '

' . __( 'Settings', 'affiliates' ) . '

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

' . $section_title . '

'; switch( $section ) { case 'integrations' : require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings-integrations.php'; Affiliates_Settings_Integrations::section(); break; case 'pages' : require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings-pages.php'; Affiliates_Settings_Pages::section(); break; case 'referrals' : require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings-referrals.php'; Affiliates_Settings_Referrals::section(); break; case 'registration' : require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings-registration.php'; Affiliates_Settings_Registration::section(); break; case 'general' : require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings-general.php'; Affiliates_Settings_General::section(); break; default : do_action( 'affiliates_settings_section', $section ); } } /** * Outputs a note to confirm settings have been saved. */ public static function settings_saved_notice() { echo '
'; echo __( 'Settings saved.', 'affiliates' ); echo '
'; } } Affiliates_Settings::init();