Plugin Directory

Changeset 1163297


Ignore:
Timestamp:
05/19/2015 11:46:23 AM (11 years ago)
Author:
themeavenue
Message:

Update files to 3.1.8

Location:
awesome-support/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • awesome-support/trunk/awesome-support.php

    r1160923 r1163297  
    1111 * Plugin URI:        http://getawesomesupport.com
    1212 * Description:       Awesome Support is a great ticketing system that will help you improve your customer satisfaction by providing a unique customer support experience.
    13  * Version:           3.1.7
     13 * Version:           3.1.8
    1414 * Author:            ThemeAvenue
    1515 * Author URI:        http://themeavenue.net
     
    2929 *----------------------------------------------------------------------------*/
    3030
    31 define( 'WPAS_VERSION',           '3.1.7' );
     31define( 'WPAS_VERSION',           '3.1.8' );
    3232define( 'WPAS_DB_VERSION',        '1' );
    3333define( 'WPAS_URL',               trailingslashit( plugin_dir_url( __FILE__ ) ) );
     
    6868 */
    6969register_activation_hook( __FILE__, array( 'Awesome_Support', 'activate' ) );
    70 register_deactivation_hook( __FILE__, array( 'Awesome_Support', 'deactivate' ) );
    7170
    7271/**
  • awesome-support/trunk/class-awesome-support.php

    r1160923 r1163297  
    5858            add_action( 'wp',                             array( $this, 'get_replies_object' ),              10, 0 ); // Generate the object used for the custom loop for displaying ticket replies
    5959            add_action( 'wpmu_new_blog',                  array( $this, 'activate_new_site' ),               10, 0 ); // Activate plugin when new blog is added
    60             add_action( 'plugins_loaded',                 array( $this, 'load_plugin_textdomain' ),           9, 0 ); // Load the plugin textdomain
     60            add_action( 'plugins_loaded',                 array( $this, 'load_plugin_textdomain' ),          11, 0 ); // Load the plugin textdomain
    6161            add_action( 'init',                           array( $this, 'init' ),                            11, 0 ); // Register main post type
    6262            add_action( 'admin_bar_menu',                 array( $this, 'toolbar_tickets_link' ),           999, 1 ); // Add a link to agent's tickets in the toolbar
    63             add_action( 'wp_print_styles',                array( $this, 'enqueue_styles' ),                  10, 0 ); // Load public-facing style sheets
    64             add_action( 'wp_print_scripts',               array( $this, 'enqueue_scripts' ),                 10, 0 ); // Load public-facing JavaScripts
     63            add_action( 'wp_enqueue_scripts',             array( $this, 'enqueue_styles' ),                  10, 0 ); // Load public-facing style sheets
     64            add_action( 'wp_enqueue_scripts',             array( $this, 'enqueue_scripts' ),                 10, 0 ); // Load public-facing JavaScripts
    6565            add_action( 'template_redirect',              array( $this, 'redirect_archive' ),                10, 0 );
    6666            add_action( 'wpas_after_registration_fields', array( $this, 'terms_and_conditions_checkbox' ),   10, 3 ); // Add terms & conditions checkbox
     
    193193                 * Redirect to the newly created ticket
    194194                 */
     195                $submit = wpas_get_option( 'ticket_submit' );
    195196                wpas_redirect( 'ticket_added_failed', add_query_arg( array( 'message' => 6 ), get_permalink( $submit ) ), $submit );
    196197                exit;
     
    235236            $can_submit_empty = apply_filters( 'wpas_can_reply_be_empty', false );
    236237
     238            /**
     239             * Get the parent ticket ID.
     240             */
     241            $parent_id = intval( $_POST['ticket_id'] );
     242
    237243            if ( empty( $_POST['wpas_user_reply'] ) && false === $can_submit_empty ) {
    238244                wpas_redirect( 'reply_not_added', add_query_arg( array( 'message' => wpas_create_notification( __( 'You cannot submit an empty reply.', 'wpas' ) ) ), get_permalink( $parent_id ) ), $parent_id );
    239245                exit;
    240246            }
    241 
    242             $parent_id = intval( $_POST['ticket_id'] );
    243247
    244248            /* Sanitize the data */
     
    274278     *
    275279     * @since  3.0.2
    276      * @param  null|WP_User $user     User to authenticate.
    277      * @param  string       $username User login
    278      * @param  string       $password User password
    279      * @return object                 WP_User if authentication succeed, WP_Error on failure
     280     *
     281     * @param  WP_User|WP_Error|null $user     User to authenticate.
     282     * @param  string                $username User login
     283     * @param  string                $password User password
     284     *
     285     * @return object                          WP_User if authentication succeed, WP_Error on failure
    280286     */
    281287    public function email_signon( $user, $username, $password ) {
     
    290296         * we don' touch it and let WordPress handle it.
    291297         */
    292         if ( !is_wp_error( $user ) ) {
     298        if ( ! is_wp_error( $user ) ) {
    293299            return $user;
    294300        }
     
    306312         * the error is probably legitimate.
    307313         */
    308         if ( !is_email( $username ) ) {
     314        if ( ! is_email( $username ) ) {
    309315            return $user;
    310316        }
     
    317323         * so let's just return it.
    318324         */
    319         if ( false === $user_data || !is_a( $user_data, 'WP_User' ) ) {
     325        if ( false === $user_data || ! is_a( $user_data, 'WP_User' ) ) {
    320326            return $user;
    321327        }
     
    408414        } else {
    409415            self::single_activate();
    410         }
    411 
    412     }
    413 
    414     /**
    415      * Fired when the plugin is deactivated.
    416      *
    417      * @since    1.0.0
    418      * @param    boolean    $network_wide    True if WPMU superadmin uses
    419      *                                       "Network Deactivate" action, false if
    420      *                                       WPMU is disabled or plugin is
    421      *                                       deactivated on an individual blog.
    422      */
    423     public static function deactivate( $network_wide ) {
    424 
    425         if ( function_exists( 'is_multisite' ) && is_multisite() ) {
    426 
    427             if ( $network_wide ) {
    428 
    429                 // Get all blog ids
    430                 $blog_ids = self::get_blog_ids();
    431 
    432                 foreach ( $blog_ids as $blog_id ) {
    433 
    434                     switch_to_blog( $blog_id );
    435                     self::single_deactivate();
    436 
    437                 }
    438 
    439                 restore_current_blog();
    440 
    441             } else {
    442                 self::single_deactivate();
    443             }
    444 
    445         } else {
    446             self::single_deactivate();
    447416        }
    448417
     
    616585
    617586    /**
    618      * Fired for each blog when the plugin is deactivated.
    619      *
    620      * @since    1.0.0
    621      */
    622     private static function single_deactivate() {
    623         // @TODO: Define deactivation functionality here
    624     }
    625 
    626     /**
    627587     * Load the plugin text domain for translation.
    628588     *
     589     * @return boolean True if the language file was loaded, false otherwise
    629590     * @since    1.0.0
    630591     */
     
    652613        }
    653614
    654         load_plugin_textdomain( 'wpas', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
     615        $language = load_plugin_textdomain( 'wpas', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    655616
    656617        /**
     
    660621            $locale = $backup;
    661622        }
     623
     624        return $language;
    662625
    663626    }
     
    866829     *
    867830     * @since  3.0.0
    868      * @param  string  $name     Template name
    869      * @param  string  $template Path to the template that was loaded
    870      * @param  array   $args     Extra arguments passed when loading the template
     831     *
     832     * @param  string $name Template name
     833     *
    871834     * @return boolean           True if the modal is loaded, false otherwise
    872835     */
    873     public function terms_and_conditions_modal( $name, $template, $args ) {
     836    public function terms_and_conditions_modal( $name ) {
    874837
    875838        if ( 'registration' !== $name ) {
    876839            return false;
    877840        }
    878 
    879         global $post;
    880841
    881842        $terms = wpas_get_option( 'terms_conditions', '' );
     
    990951     * @return void
    991952     */
    992     public function credit( $name, $template, $args ) {
     953    public function credit() {
    993954        echo '<p class="wpas-credit">Built with Awesome Support,<br> the most versatile <a href="https://wordpress.org/plugins/awesome-support/" target="_blank" title="The best support plugin for WordPress">WordPress Support Plugin</a></p>';
    994955    }
  • awesome-support/trunk/includes/addons/custom-fields/class-custom-fields.php

    r1160923 r1163297  
    116116        $option = array( 'name' => $name, 'args' => $arguments );
    117117
    118         $this->options[$name] = $option;
     118        $this->options[$name] = apply_filters( 'wpas_add_field', $option );
    119119
    120120    }
  • awesome-support/trunk/includes/admin/class-admin.php

    r1160923 r1163297  
    213213
    214214        /* Make sure this is the main query */
    215         if ( !$query->is_main_query() ) {
     215        if ( ! $query->is_main_query() ) {
    216216            return false;
    217217        }
    218218
    219219        /* Make sure this is the admin screen */
    220         if ( !is_admin() ) {
     220        if ( ! is_admin() ) {
    221221            return false;
    222222        }
     
    228228
    229229        /* If admins can see all tickets do nothing */
    230         if ( current_user_can( 'administrator' ) && true === boolval( wpas_get_option( 'admin_see_all' ) ) ) {
     230        if ( current_user_can( 'administrator' ) && true === (bool) wpas_get_option( 'admin_see_all' ) ) {
    231231            return false;
    232232        }
    233233
    234234        /* If agents can see all tickets do nothing */
    235         if ( current_user_can( 'edit_ticket' ) && !current_user_can( 'administrator' ) && true === boolval( wpas_get_option( 'agent_see_all' ) ) ) {
     235        if ( current_user_can( 'edit_ticket' ) && ! current_user_can( 'administrator' ) && true === (bool) wpas_get_option( 'agent_see_all' ) ) {
    236236            return false;
    237237        }
     
    239239        global $current_user;
    240240
    241         $query->set( 'meta_query', array(
    242             array(
    243                 'key'     => '_wpas_assignee',
    244                 'value'   => $current_user->ID,
    245                 'compare' => '=',
    246             ) )
    247         );
     241        $query->set( 'meta_key', '_wpas_assignee' );
     242        $query->set( 'meta_value', (int) $current_user->ID );
    248243
    249244        return true;
  • awesome-support/trunk/includes/admin/settings/functions-settings.php

    r1114456 r1163297  
    3838
    3939/**
    40  * List users.
    41  *
    42  * Returns a list of users based on the required
    43  * capability. If the capability is "all", all site
    44  * users are returned.
    45  *
    46  * @param  string $cap Minimum capability the user must have to be added to the list
    47  * @return array       A list of users
    48  * @since  3.0.0
    49  */
    50 function wpas_list_users( $cap = 'all' ) {
    51 
    52     $list = array();
    53 
    54     /* List all users */
    55     $all_users = get_users();
    56 
    57     foreach( $all_users as $user ) {
    58 
    59         /* Exclude agents */
    60         if( 'all' == $cap || ( 'all' != $cap && $user->has_cap( $cap ) ) ) {
    61 
    62             $user_id        = $user->ID;
    63             $user_name      = $user->data->display_name;
    64             $list[$user_id] = $user_name;
    65 
    66         }
    67 
    68     }
    69 
    70     return apply_filters( 'wpas_users_list', $list );
    71 
    72 }
    73 
    74 /**
    7540 * Get themes list.
    7641 *
  • awesome-support/trunk/includes/class-notification.php

    r1160923 r1163297  
    231231 * predefined or customized by the user.
    232232 *
    233  * @param  string  $case    Type of notification
    234  * @param  string $message Message to display
    235  * @param  boolean $echo    Whether to echo or return the notification
     233 * @param  string         $case    Type of notification
     234 * @param  boolean|string $message Message to display
     235 * @param  boolean        $echo    Whether to echo or return the notification
    236236 *
    237237 * @return void|string           Notification (with markup)
     
    239239 * @since  3.0.0
    240240 */
    241 function wpas_notification( $case, $message, $echo = true ) {
     241function wpas_notification( $case, $message = '', $echo = true ) {
    242242
    243243    $notification = new WPAS_Notification( $case, $message );
  • awesome-support/trunk/includes/functions-post.php

    r1160923 r1163297  
    733733    }
    734734
    735     $users = get_users( array( 'orderby' => 'wpas_random' ) ); // We use a unique and non-existing orderby parameter so that we can identify the query in pre_user_query
     735    $users = get_transient( 'wpas_list_agents' );
     736
     737    if ( false === $users ) {
     738        $users = get_users( array( 'orderby' => 'wpas_random' ) ); // We use a unique and non-existing orderby parameter so that we can identify the query in pre_user_query
     739        set_transient( 'wpas_list_agents', $users, 24 * 60 * 60 );
     740    }
     741
    736742    $agent = array();
    737743
     
    776782
    777783            }
    778            
     784
    779785        }
    780786
     
    808814
    809815    if ( !user_can( $agent_id, 'edit_ticket' ) ) {
    810         return new WP_Error( 'incorrect_agent', __( 'The chosen agent does not have the sufficient capapbilities to be assigned a ticket', 'wpas' ) );
     816        return new WP_Error( 'incorrect_agent', __( 'The chosen agent does not have the sufficient capabilities to be assigned a ticket', 'wpas' ) );
    811817    }
    812818
  • awesome-support/trunk/includes/functions-user.php

    r1160923 r1163297  
    22/**
    33 * Register user account.
     4 *
     5 * @param array|bool $data User data
    46 *
    57 * @since  1.0.0
     
    1416
    1517    if ( true !== $registration ) {
    16         wp_redirect( add_query_arg( array( 'message' => wpas_create_notification( __( 'Registrations are currently not allowed.', 'wpas' ) ), get_permalink( $post->ID ) ) ) );
     18        wp_redirect( add_query_arg( array(
     19            'message' => wpas_create_notification( __( 'Registrations are currently not allowed.', 'wpas' ) ),
     20            get_permalink( $post->ID )
     21        ) ) );
    1722        exit;
    1823    }
     
    2227    }
    2328
    24     $email      = isset( $data['email'] ) && !empty( $data['email'] ) ? sanitize_email( $data['email'] ) : false;
    25     $first_name = isset( $data['first_name'] ) && !empty( $data['first_name'] ) ? sanitize_text_field( $data['first_name'] ) : false;
    26     $last_name  = isset( $data['last_name'] ) && !empty( $data['last_name'] ) ? sanitize_text_field( $data['last_name'] ) : false;
    27     $pwd        = isset( $data['pwd'] ) && !empty( $data['pwd'] ) ? $data['pwd'] : false;
     29    $email      = isset( $data['email'] ) && ! empty( $data['email'] ) ? sanitize_email( $data['email'] ) : false;
     30    $first_name = isset( $data['first_name'] ) && ! empty( $data['first_name'] ) ? sanitize_text_field( $data['first_name'] ) : false;
     31    $last_name  = isset( $data['last_name'] ) && ! empty( $data['last_name'] ) ? sanitize_text_field( $data['last_name'] ) : false;
     32    $pwd        = isset( $data['pwd'] ) && ! empty( $data['pwd'] ) ? $data['pwd'] : false;
    2833
    2934    /* Save the user information in session to pre populate the form in case of error. */
     
    4449    do_action( 'wpas_pre_register_account', $data );
    4550
    46     if ( wpas_get_option( 'terms_conditions', false ) && !isset( $data['terms'] ) ) {
    47         wp_redirect( add_query_arg( array( 'message' => wpas_create_notification( __( 'You did not accept the terms and conditions.', 'wpas' ) ), get_permalink( $post->ID ) ) ) );
     51    if ( wpas_get_option( 'terms_conditions', false ) && ! isset( $data['terms'] ) ) {
     52        wp_redirect( add_query_arg( array(
     53            'message' => wpas_create_notification( __( 'You did not accept the terms and conditions.', 'wpas' ) ),
     54            get_permalink( $post->ID )
     55        ) ) );
    4856        exit;
    4957    }
     
    5159    /* Make sure we have all the necessary data. */
    5260    if ( false === ( $email || $first_name || $last_name || $pwd ) ) {
    53         wp_redirect( add_query_arg( array( 'message' => wpas_create_notification( __( 'You didn\'t correctly fill all the fields.', 'wpas' ) ), get_permalink( $post->ID ) ) ) );
     61        wp_redirect( add_query_arg( array(
     62            'message' => wpas_create_notification( __( 'You didn\'t correctly fill all the fields.', 'wpas' ) ),
     63            get_permalink( $post->ID )
     64        ) ) );
    5465        exit;
    5566    }
     
    6374        do {
    6475            $alt_username = sanitize_user( $username . $suffix );
    65             $user = get_user_by( 'login', $alt_username );
    66             $suffix++;
    67         } while( is_a( $user, 'WP_User' ) );
     76            $user         = get_user_by( 'login', $alt_username );
     77            $suffix ++;
     78        } while ( is_a( $user, 'WP_User' ) );
    6879        $username = $alt_username;
    6980    }
     
    106117
    107118        $error = $user_id->get_error_message();
    108         wp_redirect( add_query_arg( array( 'message' => wpas_create_notification( $error ), get_permalink( $post->ID ) ) ) );
     119        wp_redirect( add_query_arg( array(
     120            'message' => wpas_create_notification( $error ),
     121            get_permalink( $post->ID )
     122        ) ) );
    109123        exit;
    110124
     
    126140
    127141        if ( headers_sent() ) {
    128             wp_redirect( add_query_arg( array( 'message' => wpas_create_notification( __( 'Your account has been created. Please log-in.', 'wpas' ) ), get_permalink( $post->ID ) ) ) );
     142            wp_redirect( add_query_arg( array(
     143                'message' => wpas_create_notification( __( 'Your account has been created. Please log-in.', 'wpas' ) ),
     144                get_permalink( $post->ID )
     145            ) ) );
    129146            exit;
    130147        }
    131148
    132         if ( !is_user_logged_in() ) {
     149        if ( ! is_user_logged_in() ) {
    133150
    134151            /* Automatically log the user in */
    135152            wp_set_current_user( $user_id, $email );
    136153            wp_set_auth_cookie( $user_id );
    137            
     154
    138155            wp_redirect( get_permalink( $post->ID ) );
    139156            exit;
     
    153170 *
    154171 * @since  3.0.0
     172 *
    155173 * @param  string $field Name of the field to get the value for
     174 *
    156175 * @return string        The sanitized field value if any, an empty string otherwise
    157176 */
    158177function wpas_get_registration_field_value( $field ) {
    159178
    160     if ( isset( $_SESSION) && isset( $_SESSION['wpas_registration_form'][$field] ) ) {
    161         return sanitize_text_field( $_SESSION['wpas_registration_form'][$field] );
     179    if ( isset( $_SESSION ) && isset( $_SESSION['wpas_registration_form'][ $field ] ) ) {
     180        return sanitize_text_field( $_SESSION['wpas_registration_form'][ $field ] );
    162181    } else {
    163182        return '';
     
    181200    if ( isset( $_POST['log'] ) ) {
    182201
    183         $login = $_POST['log'];
    184         $pwd   = isset( $_POST['pwd'] ) ? $_POST['pwd'] : '';
    185202        $login = wp_signon();
    186203
     
    189206            wp_redirect( add_query_arg( array( 'message' => urlencode( base64_encode( json_encode( $error ) ) ) ), get_permalink( $post->ID ) ) );
    190207            exit;
    191         } elseif( is_a( $login, 'WP_User' ) ) {
     208        } elseif ( is_a( $login, 'WP_User' ) ) {
    192209            wp_redirect( get_permalink( $post->ID ) );
    193210            exit;
     
    205222 *
    206223 * @since  2.0.0
     224 *
    207225 * @param  integer $post_id ID of the post to display
     226 *
    208227 * @return boolean
    209228 */
     
    211230
    212231    /* Only logged in users can view */
    213     if ( !is_user_logged_in() ) {
     232    if ( ! is_user_logged_in() ) {
    214233        return false;
    215234    }
    216235
    217     if ( !current_user_can( 'view_ticket' ) ) {
     236    if ( ! current_user_can( 'view_ticket' ) ) {
    218237        return false;
    219238    }
     
    238257 *
    239258 * @since  2.0.0
     259 *
    240260 * @param  boolean $admins_allowed Shall admins/agents be allowed to reply from the frontend
    241261 * @param  integer $post_id        ID of the ticket to check
     262 *
    242263 * @return boolean                 True if the user can reply
    243264 */
     
    249270    }
    250271
    251     $admins_allowed = apply_filters( 'wpas_can_agent_reply_frontend', false ); /* Allow admins to post through front-end. The filter overwrites the function parameter. */
     272    $admins_allowed = apply_filters( 'wpas_can_agent_reply_frontend', $admins_allowed ); /* Allow admins to post through front-end. The filter overwrites the function parameter. */
    252273    $post           = get_post( $post_id );
    253274    $author_id      = $post->post_author;
    254     $reply          = wpas_get_option( 'ticket_can_reply', 'author' );
    255275
    256276    if ( is_user_logged_in() ) {
     
    258278        global $current_user;
    259279
    260         if ( !current_user_can( 'reply_ticket' ) ) {
     280        if ( ! current_user_can( 'reply_ticket' ) ) {
    261281            return false;
    262282        }
    263283
    264         $usr_mail = $current_user->data->user_email;
    265         $user_id  = $current_user->data->ID;
     284        $user_id = $current_user->data->ID;
    266285
    267286        /* If the current user is the author then yes */
    268         if( $user_id == $author_id ) {
     287        if ( $user_id == $author_id ) {
    269288            return true;
    270289        } else {
    271290
    272             if ( current_user_can( 'edit_ticket' ) && true === $admins_allowed  ) {
     291            if ( current_user_can( 'edit_ticket' ) && true === $admins_allowed ) {
    273292                return true;
    274293            } else {
     
    288307 *
    289308 * @since  3.0.0
     309 *
    290310 * @param  string $role User role
     311 *
    291312 * @return string       Nicely formatted user role
    292313 */
     
    301322    $role = str_replace( array( '-', '_' ), ' ', $role );
    302323
    303     /* Uppercase each first letter */
    304324    return ucwords( $role );
    305325
     
    311331
    312332    return apply_filters( 'wpas_can_submit_ticket', $can );
     333
     334}
     335
     336/**
     337 * Get a list of users that belong to the plugin.
     338 *
     339 * @param array $args Arguments used to filter the users
     340 *
     341 * @return array An array of users objects
     342 * @since 3.1.8
     343 */
     344function wpas_get_users( $args = array() ) {
     345
     346    $defaults = array(
     347        'exclude'     => array(),
     348        'cap'         => '',
     349        'cap_exclude' => '',
     350    );
     351
     352    /* The array where we save all users we want to keep. */
     353    $list = array();
     354
     355    /* Merge arguments. */
     356    $args = wp_parse_args( $args, $defaults );
     357
     358    /* Get the hash of the arguments that's used for caching the result. */
     359    $hash = md5( serialize( $args ) );
     360
     361    /* Check if we have a result already cached. */
     362    $result = get_transient( "wpas_list_users_$hash" );
     363
     364    /* If there is a cached result we return it and don't run the expensive query. */
     365    if ( false !== $result ) {
     366        return apply_filters( 'wpas_get_users', $result );
     367    }
     368
     369    /* Get all WordPress users */
     370    $all_users = get_users();
     371
     372    /* Loop through the users list and filter them */
     373    foreach ( $all_users as $user ) {
     374
     375        /* Check for required capability */
     376        if ( ! empty( $cap ) ) {
     377            if ( ! $user->has_cap( $args['cap'] ) ) {
     378                continue;
     379            }
     380        }
     381
     382        /* Check for excluded capability */
     383        if ( ! empty( $cap_exclude ) ) {
     384            if ( $user->has_cap( $args['cap_exclude'] ) ) {
     385                continue;
     386            }
     387        }
     388
     389        /* Maybe exclude this user from the list */
     390        if ( in_array( $user->ID, (array) $args['exclude'] ) ) {
     391            continue;
     392        }
     393
     394        /* Now we add this user to our final list. */
     395        array_push( $list, $user );
     396
     397    }
     398
     399    /* Let's cache the result so that we can avoid running this query too many times. */
     400    set_transient( "wpas_list_users_$hash", $list, apply_filters( 'wpas_list_users_cache_expiration', 60 * 60 * 24 ) );
     401
     402    return apply_filters( 'wpas_get_users', $list );
     403
     404}
     405
     406/**
     407 * List users.
     408 *
     409 * Returns a list of users based on the required
     410 * capability. If the capability is "all", all site
     411 * users are returned.
     412 *
     413 * @param  string $cap Minimum capability the user must have to be added to the list
     414 *
     415 * @return array       A list of users
     416 * @since  3.0.0
     417 */
     418function wpas_list_users( $cap = 'all' ) {
     419
     420    $list = array();
     421
     422    /* List all users */
     423    $all_users = wpas_get_users( array( 'cap' => $cap ) );
     424
     425    foreach ( $all_users as $user ) {
     426        $user_id          = $user->ID;
     427        $user_name        = $user->data->display_name;
     428        $list[ $user_id ] = $user_name;
     429    }
     430
     431    return apply_filters( 'wpas_users_list', $list );
    313432
    314433}
     
    339458    );
    340459
    341     extract( wp_parse_args( $args, $defaults ) );
     460    $args = wp_parse_args( $args, $defaults );
    342461
    343462    /* List all users */
    344     $all_users = get_users();
     463    $all_users = wpas_get_users( array( 'cap' => $args['cap'], 'cap_exclude' => $args['cap_exclude'], 'exclude' => $args['exclude'] ) );
    345464
    346465    /**
     
    352471    $marker = false;
    353472
    354     $options      = '';
    355     $current_id   = $current_user->ID;
    356     $current_name = $current_user->data->user_nicename;
    357     $current_sel  = ( $current_id == $post->post_author ) ? "selected='selected'" : '';
     473    $options = '';
    358474
    359475    /* The ticket is being created, use the current user by default */
    360     if ( !empty( $selected ) ) {
    361         $user = get_user_by( 'id', intval( $selected ) );
     476    if ( ! empty( $args['selected'] ) ) {
     477        $user = get_user_by( 'id', intval( $args['selected'] ) );
    362478        if ( false !== $user && ! is_wp_error( $user ) ) {
    363             $marker  = true;
     479            $marker = true;
    364480            $options .= "<option value='{$user->ID}' selected='selected'>{$user->data->display_name}</option>";
    365481        }
     
    368484    foreach ( $all_users as $user ) {
    369485
    370         /* Check for required capability */
    371         if ( !empty( $cap ) ) {
    372             if ( ! $user->has_cap( $cap ) ) {
    373                 continue;
    374             }
    375         }
    376 
    377         /* Check for excluded capability */
    378         if ( !empty( $cap_exclude ) ) {
    379             if ( $user->has_cap( $cap_exclude ) ) {
    380                 continue;
    381             }
    382         }
    383 
    384         /* Maybe exclude this user from the list */
    385         if ( in_array( $user->ID, (array) $exclude ) ) {
    386             continue;
    387         }
    388 
    389486        /* This user was already added, skip it */
    390         if ( ! empty( $selected ) && $user->ID === intval( $selected ) ) {
     487        if ( ! empty( $args['selected'] ) && $user->ID === intval( $args['selected'] ) ) {
    391488            continue;
    392489        }
     
    397494
    398495        if ( false === $marker ) {
    399             if ( false !== $selected ) {
    400                 if ( !empty( $selected ) ) {
    401                     if ( $selected === $user_id ) {
     496            if ( false !== $args['selected'] ) {
     497                if ( ! empty( $args['selected'] ) ) {
     498                    if ( $args['selected'] === $user_id ) {
    402499                        $selected_attr = 'selected="selected"';
    403500                    }
     
    411508
    412509        /* Set the marker as true to avoid selecting more than one user */
    413         if ( !empty( $selected_attr ) ) {
     510        if ( ! empty( $selected_attr ) ) {
    414511            $marker = true;
    415512        }
     
    421518
    422519    /* In case there is no selected user yet we add the post author, or the currently logged user (most likely an admin) */
    423     if ( true === $agent_fallback && false === $marker ) {
     520    if ( true === $args['agent_fallback'] && false === $marker ) {
    424521        $fallback    = $current_user;
    425522        $fb_selected = false === $marker ? 'selected="selected"' : '';
    426         $options     .= "<option value='{$fallback->ID}' $fb_selected>{$fallback->data->display_name}</option>";
    427     }
    428 
    429     $contents = wpas_dropdown( wp_parse_args( $args, $defaults ), $options ); 
     523        $options .= "<option value='{$fallback->ID}' $fb_selected>{$fallback->data->display_name}</option>";
     524    }
     525
     526    $contents = wpas_dropdown( wp_parse_args( $args, $defaults ), $options );
    430527
    431528    return $contents;
  • awesome-support/trunk/readme.txt

    r1160923 r1163297  
    66Requires at least: 3.5.1
    77Tested up to: 4.3
    8 Stable tag: 3.1.7
     8Stable tag: 3.1.8
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414== Description ==
    1515
     16Awesome Support is the most advanced support plugin for WordPress. It is the result of two years of work, research, and improvement. Most of its features are an answer to user requests for a helpdesk and that's what makes it the best support plugin for WordPress.
     17
    1618https://www.youtube.com/watch?v=IdSOWQI3tWU
    17 
    18 Awesome Support is the most advanced support plugin for WordPress. It is the result of two years of work, research, and improvement. Most of its features are an answer to user requests for a helpdesk and that's what makes it the best support plugin for WordPress.
    1919
    2020For support please visit the [official site](http://getawesomesupport.com).
     
    153153== Changelog ==
    154154
     155= 3.1.8 - 2015-05-19 =
     156
     157* Features
     158    * Ticket submission on front-end is now about 50% faster
     159    * Significant performance improvement in the back-end
     160
     161* Bugfixes:
     162    * Fix the PHP warning on ticket submission
     163    * Hide others tickets in admin if set this way in the settings
     164    * Fix issue with translations not working on some sites
     165
    155166= 3.1.7 - 2015-05-15 =
    156167
     
    164175    * Persian translation
    165176    * Romanian translation
    166    
     177
    167178* Bugfixes:
    168179    * Critical XSS vulnerability with custom information messages - props Anton Kulpinov
  • awesome-support/trunk/vendor/composer/ClassLoader.php

    r1114456 r1163297  
    352352                if (0 === strpos($class, $prefix)) {
    353353                    foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
    354                         if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
     354                        if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
    355355                            return $file;
    356356                        }
     
    362362        // PSR-4 fallback dirs
    363363        foreach ($this->fallbackDirsPsr4 as $dir) {
    364             if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
     364            if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
    365365                return $file;
    366366            }
     
    381381                if (0 === strpos($class, $prefix)) {
    382382                    foreach ($dirs as $dir) {
    383                         if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
     383                        if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
    384384                            return $file;
    385385                        }
     
    391391        // PSR-0 fallback dirs
    392392        foreach ($this->fallbackDirsPsr0 as $dir) {
    393             if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
     393            if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
    394394                return $file;
    395395            }
Note: See TracChangeset for help on using the changeset viewer.