WordPress.org

Plugin Directory

Changeset 1660551


Ignore:
Timestamp:
05/19/17 02:53:01 (6 months ago)
Author:
DrewAPicture
Message:

Bring trunk up to date with the 1.1.2 tag.

Location:
affiliatewp-order-details-for-affiliates/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • affiliatewp-order-details-for-affiliates/trunk/affiliatewp-order-details-for-affiliates.php

    r990785 r1660551  
    22/** 
    33 * Plugin Name: AffiliateWP - Order Details For Affiliates 
    4  * Plugin URI: http://affiliatewp.com/addons/share-purchase-details/ 
     4 * Plugin URI: http://affiliatewp.com/addons/order-details-affiliates/ 
    55 * Description: Share customer purchase information with the affiliate who referred them 
    66 * Author: Pippin Williamson and Andrew Munro 
    77 * Author URI: http://affiliatewp.com 
    8  * Version: 1.0 
     8 * Version: 1.1.2 
    99 * Text Domain: affiliatewp-order-details-for-affiliates 
    1010 * Domain Path: languages 
     
    2525 * @category Core 
    2626 * @author Andrew Munro 
    27  * @version 1.0 
     27 * @version 1.1.2 
    2828 */ 
    2929 
     
    5050    public $order_details; 
    5151    public $emails; 
     52    public $shortcodes; 
    5253 
    5354    /** 
     
    6869            self::$plugin_dir = plugin_dir_path( __FILE__ ); 
    6970            self::$plugin_url = plugin_dir_url( __FILE__ ); 
    70             self::$version    = '1.0'; 
     71            self::$version    = '1.1.2'; 
    7172 
    7273            self::$instance->load_textdomain(); 
     
    7677            self::$instance->order_details = new AffiliateWP_Order_Details_For_Affiliates_Order_Details; 
    7778            self::$instance->emails        = new AffiliateWP_Order_Details_For_Affiliates_Emails; 
     79            self::$instance->shortcodes    = new AffiliateWP_Order_Details_For_Affiliates_Shortcodes; 
    7880        } 
    7981 
     
    151153        require_once self::$plugin_dir . 'includes/class-order-details.php'; 
    152154        require_once self::$plugin_dir . 'includes/class-emails.php'; 
     155        require_once self::$plugin_dir . 'includes/class-shortcodes.php'; 
    153156 
    154157        if ( is_admin() ) { 
     
    179182        // Add template folder to hold the customer table 
    180183        add_filter( 'affwp_template_paths', array( $this, 'get_theme_template_paths' ) ); 
     184 
     185        // Add to the tabs list for 1.8.1 (fails silently if the hook doesn't exist). 
     186        add_filter( 'affwp_affiliate_area_tabs', function( $tabs ) { 
     187            return array_merge( $tabs, array( 'order-details' ) ); 
     188        } ); 
    181189    } 
    182190 
     
    189197     */ 
    190198    public function no_access() { 
    191         if ( $this->is_order_details_tab() && ! ( $this->can_access_order_details( affwp_get_affiliate_user_id( affwp_get_affiliate_id() ) ) || $this->global_order_details_access() ) ) { 
     199        if ( $this->is_order_details_tab() && ! ( $this->can_access_order_details() || $this->global_order_details_access() ) ) { 
    192200            wp_redirect( affiliate_wp()->login->get_login_url() ); exit; 
    193201        } 
     
    226234     */ 
    227235    public function add_order_details_tab( $affiliate_id, $active_tab ) { 
    228         if ( ! ( $this->can_access_order_details( affwp_get_affiliate_user_id( $affiliate_id ) ) || $this->global_order_details_access() ) ) { 
     236        if ( ! ( $this->can_access_order_details() || $this->global_order_details_access() ) ) { 
    229237            return; 
    230238        } 
     
    234242            <a href="<?php echo esc_url( add_query_arg( 'tab', 'order-details' ) ); ?>"><?php _e( 'Order Details', 'affiliate-wp' ); ?></a> 
    235243        </li> 
    236     <?php    
     244    <?php 
    237245    } 
    238246 
     
    257265     * @return boolean 
    258266     */ 
    259     public function can_access_order_details( $affiliate_id ) { 
    260         $can_receive = get_user_meta( $affiliate_id, 'affwp_order_details_access', true ); 
     267    public function can_access_order_details( $user_id = 0 ) { 
     268 
     269        // use user ID passed in, else get current user ID 
     270        $user_id = $user_id ? $user_id : get_current_user_id(); 
     271 
     272        if ( ! $user_id ) { 
     273            return false; 
     274        } 
     275 
     276        // look up meta 
     277        $can_receive = get_user_meta( $user_id, 'affwp_order_details_access', true ); 
    261278 
    262279        if ( $can_receive ) { 
  • affiliatewp-order-details-for-affiliates/trunk/includes/class-admin.php

    r990785 r1660551  
    22 
    33class AffiliateWP_Order_Details_For_Affiliates_Admin { 
    4      
     4 
    55    public function __construct() { 
    66        // update the affiliate 
     
    1111 
    1212        // add global option for access to order details 
    13         add_filter( 'affwp_settings_misc', array( $this, 'order_details_access' ) ); 
     13        add_filter( 'affwp_settings_integrations', array( $this, 'order_details_access' ) ); 
    1414    } 
    1515 
     
    3838            delete_user_meta( affwp_get_affiliate_user_id( $data['affiliate_id'] ), 'affwp_order_details_access' ); 
    3939        } 
    40          
     40 
    4141    } 
    4242 
     
    6565                <td> 
    6666                    <input type="checkbox" name="order_details_access" id="order-details-access" value="1" <?php checked( $checked, 1 ); ?> /> 
    67                     <p class="description"><?php _e( 'Allow affiliate to see the order details for each referral on their affiliate dashboard.', 'affiliatewp-order-details-for-affiliates' ); ?></p> 
     67                    <p class="description"><?php _e( 'Allow affiliate to see order details for each referral.', 'affiliatewp-order-details-for-affiliates' ); ?></p> 
    6868                </td> 
    6969            </tr> 
    7070        </table> 
    7171 
    72     <?php        
     72    <?php 
    7373    } 
    7474 
     
    8181     */ 
    8282    public function order_details_access( $fields ) { 
    83          
     83 
     84        $fields['odfa_header'] = array( 
     85            'name' => __( 'Order Details for Affiliates', 'affiliatewp-order-details-for-affiliates' ), 
     86            'type' => 'header' 
     87        ); 
     88 
    8489        $fields['order_details_access'] = array( 
    85             'name' => __( 'Allow Global Access To Order Details', 'affiliatewp-order-details-for-affiliates' ), 
     90            'name' => __( 'Allow Global Access', 'affiliatewp-order-details-for-affiliates' ), 
    8691            'desc' => __( 'Check this box if you would like all affiliates to have access to order details.', 'affiliatewp-order-details-for-affiliates' ), 
    8792            'type' => 'checkbox' 
     93        ); 
     94 
     95        $fields['odfa_disable_details'] = array( 
     96            'name' => __( 'Disable Details', 'affiliatewp-order-details-for-affiliates' ), 
     97            'desc' => __( 'Select which details should not show for an affiliate.', 'affiliatewp-order-details-for-affiliates' ), 
     98            'type' => 'multicheck', 
     99            'options' => array( 
     100                'order_number'              => __( 'Order Number', 'affiliatewp-order-details-for-affiliates' ), 
     101                'order_date'                => __( 'Order Date', 'affiliatewp-order-details-for-affiliates' ), 
     102                'order_total'               => __( 'Order Total', 'affiliatewp-order-details-for-affiliates' ), 
     103                'referral_amount'           => __( 'Referral Amount', 'affiliatewp-order-details-for-affiliates' ), 
     104                'customer_name'             => __( 'Customer Name', 'affiliatewp-order-details-for-affiliates' ), 
     105                'customer_email'            => __( 'Customer Email', 'affiliatewp-order-details-for-affiliates' ), 
     106                'customer_phone'            => __( 'Customer Phone', 'affiliatewp-order-details-for-affiliates' ), 
     107                'customer_shipping_address' => __( 'Customer Shipping Address', 'affiliatewp-order-details-for-affiliates' ), 
     108                'customer_billing_address'  => __( 'Customer Billing Address', 'affiliatewp-order-details-for-affiliates' ), 
     109            ), 
    88110        ); 
    89111 
  • affiliatewp-order-details-for-affiliates/trunk/includes/class-order-details.php

    r990785 r1660551  
    77    /** 
    88     * Allowed order details 
    9      *  
     9     * 
    1010     * @since 1.0 
    1111     * @return  array allowed order details 
     
    1313    public function allowed() { 
    1414 
     15        $disabled = affiliate_wp()->settings->get( 'odfa_disable_details' ); 
     16        $disabled = $disabled ? $disabled : array(); 
     17 
    1518        $allowed = array( 
    16             'customer_name'             => true, 
    17             'customer_email'            => true, 
    18             'customer_billing_address'  => true, 
    19             'customer_shipping_address' => true, 
    20             'customer_phone'            => true, 
    21             'order_number'              => true, 
    22             'order_total'               => true, 
    23             'order_date'                => true, 
    24             'referral_amount'           => true 
     19            'customer_name'             => array_key_exists( 'customer_name', $disabled ) ? false : true, 
     20            'customer_email'            => array_key_exists( 'customer_email', $disabled ) ? false : true, 
     21            'customer_billing_address'  => array_key_exists( 'customer_billing_address', $disabled ) ? false : true, 
     22            'customer_shipping_address' => array_key_exists( 'customer_shipping_address', $disabled ) ? false : true, 
     23            'customer_phone'            => array_key_exists( 'customer_phone', $disabled ) ? false : true, 
     24            'order_number'              => array_key_exists( 'order_number', $disabled ) ? false : true, 
     25            'order_total'               => array_key_exists( 'order_total', $disabled ) ? false : true, 
     26            'order_date'                => array_key_exists( 'order_date', $disabled ) ? false : true, 
     27            'referral_amount'           => array_key_exists( 'referral_amount', $disabled ) ? false : true, 
    2528        ); 
    2629 
     
    2932 
    3033    /** 
     34     * Has customer details or order details 
     35     * 
     36     * @since 1.0.1 
     37     * @return boolean 
     38     */ 
     39    public function has( $type = '' ) { 
     40 
     41        $is_allowed = affiliatewp_order_details_for_affiliates()->order_details->allowed(); 
     42 
     43        switch ( $type ) { 
     44 
     45            case 'customer_details': 
     46 
     47                if ( 
     48                    $is_allowed['customer_name'] || 
     49                    $is_allowed['customer_email'] || 
     50                    $is_allowed['customer_phone'] || 
     51                    $is_allowed['customer_shipping_address'] || 
     52                    $is_allowed['customer_billing_address'] 
     53 
     54                ) { 
     55                    return true; 
     56                } 
     57 
     58                break; 
     59 
     60            case 'order_details': 
     61 
     62                if ( 
     63                    $is_allowed['order_number'] || 
     64                    $is_allowed['order_total'] || 
     65                    $is_allowed['order_date'] || 
     66                    $is_allowed['referral_amount'] 
     67 
     68                ) { 
     69                    return true; 
     70                } 
     71 
     72                break; 
     73 
     74        } 
     75 
     76        return false; 
     77    } 
     78 
     79    /** 
    3180     * Retrieve specific order information 
    3281     */ 
    3382    public function get( $referral = '', $info = '' ) { 
     83         
    3484        $is_allowed = $this->allowed(); 
    3585 
     
    51101                    return $is_allowed['order_date'] ? $payment_meta['date'] : ''; 
    52102                } 
    53                  
     103 
    54104                if ( $info == 'order_total' ) { 
    55105                    return $is_allowed['order_total'] ? edd_currency_filter( edd_format_amount( edd_get_payment_amount( $referral->reference ) ) ) : ''; 
     
    85135 
    86136            case 'woocommerce': 
    87                  
     137 
    88138                if ( ! class_exists( 'WC_Order' ) ) { 
    89139                    break; 
     
    93143 
    94144                if ( $info == 'order_number' ) { 
    95                     return $is_allowed['order_number'] ? $referral->reference : ''; 
     145 
     146                    $seq_order_number = get_post_meta( $order->id, '_order_number', true ); 
     147 
     148                    // sequential order numbers compatibility 
     149                    if ( $seq_order_number && class_exists( 'WC_Seq_Order_Number_Pro' ) ) { 
     150                        $order_number = $seq_order_number; 
     151                    } else { 
     152                        $order_number = $referral->reference; 
     153                    } 
     154 
     155                    return $is_allowed['order_number'] ? $order_number : ''; 
     156 
    96157                } 
    97158 
     
    99160                    return $is_allowed['order_date'] ? $order->order_date : ''; 
    100161                } 
    101                  
     162 
    102163                if ( $info == 'order_total' ) { 
    103164                    return $is_allowed['order_total'] ? $order->get_formatted_order_total() : ''; 
     
    124185                } 
    125186 
    126                 break;   
     187                break; 
    127188        } 
    128189 
  • affiliatewp-order-details-for-affiliates/trunk/languages/affiliatewp-order-details-for-affiliates.pot

    r990785 r1660551  
     1#, fuzzy 
    12msgid "" 
    23msgstr "" 
    34"Project-Id-Version: AffiliateWP - Order Details For Affiliates\n" 
    4 "POT-Creation-Date: 2014-09-16 16:55+1200\n" 
     5"POT-Creation-Date: 2015-10-13 23:09+1300\n" 
    56"PO-Revision-Date: 2014-09-16 16:55+1200\n" 
    67"Last-Translator: Andrew Munro, Sumobi <andrew@sumobi.com>\n" 
     
    1011"Content-Type: text/plain; charset=UTF-8\n" 
    1112"Content-Transfer-Encoding: 8bit\n" 
    12 "X-Generator: Poedit 1.6.5\n" 
     13"X-Generator: Poedit 1.8.5\n" 
    1314"X-Poedit-KeywordsList: __;_e\n" 
    1415"X-Poedit-Basepath: .\n" 
     
    1718"X-Poedit-SearchPath-0: ..\n" 
    1819 
    19 #: ../affiliatewp-order-details-for-affiliates.php:95 
    20 #: ../affiliatewp-order-details-for-affiliates.php:107 
     20#: ../affiliatewp-order-details-for-affiliates.php:97 
     21#: ../affiliatewp-order-details-for-affiliates.php:109 
    2122msgid "Cheatin&#8217; huh?" 
    2223msgstr "" 
    2324 
    24 #: ../affiliatewp-order-details-for-affiliates.php:234 
    25 #: ../templates/dashboard-tab-order-details.php:15 
    26 #: ../templates/dashboard-tab-order-details.php:21 
     25#: ../affiliatewp-order-details-for-affiliates.php:237 
     26#: ../templates/dashboard-tab-order-details.php:17 
     27#: ../templates/dashboard-tab-order-details.php:26 
    2728msgid "Order Details" 
    2829msgstr "" 
    2930 
    30 #: ../affiliatewp-order-details-for-affiliates.php:298 
     31#: ../affiliatewp-order-details-for-affiliates.php:301 
    3132msgid "Get more add-ons for AffiliateWP" 
    3233msgstr "" 
    3334 
    34 #: ../affiliatewp-order-details-for-affiliates.php:298 
     35#: ../affiliatewp-order-details-for-affiliates.php:301 
    3536msgid "Get add-ons" 
    3637msgstr "" 
     
    6162 
    6263#: ../includes/class-admin.php:85 
     64msgid "Order Details for Affiliates" 
     65msgstr "" 
     66 
     67#: ../includes/class-admin.php:90 
    6368msgid "Allow Global Access To Order Details" 
    6469msgstr "" 
    6570 
    66 #: ../includes/class-admin.php:86 
     71#: ../includes/class-admin.php:91 
    6772msgid "" 
    6873"Check this box if you would like all affiliates to have access to order " 
    6974"details." 
     75msgstr "" 
     76 
     77#: ../includes/class-admin.php:96 
     78msgid "Disable Details" 
     79msgstr "" 
     80 
     81#: ../includes/class-admin.php:97 
     82msgid "Select which details should not show for an affiliate." 
     83msgstr "" 
     84 
     85#: ../includes/class-admin.php:100 
     86msgid "Order Number" 
     87msgstr "" 
     88 
     89#: ../includes/class-admin.php:101 
     90msgid "Order Date" 
     91msgstr "" 
     92 
     93#: ../includes/class-admin.php:102 
     94msgid "Order Total" 
     95msgstr "" 
     96 
     97#: ../includes/class-admin.php:103 
     98msgid "Referral Amount" 
     99msgstr "" 
     100 
     101#: ../includes/class-admin.php:104 
     102msgid "Customer Name" 
     103msgstr "" 
     104 
     105#: ../includes/class-admin.php:105 
     106msgid "Customer Email" 
     107msgstr "" 
     108 
     109#: ../includes/class-admin.php:106 
     110msgid "Customer Phone" 
     111msgstr "" 
     112 
     113#: ../includes/class-admin.php:107 
     114msgid "Customer Shipping Address" 
     115msgstr "" 
     116 
     117#: ../includes/class-admin.php:108 
     118msgid "Customer Billing Address" 
    70119msgstr "" 
    71120 
     
    83132 
    84133#: ../includes/class-emails.php:100 
    85 #: ../templates/dashboard-tab-order-details.php:49 
     134#: ../templates/dashboard-tab-order-details.php:60 
    86135msgid "Order Number:" 
    87136msgstr "" 
    88137 
    89138#: ../includes/class-emails.php:107 
    90 #: ../templates/dashboard-tab-order-details.php:56 
     139#: ../templates/dashboard-tab-order-details.php:67 
    91140msgid "Order Date:" 
    92141msgstr "" 
    93142 
    94143#: ../includes/class-emails.php:114 
    95 #: ../templates/dashboard-tab-order-details.php:63 
     144#: ../templates/dashboard-tab-order-details.php:74 
    96145msgid "Order Total:" 
    97146msgstr "" 
    98147 
    99148#: ../includes/class-emails.php:121 
    100 #: ../templates/dashboard-tab-order-details.php:70 
     149#: ../templates/dashboard-tab-order-details.php:81 
    101150msgid "Referral Amount:" 
    102151msgstr "" 
     
    122171msgstr "" 
    123172 
    124 #: ../templates/dashboard-tab-order-details.php:22 
     173#: ../templates/dashboard-tab-order-details.php:30 
    125174msgid "Customer Information" 
    126175msgstr "" 
    127176 
    128 #: ../templates/dashboard-tab-order-details.php:82 
     177#: ../templates/dashboard-tab-order-details.php:95 
    129178msgid "Name:" 
    130179msgstr "" 
    131180 
    132 #: ../templates/dashboard-tab-order-details.php:86 
     181#: ../templates/dashboard-tab-order-details.php:99 
    133182msgid "Email:" 
    134183msgstr "" 
    135184 
    136 #: ../templates/dashboard-tab-order-details.php:90 
     185#: ../templates/dashboard-tab-order-details.php:103 
    137186msgid "Phone:" 
    138187msgstr "" 
    139188 
    140 #: ../templates/dashboard-tab-order-details.php:95 
     189#: ../templates/dashboard-tab-order-details.php:108 
    141190msgid "Shipping Address:" 
    142191msgstr "" 
    143192 
    144 #: ../templates/dashboard-tab-order-details.php:99 
     193#: ../templates/dashboard-tab-order-details.php:112 
    145194msgid "Billing Address:" 
    146195msgstr "" 
    147196 
    148 #: ../templates/dashboard-tab-order-details.php:112 
     197#: ../templates/dashboard-tab-order-details.php:128 
    149198msgid "There are currently no order details to display." 
    150199msgstr "" 
  • affiliatewp-order-details-for-affiliates/trunk/templates/dashboard-tab-order-details.php

    r990785 r1660551  
    33 
    44    $is_allowed = $affwp_odfa->order_details->allowed(); 
    5     $referrals  = apply_filters( 'affwp_odfa_referral_args', affiliate_wp()->referrals->get_referrals(  
    6         array(  
     5 
     6    $referrals  = apply_filters( 'affwp_odfa_referral_args', affiliate_wp()->referrals->get_referrals( 
     7        array( 
    78            'affiliate_id' => affwp_get_affiliate_id(), // only get order details from the logged-in affiliate 
    89            'number'       => -1,                       // show all 
    9         )  
     10            'status'       => 'unpaid' 
     11        ) 
    1012    ), affwp_get_affiliate_id() ); 
    1113?> 
     
    1618 
    1719    <?php if ( $referrals ) : ?> 
     20 
     21    <?php if ( $affwp_odfa->order_details->has( 'order_details' ) || $affwp_odfa->order_details->has( 'customer_details' ) ) : ?> 
    1822    <table class="affwp-table"> 
    1923        <thead> 
    2024            <tr> 
     25                <?php if ( $affwp_odfa->order_details->has( 'order_details' ) ) : ?> 
    2126                <th><?php _e( 'Order Details', 'affiliatewp-order-details-for-affiliates' ); ?></th> 
     27                <?php endif; ?> 
     28 
     29                <?php if ( $affwp_odfa->order_details->has( 'customer_details' ) ) : ?> 
    2230                <th><?php _e( 'Customer Information', 'affiliatewp-order-details-for-affiliates' ); ?></th> 
     31                <?php endif; ?> 
    2332            </tr> 
    2433        </thead> 
     
    2837 
    2938            foreach ( $referrals as $referral ) { 
    30                  
     39 
    3140                $order_number              = $affwp_odfa->order_details->get( $referral, 'order_number' ); 
    3241                $order_date                = $affwp_odfa->order_details->get( $referral, 'order_date' ); 
     
    4251            ?> 
    4352                <tr> 
     53 
     54                    <?php if ( $affwp_odfa->order_details->has( 'order_details' ) ) : ?> 
    4455                    <td> 
    4556                        <?php do_action( 'affwp_odfa_order_details_start', $referral ); ?> 
     
    7586                        <?php do_action( 'affwp_odfa_order_details_end', $referral ); ?> 
    7687                    </td> 
    77                  
     88                    <?php endif; ?> 
     89 
     90                    <?php if ( $affwp_odfa->order_details->has( 'customer_details' ) ) : ?> 
    7891                    <td> 
    7992                        <?php do_action( 'affwp_odfa_customer_details_start', $referral ); ?> 
     
    90103                            <p><strong><?php _e( 'Phone:', 'affiliatewp-order-details-for-affiliates' ); ?></strong><br /><?php echo $customer_phone; ?></p> 
    91104                        <?php endif; ?> 
    92                          
     105 
    93106 
    94107                        <?php if ( $is_allowed['customer_shipping_address'] && isset( $customer_shipping_address ) ) : ?> 
     
    102115                        <?php do_action( 'affwp_odfa_customer_details_end', $referral ); ?> 
    103116                    </td> 
     117                <?php endif; ?> 
     118 
    104119                </tr> 
    105120                <?php 
     
    108123        </tbody> 
    109124    </table> 
     125    <?php endif; ?> 
    110126 
    111127    <?php else : ?> 
    112128        <p><?php _e( 'There are currently no order details to display.', 'affiliatewp-order-details-for-affiliates' ); ?></p> 
    113129    <?php endif; ?> 
    114 </div>   
     130</div> 
Note: See TracChangeset for help on using the changeset viewer.