Click to Chat for WhatsApp Chat - Version 1.1

Version Description

  • convert plugin to bit of OOP style
Download this release

Release Info

Developer bhvreddy
Plugin Icon 128x128 Click to Chat for WhatsApp Chat
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

admin/admin.php CHANGED
@@ -1,21 +1,25 @@
1
<?php
2
- /*
3
* starting point for the admin side of this plugin.
4
*
5
* include other file here .. which need in admin side.
6
*
7
- * In click-to-chat.php this file will be loaded as is_admin
8
*/
9
10
if ( ! defined( 'ABSPATH' ) ) exit;
11
12
/*************** includes ***********/
13
- require_once('add_styles_scripts_admin.php');
14
15
16
- require_once('admin_menu.php');
17
- require_once('admin_page.php');
18
- require_once('admin_page_customize_styles.php');
19
20
21
1
<?php
2
+ /**
3
* starting point for the admin side of this plugin.
4
*
5
* include other file here .. which need in admin side.
6
*
7
+ * In click-to-chat.php this file will be loaded as is_admin
8
+ *
9
+ * @package ccw
10
+ * @subpackage Administration
11
+ * @since 1.0
12
*/
13
14
if ( ! defined( 'ABSPATH' ) ) exit;
15
16
/*************** includes ***********/
17
+ require_once('class-ccw-add-styles-scripts-admin.php');
18
19
20
+ require_once('class-ccw-admin-menu.php');
21
+ require_once('class-ccw-admin-page.php');
22
+ require_once('class-ccw-admin-page-customize-styles.php');
23
24
25
admin/admin_menu.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
- /*
3
- * Admin - menu page - add_menu_page for this plugin - top level menu
4
- * calls settings_page.php ( ccw_settings_page - > require_once('settings_page.php') )
5
- * and page content display at admin_menu.php
6
- */
7
-
8
- if ( ! defined( 'ABSPATH' ) ) exit;
9
-
10
- if( ! function_exists('ccw_options_page') ) {
11
-
12
- function ccw_options_page() {
13
- add_menu_page(
14
- 'Click to Chat for WhatsApp - Plugin Option Page',
15
- 'Click to Chat',
16
- 'manage_options',
17
- 'click-to-chat',
18
- 'ccw_settings_page',
19
- 'dashicons-format-chat'
20
- );
21
- }
22
- }
23
-
24
- add_action('admin_menu', 'ccw_options_page');
25
-
26
-
27
- if( ! function_exists('ccw_settings_page') ) {
28
-
29
- function ccw_settings_page() {
30
-
31
- if ( ! current_user_can('manage_options') ) {
32
- return;
33
- }
34
-
35
- require_once('settings_page.php');
36
-
37
- }
38
- }
39
-
40
-
41
-
42
-
43
- // second page
44
- if( ! function_exists('ccw_options_page_two') ) {
45
-
46
- function ccw_options_page_two() {
47
- add_submenu_page(
48
- 'click-to-chat',
49
- 'Edit Styles',
50
- 'Customize Styles',
51
- 'manage_options',
52
- 'ccw-edit-styles',
53
- 'ccw_settings_page_two'
54
- );
55
-
56
- }
57
- }
58
-
59
- add_action('admin_menu', 'ccw_options_page_two');
60
-
61
-
62
- if( ! function_exists('ccw_settings_page_two') ) {
63
-
64
- function ccw_settings_page_two() {
65
-
66
- if ( ! current_user_can('manage_options') ) {
67
- return;
68
- }
69
-
70
- require_once('sp_customize_styles.php');
71
-
72
- }
73
- }
admin/{add_styles_scripts_admin.php → class-ccw-add-styles-scripts-admin.php} RENAMED
@@ -1,17 +1,24 @@
1
<?php
2
- /*
3
* Register css styles, javascript files at admin side
4
* instead of register multiple styles - as using sass in dev env,
5
* import files and at final create less css files
6
*/
7
8
if ( ! defined( 'ABSPATH' ) ) exit;
9
10
- // Register css styles, javascript files only on 'click-to-chat' page
11
- if( ! function_exists('ccw_register_files_admin') ) {
12
-
13
- function ccw_register_files_admin($hook) {
14
15
// ?page=click-to-chat
16
if( 'toplevel_page_click-to-chat' == $hook || 'click-to-chat_page_ccw-edit-styles' == $hook ) {
17
@@ -32,8 +39,12 @@ if( ! function_exists('ccw_register_files_admin') ) {
32
33
34
}
35
-
36
}
37
38
39
- add_action('admin_enqueue_scripts', 'ccw_register_files_admin');
1
<?php
2
+ /**
3
* Register css styles, javascript files at admin side
4
* instead of register multiple styles - as using sass in dev env,
5
* import files and at final create less css files
6
+ *
7
+ * @package ccw
8
+ * @subpackage Administration
9
+ * @since 1.0
10
*/
11
12
if ( ! defined( 'ABSPATH' ) ) exit;
13
14
+ if ( !class_exists( 'CCW_Add_Styles_Scripts_Admin' ) ) :
15
+
16
+ class CCW_Add_Styles_Scripts_Admin {
17
18
+
19
+ // Register css styles, javascript files only on 'click-to-chat' page
20
+ function ccw_register_files_admin($hook) {
21
+
22
// ?page=click-to-chat
23
if( 'toplevel_page_click-to-chat' == $hook || 'click-to-chat_page_ccw-edit-styles' == $hook ) {
24
39
40
41
}
42
+
43
}
44
45
+ $add_styles_scripts_admin = new CCW_Add_Styles_Scripts_Admin();
46
+
47
+ add_action('admin_enqueue_scripts', array( $add_styles_scripts_admin, 'ccw_register_files_admin' ) );
48
+
49
50
+ endif; // END class_exists check
admin/class-ccw-admin-menu.php ADDED
@@ -0,0 +1,73 @@
1
+ <?php
2
+ /**
3
+ * Admin - menu page - add_menu_page for this plugin - top level menu
4
+ * calls settings_page.php ( ccw_settings_page - > require_once('settings_page.php') )
5
+ * and page content display at admin_menu.php
6
+ *
7
+ * @package ccw
8
+ * @subpackage Administration
9
+ * @since 1.0
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( !class_exists( 'CCW_Admin_Menu' ) ) :
15
+
16
+ class CCW_Admin_Menu {
17
+
18
+ // top level page
19
+ function ccw_options_page() {
20
+ add_menu_page(
21
+ 'Click to Chat for WhatsApp - Plugin Option Page',
22
+ 'Click to Chat',
23
+ 'manage_options',
24
+ 'click-to-chat',
25
+ array( $this, 'ccw_settings_page' ),
26
+ 'dashicons-format-chat'
27
+ );
28
+ }
29
+
30
+ // top level page - setting page
31
+ function ccw_settings_page() {
32
+
33
+ if ( ! current_user_can('manage_options') ) {
34
+ return;
35
+ }
36
+
37
+ require_once('settings_page.php');
38
+ }
39
+
40
+
41
+ // customize style page
42
+ function ccw_options_page_two() {
43
+ add_submenu_page(
44
+ 'click-to-chat',
45
+ 'Edit Styles',
46
+ 'Customize Styles',
47
+ 'manage_options',
48
+ 'ccw-edit-styles',
49
+ array( $this, 'ccw_settings_page_two' )
50
+ );
51
+
52
+ }
53
+
54
+ // customize style page - setting page
55
+ function ccw_settings_page_two() {
56
+
57
+ if ( ! current_user_can('manage_options') ) {
58
+ return;
59
+ }
60
+
61
+ require_once('sp_customize_styles.php');
62
+ }
63
+
64
+
65
+ }
66
+
67
+ $admin_menu = new CCW_Admin_Menu();
68
+
69
+ add_action('admin_menu', array( $admin_menu, 'ccw_options_page') );
70
+
71
+ add_action('admin_menu', array( $admin_menu, 'ccw_options_page_two') );
72
+
73
+ endif; // END class_exists check
admin/{admin_page_customize_styles.php → class-ccw-admin-page-customize-styles.php} RENAMED
@@ -1,44 +1,46 @@
1
<?php
2
- /*
3
* content of the options page .. Customize Styles ..
4
* admin_menu.php -> settings_page.php -> admin_page.php
5
* in name exists - this short values - it means
6
* cs - customize styles
7
- * cb - call back - function
8
*/
9
10
if ( ! defined( 'ABSPATH' ) ) exit;
11
12
- function ccw_customize_styles() {
13
14
- register_setting( 'ccw_settings_group_cs', 'ccw_options_cs' , 'ccw_options_sanitize_cs_cb' );
15
-
16
- add_settings_section( 'ccw_settings_cs', '', 'ccw_settings_section_cs_cb', 'ccw_options_settings_cs' );
17
-
18
- add_settings_field( 'ccw_style_1_cs', 'Style 1', 'ccw_style_1_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
19
- add_settings_field( 'ccw_style_2_cs', 'Style 2', 'ccw_style_2_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
20
- add_settings_field( 'ccw_style_3_cs', 'Style 3', 'ccw_style_3_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
21
- add_settings_field( 'ccw_style_4_cs', 'Style 4', 'ccw_style_4_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
22
- add_settings_field( 'ccw_style_5_cs', 'Style 5', 'ccw_style_5_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
23
- add_settings_field( 'ccw_style_6_cs', 'Style 6', 'ccw_style_6_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
24
- add_settings_field( 'ccw_style_7_cs', 'Style 7', 'ccw_style_7_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
25
- add_settings_field( 'ccw_style_8_cs', 'Style 8', 'ccw_style_8_cb', 'ccw_options_settings_cs', 'ccw_settings_cs' );
26
-
27
- }
28
- add_action( 'admin_init', 'ccw_customize_styles' );
29
30
31
32
- if( ! function_exists('ccw_settings_section_cs_cb') ) {
33
34
function ccw_settings_section_cs_cb() {
35
echo '<h1>Customize Styles</h1>';
36
}
37
- }
38
39
40
- if( ! function_exists('ccw_style_1_cb') ) {
41
-
42
function ccw_style_1_cb() {
43
$ccw_style_1 = get_option('ccw_options_cs');
44
?>
@@ -116,10 +118,7 @@ if( ! function_exists('ccw_style_1_cb') ) {
116
</ul>
117
<?php
118
}
119
- }
120
121
-
122
- if( ! function_exists('ccw_style_2_cb') ) {
123
124
function ccw_style_2_cb() {
125
$ccw_style_2 = get_option('ccw_options_cs');
@@ -189,11 +188,8 @@ if( ! function_exists('ccw_style_2_cb') ) {
189
</ul>
190
<?php
191
}
192
- }
193
194
195
- if( ! function_exists('ccw_style_3_cb') ) {
196
-
197
function ccw_style_3_cb() {
198
$ccw_style_3 = get_option('ccw_options_cs');
199
?>
@@ -218,10 +214,8 @@ if( ! function_exists('ccw_style_3_cb') ) {
218
219
<?php
220
}
221
- }
222
223
- if( ! function_exists('ccw_style_4_cb') ) {
224
-
225
function ccw_style_4_cb() {
226
$ccw_style_4 = get_option('ccw_options_cs');
227
?>
@@ -256,12 +250,8 @@ if( ! function_exists('ccw_style_4_cb') ) {
256
257
<?php
258
}
259
- }
260
-
261
262
263
- if( ! function_exists('ccw_style_5_cb') ) {
264
-
265
function ccw_style_5_cb() {
266
$ccw_style_5 = get_option('ccw_options_cs');
267
?>
@@ -304,11 +294,8 @@ if( ! function_exists('ccw_style_5_cb') ) {
304
305
<?php
306
}
307
- }
308
309
310
- if( ! function_exists('ccw_style_6_cb') ) {
311
-
312
function ccw_style_6_cb() {
313
$ccw_style_6 = get_option('ccw_options_cs');
314
?>
@@ -400,12 +387,9 @@ if( ! function_exists('ccw_style_6_cb') ) {
400
401
<?php
402
}
403
- }
404
405
406
407
- if( ! function_exists('ccw_style_7_cb') ) {
408
-
409
function ccw_style_7_cb() {
410
$ccw_style_7 = get_option('ccw_options_cs');
411
?>
@@ -499,11 +483,8 @@ if( ! function_exists('ccw_style_7_cb') ) {
499
500
<?php
501
}
502
- }
503
504
505
- if( ! function_exists('ccw_style_8_cb') ) {
506
-
507
function ccw_style_8_cb() {
508
$ccw_style_8 = get_option('ccw_options_cs');
509
$s8_icon_float = esc_attr( $ccw_style_8['s8_icon_float'] )
@@ -598,14 +579,10 @@ if( ! function_exists('ccw_style_8_cb') ) {
598
599
<?php
600
}
601
- }
602
-
603
604
605
606
607
- if( ! function_exists('ccw_options_sanitize_cs_cb') ) {
608
-
609
function ccw_options_sanitize_cs_cb( $input ) {
610
611
if ( ! current_user_can( 'manage_options' ) ) {
@@ -739,4 +716,12 @@ if( ! function_exists('ccw_options_sanitize_cs_cb') ) {
739
740
return $new_input;
741
}
742
- }
1
<?php
2
+ /**
3
* content of the options page .. Customize Styles ..
4
* admin_menu.php -> settings_page.php -> admin_page.php
5
* in name exists - this short values - it means
6
* cs - customize styles
7
+ * cb - call back - function
8
+ *
9
+ * @package ccw
10
+ * @subpackage Administration
11
+ * @since 1.0
12
*/
13
14
if ( ! defined( 'ABSPATH' ) ) exit;
15
16
+ if ( !class_exists( 'CCW_Admin_Page_Customize_Styles' ) ) :
17
18
+ class CCW_Admin_Page_Customize_Styles {
19
20
21
+ function customize_styles() {
22
+
23
+ register_setting( 'ccw_settings_group_cs', 'ccw_options_cs' , 'ccw_options_sanitize_cs_cb' );
24
+
25
+ add_settings_section( 'ccw_settings_cs', '', array( $this, 'ccw_settings_section_cs_cb' ), 'ccw_options_settings_cs' );
26
+
27
+ add_settings_field( 'ccw_style_1_cs', 'Style 1', array( $this, 'ccw_style_1_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
28
+ add_settings_field( 'ccw_style_2_cs', 'Style 2', array( $this, 'ccw_style_2_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
29
+ add_settings_field( 'ccw_style_3_cs', 'Style 3', array( $this, 'ccw_style_3_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
30
+ add_settings_field( 'ccw_style_4_cs', 'Style 4', array( $this, 'ccw_style_4_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
31
+ add_settings_field( 'ccw_style_5_cs', 'Style 5', array( $this, 'ccw_style_5_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
32
+ add_settings_field( 'ccw_style_6_cs', 'Style 6', array( $this, 'ccw_style_6_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
33
+ add_settings_field( 'ccw_style_7_cs', 'Style 7', array( $this, 'ccw_style_7_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
34
+ add_settings_field( 'ccw_style_8_cs', 'Style 8', array( $this, 'ccw_style_8_cb' ), 'ccw_options_settings_cs', 'ccw_settings_cs' );
35
+
36
+ }
37
38
39
function ccw_settings_section_cs_cb() {
40
echo '<h1>Customize Styles</h1>';
41
}
42
43
44
function ccw_style_1_cb() {
45
$ccw_style_1 = get_option('ccw_options_cs');
46
?>
118
</ul>
119
<?php
120
}
121
122
123
function ccw_style_2_cb() {
124
$ccw_style_2 = get_option('ccw_options_cs');
188
</ul>
189
<?php
190
}
191
192
193
function ccw_style_3_cb() {
194
$ccw_style_3 = get_option('ccw_options_cs');
195
?>
214
215
<?php
216
}
217
218
+
219
function ccw_style_4_cb() {
220
$ccw_style_4 = get_option('ccw_options_cs');
221
?>
250
251
<?php
252
}
253
254
255
function ccw_style_5_cb() {
256
$ccw_style_5 = get_option('ccw_options_cs');
257
?>
294
295
<?php
296
}
297
298
299
function ccw_style_6_cb() {
300
$ccw_style_6 = get_option('ccw_options_cs');
301
?>
387
388
<?php
389
}
390
391
392
393
function ccw_style_7_cb() {
394
$ccw_style_7 = get_option('ccw_options_cs');
395
?>
483
484
<?php
485
}
486
487
488
function ccw_style_8_cb() {
489
$ccw_style_8 = get_option('ccw_options_cs');
490
$s8_icon_float = esc_attr( $ccw_style_8['s8_icon_float'] )
579
580
<?php
581
}
582
583
584
585
586
function ccw_options_sanitize_cs_cb( $input ) {
587
588
if ( ! current_user_can( 'manage_options' ) ) {
716
717
return $new_input;
718
}
719
+
720
+
721
+ }
722
+
723
+ $ccw_customize_styles = new CCW_Admin_Page_Customize_Styles();
724
+
725
+ add_action( 'admin_init', array( $ccw_customize_styles, 'customize_styles') );
726
+
727
+ endif; // END class_exists check
admin/{admin_page.php → class-ccw-admin-page.php} RENAMED
@@ -1,49 +1,49 @@
1
<?php
2
- /*
3
* content of the options page ..
4
* admin_menu.php -> settings_page.php -> admin_page.php
5
*/
6
7
if ( ! defined( 'ABSPATH' ) ) exit;
8
9
- function ccw_custom_settings() {
10
11
- register_setting( 'ccw_settings_group', 'ccw_options' , 'ccw_options_sanitize' );
12
-
13
- add_settings_section( 'ccw_settings', '', 'ccw_settings_section', 'ccw_options_settings' );
14
-
15
- add_settings_field( 'ccw_enable', 'Enable Floating Styles', 'ccw_enable_cb', 'ccw_options_settings', 'ccw_settings' );
16
- add_settings_field( 'ccw_enable_sc', 'Enable ShortCodes', 'ccw_enable_sc_cb', 'ccw_options_settings', 'ccw_settings' );
17
- add_settings_field( 'ccw_return_type', 'Return Type', 'ccw_return_type_cb', 'ccw_options_settings', 'ccw_settings' );
18
- add_settings_field( 'ccw_number', 'WhatsApp Number', 'ccw_number_input_cb', 'ccw_options_settings', 'ccw_settings' );
19
- add_settings_field( 'ccw_group_id', 'Group Id', 'ccw_group_id_cb', 'ccw_options_settings', 'ccw_settings' );
20
- add_settings_field( 'ccw_style', 'Style for Desktops', 'ccw_style_cb', 'ccw_options_settings', 'ccw_settings' );
21
- add_settings_field( 'ccw_style_mobile', 'Style for Mobile Devices', 'ccw_style_mobile_cb', 'ccw_options_settings', 'ccw_settings' );
22
- add_settings_field( 'ccw_position', 'Position to Place', 'ccw_position_input_cb', 'ccw_options_settings', 'ccw_settings' );
23
- add_settings_field( 'ccw_placeholder', 'Text to Display', 'ccw_input_placeholder_cb', 'ccw_options_settings', 'ccw_settings' );
24
- add_settings_field( 'ccw_checkbox', 'Show / Hide ', 'ccw_checkbox_cb', 'ccw_options_settings', 'ccw_settings' );
25
- add_settings_field( 'ccw_list_id_tohide', 'Posts, Pages Id\'s to Hide', 'ccw_list_id_tohide_cb', 'ccw_options_settings', 'ccw_settings' );
26
- add_settings_field( 'ccw_list_cat_tohide', 'Categorys to Hide', 'ccw_list_cat_tohide_cb', 'ccw_options_settings', 'ccw_settings' );
27
- add_settings_field( 'ccw_custom_shortcode', 'Shortcode name', 'ccw_custom_shortcode_cb', 'ccw_options_settings', 'ccw_settings' );
28
-
29
- }
30
-
31
-
32
- add_action( 'admin_init', 'ccw_custom_settings' );
33
34
35
- // heading
36
- if( ! function_exists('ccw_settings_section') ) {
37
38
function ccw_settings_section() {
39
echo '<h1>Click to Chat For WhatsApp - Global Settings</h1>';
40
}
41
- }
42
43
44
- // enable / disable floating styles
45
- if( ! function_exists('ccw_enable_cb') ) {
46
-
47
function ccw_enable_cb() {
48
$ccw_enable = get_option('ccw_options');
49
?>
@@ -58,11 +58,8 @@ if( ! function_exists('ccw_enable_cb') ) {
58
</div>
59
<?php
60
}
61
- }
62
63
- // enable / disable shortcodes
64
- if( ! function_exists('ccw_enable_sc_cb') ) {
65
-
66
function ccw_enable_sc_cb() {
67
$ccw_enable_sc = get_option('ccw_options');
68
?>
@@ -73,16 +70,13 @@ if( ! function_exists('ccw_enable_sc_cb') ) {
73
<option value="2" <?php echo esc_attr( $ccw_enable_sc['enable_sc'] ) == 2 ? 'SELECTED' : ''; ?> >Yes</option>
74
</select>
75
<label>enable ShortCodes</label>
76
- <p class="description"> If Selected - No - then Hides Shortcodes and its syntax - <a target="_blank" href="https://medium.com/clicktochat/enable-disable-styles-84293dca3fbd">more info</a> </p>
77
</div>
78
</div>
79
<?php
80
}
81
- }
82
83
- // Return type - chat or group chat
84
- if( ! function_exists('ccw_return_type_cb') ) {
85
-
86
function ccw_return_type_cb() {
87
$ccw_return_type = get_option('ccw_options');
88
?>
@@ -93,17 +87,14 @@ if( ! function_exists('ccw_return_type_cb') ) {
93
<option value="group_chat" <?php echo esc_attr( $ccw_return_type['return_type'] ) == 'group_chat' ? 'SELECTED' : ''; ?> >Group chat - Invite</option>
94
</select>
95
<label>Default return type - Chat or Group Chat Invite</label>
96
- <p class="description"> Default return type for Floating Style, shortcodes. But for shortcodes can change using shortcode attributes - <a target="_blank" href="https://medium.com/clicktochat/return-type-451635e320eb">more info</a> </p>
97
</div>
98
</div>
99
<?php
100
}
101
- }
102
103
104
- // Desktop - select style
105
- if( ! function_exists('ccw_style_cb') ) {
106
-
107
function ccw_style_cb() {
108
$ccw_style = get_option('ccw_options');
109
$style_value = esc_attr( $ccw_style['style'] );
@@ -122,16 +113,13 @@ if( ! function_exists('ccw_style_cb') ) {
122
<option value="0" <?php echo $style_value == 0 ? 'SELECTED' : ''; ?> >Hide on Desktop Devices</option>
123
</select>
124
<label>Select Style for Destops</label>
125
- <p class="description"> - <a target="_blank" href="https://medium.com/clicktochat/select-styles-48527f73e697">List of syles with images</a> </p>
126
</div>
127
</div>
128
<?php
129
}
130
- }
131
132
- // Mobile - Select Style
133
- if( ! function_exists('ccw_style_mobile_cb') ) {
134
-
135
function ccw_style_mobile_cb() {
136
$ccw_stylemobile = get_option('ccw_options');
137
$style_mobile_value = esc_attr( $ccw_stylemobile['stylemobile'] );
@@ -154,11 +142,8 @@ if( ! function_exists('ccw_style_mobile_cb') ) {
154
</div>
155
<?php
156
}
157
- }
158
159
- // number
160
- if( ! function_exists('ccw_number_input_cb') ) {
161
-
162
function ccw_number_input_cb() {
163
$ccw_number = get_option('ccw_options');
164
?>
@@ -166,16 +151,13 @@ if( ! function_exists('ccw_number_input_cb') ) {
166
<div class="input-field col s12">
167
<input name="ccw_options[number]" value="<?php echo esc_attr( $ccw_number['number'] ) ?>" id="whatsapp_number" type="text" class="validate input-margin">
168
<label for="whatsapp_number">Enter whatsapp number </label>
169
- <p class="description">Enter whatsapp number with country code ( e.g. 916123456789 ) please dont include +, ( here in e.g. 91 is country code 6123456789 is mobile number - <a target="_blank" href="https://medium.com/clicktochat/whatsapp-number-b155206825c8">more info</a> ) </p>
170
</div>
171
</div>
172
<?php
173
}
174
- }
175
176
- // Group ID
177
- if( ! function_exists('ccw_group_id_cb') ) {
178
-
179
function ccw_group_id_cb() {
180
$ccw_group_id = get_option('ccw_options');
181
?>
@@ -188,11 +170,8 @@ if( ! function_exists('ccw_group_id_cb') ) {
188
</div>
189
<?php
190
}
191
- }
192
193
- // postion
194
- if( ! function_exists('ccw_position_input_cb') ) {
195
-
196
function ccw_position_input_cb() {
197
$ccw_position = get_option('ccw_options');
198
$ccw_position_value = esc_attr( $ccw_position['position'] )
@@ -258,11 +237,8 @@ if( ! function_exists('ccw_position_input_cb') ) {
258
259
<?php
260
}
261
- }
262
263
- // Text - placeholder
264
- if( ! function_exists('ccw_input_placeholder_cb') ) {
265
-
266
function ccw_input_placeholder_cb() {
267
$ccw_placeholder = get_option('ccw_options');
268
?>
@@ -275,11 +251,8 @@ if( ! function_exists('ccw_input_placeholder_cb') ) {
275
</div>
276
<?php
277
}
278
- }
279
-
280
- // checkboxes - based on Type of posts ..
281
- if( ! function_exists('ccw_checkbox_cb') ) {
282
283
function ccw_checkbox_cb() {
284
$ccw_checkbox = get_option('ccw_options');
285
@@ -412,11 +385,8 @@ if( ! function_exists('ccw_checkbox_cb') ) {
412
<p class="description"> check to show, uncheck to hide - Show/ Hide - Styles - based on type of the page <a target="_blank" href="https://medium.com/clicktochat/show-hide-styles-based-on-type-of-the-page-4f0542a92909">more info</a> </p>
413
<?php
414
}
415
- }
416
417
// ID 's list to hide styles
418
- if( ! function_exists('ccw_list_id_tohide_cb') ) {
419
-
420
function ccw_list_id_tohide_cb() {
421
$ccw_list_id_tohide = get_option('ccw_options');
422
?>
@@ -429,12 +399,8 @@ if( ! function_exists('ccw_list_id_tohide_cb') ) {
429
</div>
430
<?php
431
}
432
- }
433
434
-
435
- // Categorys list - to hide
436
- if( ! function_exists('ccw_list_cat_tohide_cb') ) {
437
-
438
function ccw_list_cat_tohide_cb() {
439
$ccw_list_cat_tohide = get_option('ccw_options');
440
?>
@@ -447,11 +413,8 @@ if( ! function_exists('ccw_list_cat_tohide_cb') ) {
447
</div>
448
<?php
449
}
450
- }
451
452
- // Custom shortcode
453
- if( ! function_exists('ccw_custom_shortcode_cb') ) {
454
-
455
function ccw_custom_shortcode_cb() {
456
$ccw_shortcode = get_option('ccw_options');
457
?>
@@ -471,11 +434,8 @@ if( ! function_exists('ccw_custom_shortcode_cb') ) {
471
</div>
472
<?php
473
}
474
- }
475
476
- // Sanitize callback ..
477
- if( ! function_exists('ccw_options_sanitize') ) {
478
-
479
function ccw_options_sanitize( $input ) {
480
481
if ( ! current_user_can( 'manage_options' ) ) {
@@ -568,4 +528,14 @@ if( ! function_exists('ccw_options_sanitize') ) {
568
// $new_input = sanitize_text_field($input);
569
return $new_input;
570
}
571
- }
1
<?php
2
+ /**
3
* content of the options page ..
4
* admin_menu.php -> settings_page.php -> admin_page.php
5
+ *
6
+ * @package ccw
7
+ * @subpackage Administration
8
+ * @since 1.0
9
*/
10
11
if ( ! defined( 'ABSPATH' ) ) exit;
12
13
+ if ( !class_exists( 'CCW_Admin_Page' ) ) :
14
15
+ class CCW_Admin_Page {
16
17
+ function ccw_custom_settings() {
18
+
19
+ register_setting( 'ccw_settings_group', 'ccw_options' , 'ccw_options_sanitize' );
20
+
21
+ add_settings_section( 'ccw_settings', '', array( $this, 'ccw_settings_section' ), 'ccw_options_settings' );
22
+
23
+ add_settings_field( 'ccw_enable', 'Enable Floating Styles', array( $this, 'ccw_enable_cb' ), 'ccw_options_settings', 'ccw_settings' );
24
+ add_settings_field( 'ccw_enable_sc', 'Enable ShortCodes', array( $this, 'ccw_enable_sc_cb' ), 'ccw_options_settings', 'ccw_settings' );
25
+ add_settings_field( 'ccw_return_type', 'Return Type', array( $this, 'ccw_return_type_cb' ), 'ccw_options_settings', 'ccw_settings' );
26
+ add_settings_field( 'ccw_number', 'WhatsApp Number', array( $this, 'ccw_number_input_cb' ), 'ccw_options_settings', 'ccw_settings' );
27
+ add_settings_field( 'ccw_group_id', 'Group Id', array( $this, 'ccw_group_id_cb' ), 'ccw_options_settings', 'ccw_settings' );
28
+ add_settings_field( 'ccw_style', 'Style for Desktops', array( $this, 'ccw_style_cb' ), 'ccw_options_settings', 'ccw_settings' );
29
+ add_settings_field( 'ccw_style_mobile', 'Style for Mobile Devices', array( $this, 'ccw_style_mobile_cb' ), 'ccw_options_settings', 'ccw_settings' );
30
+ add_settings_field( 'ccw_position', 'Position to Place', array( $this, 'ccw_position_input_cb' ), 'ccw_options_settings', 'ccw_settings' );
31
+ add_settings_field( 'ccw_placeholder', 'Text to Display', array( $this, 'ccw_input_placeholder_cb' ), 'ccw_options_settings', 'ccw_settings' );
32
+ add_settings_field( 'ccw_checkbox', 'Show / Hide ', array( $this, 'ccw_checkbox_cb' ), 'ccw_options_settings', 'ccw_settings' );
33
+ add_settings_field( 'ccw_list_id_tohide', 'Posts, Pages Id\'s to Hide', array( $this, 'ccw_list_id_tohide_cb' ), 'ccw_options_settings', 'ccw_settings' );
34
+ add_settings_field( 'ccw_list_cat_tohide', 'Categorys to Hide', array( $this, 'ccw_list_cat_tohide_cb' ), 'ccw_options_settings', 'ccw_settings' );
35
+ add_settings_field( 'ccw_custom_shortcode', 'Shortcode name', array( $this, 'ccw_custom_shortcode_cb' ), 'ccw_options_settings', 'ccw_settings' );
36
+
37
+ }
38
39
40
+ // heading
41
function ccw_settings_section() {
42
echo '<h1>Click to Chat For WhatsApp - Global Settings</h1>';
43
}
44
45
46
+ // enable / disable floating styles
47
function ccw_enable_cb() {
48
$ccw_enable = get_option('ccw_options');
49
?>
58
</div>
59
<?php
60
}
61
62
+ // enable / disable shortcodes
63
function ccw_enable_sc_cb() {
64
$ccw_enable_sc = get_option('ccw_options');
65
?>
70
<option value="2" <?php echo esc_attr( $ccw_enable_sc['enable_sc'] ) == 2 ? 'SELECTED' : ''; ?> >Yes</option>
71
</select>
72
<label>enable ShortCodes</label>
73
+ <p class="description"> If Selected - No - then Hides Shortcodes and its syntax - <a target="_blank" href="https: //medium.com/clicktochat/enable-disable-styles-84293dca3fbd">more info</a> </p>
74
</div>
75
</div>
76
<?php
77
}
78
79
+ // Return type - chat or group chat
80
function ccw_return_type_cb() {
81
$ccw_return_type = get_option('ccw_options');
82
?>
87
<option value="group_chat" <?php echo esc_attr( $ccw_return_type['return_type'] ) == 'group_chat' ? 'SELECTED' : ''; ?> >Group chat - Invite</option>
88
</select>
89
<label>Default return type - Chat or Group Chat Invite</label>
90
+ <p class="description"> Default return type for Floating Style, shortcodes. But for shortcodes can change using shortcode attributes - <a target="_blank" href="https: //medium.com/clicktochat/return-type-451635e320eb">more info</a> </p>
91
</div>
92
</div>
93
<?php
94
}
95
96
97
+ // Desktop - select style
98
function ccw_style_cb() {
99
$ccw_style = get_option('ccw_options');
100
$style_value = esc_attr( $ccw_style['style'] );
113
<option value="0" <?php echo $style_value == 0 ? 'SELECTED' : ''; ?> >Hide on Desktop Devices</option>
114
</select>
115
<label>Select Style for Destops</label>
116
+ <p class="description"> - <a target="_blank" href="https: //medium.com/clicktochat/select-styles-48527f73e697">List of syles with images</a> </p>
117
</div>
118
</div>
119
<?php
120
}
121
122
+ // Mobile - Select Style
123
function ccw_style_mobile_cb() {
124
$ccw_stylemobile = get_option('ccw_options');
125
$style_mobile_value = esc_attr( $ccw_stylemobile['stylemobile'] );
142
</div>
143
<?php
144
}
145
146
+ // number
147
function ccw_number_input_cb() {
148
$ccw_number = get_option('ccw_options');
149
?>
151
<div class="input-field col s12">
152
<input name="ccw_options[number]" value="<?php echo esc_attr( $ccw_number['number'] ) ?>" id="whatsapp_number" type="text" class="validate input-margin">
153
<label for="whatsapp_number">Enter whatsapp number </label>
154
+ <p class="description">Enter whatsapp number with country code ( e.g. 916123456789 ) please dont include +, ( here in e.g. 91 is country code 6123456789 is mobile number - <a target="_blank" href="https: //medium.com/clicktochat/whatsapp-number-b155206825c8">more info</a> ) </p>
155
</div>
156
</div>
157
<?php
158
}
159
160
+ // Group ID
161
function ccw_group_id_cb() {
162
$ccw_group_id = get_option('ccw_options');
163
?>
170
</div>
171
<?php
172
}
173
174
+ // postion
175
function ccw_position_input_cb() {
176
$ccw_position = get_option('ccw_options');
177
$ccw_position_value = esc_attr( $ccw_position['position'] )
237
238
<?php
239
}
240
241
+ // Text - placeholder
242
function ccw_input_placeholder_cb() {
243
$ccw_placeholder = get_option('ccw_options');
244
?>
251
</div>
252
<?php
253
}
254
255
+ // checkboxes - based on Type of posts ..
256
function ccw_checkbox_cb() {
257
$ccw_checkbox = get_option('ccw_options');
258
385
<p class="description"> check to show, uncheck to hide - Show/ Hide - Styles - based on type of the page <a target="_blank" href="https://medium.com/clicktochat/show-hide-styles-based-on-type-of-the-page-4f0542a92909">more info</a> </p>
386
<?php
387
}
388
389
// ID 's list to hide styles
390
function ccw_list_id_tohide_cb() {
391
$ccw_list_id_tohide = get_option('ccw_options');
392
?>
399
</div>
400
<?php
401
}
402
403
+ // Categorys list - to hide
404
function ccw_list_cat_tohide_cb() {
405
$ccw_list_cat_tohide = get_option('ccw_options');
406
?>
413
</div>
414
<?php
415
}
416
417
+ // Custom shortcode
418
function ccw_custom_shortcode_cb() {
419
$ccw_shortcode = get_option('ccw_options');
420
?>
434
</div>
435
<?php
436
}
437
438
+ // Sanitize callback ..
439
function ccw_options_sanitize( $input ) {
440
441
if ( ! current_user_can( 'manage_options' ) ) {
528
// $new_input = sanitize_text_field($input);
529
return $new_input;
530
}
531
+
532
+
533
+ }
534
+
535
+
536
+
537
+ $admin_page = new CCW_Admin_Page();
538
+
539
+ add_action( 'admin_init', array( $admin_page,'ccw_custom_settings' ) );
540
+
541
+ endif; // END class_exists check
admin/default-values.php CHANGED
@@ -1,11 +1,14 @@
1
<?php
2
- /*
3
* set the default values
4
* which stores in database options table
5
* dont override user settings
6
* get user setting value and merge with newly added values
7
*
8
* ccw_plugin_details - this values will be overrides..
9
*/
10
11
if ( ! defined( 'ABSPATH' ) ) exit;
@@ -13,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
13
14
// plugin details
15
$plugin_details = array(
16
- 'version' => '1.0.0',
17
);
18
19
// Always use update_option - override new values .. don't preseve already existing values
1
<?php
2
+ /**
3
* set the default values
4
* which stores in database options table
5
* dont override user settings
6
* get user setting value and merge with newly added values
7
*
8
* ccw_plugin_details - this values will be overrides..
9
+ *
10
+ * @package ccw
11
+ * @since 1.0
12
*/
13
14
if ( ! defined( 'ABSPATH' ) ) exit;
16
17
// plugin details
18
$plugin_details = array(
19
+ 'version' => '1.1',
20
);
21
22
// Always use update_option - override new values .. don't preseve already existing values
admin/settings_page.php CHANGED
@@ -1,7 +1,11 @@
1
<?php
2
- /*
3
* options page
4
- * content of this page load / continue at admin_page.php
5
*/
6
7
if ( ! defined( 'ABSPATH' ) ) exit;
1
<?php
2
+ /**
3
* options page
4
+ * content of this page load / continue at admin_page.php
5
+ *
6
+ * @package ccw
7
+ * @subpackage Administration
8
+ * @since 1.0
9
*/
10
11
if ( ! defined( 'ABSPATH' ) ) exit;
admin/sp_customize_styles.php CHANGED
@@ -1,9 +1,13 @@
1
<?php
2
- /*
3
* settings page - customize styles ( settings_page.php is main page and this is sub page )
4
* options page
5
* content of this page load / continue at admin_page_customize_styles.php
6
* cs - customize styles
7
*/
8
9
if ( ! defined( 'ABSPATH' ) ) exit;
1
<?php
2
+ /**
3
* settings page - customize styles ( settings_page.php is main page and this is sub page )
4
* options page
5
* content of this page load / continue at admin_page_customize_styles.php
6
* cs - customize styles
7
+ *
8
+ * @package ccw
9
+ * @subpackage Administration
10
+ * @since 1.0
11
*/
12
13
if ( ! defined( 'ABSPATH' ) ) exit;
click-to-chat.php CHANGED
@@ -1,14 +1,14 @@
1
<?php
2
/*
3
Plugin Name: Click to Chat for WhatsApp
4
- Plugin URI: https://codecanyon.net/user/bhvr
5
Description: Lets make your Web page visitor contact you through WhatsApp with a single click/tap
6
- Version: 1.0
7
- Author: bhvr
8
Author URI: https://venkat.club/
9
- License: GPL2
10
- License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
- Text Domain: wp_chat
12
*/
13
14
if ( ! defined( 'WPINC' ) ) {
@@ -28,31 +28,31 @@ if ( !defined('CCW_PLUGIN_DIR') ) {
28
29
if ( !defined('CCW_VERSION') ) {
30
/**
31
- * @if-changes - if this value changes
32
* dont forget to change 'version' in $plugin_details in default-values.php, in readme.txt file
33
*/
34
- define( 'CCW_VERSION', '1.0.0' );
35
}
36
37
38
39
/*************** includes ***********/
40
- require_once('inc/first.php');
41
require_once('inc/is-mobile.php');
42
require_once('inc/commons/variables.php');
43
44
45
if ( is_admin() ) {
46
// we are in admin mode
47
- require_once( dirname( __FILE__ ) . '/admin/admin.php' );
48
} else {
49
- require_once('inc/add_styles_scripts.php');
50
- require_once( 'inc/shortcode.php' );
51
52
if ( 1 == $isMob ) {
53
- require_once('inc/chatbot-mobile.php');
54
} else {
55
- require_once('inc/chatbot.php');
56
}
57
58
}
@@ -60,12 +60,12 @@ if ( is_admin() ) {
60
61
62
/*************** hooks ***********/
63
- register_activation_hook( __FILE__, 'ccw_activation_plugin' );
64
- register_deactivation_hook( __FILE__, 'ccw_deactivate_plugin' );
65
- register_uninstall_hook(__FILE__, 'ccw_uninstall_plugin');
66
67
add_filter('widget_text', 'do_shortcode');
68
// add_filter( 'the_excerpt', 'do_shortcode');
69
70
// need to run this to check if plugin updated ..
71
- add_action('plugins_loaded', 'ccw_plugin_version_check');
1
<?php
2
/*
3
Plugin Name: Click to Chat for WhatsApp
4
+ Plugin URI: https://wordpress.org/plugins/click-to-chat-for-whatsapp/
5
Description: Lets make your Web page visitor contact you through WhatsApp with a single click/tap
6
+ Version: 1.1
7
+ Author: Venkat
8
Author URI: https://venkat.club/
9
+ License: GPL2
10
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
+ Text Domain: ccw_text
12
*/
13
14
if ( ! defined( 'WPINC' ) ) {
28
29
if ( !defined('CCW_VERSION') ) {
30
/**
31
+ * #### if-changes ##### - if this value changes
32
* dont forget to change 'version' in $plugin_details in default-values.php, in readme.txt file
33
*/
34
+ define( 'CCW_VERSION', '1.1' );
35
}
36
37
38
39
/*************** includes ***********/
40
+ require_once('inc/class-ccw-first.php');
41
require_once('inc/is-mobile.php');
42
require_once('inc/commons/variables.php');
43
44
45
if ( is_admin() ) {
46
// we are in admin mode
47
+ require_once( CCW_PLUGIN_DIR . '/admin/admin.php' );
48
} else {
49
+ require_once('inc/class-ccw-add-styles-scripts.php');
50
+ require_once('inc/class-ccw-shortcode.php');
51
52
if ( 1 == $isMob ) {
53
+ require_once('inc/class-ccw-chatbot-mobile.php');
54
} else {
55
+ require_once('inc/class-ccw-chatbot.php');
56
}
57
58
}
60
61
62
/*************** hooks ***********/
63
+ register_activation_hook( __FILE__, array( 'CCW_first', 'activate' ) );
64
+ register_deactivation_hook( __FILE__, array( 'CCW_first', 'deactivate' ) );
65
+ register_uninstall_hook(__FILE__, array( 'CCW_first', 'uninstall' ) );
66
67
add_filter('widget_text', 'do_shortcode');
68
// add_filter( 'the_excerpt', 'do_shortcode');
69
70
// need to run this to check if plugin updated ..
71
+ add_action('plugins_loaded', array( 'CCW_first', 'version_check' ) );
inc/{add_styles_scripts.php → class-ccw-add-styles-scripts.php} RENAMED
@@ -1,13 +1,24 @@
1
<?php
2
- /*
3
* css, javascript files for front end.
4
* if need to register for admin side at at add_stles_scripts_admin.php file
5
*/
6
7
if ( ! defined( 'ABSPATH' ) ) exit;
8
9
- if( ! function_exists('ccw_register_files') ) {
10
-
11
function ccw_register_files() {
12
wp_register_style('ccw_new_css', plugins_url( 'assets/css/main.css', dirname(__FILE__) ), '', CCW_VERSION );
13
@@ -15,7 +26,11 @@ if( ! function_exists('ccw_register_files') ) {
15
16
wp_enqueue_script( 'ccw_app', plugins_url( 'assets/js/app.js', dirname(__FILE__) ), array ( 'jquery' ), CCW_VERSION );
17
}
18
}
19
20
21
- add_action('wp_enqueue_scripts', 'ccw_register_files');
1
<?php
2
+ /**
3
* css, javascript files for front end.
4
* if need to register for admin side at at add_stles_scripts_admin.php file
5
+ *
6
+ * @package ccw
7
+ * @since 1.0
8
*/
9
10
if ( ! defined( 'ABSPATH' ) ) exit;
11
12
+ if ( !class_exists( 'CCW_Add_Styles_Scripts' ) ) :
13
+
14
+ class CCW_Add_Styles_Scripts {
15
+
16
+
17
+ /**
18
+ * Register styles - front end ( non admin )
19
+ *
20
+ * @since 1.0
21
+ */
22
function ccw_register_files() {
23
wp_register_style('ccw_new_css', plugins_url( 'assets/css/main.css', dirname(__FILE__) ), '', CCW_VERSION );
24
26
27
wp_enqueue_script( 'ccw_app', plugins_url( 'assets/js/app.js', dirname(__FILE__) ), array ( 'jquery' ), CCW_VERSION );
28
}
29
+
30
}
31
32
+ $add_styles_scripts = new CCW_Add_Styles_Scripts();
33
+
34
+ add_action('wp_enqueue_scripts', array( $add_styles_scripts, 'ccw_register_files' ) );
35
36
+ endif; // END class_exists check
inc/{chatbot-mobile.php → class-ccw-chatbot-mobile.php} RENAMED
@@ -1,16 +1,27 @@
1
<?php
2
- /*
3
* chatbot.php and chatbot-mobile.php are identical
4
* but seperated because to choose different style per device
5
* $style_mobile = $GLOBALS["ccw_stylemobile"];
6
*/
7
8
if ( ! defined( 'ABSPATH' ) ) exit;
9
10
- if( ! function_exists('ccw_chatbot') ) {
11
12
- function ccw_chatbot() {
13
14
$enable = $GLOBALS["ccw_enable"];
15
$num = $GLOBALS["ccw_num"];
16
$val = $GLOBALS["ccw_val"];
@@ -86,7 +97,13 @@ if( ! function_exists('ccw_chatbot') ) {
86
require_once('commons/styles.php');
87
88
}
89
}
90
91
- // add_action( 'wp_head', 'ccw_chatbot' );
92
- add_action( 'wp_footer', 'ccw_chatbot' );
1
<?php
2
+ /**
3
* chatbot.php and chatbot-mobile.php are identical
4
* but seperated because to choose different style per device
5
* $style_mobile = $GLOBALS["ccw_stylemobile"];
6
+ *
7
+ * @package ccw
8
+ * @since 1.0
9
*/
10
11
if ( ! defined( 'ABSPATH' ) ) exit;
12
13
+ if ( !class_exists( 'CCW_Chatbot_Mobile' ) ) :
14
15
+ class CCW_Chatbot_Mobile {
16
17
+
18
+ /**
19
+ * Display - styles for mobile devices
20
+ *
21
+ * @since 1.0
22
+ */
23
+ function chatbot_mobile() {
24
+
25
$enable = $GLOBALS["ccw_enable"];
26
$num = $GLOBALS["ccw_num"];
27
$val = $GLOBALS["ccw_val"];
97
require_once('commons/styles.php');
98
99
}
100
+
101
}
102
103
+ $chatbot_mobile = new CCW_Chatbot_Mobile();
104
+
105
+
106
+ // add_action( 'wp_head', 'chatbot' );
107
+ add_action( 'wp_footer', array( $chatbot_mobile, 'chatbot_mobile' ) );
108
+
109
+ endif; // END class_exists check
inc/{chatbot.php → class-ccw-chatbot.php} RENAMED
@@ -1,14 +1,25 @@
1
<?php
2
- /*
3
* chatbot.php and chatbot-mobile.php are identical
4
* but seperated because to choose different style per device
5
*/
6
7
if ( ! defined( 'ABSPATH' ) ) exit;
8
9
- if( ! function_exists('ccw_chatbot') ) {
10
11
- function ccw_chatbot() {
12
13
$enable = $GLOBALS["ccw_enable"];
14
$num = $GLOBALS["ccw_num"];
@@ -84,8 +95,14 @@ if( ! function_exists('ccw_chatbot') ) {
84
require_once('commons/styles.php');
85
86
}
87
}
88
89
90
- // add_action( 'wp_head', 'ccw_chatbot' );
91
- add_action( 'wp_footer', 'ccw_chatbot' );
1
<?php
2
+ /**
3
* chatbot.php and chatbot-mobile.php are identical
4
* but seperated because to choose different style per device
5
+ *
6
+ * @package ccw
7
+ * @since 1.0
8
*/
9
10
if ( ! defined( 'ABSPATH' ) ) exit;
11
12
+ if ( !class_exists( 'CCW_Chatbot' ) ) :
13
+
14
+ class CCW_Chatbot {
15
16
+
17
+ /**
18
+ * Display - styles for Desktop devices ( non mobile devices )
19
+ *
20
+ * @since 1.0
21
+ */
22
+ function chatbot() {
23
24
$enable = $GLOBALS["ccw_enable"];
25
$num = $GLOBALS["ccw_num"];
95
require_once('commons/styles.php');
96
97
}
98
+
99
}
100
101
102
+ $chatbot = new CCW_Chatbot();
103
+
104
+
105
+ // add_action( 'wp_head', 'chatbot' );
106
+ add_action( 'wp_footer', array( $chatbot, 'chatbot' ) );
107
+
108
+ endif; // END class_exists check
inc/{first.php → class-ccw-first.php} RENAMED
@@ -1,53 +1,49 @@
1
<?php
2
- /*
3
* After the initial file loaded this file is loaded first
4
* three function - while actiavte , deactivate , uninstall( while deleting )
5
* as plan to preserve the database options which usefull when reinstall plugin/ update
6
* so that setting wont last
7
* and as no custom post types or so.. to flush rewrite rules
8
* so deactivate, uninstall not doing any thing here
9
*/
10
11
-
12
if ( ! defined( 'ABSPATH' ) ) exit;
13
14
- // when plugin activate
15
- if( ! function_exists('ccw_activation_plugin') ) {
16
17
- function ccw_activation_plugin() {
18
19
// add default values to options db
20
- require_once( dirname(dirname(__FILE__)) . '/admin/default-values.php' );
21
-
22
}
23
- }
24
-
25
-
26
- // when plugin deactivate
27
- if( ! function_exists('ccw_deactivate_plugin') ) {
28
29
- function ccw_deactivate_plugin() {
30
}
31
- }
32
33
- // when plugin uninstall
34
- if( ! function_exists('ccw_uninstall_plugin') ) {
35
-
36
- function ccw_uninstall_plugin() {
37
}
38
- }
39
40
-
41
- // for plugin updates - run on plugins_loaded
42
- if( ! function_exists('ccw_plugin_version_check') ) {
43
-
44
- function ccw_plugin_version_check() {
45
46
$ccw_plugin_details = get_option('ccw_plugin_details');
47
48
if ( CCW_VERSION !== $ccw_plugin_details['version'] ) {
49
// to update the plugin - just like activate plugin
50
- ccw_activation_plugin();
51
}
52
}
53
- }
1
<?php
2
+ /**
3
* After the initial file loaded this file is loaded first
4
* three function - while actiavte , deactivate , uninstall( while deleting )
5
* as plan to preserve the database options which usefull when reinstall plugin/ update
6
* so that setting wont last
7
* and as no custom post types or so.. to flush rewrite rules
8
* so deactivate, uninstall not doing any thing here
9
+ *
10
+ * @package ccw
11
+ * @since 1.0
12
*/
13
14
if ( ! defined( 'ABSPATH' ) ) exit;
15
16
+ if ( !class_exists( 'CCW_first' ) ) :
17
18
+ class CCW_first {
19
20
+ // when plugin activate
21
+ public static function activate() {
22
// add default values to options db
23
+ require_once( CCW_PLUGIN_DIR . '/admin/default-values.php' );
24
}
25
26
+ // when plugin deactivate
27
+ public static function deactivate() {
28
}
29
30
+ // when plugin uninstall
31
+ public static function uninstall() {
32
}
33
34
+ // for plugin updates - run on plugins_loaded
35
+ public static function version_check() {
36
37
$ccw_plugin_details = get_option('ccw_plugin_details');
38
39
if ( CCW_VERSION !== $ccw_plugin_details['version'] ) {
40
// to update the plugin - just like activate plugin
41
+ self::activate();
42
+
43
}
44
}
45
+
46
+
47
+ }
48
+
49
+ endif; // END class_exists check
inc/{shortcode.php → class-ccw-shortcode.php} RENAMED
@@ -1,15 +1,20 @@
1
<?php
2
- /*
3
* shortcodes
4
* base shorcode name is [chat]
5
* for list of attribute support check -> shortcode_atts ( $a )
6
*/
7
8
if ( ! defined( 'ABSPATH' ) ) exit;
9
10
- if( ! function_exists('ccw_shortcode') ) {
11
12
- function ccw_shortcode($atts = [], $content = null, $shortcode = '') {
13
14
$enable_sc = $GLOBALS["ccw_enable_sc"];
15
$global_num = $GLOBALS["ccw_num"];
@@ -401,16 +406,21 @@ if( ! function_exists('ccw_shortcode') ) {
401
return $o;
402
403
}
404
- }
405
-
406
407
-
408
- // Register shortcode
409
- if( ! function_exists('ccw_shortcodes_init') ) {
410
411
function ccw_shortcodes_init() {
412
- // add_shortcode('chat', 'ccw_shortcode');
413
- add_shortcode($GLOBALS["ccw_shortcode"], 'ccw_shortcode');
414
}
415
}
416
- add_action('init', 'ccw_shortcodes_init');
1
<?php
2
+ /**
3
* shortcodes
4
* base shorcode name is [chat]
5
* for list of attribute support check -> shortcode_atts ( $a )
6
+ *
7
+ * @package ccw
8
+ * @since 1.0
9
*/
10
11
if ( ! defined( 'ABSPATH' ) ) exit;
12
13
+ if ( !class_exists( 'CCW_Shortcode' ) ) :
14
15
+ class CCW_Shortcode {
16
+
17
+ function shortcode($atts = [], $content = null, $shortcode = '') {
18
19
$enable_sc = $GLOBALS["ccw_enable_sc"];
20
$global_num = $GLOBALS["ccw_num"];
406
return $o;
407
408
}
409
410
411
+
412
+ // Register shortcode
413
function ccw_shortcodes_init() {
414
+ // add_shortcode('chat', 'shortcode');
415
+ add_shortcode($GLOBALS["ccw_shortcode"], array( $this, 'shortcode' ) );
416
}
417
+
418
+
419
}
420
+
421
+
422
+ $shortcode = new CCW_Shortcode();
423
+
424
+ add_action('init', array( $shortcode, 'ccw_shortcodes_init' ) );
425
+
426
+ endif; // END class_exists check
inc/commons/positions.php CHANGED
@@ -1,7 +1,10 @@
1
<?php
2
- /*
3
* get Positions
4
* used on - chatbot.php, chatbot-mobile.php
5
*/
6
7
if ( ! defined( 'ABSPATH' ) ) exit;
1
<?php
2
+ /**
3
* get Positions
4
* used on - chatbot.php, chatbot-mobile.php
5
+ *
6
+ * @package ccw
7
+ * @since 1.0
8
*/
9
10
if ( ! defined( 'ABSPATH' ) ) exit;
inc/commons/styles.php CHANGED
@@ -1,7 +1,10 @@
1
<?php
2
- /*
3
* List of Styles
4
* used on - chatbot.php, chatbot-mobile.php
5
*/
6
7
if ( ! defined( 'ABSPATH' ) ) exit;
1
<?php
2
+ /**
3
* List of Styles
4
* used on - chatbot.php, chatbot-mobile.php
5
+ *
6
+ * @package ccw
7
+ * @since 1.0
8
*/
9
10
if ( ! defined( 'ABSPATH' ) ) exit;
inc/commons/variables.php CHANGED
@@ -1,8 +1,11 @@
1
<?php
2
- /*
3
* Global Variables
4
* One more Global Variable specified in is-mobile.php
5
* One more Global Variable used in shortcode.php
6
*/
7
8
if ( ! defined( 'ABSPATH' ) ) exit;
1
<?php
2
+ /**
3
* Global Variables
4
* One more Global Variable specified in is-mobile.php
5
* One more Global Variable used in shortcode.php
6
+ *
7
+ * @package ccw
8
+ * @since 1.0
9
*/
10
11
if ( ! defined( 'ABSPATH' ) ) exit;
inc/is-mobile.php CHANGED
@@ -1,7 +1,10 @@
1
<?php
2
- /*
3
* calling a global varibale tell that this is a mobile device or not
4
* but at whatsapp-url this is not worked as that page redirects
5
*/
6
7
if ( ! defined( 'ABSPATH' ) ) exit;
1
<?php
2
+ /**
3
* calling a global varibale tell that this is a mobile device or not
4
* but at whatsapp-url this is not worked as that page redirects
5
+ *
6
+ * @package ccw
7
+ * @since 1.0
8
*/
9
10
if ( ! defined( 'ABSPATH' ) ) exit;
inc/whatsapp-url-group.php CHANGED
@@ -1,9 +1,12 @@
1
<?php
2
- /*
3
* when user click on items this page will load
4
* and here settings added as where to navigate
5
* but at some place added navigation using onclick
6
* at shorcode.php -> attribute for shortcode - > img_click_link
7
*/
8
9
require_once( explode( "wp-content" , __FILE__ )[0] . "wp-load.php" );
1
<?php
2
+ /**
3
* when user click on items this page will load
4
* and here settings added as where to navigate
5
* but at some place added navigation using onclick
6
* at shorcode.php -> attribute for shortcode - > img_click_link
7
+ *
8
+ * @package ccw
9
+ * @since 1.0
10
*/
11
12
require_once( explode( "wp-content" , __FILE__ )[0] . "wp-load.php" );
inc/whatsapp-url.php CHANGED
@@ -1,5 +1,5 @@
1
<?php
2
- /*
3
* when user click on items this page will load
4
* and here settings added as where to navigate
5
* but at some place added navigation using onclick
@@ -8,6 +8,9 @@
8
* $subject , $is_mobile - if value exists then it use, if not then rest works.
9
* $subject i.e. post subject - it works for style-1 form action ..
10
* $is_mobile get value if it is a mobile device or tab ..
11
*/
12
13
require_once( explode( "wp-content" , __FILE__ )[0] . "wp-load.php" );
1
<?php
2
+ /**
3
* when user click on items this page will load
4
* and here settings added as where to navigate
5
* but at some place added navigation using onclick
8
* $subject , $is_mobile - if value exists then it use, if not then rest works.
9
* $subject i.e. post subject - it works for style-1 form action ..
10
* $is_mobile get value if it is a mobile device or tab ..
11
+ *
12
+ * @package ccw
13
+ * @since 1.0
14
*/
15
16
require_once( explode( "wp-content" , __FILE__ )[0] . "wp-load.php" );
readme.txt CHANGED
@@ -13,69 +13,88 @@ Let's make your Web page visitors Contact you through WhatsApp with a single cli
13
== Description ==
14
Let's make your Web page visitors Contact you through WhatsApp with a single click
15
16
- Documentation: https://medium.com/clicktochat
17
- Demo, Examples: https://venkat.club/
18
19
- There are Eight Styles
20
21
There are eight Styles to select
22
23
- 1. ** Style-1:** Input field, where user can enter text and click send to navigate to WhatsApp page with text
24
- 1. ** Style-2:** Plan text with a link to WhatsApp
25
- 1. ** Style-3:** It's a WhatsApp logo, where user can click on the logo to navigate to WhatsApp Page or App
26
- 1. ** Style-4:** It's a combination of WhatsApp logo and a text message - Generally called as Chip
27
- 1. ** Style-5:** plain WhatApp icon - can customize color, height
28
- 1. ** Style-6:** Icon with Circle border
29
- 1. ** Style-7:** Icon with box border
30
- 1. ** Style-8:** Button with text, icon
31
32
- When the user clicks an item:
33
34
If website loads on a Mobile device and if WhatsApp is installed on that device, it will directly navigate to WhatsApp App.
35
36
- If website loads in web browsers it will navigate to WhatsApp Web page
37
38
39
- Shortcodes:
40
41
- Can add styles with in line of your post content
42
- By default, Shortcodes take value from what saved in your plugin settings pages, if need to change for a shortcode alone, can add attributes with in shortcode
43
44
- [chat]
45
46
- To Change number for a shortcode
47
48
- [chat num=911234567890]
49
50
- To change Style
51
52
- [chat style=1]
53
54
- To Change Style, Number
55
-
56
- [chat style=2 num=911234567890]
57
-
58
- To change the display text value ( for style-1, style-2, style-4, style-8 )
59
-
60
- [chat val='chat with CEO' num=10123456789]
61
-
62
- Add Shortcodes in Widget Area
63
64
Add a text widget in widget area, and then add shortcode with in that text widget
65
66
67
-
68
== Installation ==
69
- unzip Click-to-Chat file and
70
- Upload "Click-to-Chat" folder to the "/wp-content/plugins/" directory.
71
- Activate the plugin through the "Plugins" menu in WordPress.
72
73
74
== Changelog ==
75
- = 1.0.0 =
76
* Initial release.
77
78
79
== WhatsApp icon, logo image ==
80
WhatsApp logo with file name WhatsApp_logo_12.png
81
with in assets/img is downloaded from https://www.whatsappbrand.com/
13
== Description ==
14
Let's make your Web page visitors Contact you through WhatsApp with a single click
15
16
+ [Documentation, Demo, Examples](https://venkat.club/)
17
+ [settings fields doc](https://medium.com/clicktochat) - it easy, with out this doc, to change setting, but added for more info.
18
19
+ = There are Eight Styles =
20
21
There are eight Styles to select
22
23
+ 1. **Style-1:** Input field, where user can enter text and click send to navigate to WhatsApp page with text
24
+ 1. **Style-2:** Plan text with a link to WhatsApp
25
+ 1. **Style-3:** It's a WhatsApp logo, where user can click on the logo to navigate to WhatsApp Page or App
26
+ 1. **Style-4:** It's a combination of WhatsApp logo and a text message - Generally called as Chip
27
+ 1. **Style-5:** plain WhatsApp icon - can customize color, height
28
+ 1. **Style-6:** Icon with Circle border
29
+ 1. **Style-7:** Icon with box border
30
+ 1. **Style-8:** Button with text, icon
31
32
+ = When user clicks an item: =
33
34
If website loads on a Mobile device and if WhatsApp is installed on that device, it will directly navigate to WhatsApp App.
35
36
+ If website loads in web browsers it will navigate to WhatsApp Webpage
37
38
39
+ = Shortcodes: =
40
41
+ Can add styles within line of your post content
42
+ By default, Shortcodes take value from what saved in your plugin settings pages, if need to change for a shortcode alone, can add attributes within shortcode
43
44
+ **[chat]**
45
46
+ **[chat num=911234567890]** - To Change number for a shortcode
47
48
+ **[chat style=1]** - To change Style
49
50
+ **[chat style=2 num=911234567890]** - To Change Style, Number
51
52
+ **[chat val='chat with CEO' num=10123456789]** - To change the display text value ( for style-1, style-2, style-4, style-8 )
53
54
+ = Add Shortcodes in Widget Area =
55
56
Add a text widget in widget area, and then add shortcode with in that text widget
57
58
59
== Installation ==
60
61
+ = using FTP or similar =
62
+ * unzip Click-to-Chat file and
63
+ * Upload "Click-to-Chat" folder to the "/wp-content/plugins/" directory.
64
+ * Activate the plugin through the "Plugins" menu in WordPress.
65
+
66
+ = From Dashboard ( WordPress admin ) =
67
+ * plugins -> Add New
68
+ * search for 'click to chat for whatsapp'
69
+ * click on Install Now and then Active.
70
71
== Changelog ==
72
+
73
+ = 1.1 =
74
+ * convert plugin to bit of OOP style
75
+
76
+ = 1.0 =
77
* Initial release.
78
79
80
+ == screenshots ==
81
+
82
+ 1. List of Style 1 to 4
83
+ 1. List of Style 5 to 8
84
+ 1. Global Setting page
85
+ 1. Global Setting page
86
+ 1. Style each Styles
87
+ 1. can add shortcodes in Text Widget
88
+ 1. example - shortcodes
89
+ 1. Style - 1 - Input field
90
+ 1. Style - 2 - plain link
91
+ 1. Style - 3 - WhatsApp logo
92
+ 1. Style - 4 - Chip
93
+ 1. Style - 5 - icon
94
+ 1. Style - 6 - icon with circle border
95
+ 1. Style - 7 - icon with box border
96
+ 1. Style - 8 - button
97
+
98
== WhatsApp icon, logo image ==
99
WhatsApp logo with file name WhatsApp_logo_12.png
100
with in assets/img is downloaded from https://www.whatsappbrand.com/