Plugin Directory

Changeset 1049994


Ignore:
Timestamp:
12/20/2014 04:06:57 AM (11 years ago)
Author:
themeavenue
Message:

Update to 3.0.1

Location:
awesome-support/trunk
Files:
10 edited

Legend:

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

    r1048776 r1049994  
    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.0.0
     13 * Version:           3.0.1
    1414 * Author:            ThemeAvenue
    1515 * Author URI:        http://themeavenue.net
     
    2929 *----------------------------------------------------------------------------*/
    3030
    31 define( 'WPAS_VERSION',           '3.0.0' );
     31define( 'WPAS_VERSION',           '3.0.1' );
    3232define( 'WPAS_DB_VERSION',        '1' );
    3333define( 'WPAS_URL',               trailingslashit( plugin_dir_url( __FILE__ ) ) );
  • awesome-support/trunk/class-awesome-support.php

    r1048776 r1049994  
    3030     */
    3131    private function __construct() {
    32 
    33         /**
    34          * Ticket post type slug.
    35          *
    36          * @since 1.0.0
    37          * @var   string
    38          */
    39         $this->slug = 'ticket';
    4032
    4133        add_action( 'plugins_loaded',                 array( 'WPAS_Ticket_Post_Type', 'get_instance' ), 11 );
     
    10799         */
    108100        if ( isset( $_POST['wpas_registration'] ) ) {
    109             add_action( 'wp', 'wpas_register_account' );
     101            add_action( 'wp', 'wpas_register_account', 10, 0 );
    110102        }
    111103
  • awesome-support/trunk/includes/addons/custom-fields/class-display.php

    r1048776 r1049994  
    9191        global $post;
    9292
    93         $field_id = 'wpas_' . $field['name'];
    94         $label    = wpas_get_field_title( $field );
    95         $current  = get_the_terms( $post->ID, sanitize_text_field( $field['name'] ) );
    96         $terms    = get_terms( sanitize_text_field( $field['name'] ), array( 'hide_empty' => 0 ) );
    97         $value    = '';
     93        $field_id      = 'wpas_' . $field['name'];
     94        $label         = wpas_get_field_title( $field );
     95        $current       = get_the_terms( $post->ID, sanitize_text_field( $field['name'] ) );
     96        $terms         = get_terms( sanitize_text_field( $field['name'] ), array( 'hide_empty' => 0 ) );
     97        $value         = '';
     98        $ordered_terms = array();
    9899
    99100        if ( is_array( $current ) ) {
     
    109110            return;
    110111        }
     112
     113        /**
     114         * Re-order the terms hierarchically.
     115         */
     116        wpas_sort_terms_hierarchicaly( $terms, $ordered_terms );
    111117        ?>
    112118
     
    120126
    121127                    <?php
    122                     foreach( $terms as $term ) { ?>
    123                         <option value="<?php echo $term->slug; ?>" <?php if( $term->slug == $value ) { echo 'selected="selected"'; } ?>><?php echo $term->name; ?></option>
    124                     <?php } ?>
     128                    foreach ( $ordered_terms as $term ) {
     129                        wpas_hierarchical_taxonomy_dropdown_options( $term, $value );
     130                    } ?>
    125131
    126132                </select>
     
    189195
    190196}
     197
     198/**
     199 * Recursively sort an array of taxonomy terms hierarchically. Child categories will be
     200 * placed under a 'children' member of their parent term.
     201 *
     202 * @since  3.0.1
     203 * @param Array   $cats     taxonomy term objects to sort
     204 * @param Array   $into     result array to put them in
     205 * @param integer $parentId the current parent ID to put them in
     206 * @link  http://wordpress.stackexchange.com/a/99516/16176
     207 */
     208function wpas_sort_terms_hierarchicaly( Array &$cats, Array &$into, $parentId = 0 ) {
     209
     210    foreach ($cats as $i => $cat) {
     211        if ($cat->parent == $parentId) {
     212            $into[$cat->term_id] = $cat;
     213            unset($cats[$i]);
     214        }
     215    }
     216
     217    foreach ($into as $topCat) {
     218        $topCat->children = array();
     219        wpas_sort_terms_hierarchicaly( $cats, $topCat->children, $topCat->term_id );
     220    }
     221}
     222
     223/**
     224 * Recursively displays hierarchical options into a select dropdown.
     225 *
     226 * @since  3.0.1
     227 * @param  object $term  The term to display
     228 * @param  string $value The value to compare against
     229 * @return void
     230 */
     231function wpas_hierarchical_taxonomy_dropdown_options( $term, $value, $level = 1 ) {
     232
     233    $option = '';
     234
     235    /* Add a visual indication that this is a child term */
     236    if ( 1 !== $level ) {
     237        for ( $i = 1; $i < ( $level - 1 ); $i++ ) {
     238            $option .= '&nbsp;&nbsp;&nbsp;&nbsp;';
     239        }
     240        $option .= '&angrt; ';
     241    }
     242
     243    $option .= $term->name;
     244    ?>
     245
     246    <option value="<?php echo $term->slug; ?>" <?php if( $term->slug == $value ) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option>
     247
     248    <?php if ( isset( $term->children ) && !empty( $term->children ) ) {
     249        ++$level;
     250        foreach ( $term->children as $child ) {
     251            wpas_hierarchical_taxonomy_dropdown_options( $child, $value, $level );
     252        }
     253    }
     254
     255}
  • awesome-support/trunk/includes/admin/class-admin.php

    r1048776 r1049994  
    6464            require_once( WPAS_PATH . 'includes/admin/class-admin-titan.php' );
    6565            require_once( WPAS_PATH . 'includes/admin/class-admin-help.php' );
    66             require_once( WPAS_PATH . 'includes/class-remote-notification-client.php' );
     66           
     67            if ( !class_exists( 'TAV_Remote_Notification_Client' ) ) {
     68                require_once( WPAS_PATH . 'includes/class-remote-notification-client.php' );
     69            }
    6770
    6871            /* Load settings files */
  • awesome-support/trunk/includes/class-notification.php

    r1048776 r1049994  
    117117        if ( is_null( $this->message ) || false === $this->case ) {
    118118            return false;
    119         }
    120 
    121         return $this->template();
     119        }
     120
     121        ob_start();
     122        $this->template();
     123        $notification = ob_get_clean();
     124       
     125        return $notification;
    122126
    123127    }
     
    239243
    240244    if( true === $echo ) {
    241         echo $notification->notify( $case, $message );
     245        echo $notification->notify();
    242246    }
    243247
    244248    else {
    245         return $notification->notify( $case, $message );
     249        return $notification->notify();
    246250    }
    247251
  • awesome-support/trunk/includes/functions-general.php

    r1048776 r1049994  
    1313
    1414    /* Return option value if exists */
    15     if ( isset( $options[$option] ) ) {
    16         return apply_filters( 'wpas_option_' . $option, $options[$option] );
    17     }
    18 
    19     /* Otherwise return $default value */
    20     else {
    21         return $default;
    22     }
     15    $value = isset( $options[$option] ) ? $options[$option] : $default;
     16
     17    return apply_filters( 'wpas_option_' . $option, $value );
    2318
    2419}
  • awesome-support/trunk/includes/functions-post.php

    r1048776 r1049994  
    9494
    9595        /* Redirect to submit page */
    96         wp_redirect( add_query_arg( array( 'message' => urlencode( base64_encode( json_encode( $messages ) ) ) ), get_permalink( $submit ) ) );
     96        wp_redirect( add_query_arg( array( 'message' => wpas_create_notification( $messages ), get_permalink( $submit ) ) ) );
    9797
    9898        exit;
  • awesome-support/trunk/includes/functions-user.php

    r1048776 r1049994  
    66 * @return void
    77 */
    8 function wpas_register_account() {
     8function wpas_register_account( $data = false ) {
    99
    1010    global $post;
     
    1818    }
    1919
    20     $email      = isset( $_POST['email'] ) && !empty( $_POST['email'] ) ? sanitize_email( $_POST['email'] ) : false;
    21     $first_name = isset( $_POST['first_name'] ) && !empty( $_POST['first_name'] ) ? sanitize_text_field( $_POST['first_name'] ) : false;
    22     $last_name  = isset( $_POST['last_name'] ) && !empty( $_POST['last_name'] ) ? sanitize_text_field( $_POST['last_name'] ) : false;
    23     $pwd        = isset( $_POST['pwd'] ) && !empty( $_POST['pwd'] ) ? $_POST['pwd'] : false;
    24     $pwd2       = isset( $_POST['pwd-validate'] ) && !empty( $_POST['pwd-validate'] ) ? $_POST['pwd-validate'] : false;
     20    if ( false === $data ) {
     21        $data = $_POST;
     22    }
     23
     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;
     28    $pwd2       = isset( $data['pwd-validate'] ) && !empty( $data['pwd-validate'] ) ? $data['pwd-validate'] : false;
    2529
    2630    /* Save the user information in session to pre populate the form in case of error. */
     
    3135    );
    3236
    33     if ( wpas_get_option( 'terms_conditions', false ) && !isset( $_POST['terms'] ) ) {
     37    /**
     38     * wpas_pre_register_account hook
     39     *
     40     * This hook is triggered all the time
     41     * even if the checks don't pass.
     42     *
     43     * @since  3.0.1
     44     */
     45    do_action( 'wpas_pre_register_account', $data );
     46
     47    if ( wpas_get_option( 'terms_conditions', false ) && !isset( $data['terms'] ) ) {
    3448        wp_redirect( add_query_arg( array( 'message' => wpas_create_notification( __( 'You did not accept the terms and conditions.', 'wpas' ) ), get_permalink( $post->ID ) ) ) );
    3549        exit;
     
    7286    );
    7387
     88    /**
     89     * wpas_register_account_before hook
     90     *
     91     * Fired right before the user is added to the database.
     92     */
     93    do_action( 'wpas_register_account_before', $args );
     94
    7495    $user_id = wp_insert_user( apply_filters( 'wpas_user_registration_data', $args ) );
    7596
    7697    if ( is_wp_error( $user_id ) ) {
     98
     99        /**
     100         * wpas_register_account_before hook
     101         *
     102         * Fired right after a failed attempt to register a user.
     103         *
     104         * @since  3.0.1
     105         */
     106        do_action( 'wpas_register_account_failed', $user_id, $args );
    77107
    78108        $error = $user_id->get_error_message();
     
    81111
    82112    } else {
     113
     114        /**
     115         * wpas_register_account_before hook
     116         *
     117         * Fired right after the user is successfully added to the database.
     118         *
     119         * @since  3.0.1
     120         */
     121        do_action( 'wpas_register_account_after', $user_id, $args );
    83122
    84123        /* Delete the user information data from session. */
  • awesome-support/trunk/includes/shortcodes/shortcode-submit.php

    r1048776 r1049994  
    2424         */
    2525        do_action( 'wpas_frontend_plugin_page_top', $post->ID, $post );
    26 
    27         if ( isset( $_GET['message'] ) ) {
    28             wpas_notification( 'decode', $_GET['message'] );
    29         }
    3026
    3127        /* If user is not logged in we display the register form */
  • awesome-support/trunk/includes/shortcodes/shortcode-tickets.php

    r1048776 r1049994  
    66function wpas_sc_client_account() {
    77
    8     global $wpas_tickets, $current_user;
     8    global $wpas_tickets, $current_user, $post;
    99
    1010    /**
Note: See TracChangeset for help on using the changeset viewer.