class-affiliates-affiliate-profile-wordpress.php
5.82 KB
<?php
class Affiliates_Affiliate_Profile_WordPress extends Affiliates_Affiliate_Profile { const IXAP183 = 'affiliate-profile-nonce'; const IXAP423 = 'edit-profile'; static function init() { add_shortcode( 'affiliates_affiliate_profile', array( __CLASS__, 'profile_shortcode' ) ); } static function profile_shortcode( $IXAP223, $IXAP167 = null ) { $IXAP15 = null; $IXAP105 = shortcode_atts( self::$IXAP180, $IXAP223 ); return self::render_profile( $IXAP105 ); } static function render_profile( $IXAP105 = array() ) { global $affiliates_options, $affiliates_db; wp_enqueue_style( 'affiliates' ); $IXAP62 = ''; $IXAP24 = Affiliates_Affiliate_WordPress::get_user_affiliate_id(); if ( $IXAP24 === false ) { return $IXAP62; } $IXAP370 = Affiliates_Affiliate_WordPress::get_affiliate( $IXAP24 ); $IXAP424 = isset( $IXAP105['show_name'] ) ? $IXAP105['show_name'] : self::$IXAP180['show_name']; $IXAP425 = $IXAP424 && isset( $IXAP105['edit_name'] ) ? $IXAP105['edit_name'] : self::$IXAP180['edit_name']; $IXAP426 = isset( $IXAP105['show_email'] ) ? $IXAP105['show_email'] : self::$IXAP180['show_email']; $IXAP427 = $IXAP426 && isset( $IXAP105['edit_email'] ) ? $IXAP105['edit_email'] : self::$IXAP180['edit_email']; $IXAP428 = isset( $IXAP105['show_attributes'] ) ? $IXAP105['show_attributes'] : self::$IXAP180['show_attributes']; if ( $IXAP428 ) { $IXAP428 = explode( ",", $IXAP428 ); $IXAP429 = array(); foreach ( $IXAP428 as $IXAP412 ) { $IXAP412 = trim( $IXAP412 ); if ( Affiliates_Attributes::validate_key( $IXAP412 ) ) { $IXAP429[] = $IXAP412; } } $IXAP428 = $IXAP429; } else { $IXAP428 = array(); } $IXAP430 = isset( $IXAP105['edit_attributes'] ) ? $IXAP105['edit_attributes'] : self::$IXAP180['edit_attributes']; if ( $IXAP430 ) { $IXAP429 = explode( ",", $IXAP430 ); $IXAP430 = array(); foreach ( $IXAP429 as $IXAP412 ) { if ( in_array( $IXAP412, $IXAP428 ) ) { $IXAP430[] = $IXAP412; } } } else { $IXAP430 = array(); } if ( isset( $_POST[self::IXAP183] ) ) { if ( !wp_verify_nonce( $_POST[self::IXAP183], self::IXAP423 ) ) { wp_die( __( 'Access denied.', AFFILIATES_PRO_PLUGIN_DOMAIN ) ); } if ( $IXAP425 && isset( $_POST['first_name'] ) && ( $_POST['last_name'] ) ) { $IXAP43 = $_POST['first_name'] . " " . $_POST['last_name']; if ( $IXAP370->name != $IXAP43 ) { if ( $IXAP9 = Affiliates_Affiliate_WordPress::get_affiliate_user_id( $IXAP24 ) ) { if ( $IXAP431 = Affiliates_Utility::filter( $_POST['first_name'] ) ) { update_user_meta( $IXAP9, 'first_name', $IXAP431 ); } if ( $IXAP432 = Affiliates_Utility::filter( $_POST['last_name'] ) ) { update_user_meta( $IXAP9, 'last_name', $IXAP432 ); } } Affiliates_Affiliate_WordPress::update_name( $IXAP24, $IXAP43 ); } } if ( $IXAP427 && isset( $_POST['affiliate_email'] ) && ( $_POST['affiliate_email'] != $IXAP370->email ) ) { if ( ( $IXAP433 = Affiliates_Validator::validate_email( $_POST['affiliate_email'] ) ) && !email_exists( $IXAP433 ) ) { if ( $IXAP433 = Affiliates_Affiliate_WordPress::update_email( $IXAP24, $IXAP433 ) ) { if ( $IXAP9 = Affiliates_Affiliate_WordPress::get_affiliate_user_id( $IXAP24 ) ) { $IXAP434 = array( 'ID' => $IXAP9, 'user_email' => $IXAP433 ); wp_update_user( $IXAP434 ); } } } } foreach ( $IXAP430 as $IXAP412 ) { $IXAP435 = "aff_attr_" . $IXAP412; if ( isset( $_POST[$IXAP435] ) ) { Affiliates_Affiliate_WordPress::update_attribute( $IXAP24, $IXAP412, $_POST[$IXAP435] ); } } } $IXAP370 = Affiliates_Affiliate_WordPress::get_affiliate( $IXAP24 ); $IXAP62 .= '<div class="affiliate-profile">' . '<form id="affiliate-profile" action="" method="post">'; if ( $IXAP424 ) { $IXAP436 = !$IXAP425 ? ' readonly="readonly" ' : ''; if ( $IXAP9 = Affiliates_Affiliate_WordPress::get_affiliate_user_id( $IXAP24 ) ) { $IXAP431 = get_user_meta( $IXAP9, 'first_name', true ); $IXAP432 = get_user_meta( $IXAP9, 'last_name', true ); } else { $IXAP431 = ''; $IXAP432 = ''; } $IXAP62 .= '<div class="field first-name">' . '<label for="first_name">' . __( 'First Name', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . '<input ' . $IXAP436 . ' name="first_name" type="text" value="' . esc_attr( $IXAP431 ) . '"/>'. '</div>'; $IXAP62 .= '<div class="field last-name">' . '<label for="last_name">' . __( 'Last Name', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . '<input ' . $IXAP436 . ' name="last_name" type="text" value="' . esc_attr( $IXAP432 ) . '"/>'. '</div>'; } if ( $IXAP426 ) { $IXAP436 = !$IXAP427 ? ' readonly="readonly" ' : ''; $IXAP62 .= '<div class="field affiliate-email">' . '<label for="affiliate_email">' . __( 'Email', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . '<input ' . $IXAP436 . ' name="affiliate_email" type="text" value="' . esc_attr( $IXAP370->email ) . '"/>'. '</div>'; } if ( $IXAP428 ) { $IXAP25 = $affiliates_db->get_tablename( 'affiliates_attributes' ); $IXAP437 = $affiliates_db->get_objects( "SELECT * FROM $IXAP25 WHERE affiliate_id = %d", $IXAP24 ); $IXAP277 = array(); foreach ( $IXAP437 as $IXAP412 ) { $IXAP277[$IXAP412->attr_key] = $IXAP412->attr_value; } $IXAP438 = Affiliates_Attributes::get_keys(); foreach ( $IXAP428 as $IXAP365 ) { $IXAP368 = isset( $IXAP277[$IXAP365] ) ? $IXAP277[$IXAP365] : ''; $IXAP436 = !in_array( $IXAP365, $IXAP430 ) ? ' readonly="readonly" ' : ''; $IXAP435 = "aff_attr_" . $IXAP365; $IXAP62 .= '<div class="field affiliate-attribute ' . esc_attr( $IXAP365 ) . '">' . '<label for="' . esc_attr( $IXAP435 ) . '">' . __( $IXAP438[$IXAP365], AFFILIATES_PRO_PLUGIN_DOMAIN ) . '</label>' . '<input ' . $IXAP436 . ' name="' . esc_attr( $IXAP435 ) . '" type="text" value="' . esc_attr( $IXAP368 ) . '"/>'. '</div>'; } } if ( $IXAP425 || $IXAP427 || $IXAP430 ) { $IXAP62 .= '<div class="submit">' . wp_nonce_field( self::IXAP423, self::IXAP183, true, false ) . '<input type="submit" value="' . __( 'Save', AFFILIATES_PRO_PLUGIN_DOMAIN ) . '"/>' . '<input type="hidden" value="submitted" name="submitted"/>' . '</div>'; } $IXAP62 .= '</form>'; $IXAP62 .= '</div>'; return $IXAP62; } } Affiliates_Affiliate_Profile_WordPress::init();