' . __( 'The Affiliates BuddyPress Integration plugin requires an appropriate Affiliates plugin: Affiliates, Affiliates Pro or Affiliates Enterprise.', 'affiliates-buddypress' ) . ''; } if ( !$affiliates_is_active ) { $result = false; } if ( $result ) { add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ), 40 ); if ( !class_exists( 'Affiliates_BuddyPress' ) ) { require_once 'lib/class-affiliates-buddypress.php'; } } } /** * Load scripts ... currently not used. */ public static function enqueue_scripts() { wp_register_style( 'affbp-admin-styles', AFFILIATES_BUDDYPRESS_PLUGIN_URL . '/css/admin-styles.css', array(), AFFILIATES_BUDDYPRESS_VERSION ); } /** * Hooked on admin_notices and prints admin notices if any. */ public static function admin_notices() { if ( !empty( self::$notices ) ) { foreach ( self::$notices as $notice ) { echo $notice; } } } /** * Adds the admin section. */ public static function admin_menu() { $admin_page = add_submenu_page( 'affiliates-admin', __( 'BuddyPress', 'affiliates-buddypress' ), __( 'BuddyPress', 'affiliates-buddypress' ), AFFILIATES_ADMINISTER_AFFILIATES, 'affiliates-admin-buddypress', array( __CLASS__, 'buddypress_admin_page' ) ); } public static function buddypress_admin_page () { global $wpdb; if ( !current_user_can( AFFILIATES_ADMINISTER_AFFILIATES ) ) { wp_die( __( 'Access denied.', 'affiliates' ) ); } $output = ''; $output .= '
'; $output .= __( 'Here you can select the page that should be displayed in the BuddyPress user profiles under an additional Affiliates section.', 'affiliates-buddypress' ); $output .= ' '; $output .= __( 'If you have already generated an affiliate area, you can choose that page.', 'affiliates-buddypress' ); $output .= ' '; $output .= __( 'Alternatively, you can use any customized page that is using at least one Affiliates shortcode.', 'affiliates-buddypress' ); $output .= '
'; if ( isset( $_POST['submit'] ) ) { if ( wp_verify_nonce( $_POST['affiliates-buddypress-nonce'], 'save' ) ) { delete_option( 'affiliates-buddypress-page' ); if ( !empty( $_POST['affiliates-buddypress-page'] ) ) { add_option( 'affiliates-buddypress-page', $_POST[ 'affiliates-buddypress-page' ] ); } $position = !empty( $_POST['affiliates-buddypress-page-position'] ) ? intval( $_POST['affiliates-buddypress-page-position'] ) : Affiliates_BuddyPress::NAV_ITEM_POSITION; delete_option( 'affiliates-buddypress-page-position' ); add_option( 'affiliates-buddypress-page-position', $position ); $output .= '