| 1 |
<?php |
| 2 |
/** |
| 3 |
* Contextual Help. |
| 4 |
* |
| 5 |
* @package Admin/Help |
| 6 |
* @author Julien Liabeuf <julien@liabeuf.fr> |
| 7 |
* @license GPL-2.0+ |
| 8 |
* @link https://getawesomesupport.com |
| 9 |
* @copyright 2014-2017 AwesomeSupport |
| 10 |
*/ |
| 11 |
|
| 12 |
class WPAS_Help { |
| 13 |
|
| 14 |
/** |
| 15 |
* Instance of this class. |
| 16 |
* |
| 17 |
* @since 1.0.0 |
| 18 |
* @var object |
| 19 |
*/ |
| 20 |
protected static $instance = null; |
| 21 |
|
| 22 |
public function __construct() |
| 23 |
{ |
| 24 |
add_filter( 'admin_head', array( $this, 'settings_general_contextual_help' ), 10, 3 ); |
| 25 |
add_filter( 'admin_head', array( $this, 'settings_registration_help' ), 10, 3 ); |
| 26 |
add_filter( 'admin_head', array( $this, 'settings_products_management_help' ), 10, 3 ); |
| 27 |
add_filter( 'admin_head', array( $this, 'settings_notifications_contextual_help' ), 10, 3 ); |
| 28 |
add_filter( 'admin_head', array( $this, 'settings_advanced_contextual_help' ), 10, 3 ); |
| 29 |
|
| 30 |
add_filter( 'admin_head', array( $this, 'settings_moderated_registration_help' ), 10, 3 ); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Return an instance of this class. |
| 35 |
* |
| 36 |
* @since 3.0.0 |
| 37 |
* @return object A single instance of this class. |
| 38 |
*/ |
| 39 |
public static function get_instance() { |
| 40 |
|
| 41 |
// If the single instance hasn't been set, set it now. |
| 42 |
if ( null == self::$instance ) { |
| 43 |
self::$instance = new self; |
| 44 |
} |
| 45 |
|
| 46 |
return self::$instance; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* General settings contextual help. |
| 51 |
* |
| 52 |
* @since 1.0.0 |
| 53 |
* @return void |
| 54 |
*/ |
| 55 |
public function settings_general_contextual_help() { |
| 56 |
|
| 57 |
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; |
| 58 |
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; |
| 59 |
|
| 60 |
if( 'ticket' !== $post_type || 'general' !== $tab ) { |
| 61 |
return; |
| 62 |
} |
| 63 |
|
| 64 |
$screen = get_current_screen(); |
| 65 |
|
| 66 |
$screen->add_help_tab( array( |
| 67 |
'id' => 'default_assignee', |
| 68 |
'title' => __( 'Default Assignee', 'awesome-support' ), |
| 69 |
'content' => __( '<h2>Default Assignee</h2><p>Even though the plugin will try to assign new tickets to the less busy agents, we need to know who to assign to in case we can\'t find a perfect fit for the new tickets.</p>', 'awesome-support' ) |
| 70 |
) ); |
| 71 |
|
| 72 |
$screen->add_help_tab( array( |
| 73 |
'id' => 'assignee_use_select2', |
| 74 |
'title' => __( 'Use Select2', 'awesome-support' ), |
| 75 |
'content' => __( '<h2>Use SELECT2 For Staff Drop-downs</h2><p>A SELECT2 drop-down is used when you have a large list of items which would take a long time to render on the screen. Instead, the user gets to limit the list by searching and seeing the results show up in real-time. Most sites will not hav a large number of agents so this option is usually turned off.</p>', 'awesome-support' ) |
| 76 |
) ); |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Registration settings contextual help. |
| 82 |
* |
| 83 |
* @since 5.2.0 |
| 84 |
* @return void |
| 85 |
*/ |
| 86 |
public function settings_registration_help() { |
| 87 |
|
| 88 |
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; |
| 89 |
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; |
| 90 |
|
| 91 |
if( 'ticket' !== $post_type || 'registration' !== $tab ) { |
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
$screen = get_current_screen(); |
| 96 |
|
| 97 |
$screen->add_help_tab( array( |
| 98 |
'id' => 'allow_registrations', |
| 99 |
'title' => __( 'Allow Registrations', 'awesome-support' ), |
| 100 |
'content' => __( '<h2>Allow Registrations</h2><p>You WordPress site can be set to accept new registrations or not. By default, it doesn\'t. However, with closed registrations, this plugin becomes useless. This is why we added a separate setting to allow registrations. Users registering through Awesome Support will be given a specific role (<code>Support User</code>) with very limited privileges.</p><p>If you allow registrations through the plugin but not through WordPress, users will only be able to register through our registration form.</p>', 'awesome-support' ) |
| 101 |
) ); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Moderated registration contextual help. |
| 106 |
* |
| 107 |
* @return void |
| 108 |
*/ |
| 109 |
public function settings_moderated_registration_help() { |
| 110 |
|
| 111 |
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; |
| 112 |
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; |
| 113 |
|
| 114 |
if( 'ticket' !== $post_type || 'modregistration' !== $tab ) { |
| 115 |
return; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Gather the list of e-mail template tags and their description |
| 120 |
*/ |
| 121 |
$list_tags = WPAS_User_Email_Notification::get_tags(); |
| 122 |
|
| 123 |
$tags = '<table class="widefat"><thead><th class="row-title">' . __( 'Tag', 'awesome-support' ) . '</th><th>' . __( 'Description', 'awesome-support' ) . '</th></thead><tbody>'; |
| 124 |
|
| 125 |
foreach ( $list_tags as $the_tag ) { |
| 126 |
$tags .= '<tr><td class="row-title"><strong>' . $the_tag['tag'] . '</strong></td><td>' . $the_tag['desc'] . '</td></tr>'; |
| 127 |
} |
| 128 |
|
| 129 |
$tags .= '</tbody></table>'; |
| 130 |
|
| 131 |
$screen = get_current_screen(); |
| 132 |
|
| 133 |
// translators: %s is a list of available template tags for email setup. |
| 134 |
$content = sprintf( __( '<p>When setting up your e-mails templates, you can use a certain number of template tags allowing you to dynamically add user-related information at the moment the e-mail is sent. Here is the list of available tags:</p>%s', 'awesome-support' ), $tags ); |
| 135 |
$screen->add_help_tab( array( |
| 136 |
'id' => 'user-email-template-tags', |
| 137 |
'title' => __( 'Email Template Tags', 'awesome-support' ), |
| 138 |
'content' => $content |
| 139 |
) ); |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Products management contextual help. |
| 145 |
* |
| 146 |
* @since 5.2.0 |
| 147 |
* @return void |
| 148 |
*/ |
| 149 |
public function settings_products_management_help() { |
| 150 |
|
| 151 |
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; |
| 152 |
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; |
| 153 |
|
| 154 |
if( 'ticket' !== $post_type || 'products-management' !== $tab ) { |
| 155 |
return; |
| 156 |
} |
| 157 |
|
| 158 |
$screen = get_current_screen(); |
| 159 |
|
| 160 |
$screen->add_help_tab( array( |
| 161 |
'id' => 'multiple_products', |
| 162 |
'title' => __( 'Multiple Products', 'awesome-support' ), |
| 163 |
'content' => __( '<h2>Multiple Products</h2><p>The plugin can handle single product and multiple products support. If you do need to provide support for multiple products it is very important that you do NOT use a custom field or taxonomy and use the «Multiple Products» option instead.</p><p>The reason why it is so important is that many addons for Awesome Support are using the built-in products management system to work properly.</p>', 'awesome-support' ) |
| 164 |
) ); |
| 165 |
|
| 166 |
$screen->add_help_tab( array( |
| 167 |
'id' => 'products_synchronize', |
| 168 |
'title' => __( 'Synchronize Products', 'awesome-support' ), |
| 169 |
'content' => __( '<h2>Synchronize WooCommerce or EDD Products</h2><p>If you have WooCommerce or EDD installed, you will see an option allowing you to turn on synchronization between those plugins and the Awesome Support product list. But, you cannot synchronize your product list to both simultanously. If you have both WC and EDD installed and active for some reason then you will be synchronizing with WooCommerce.</p>', 'awesome-support' ) |
| 170 |
) ); |
| 171 |
|
| 172 |
$screen->add_help_tab( array( |
| 173 |
'id' => 'products_slug', |
| 174 |
'title' => __( 'Slug', 'awesome-support' ), |
| 175 |
'content' => __( '<h2>Slug</h2><p>Change this if you would like the URL for your products to include something other than PRODUCT.</p>', 'awesome-support' ) |
| 176 |
) ); |
| 177 |
|
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Notifications settings contextual help. |
| 182 |
* |
| 183 |
* @since 1.0.0 |
| 184 |
* @return void |
| 185 |
*/ |
| 186 |
public function settings_notifications_contextual_help() { |
| 187 |
|
| 188 |
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; |
| 189 |
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; |
| 190 |
if( 'ticket' !== $post_type || 'email' !== $tab ) { |
| 191 |
return; |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* Gather the list of e-mail template tags and their description |
| 196 |
*/ |
| 197 |
$list_tags = WPAS_Email_Notification::get_tags(); |
| 198 |
|
| 199 |
$tags = '<table class="widefat"><thead><th class="row-title">' . __( 'Tag', 'awesome-support' ) . '</th><th>' . __( 'Description', 'awesome-support' ) . '</th></thead><tbody>'; |
| 200 |
|
| 201 |
foreach ( $list_tags as $the_tag ) { |
| 202 |
$tags .= '<tr><td class="row-title"><strong>' . $the_tag['tag'] . '</strong></td><td>' . $the_tag['desc'] . '</td></tr>'; |
| 203 |
} |
| 204 |
|
| 205 |
$tags .= '</tbody></table>'; |
| 206 |
|
| 207 |
$screen = get_current_screen(); |
| 208 |
|
| 209 |
$screen->add_help_tab( array( |
| 210 |
'id' => 'email-html-template', |
| 211 |
'title' => __( 'Use HTML Template', 'awesome-support' ), |
| 212 |
'content' => __( '<h2>Use HTML Template</h2><p>Wrap all outgoing emails in a set of pretty HTML forms and tags. With this option turned on you can set a LOGO and create fancy header and footers around your outgoing email alerts.</p><p>However, if you have another plugin installed that already wraps all WordPress outgoing emails in a fancy HTML template then you should turn this option OFF.</p>', 'awesome-support' ) |
| 213 |
) ); |
| 214 |
|
| 215 |
// translators: %s is a list of available template tags for email setup. |
| 216 |
$content = sprintf( __( '<p>When setting up your e-mails templates, you can use a certain number of template tags allowing you to dynamically add ticket-related information at the moment the e-mail is sent. Here is the list of available tags:</p>%s', 'awesome-support' ), $tags ); |
| 217 |
$screen->add_help_tab( array( |
| 218 |
'id' => 'template-tags', |
| 219 |
'title' => __( 'Email Template Tags', 'awesome-support' ), |
| 220 |
'content' => $content |
| 221 |
) ); |
| 222 |
|
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* Advanced settings contextual help. |
| 227 |
* |
| 228 |
* @since 1.0.0 |
| 229 |
* @return void |
| 230 |
*/ |
| 231 |
public function settings_advanced_contextual_help() { |
| 232 |
|
| 233 |
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; |
| 234 |
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; |
| 235 |
|
| 236 |
if( 'ticket' !== $post_type || 'advanced' !== $tab ) { |
| 237 |
return; |
| 238 |
} |
| 239 |
|
| 240 |
$screen = get_current_screen(); |
| 241 |
|
| 242 |
$screen->add_help_tab( array( |
| 243 |
'id' => 'custom_login', |
| 244 |
'title' => __( 'Custom Login Page', 'awesome-support' ), |
| 245 |
'content' => __( '<h2>Custom Login Page</h2><p>This can be a dangerous setting. It is here to allow advanced users to create their own login / registration page. If you don\'t like our login form, you can replace it by your own.</p><p>To do so, create a new page containing the form (either with the use of a shortcode or a page template), then set this newly created page as the "Custom Login / Registration Page" in the setting below.</p><p><strong>Beware</strong>, setting a wrong page as the custom login page can either show a blank page or create an infinite loop.</p>', 'awesome-support' ) |
| 246 |
) ); |
| 247 |
|
| 248 |
} |
| 249 |
|
| 250 |
} |