22
33namespace BitApps \WPTelemetry \Telemetry \Feedback ;
44
5- use BitApps \WPTelemetry \Telemetry \Client ;
5+ use BitApps \WPTelemetry \Telemetry \Telemetry ;
6+ use BitApps \WPTelemetry \Telemetry \TelemetryConfig ;
67
78class Feedback
89{
9- private $ client ;
10-
11- public function __construct (Client $ client )
12- {
13- $ this ->client = $ client ;
14-
15- $ this ->init ();
16- }
17-
1810 public function init ()
1911 {
20- add_action ('wp_ajax_ ' . $ this -> client -> prefix . 'deactivate_feedback ' , [$ this , 'handleDeactivateFeedback ' ]);
12+ add_action ('wp_ajax_ ' . TelemetryConfig:: getPrefix () . 'deactivate_feedback ' , [$ this , 'handleDeactivateFeedback ' ]);
2113
2214 add_action ('current_screen ' , [$ this , 'loadAllScripts ' ]);
2315 }
@@ -43,8 +35,8 @@ public function enqueueFeedbackDialogScripts()
4335 add_action ('admin_footer ' , [$ this , 'printDeactivateFeedbackDialog ' ]);
4436
4537 $ cssFilePath = $ this ->getAssetPath () . 'resources/css/deactivateModalStyle.css ' ;
46- wp_register_style ($ this -> client -> prefix . 'deactivate_modal ' , $ cssFilePath , [], $ this -> client -> version );
47- wp_enqueue_style ($ this -> client -> prefix . 'deactivate_modal ' );
38+ wp_register_style (TelemetryConfig:: getPrefix () . 'deactivate_modal ' , $ cssFilePath , [], TelemetryConfig:: getVersion () );
39+ wp_enqueue_style (TelemetryConfig:: getPrefix () . 'deactivate_modal ' );
4840 }
4941
5042 public static function getAssetPath ()
@@ -61,10 +53,10 @@ public static function getAssetPath()
6153 */
6254 public function printDeactivateFeedbackDialog ()
6355 {
64- $ this -> client -> view ('deactivateModal ' , [
65- 'slug ' => $ this -> client -> slug ,
66- 'prefix ' => $ this -> client -> prefix ,
67- 'title ' => $ this -> client -> title ,
56+ Telemetry:: view ('deactivateModal ' , [
57+ 'slug ' => TelemetryConfig:: getSlug () ,
58+ 'prefix ' => TelemetryConfig:: getPrefix () ,
59+ 'title ' => TelemetryConfig:: getTitle () ,
6860 'reasons ' => $ this ->getDeactivateReasons (),
6961 ]);
7062 }
@@ -73,37 +65,37 @@ public function getDeactivateReasons()
7365 {
7466 $ reasons = [
7567 'found_a_better_plugin ' => [
76- 'title ' => esc_html__ ('Found a better plugin ' , $ this -> client -> slug ),
77- 'placeholder ' => esc_html__ ('Which plugin? ' , $ this -> client -> slug ),
68+ 'title ' => esc_html__ ('Found a better plugin ' , TelemetryConfig:: getSlug () ),
69+ 'placeholder ' => esc_html__ ('Which plugin? ' , TelemetryConfig:: getSlug () ),
7870 ],
7971 'missing_specific_feature ' => [
80- 'title ' => esc_html__ ('Missing a specific feature ' , $ this -> client -> slug ),
81- 'placeholder ' => esc_html__ ('Could you tell us more about that feature? ' , $ this -> client -> slug ),
72+ 'title ' => esc_html__ ('Missing a specific feature ' , TelemetryConfig:: getSlug () ),
73+ 'placeholder ' => esc_html__ ('Could you tell us more about that feature? ' , TelemetryConfig:: getSlug () ),
8274 ],
8375 'not_working ' => [
84- 'title ' => esc_html__ ('Not working ' , $ this -> client -> slug ),
85- 'placeholder ' => esc_html__ ('Could you tell us what is not working? ' , $ this -> client -> slug ),
76+ 'title ' => esc_html__ ('Not working ' , TelemetryConfig:: getSlug () ),
77+ 'placeholder ' => esc_html__ ('Could you tell us what is not working? ' , TelemetryConfig:: getSlug () ),
8678 ],
8779 'not_working_as_expected ' => [
88- 'title ' => esc_html__ ('Not working as expected ' , $ this -> client -> slug ),
89- 'placeholder ' => esc_html__ ('Could you tell us what do you expect? ' , $ this -> client -> slug ),
80+ 'title ' => esc_html__ ('Not working as expected ' , TelemetryConfig:: getSlug () ),
81+ 'placeholder ' => esc_html__ ('Could you tell us what do you expect? ' , TelemetryConfig:: getSlug () ),
9082 ],
9183 'temporary_deactivation ' => [
92- 'title ' => esc_html__ ('It \'s a temporary deactivation ' , $ this -> client -> slug ),
84+ 'title ' => esc_html__ ('It \'s a temporary deactivation ' , TelemetryConfig:: getSlug () ),
9385 'placeholder ' => '' ,
9486 ],
95- $ this -> client -> prefix . 'pro ' => [
96- 'title ' => esc_html__ ('I have ' . $ this -> client -> title . ' Pro ' , $ this -> client -> slug ),
87+ TelemetryConfig:: getPrefix () . 'pro ' => [
88+ 'title ' => esc_html__ ('I have ' . TelemetryConfig:: getTitle () . ' Pro ' , TelemetryConfig:: getSlug () ),
9789 'placeholder ' => '' ,
98- 'alert ' => esc_html__ ('Wait! Don \'t deactivate ' . $ this -> client -> title . '. You have to activate both ' . $ this -> client -> title . ' and ' . $ this -> client -> title . ' Pro in order to work the plugin. ' , $ this -> client -> slug ),
90+ 'alert ' => esc_html__ ('Wait! Don \'t deactivate ' . TelemetryConfig:: getTitle () . '. You have to activate both ' . TelemetryConfig:: getTitle () . ' and ' . TelemetryConfig:: getTitle () . ' Pro in order to work the plugin. ' , TelemetryConfig:: getSlug () ),
9991 ],
10092 'other ' => [
101- 'title ' => esc_html__ ('Other ' , $ this -> client -> slug ),
102- 'placeholder ' => esc_html__ ('Please share the reason ' , $ this -> client -> slug ),
93+ 'title ' => esc_html__ ('Other ' , TelemetryConfig:: getSlug () ),
94+ 'placeholder ' => esc_html__ ('Please share the reason ' , TelemetryConfig:: getSlug () ),
10395 ],
10496 ];
10597
106- return apply_filters ($ this -> client -> prefix . 'deactivate_reasons ' , $ reasons, $ this -> client );
98+ return apply_filters (TelemetryConfig:: getPrefix () . 'deactivate_reasons ' , $ reasons );
10799 }
108100
109101 /**
@@ -119,20 +111,20 @@ public function handleDeactivateFeedback()
119111 return ;
120112 }
121113
122- if (!wp_verify_nonce (sanitize_key (wp_unslash ($ _POST ['_ajax_nonce ' ])), $ this -> client -> prefix . 'nonce ' )) {
114+ if (!wp_verify_nonce (sanitize_key (wp_unslash ($ _POST ['_ajax_nonce ' ])), TelemetryConfig:: getPrefix () . 'nonce ' )) {
123115 wp_send_json_error ('Nonce verification failed ' );
124116 }
125117
126118 if (!current_user_can ('activate_plugins ' )) {
127119 wp_send_json_error ('Permission denied ' );
128120 }
129121
130- $ report = $ this -> client -> report -> getTrackingData () ;
122+ $ report = [] ;
131123 $ report ['site_lang ' ] = get_bloginfo ('language ' );
132124 $ report ['feedback_key ' ] = sanitize_text_field (wp_unslash ($ _POST ['reason_key ' ])) ?: null ;
133125 $ report ['feedback ' ] = sanitize_text_field (wp_unslash ($ _POST ["reason_ {$ report ['feedback_key ' ]}" ])) ?: null ;
134126
135- $ this -> client -> sendReport ('deactivate-reason ' , $ report );
127+ Telemetry:: sendReport ('deactivate-reason ' , $ report );
136128
137129 wp_send_json_success ();
138130 }
0 commit comments