logout(); echo ""; } // ticket URL authentication. $advanced = get_option( 'wpsc-ms-advanced-settings' ); if ( ! $advanced['ticket-url-auth'] ) { $ticket_id = isset( $_REQUEST['ticket-id'] ) ? intval( $_REQUEST['ticket-id'] ) : 0; // phpcs:ignore if ( ! $ticket_id ) { $ticket_id = isset( $_REQUEST['ticket_id'] ) ? intval( $_REQUEST['ticket_id'] ) : 0; // phpcs:ignore } $auth_code = isset( $_REQUEST['auth-code'] ) ? sanitize_text_field( $_REQUEST['auth-code'] ) : ''; // phpcs:ignore if ( ! $auth_code ) { $auth_code = isset( $_REQUEST['auth_code'] ) ? sanitize_text_field( $_REQUEST['auth_code'] ) : ''; // phpcs:ignore } if ( $ticket_id && $auth_code ) { $ticket = new WPSC_Ticket( $ticket_id ); self::$url_auth = $ticket->auth_code == $auth_code ? true : false; } } ob_start();?> user->ID ) { // agent. if ( $current_user->is_agent && in_array( $current_user->agent->role, $gs['allow-create-ticket'] ) ) { $allow_create_ticket = true; } // registered user. if ( ! $current_user->is_agent && in_array( 'registered-user', $gs['allow-create-ticket'] ) ) { $allow_create_ticket = true; } } elseif ( in_array( 'guest', $gs['allow-create-ticket'] ) ) { // guest. $allow_create_ticket = true; } self::$allow_create_ticket = $allow_create_ticket; // return if guest user. if ( ! ( ! $current_user->is_guest || $current_user->is_customer ) ) { return; } // get default tab. $tab = 'ticket-list'; if ( $current_user->is_agent ) { $tab = $current_user->agent->get_default_tab(); } $section = array(); // Supportcandy dashboard. if ( $current_user->is_agent && $current_user->agent->has_cap( 'dash-access' ) ) { $sections['dashboard'] = array( 'slug' => 'dashboard', 'icon' => 'dashboard', 'label' => esc_attr__( 'Dashboard', 'supportcandy' ), 'callback' => 'wpsc_get_agent_dashboard', ); } // ticket list. $sections['ticket-list'] = array( 'slug' => 'ticket_list', 'icon' => 'list-alt', 'label' => esc_attr__( 'Ticket List', 'supportcandy' ), 'callback' => 'wpsc_get_ticket_list', ); // new ticket. if ( $allow_create_ticket ) { $sections['new-ticket'] = array( 'slug' => 'new_ticket', 'icon' => 'plus-square', 'label' => esc_attr__( 'New Ticket', 'supportcandy' ), 'callback' => 'wpsc_get_ticket_form', ); } // my profile. if ( $ms['allow-my-profile'] ) { $sections['my-profile'] = array( 'slug' => 'my_profile', 'icon' => 'id-card', 'label' => esc_attr__( 'My Profile', 'supportcandy' ), 'callback' => 'wpsc_get_user_profile', ); } // agent profile. if ( $current_user->is_agent && $ms['allow-agent-profile'] ) { $sections['agent-profile'] = array( 'slug' => 'agent_profile', 'icon' => 'headset', 'label' => esc_attr__( 'Agent Profile', 'supportcandy' ), 'callback' => 'wpsc_get_agent_profile', ); } self::$sections = apply_filters( 'wpsc_shortcode_sections', $sections ); self::$current_section = isset( $_REQUEST['wpsc-section'] ) ? sanitize_text_field( $_REQUEST['wpsc-section'] ) : $tab; // phpcs:ignore } /** * Add localizations to local JS * * @param array $localizations - localization list. * @return array */ public static function localizations( $localizations ) { // Humbargar Titles. $localizations['humbargar_titles'] = self::get_humbargar_titles(); // Current section. $localizations['current_section'] = self::$current_section; // Current ticket id. if ( self::$current_section === 'ticket-list' && isset( $_REQUEST['ticket-id'] ) ) { // phpcs:ignore $localizations['current_ticket_id'] = intval( $_REQUEST['ticket-id'] ); // phpcs:ignore } return $localizations; } /** * Print humbargar menu in footer * * @return void */ public static function humbargar_menu() { $current_user = WPSC_Current_User::$current_user; ?> ' . esc_attr( $section['label'] ) . ''; $titles[ $section['slug'] ] = ob_get_clean(); } return $titles; } /** * Load js functions for this shortcode * * @return void */ public static function load_js_functions() { ?> is_agent ? $agent_settings['ticket-reply-redirect'] : $customer_settings['ticket-reply-redirect']; $call_to_function = $redirect == 'ticket-list' ? 'wpsc_get_ticket_list();' : 'wpsc_get_individual_ticket(ticket_id)'; echo esc_attr( $call_to_function ) . PHP_EOL; } /** * JS after close ticket * * @return void */ public static function js_after_close_ticket() { echo 'wpsc_get_ticket_list();' . PHP_EOL; } } endif; WPSC_Shortcode_One::init();