settings->get( 'affiliates_page' ) ) || has_shortcode( $post->post_content, 'affiliate_area_creatives' ) || has_shortcode( $post->post_content, 'affiliate_area_graphs' ) || has_shortcode( $post->post_content, 'affiliate_area_referrals' ) || has_shortcode( $post->post_content, 'affiliate_area_settings' ) || has_shortcode( $post->post_content, 'affiliate_area_stats' ) || has_shortcode( $post->post_content, 'affiliate_area_urls' ) || has_shortcode( $post->post_content, 'affiliate_area_visits' ) || has_shortcode( $post->post_content, 'affiliate_area_notices' ) ) { $ret = true; } return $ret; } /** * Load the jQuery UI datepicker and styling for the [affiliate_area_graphs] shortcode * * @since 1.1.6 * @return void */ public function load_datepicker() { global $post; if ( ! is_object( $post ) ) { return; } if ( has_shortcode( $post->post_content, 'affiliate_area_graphs' ) ) { wp_enqueue_script( 'jquery-ui-datepicker' ); wp_enqueue_style( 'jquery-ui-css' ); } } /** * [affiliate_area_graphs] shortcode * * @since 1.0 */ public function affiliate_area_graphs( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'graphs' ); echo '
'; $content = ob_get_clean(); // Rendered tab HTML carries visitor data (campaigns, URLs, referrers), so return it as core's Affiliate Area does, never re-parsed as shortcodes. return $content; } /** * [affiliate_area_settings] shortcode * * @since 1.0 */ public function affiliate_area_settings( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'settings' ); echo '
'; $content = ob_get_clean(); return $content; } /** * [affiliate_area_creatives] shortcode * * @since 1.0 */ public function affiliate_area_creatives( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'creatives' ); echo '
'; $content = ob_get_clean(); return $content; } /** * [affiliate_area_referrals] shortcode * * @since 1.0 */ public function affiliate_area_referrals( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'referrals' ); echo '
'; $content = ob_get_clean(); return $content; } /** * [affiliate_area_stats] shortcode * * @since 1.0 */ public function affiliate_area_stats( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'stats' ); echo '
'; $content = ob_get_clean(); return $content; } /** * [affiliate_area_urls] shortcode * * @since 1.0 */ function affiliate_area_urls( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'urls' ); echo '
'; $content = ob_get_clean(); return $content; } /** * [affiliate_area_visits] shortcode * * @since 1.0 */ function affiliate_area_visits( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'visits' ); echo '
'; $content = ob_get_clean(); return $content; } /** * [affiliate_area_payouts] shortcode * * @since 1.1.4 */ function affiliate_area_payouts( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); echo '
'; affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'payouts' ); echo '
'; $content = ob_get_clean(); return $content; } /** * Show the total number of unpaid/paid referrals for the logged in affiliate * * [affiliate_referrals status="paid"] * [affiliate_referrals status="unpaid"] * * @since 1.1 */ function affiliate_referrals( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } $atts = shortcode_atts( array( 'status' => '' ), $atts, 'affiliate_referrals' ); switch ( $atts['status'] ) { case 'paid': $content = affwp_count_referrals( affwp_get_affiliate_id(), 'paid' ); break; case 'unpaid': $content = affwp_count_referrals( affwp_get_affiliate_id(), 'unpaid' ); break; } return do_shortcode( $content ); } /** * Show an affiliate's total unpaid/paid earnings * * [affiliate_earnings status="paid"] * [affiliate_earnings status="unpaid"] * * @since 1.1 */ function affiliate_earnings( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } $atts = shortcode_atts( array( 'status' => '' ), $atts, 'affiliate_earnings' ); switch ( $atts['status'] ) { case 'paid': $content = affwp_get_affiliate_earnings( affwp_get_affiliate_id(), true ); break; case 'unpaid': $content = affwp_get_affiliate_unpaid_earnings( affwp_get_affiliate_id(), true ); break; } return do_shortcode( $content ); } /** * Show the total number of visits an affiliate has had * * [affiliate_visits] * * @since 1.1 */ function affiliate_visits( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } $content = affwp_count_visits( affwp_get_affiliate_id() ); return do_shortcode( $content ); } /** * Show an affiliate's conversion rate * * [affiliate_conversion_rate] * * @since 1.1 */ function affiliate_conversion_rate( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } $content = affwp_get_affiliate_conversion_rate( affwp_get_affiliate_id() ); return do_shortcode( $content ); } /** * Show an affiliate's commission rate * * [affiliate_commission_rate] * * @since 1.1 */ function affiliate_commission_rate( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } $content = affwp_get_affiliate_rate( affwp_get_affiliate_id(), true ); return do_shortcode( $content ); } /** * Show an affiliate's campaign stats * * [affiliate_campaign_stats] * * @since 1.1.1 */ function affiliate_campaign_stats( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } ob_start(); ?>
campaign ) ? esc_html( $campaign->campaign ) : esc_html__( 'None set', 'affiliatewp-affiliate-area-shortcodes' ); ?> visits ); ?> unique_visits ); ?> referrals ); ?> conversion_rate ) ); ?>%
'' ), $atts, 'affiliate_name' ); if ( isset( $atts['first_name_only'] ) && 'yes' === $atts['first_name_only'] ) { $current_user = wp_get_current_user(); $content = $current_user->user_firstname; } else { $content = affiliate_wp()->affiliates->get_affiliate_name( affwp_get_affiliate_id() ); } // The affiliate name is user data, not shortcode content: escape it for output rather // than re-parsing it through do_shortcode(). return esc_html( $content ); } /** * Show an affiliate's website url * * [affiliate_website] * * @since 1.1.3 */ public function affiliate_website( $atts, $content = null ) { if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) { return; } $current_user = wp_get_current_user(); $content = $current_user->user_url; // The affiliate website is user data, not shortcode content: escape it as a URL rather // than re-parsing it through do_shortcode(). return esc_url( $content ); } /** * Show dashboard notices * * [affiliate_area_notices] * * @since 1.1.5 */ public function affiliate_area_notices( $atts, $content = null ) { if ( ! ( is_user_logged_in() && affwp_is_affiliate() ) ) { return; } $atts = shortcode_atts( array( 'pending' => __( 'Your affiliate account is pending approval', 'affiliatewp-affiliate-area-shortcodes' ), 'inactive' => __( 'Your affiliate account is not active', 'affiliatewp-affiliate-area-shortcodes' ), 'rejected' => __( 'Your affiliate account request has been rejected', 'affiliatewp-affiliate-area-shortcodes' ), 'profile_updated' => __( 'Your affiliate profile has been updated', 'affiliatewp-affiliate-area-shortcodes' ) ), $atts, 'affiliate_area_notices' ); $notice = ''; if ( 'pending' == affwp_get_affiliate_status( affwp_get_affiliate_id() ) ) { $notice = $atts['pending']; } elseif ( 'inactive' == affwp_get_affiliate_status( affwp_get_affiliate_id() ) ) { $notice = $atts['inactive']; } elseif ( 'rejected' == affwp_get_affiliate_status( affwp_get_affiliate_id() ) ) { $notice = $atts['rejected']; } elseif ( ! empty( $_GET['affwp_notice'] ) && 'profile-updated' === sanitize_key( wp_unslash( $_GET['affwp_notice'] ) ) ) { $notice = $atts['profile_updated']; } ob_start(); // Notice text comes from shortcode attributes: keep the HTML a post author may use, strip the rest. if ( $notice ): ?>

settings->get( 'affiliates_page' ) ? affiliate_wp()->login->get_login_url() : home_url(); $redirect = apply_filters( 'affwp_aas_logout_redirect', $redirect ); $content = apply_filters( 'affwp_aas_logout_link', '' . __( 'Log out', 'affiliatewp-affiliate-area-shortcodes' ) . '', $redirect ); return do_shortcode( $content ); } } new AffiliateWP_AAS;