PluginProbe
Awesome Support – WordPress HelpDesk & Support Plugin / trunk
Awesome Support – WordPress HelpDesk & Support Plugin vtrunk
6.4.0 trunk 3.0.0 3.0.1 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 All 95 releases
awesome-support / includes / admin / functions-menu.php

functions-menu.php in Awesome Support – WordPress HelpDesk & Support Plugin trunk, at includes/admin/functions-menu.php

186 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Awesome Support/Admin/Functions/Menu
4 * @author AwesomeSupport <contact@getawesomesupport.com>
5 * @license GPL-2.0+
6 * @link https://getawesomesupport.com
7 * @copyright 2015-2017 AwesomeSupport
8 */
9
10 // If this file is called directly, abort.
11 if ( ! defined( 'WPINC' ) ) {
12 die;
13 }
14
15 add_action( 'admin_menu', 'wpas_register_submenu_items' );
16 /**
17 * Register all submenu items.
18 *
19 * @since 3.0.0
20 * @return void
21 */
22 function wpas_register_submenu_items() {
23
24 add_submenu_page( 'edit.php?post_type=ticket', __( 'Debugging Tools', 'awesome-support' ), __( 'Tools', 'awesome-support' ), 'administrator', 'wpas-status', 'wpas_display_status_page' );
25
26 add_submenu_page( 'edit.php?post_type=ticket', __( 'Awesome Support Addons', 'awesome-support' ), '<span style="color:#f39c12;">' . __( 'Addons', 'awesome-support' ) . '</span>', 'edit_posts', 'wpas-addons', 'wpas_display_addons_page' );
27
28 if ( ! defined( 'WPAS_SAAS' ) || ( defined( 'WPAS_SAAS' ) && false === WPAS_SAAS ) ) {
29
30 add_submenu_page( 'edit.php?post_type=ticket', __( 'Get a Free Addon', 'awesome-support' ), '<span style="color:#f39c12;">' . esc_html__( 'Get a Free Addon!', 'awesome-support' ) . '</span>', 'administrator', 'wpas-optin', 'wpas_display_optin_page' );
31
32 add_submenu_page( 'edit.php?post_type=ticket', __( 'Help & Support', 'awesome-support' ), '<span style="color:#4CBBA7;">' . esc_html__( 'Help & Support', 'awesome-support' ) . '</span>', 'administrator', 'wpas-help-and-support', 'wpas_display_help_and_support_page' );
33
34 // Premium-only Get Help button (visible when at least one addon is active)
35 if ( ! empty( WPAS()->addons ) ) {
36 add_submenu_page( 'edit.php?post_type=ticket', __( 'Get Help', 'awesome-support' ), '<span style="display:inline-block; background:#4CBBA7; font-weight:600; border-radius:3px; padding:2px 8px; color:#fff;">' . esc_html__( 'Get Help', 'awesome-support' ) . '</span>', 'edit_posts', 'wpas-get-help', 'wpas_display_get_help_page' );
37 }
38
39 /**
40 * Provides a hook for Addons to add their menu item in the right location, i.e. above the "About" page.
41 *
42 * @since 4.3.3
43 *
44 * @param string Passes the Awesome Support parent slug to the addon.
45 */
46 do_action( 'wpas_addon_submenu_page', 'edit.php?post_type=ticket' );
47
48 add_submenu_page( 'edit.php?post_type=ticket', __( 'About Awesome Support', 'awesome-support' ), __( 'About', 'awesome-support' ), 'edit_posts', 'wpas-about', 'wpas_display_about_page' );
49
50 }
51
52 // Hide the free addon page if the user already claimed it
53 if ( true === wpas_is_free_addon_page_dismissed() ) {
54 remove_submenu_page( 'edit.php?post_type=ticket', 'wpas-optin' );
55 }
56 }
57
58 add_action( 'admin_menu', 'wpas_tickets_count' );
59 /**
60 * Add ticket count in admin menu item.
61 *
62 * @return boolean True if the ticket count was added, false otherwise
63 * @since 1.0.0
64 */
65 function wpas_tickets_count() {
66
67 if ( false === (bool) wpas_get_option( 'show_count' ) ) {
68 return false;
69 }
70
71 global $menu, $current_user;
72
73 $count_cache = get_site_transient( 'wpas_tickets_counts' );
74
75 if( !is_array($count_cache) )
76 {
77 $count_cache = array();
78 }
79 if ( wpas_is_asadmin() && false === boolval( wpas_get_option( 'admin_see_all' ) )
80 || ! wpas_is_asadmin() && wpas_is_agent() && false === boolval( wpas_get_option( 'agent_see_all' ) )
81 ) {
82 // Display tickets was assign to current user
83 if( is_array( $count_cache ) && isset( $count_cache[ $current_user->ID ] ) )
84 {
85 $count = $count_cache[ $current_user->ID ];
86 }
87 else
88 {
89 $agent = new WPAS_Member_Agent( $current_user->ID );
90 $count = $agent->open_tickets();
91 $count_cache[$current_user->ID] = $count;
92 set_site_transient( 'wpas_tickets_counts', $count_cache, DAY_IN_SECONDS );
93 }
94
95 } else {
96
97 // Display all Opened tickets
98 if( is_array( $count_cache ) && isset( $count_cache['all'] ) )
99 {
100 $count = $count_cache['all'];
101 }
102 else
103 {
104 $count = wpas_get_tickets( 'open', [], 'any', true, true );
105 $count_cache['all'] = $count;
106 set_site_transient( 'wpas_tickets_counts', $count_cache, DAY_IN_SECONDS );
107 }
108 }
109
110 if ( 0 === $count ) {
111 return false;
112 }
113
114 foreach ( $menu as $key => $value ) {
115 if ( $menu[ $key ][2] == 'edit.php?post_type=ticket' ) {
116 $menu[ $key ][0] .= ' <span class="awaiting-mod count-' . $count . '"><span class="pending-count">' . $count . '</span></span>';
117 }
118 }
119
120 return true;
121 }
122
123 /**
124 * Render the about page for this plugin.
125 *
126 * @since 3.0.0
127 */
128 function wpas_display_about_page() {
129 include_once( WPAS_PATH . 'includes/admin/views/about.php' );
130 }
131
132 /**
133 * Render the addons page for this plugin.
134 *
135 * @since 3.0.0
136 */
137 function wpas_display_addons_page() {
138 include_once( WPAS_PATH . 'includes/admin/views/addons.php' );
139 }
140
141 /**
142 * Render the free addon page
143 *
144 * @since 3.3.3
145 */
146 function wpas_display_optin_page() {
147 include_once( WPAS_PATH . 'includes/admin/views/opt-in.php' );
148 }
149
150 /**
151 * Render the help & support options page
152 *
153 * @since 5.2.0
154 */
155 function wpas_display_help_and_support_page() {
156 include_once( WPAS_PATH . 'includes/admin/views/wpas-help-and-support.php' );
157 }
158
159 /**
160 * Render the system status.
161 *
162 * @since 3.0.0
163 */
164 function wpas_display_status_page() {
165 include_once( WPAS_PATH . 'includes/admin/views/status.php' );
166 }
167
168 /**
169 * Redirect to the Get Help page.
170 *
171 * @since 3.0.0
172 */
173 function wpas_display_get_help_page() {
174 $link = 'https://getawesomesupport.com/submit-ticket/';
175 if ( ! headers_sent() ) {
176 wp_redirect( $link );
177 exit;
178 } else {
179 include_once( WPAS_PATH . 'includes/admin/views/wpas-help-and-support.php' );
180 echo '<script type="text/javascript">';
181 echo 'window.location.href="'.$link.'";';
182 echo '</script>';
183 echo '<noscript><meta http-equiv="refresh" content="0;url='.$link.'" /></noscript>';
184 exit;
185 }
186 }