|
1
|
|
|
<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2
|
|
|
/** |
|
3
|
|
|
* Main controller file for wpshop help |
|
4
|
|
|
* |
|
5
|
|
|
* @author Eoxia development team <[email protected]> |
|
6
|
|
|
* @version 1.0 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Main controller class for wpshop help |
|
11
|
|
|
* |
|
12
|
|
|
* @author Eoxia development team <[email protected]> |
|
13
|
|
|
* @version 1.0 |
|
14
|
|
|
*/ |
|
15
|
|
|
class wps_help_bubble_ctr { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* CORE - Instanciate wpshop help |
|
19
|
|
|
*/ |
|
20
|
|
|
function __construct() { |
|
|
|
|
|
|
21
|
|
|
/** Call style & javascript for administration */ |
|
22
|
|
|
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) ); |
|
23
|
|
|
|
|
24
|
|
|
/** Add the scripts into admin footer for future use */ |
|
25
|
|
|
add_action( 'admin_print_footer_scripts', array( &$this, 'wps_dashboard_help') ); |
|
26
|
|
|
|
|
27
|
|
|
/** Ajax actions **/ |
|
28
|
|
|
add_action( 'wp_ajax_close_wps_help_window', array( &$this, 'wps_ajax_close_wps_help_window' ) ); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Include stylesheets |
|
33
|
|
|
*/ |
|
34
|
|
|
function admin_scripts() { |
|
|
|
|
|
|
35
|
|
|
wp_enqueue_style( 'wp-pointer' ); |
|
36
|
|
|
wp_enqueue_script( 'wp-pointer' ); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* AJAX - Save into current user meta the different help that have to be closed next time the user will be logged in |
|
41
|
|
|
*/ |
|
42
|
|
|
function wps_ajax_close_wps_help_window() { |
|
|
|
|
|
|
43
|
|
|
$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
44
|
|
|
|
|
45
|
|
|
if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_close_wps_help_window' ) ) |
|
46
|
|
|
wp_die(); |
|
47
|
|
|
|
|
48
|
|
|
$status = false; |
|
49
|
|
|
$result = ''; |
|
50
|
|
|
$pointer_id = !empty( $_POST['pointer_id']) ? wpshop_tools::varSanitizer( $_POST['pointer_id'] ) : ''; |
|
51
|
|
|
if ( !empty($pointer_id) ) { |
|
52
|
|
|
$seen_help_windows = get_user_meta( get_current_user_id(), '_wps_closed_help', true); |
|
53
|
|
|
$seen_help_windows[ $pointer_id ] = true; |
|
54
|
|
|
|
|
55
|
|
|
update_user_meta( get_current_user_id(), '_wps_closed_help', $seen_help_windows); |
|
56
|
|
|
$status = true; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$response = array( 'status' => $status, 'response' => $result ); |
|
60
|
|
|
wp_die( json_encode( $response ) ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* WORDPRESS HOOK - FOOTER SCRIPTS - Create the help messages for wpshop. only create them into required pages by loking at current screen |
|
65
|
|
|
*/ |
|
66
|
|
|
function wps_dashboard_help() { |
|
|
|
|
|
|
67
|
|
|
/** Initialise help messages */ |
|
68
|
|
|
$help_cases = null; |
|
69
|
|
|
|
|
70
|
|
|
/** Get current screen in order to load messages only in required pages */ |
|
71
|
|
|
$current_screen = get_current_screen(); |
|
72
|
|
|
$current_screen->id = 'disable'; |
|
73
|
|
|
switch ( $current_screen->id ) { |
|
74
|
|
|
case 'toplevel_page_wpshop_dashboard': |
|
75
|
|
|
$help_cases[ 'download_newsletter_contacts' ] = array( 'edge' => 'left', 'at' => 'left bottom', 'my' => 'left top', 'pointer_id' => '#download_newsletter_contacts' ); |
|
76
|
|
|
break; |
|
77
|
|
|
|
|
78
|
|
|
case 'wpshop_product': |
|
79
|
|
|
$help_cases[ 'product_page_categories' ] = array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_categorydiv'); |
|
80
|
|
|
$help_cases[ 'product_datas_configuration' ] = array( 'edge' => 'bottom', 'at' => 'center top', 'my' => 'bottom right', 'pointer_id' => '#wpshop_product_fixed_tab'); |
|
81
|
|
|
$help_cases[ 'product_display_configuration' ] = array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '.wpshop_product_data_display_tab' ); |
|
82
|
|
|
$help_cases[ 'product_variations' ] = array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_new_variation_list_button' ); |
|
83
|
|
|
$help_cases[ 'product_variations_configuration' ] = array( 'edge' => 'bottom', 'at' => 'right bottom', 'my' => 'bottom', 'pointer_id' => '#wpshop_variation_parameters_button' ); |
|
84
|
|
|
$help_cases[ 'add_product_automaticly_to_cart' ] = array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_product_options' ); |
|
85
|
|
|
break; |
|
86
|
|
|
|
|
87
|
|
|
case 'edit-wpshop_product_category': |
|
88
|
|
|
$help_cases[ 'category_filterable_attributes' ] = array( 'edge' => 'bottom', 'at' => 'top', 'my' => 'bottom', 'pointer_id' => '.filterable_attributes_container' ); |
|
89
|
|
|
$help_cases[ 'category_picture' ] = array( 'edge' => 'bottom', 'at' => '', 'my' => 'bottom', 'pointer_id' => '.category_new_picture_upload' ); |
|
90
|
|
|
break; |
|
91
|
|
|
|
|
92
|
|
|
case 'wpshop_shop_order': |
|
93
|
|
|
$help_cases[ 'order_customer_comment' ] = array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_customer_comment' ); |
|
94
|
|
|
$help_cases[ 'order_notification_message' ] = array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_private_comments' ); |
|
95
|
|
|
$help_cases[ 'order_shipping_box' ] = array( 'edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_order_shipping' ); |
|
96
|
|
|
break; |
|
97
|
|
|
|
|
98
|
|
|
case 'wpshop_shop_message': |
|
99
|
|
|
$help_cases[ 'message_historic' ] = array( 'edge' => 'bottom', 'at' => '', 'my' => '', 'pointer_id' => '#wpshop_message_histo' ); |
|
100
|
|
|
break; |
|
101
|
|
|
|
|
102
|
|
|
case 'settings_page_wpshop_option': |
|
103
|
|
|
$help_cases[ 'options_payment_part' ] = array ('edge' => 'right', 'at' => '', 'my' => '', 'pointer_id' => '#wps_payment_mode_list_container' ); |
|
104
|
|
|
break; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
if ( !empty( $help_cases ) ) { |
|
108
|
|
|
/** Get help data seen by user **/ |
|
109
|
|
|
$closed_help_window = get_user_meta( get_current_user_id(), '_wps_closed_help', true); |
|
110
|
|
|
|
|
111
|
|
|
/** Read the different help cases */ |
|
112
|
|
|
foreach( $help_cases as $help_id => $help_case ) { |
|
113
|
|
|
if ( empty( $closed_help_window ) || ( !empty( $closed_help_window ) && !array_key_exists( $help_id, $closed_help_window ) ) ){ |
|
114
|
|
|
switch( $help_id ) { |
|
115
|
|
|
case 'download_newsletter_contacts' : |
|
116
|
|
|
$pointer_content = '<h3>' .__( 'Customers information download', 'wpshop'). '</h3>'; |
|
117
|
|
|
$pointer_content .= '<p>' .__( 'You can download emails of customers who accept to receive your commercials offers or your partners commercials offers by newsletter', 'wpshop'). '</p>'; |
|
118
|
|
|
break; |
|
119
|
|
|
|
|
120
|
|
|
case 'product_page_categories' : |
|
121
|
|
|
$pointer_content = '<h3>' .__( 'WPShop Categories', 'wpshop'). '</h3>'; |
|
122
|
|
|
$pointer_content .= '<p>' .__( 'You can classify your products by category.', 'wpshop'). '<br/></p>'; |
|
123
|
|
|
$pointer_content .= '<p><a href="' .admin_url('edit-tags.php?taxonomy=wpshop_product_category&post_type=wpshop_product'). '" class="button-primary" target="_blank">' .__('Create my WPShop categories', 'wpshop' ). '</a></p>'; |
|
124
|
|
|
break; |
|
125
|
|
|
|
|
126
|
|
|
case 'product_datas_configuration' : |
|
127
|
|
|
$pointer_content = '<h3>' .__( 'Product configurations', 'wpshop'). '</h3>'; |
|
128
|
|
|
$pointer_content .= '<p>' .__( 'Here, you can configure your product (Price, weight, reference and all attributes you want to create and affect to products', 'wpshop'). '</p>'; |
|
129
|
|
|
break; |
|
130
|
|
|
|
|
131
|
|
|
case 'product_display_configuration' : |
|
132
|
|
|
$pointer_content = '<h3>' .__( 'Product display configurations', 'wpshop'). '</h3>'; |
|
133
|
|
|
$pointer_content .= '<p>' .__( 'Here, you can manage what elements you want to display on your product page', 'wpshop' ). '</p>'; |
|
134
|
|
|
break; |
|
135
|
|
|
|
|
136
|
|
|
case 'product_variations' : |
|
137
|
|
|
$pointer_content = '<h3>' .__( 'Product variations', 'wpshop'). '</h3>'; |
|
138
|
|
|
$pointer_content .= '<p>' .__( 'Here, you can generate your product variations.', 'wpshop'). '</p><br/>'; |
|
139
|
|
|
$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/configurer-un-produit-avec-des-options/" class="button-primary" target="_blank">' .__('Read the tutorial', 'wpshop').'</a></p>'; |
|
140
|
|
|
break; |
|
141
|
|
|
|
|
142
|
|
|
case 'product_variations_configuration' : |
|
143
|
|
|
$pointer_content = '<h3>' .__( 'Variations configuration', 'wpshop'). '</h3>'; |
|
144
|
|
|
$pointer_content .= '<p>' .__( 'Here, you can manage your product variations configurations (Display "Price from", variation price priority...).', 'wpshop'). '</p>'; |
|
145
|
|
|
break; |
|
146
|
|
|
|
|
147
|
|
|
case 'add_product_automaticly_to_cart' : |
|
148
|
|
|
$pointer_content = '<h3>' .__('Add product to cart', 'wpshop'). '</h3>'; |
|
149
|
|
|
$pointer_content .= '<p>' .__( 'If you check this checkbox, this produc will be add automaticly to cart. This functionnality is helpful if you want to bill fees for example.', 'wpshop' ). '</p>'; |
|
150
|
|
|
break; |
|
151
|
|
|
|
|
152
|
|
|
case 'category_filterable_attributes' : |
|
153
|
|
|
$pointer_content = '<h3>' .__('Filterable search', 'wpshop'). '</h3>'; |
|
154
|
|
|
$pointer_content .= '<p>' .__( 'You can add a filter search to your WPShop, here will be display all available attributes for a filter search in this category', 'wpshop' ). '</p><br/>'; |
|
155
|
|
|
$pointer_content .= '<p><a href="http://www.wpshop.fr/documentations/la-recherche-par-filtre/" class="button-primary" target="_blank">' .__('Read the filter search tutorial', 'wpshop').'</a></p>'; |
|
156
|
|
|
break; |
|
157
|
|
|
|
|
158
|
|
|
case 'category_picture' : |
|
159
|
|
|
$pointer_content = '<h3>' .__('Category image', 'wpshop'). '</h3>'; |
|
160
|
|
|
$pointer_content .= '<p>' .__( 'You can add a picture to illustrate your category', 'wpshop' ). '</p>'; |
|
161
|
|
|
break; |
|
162
|
|
|
|
|
163
|
|
|
case 'order_customer_comment' : |
|
164
|
|
|
$pointer_content = '<h3>' .__('Order customer comment', 'wpshop'). '</h3>'; |
|
165
|
|
|
$pointer_content .= '<p>' .__( 'Here is displayed the customer comment wrote during the order', 'wpshop' ). '</p>'; |
|
166
|
|
|
break; |
|
167
|
|
|
|
|
168
|
|
|
case 'message_historic' : |
|
169
|
|
|
$pointer_content = '<h3>' .__('Message Historic', 'wpshop'). '</h3>'; |
|
170
|
|
|
$pointer_content .= '<p>' .__( 'This is this message historic. You can check here if an automatic e-mail was send to a customer', 'wpshop' ). '</p>'; |
|
171
|
|
|
break; |
|
172
|
|
|
|
|
173
|
|
|
case 'order_notification_message' : |
|
174
|
|
|
$pointer_content = '<h3>' .__('Order notification', 'wpshop'). '</h3>'; |
|
175
|
|
|
$pointer_content .= '<p>' .__( 'You can add a private comment to the order or send an comment to customer about this order', 'wpshop' ). '</p>'; |
|
176
|
|
|
break; |
|
177
|
|
|
|
|
178
|
|
|
case 'order_shipping_box' : |
|
179
|
|
|
$pointer_content = '<h3>' .__('Shipping actions', 'wpshop'). '</h3>'; |
|
180
|
|
|
$pointer_content .= '<p>' .__( 'Here, you can manage your shipping actions, download the shipping slip.', 'wpshop' ). '</p>'; |
|
181
|
|
|
break; |
|
182
|
|
|
|
|
183
|
|
|
case 'options_payment_part' : |
|
184
|
|
|
$pointer_content = '<h3>' .__('Payment configuration', 'wpshop'). '</h3><p>' .__( 'You can manage your payment methods (Change name, add description, add a logo and apply configurations ). You can add others payment methods', 'wpshop' ). '</p><br/><p><a href="http://shop.eoxia.com/boutique/shop/modules-wpshop/modules-de-paiement/" class="button-primary" target="_blank">' .__('See available payment methods', 'wpshop').'</a></p>'; |
|
185
|
|
|
break; |
|
186
|
|
|
|
|
187
|
|
|
default : |
|
188
|
|
|
$pointer_content = ''; |
|
189
|
|
|
break; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, 'backend', 'help', 'container_bubble' ) ); |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
} |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
} |
|
199
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.