PluginProbe
Survey Maker by AYS / 5.2.3.0
Survey Maker by AYS v5.2.3.0
5.2.4.1 5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 All 154 releases
survey-maker / includes / class-survey-maker-ays-welcome.php

class-survey-maker-ays-welcome.php in Survey Maker by AYS 5.2.3.0, at includes/class-survey-maker-ays-welcome.php

206 lines 7.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Survey_Maker_Ays_Welcome {
4
5 /**
6 * Hidden welcome page slug.
7 *
8 * @since 4.6.4
9 */
10 const SLUG = 'survey-maker-getting-started';
11
12 /**
13 * Primary class constructor.
14 *
15 * @since 4.6.4
16 */
17 public function __construct() {
18 add_action( 'plugins_loaded', [ $this, 'hooks' ] );
19 }
20
21 public function hooks() {
22 add_action( 'admin_menu', [ $this, 'register' ] );
23 add_action( 'admin_head', [ $this, 'hide_menu' ] );
24 add_action( 'admin_init', [ $this, 'redirect' ], 9999 );
25 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] );
26 // add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );s
27 }
28
29 /**
30 * Register the pages to be used for the Welcome screen (and tabs).
31 *
32 * These pages will be removed from the Dashboard menu, so they will
33 * not actually show. Sneaky, sneaky.
34 *
35 * @since 1.0.0
36 */
37 public function register() {
38 add_dashboard_page(
39 esc_html__( 'Welcome to Survey Maker', "survey-maker" ),
40 esc_html__( 'Welcome to Survey Maker', "survey-maker" ),
41 'manage_options',
42 self::SLUG,
43 [ $this, 'output' ]
44 );
45 }
46
47 /**
48 * Removed the dashboard pages from the admin menu.
49 *
50 * This means the pages are still available to us, but hidden.
51 *
52 * @since 4.6.4
53 */
54 public function hide_menu() {
55
56 remove_submenu_page( 'index.php', self::SLUG );
57 }
58
59 /**
60 * Welcome screen redirect.
61 *
62 * This function checks if a new install or update has just occurred. If so,
63 * then we redirect the user to the appropriate page.
64 *
65 * @since 4.6.4
66 */
67 public function redirect() {
68
69 $current_page = isset( $_GET['page'] ) ? $_GET['page'] : '';
70
71 // Check if we are already on the welcome page.
72 // if ( $current_page === self::SLUG ) {
73 // return;
74 // }
75
76 $terms_activation = get_option('survey_maker_show_agree_terms');
77 $first_activation = get_option('survey_maker_first_time_activation_page', false);
78
79
80 if($current_page === self::SLUG && $terms_activation && $terms_activation == 'hide'){
81 wp_safe_redirect( admin_url( 'admin.php?page=survey-maker' ) );
82 }
83
84 if(isset($_POST['survey_maker_agree_terms']) && $_POST['survey_maker_agree_terms'] === 'agree'){
85 $this->ays_survey_request( 'agree' );
86 update_option('survey_maker_agree_terms', 'true');
87 update_option('survey_maker_show_agree_terms', 'hide');
88 wp_safe_redirect( admin_url( 'admin.php?page=survey-maker' ) );
89 }
90
91 if(isset($_POST['survey_maker_cancel_terms']) && $_POST['survey_maker_cancel_terms'] === 'cancel'){
92 $this->ays_survey_request( 'cancel' );
93 update_option('survey_maker_agree_terms', 'false');
94 update_option('survey_maker_show_agree_terms', 'hide');
95 wp_safe_redirect( admin_url( 'admin.php?page=survey-maker' ) );
96 }
97
98 if($current_page === self::SLUG){
99 return;
100 }
101 if ( isset($_GET['page']) && strpos($_GET['page'], SURVEY_MAKER_NAME) !== false && !$terms_activation && $first_activation) {
102 wp_safe_redirect( admin_url( 'index.php?page=' . self::SLUG ) );
103 exit;
104 }
105
106 }
107
108 /**
109 * Enqueue custom CSS styles for the welcome page.
110 *
111 * @since 4.6.4
112 */
113 public function enqueue_styles() {
114 wp_enqueue_style(
115 'survey-maker-welcome-css',
116 esc_url(SURVEY_MAKER_ADMIN_URL) . '/css/survey-maker-welcome.css',
117 array(), false, 'all');
118 }
119
120 /**
121 * Register the JavaScript for the welcome page.
122 *
123 * @since 4.6.4
124 */
125 // public function enqueue_scripts() {
126
127 // wp_enqueue_script( 'survey-maker-tu-data', esc_url(SURVEY_MAKER_ADMIN_URL) . '/js/extras/survey-maker-tu-data.js', array('jquery'), false, true);
128 // }
129
130 /**
131 * Getting Started screen. Shows after first install.
132 *
133 * @since 1.0.0
134 */
135 public function output() {
136 ?>
137 <style>
138 #wpcontent {
139 padding-left: 0 !important;
140 position: relative;
141 }
142 #ays-survey-new-mega-bundle-dicount-month-main,
143 .ays-notice-banner,
144 #wpfooter,
145 #wpbody-content .ays_ask_question_content{
146 display: none;
147 }
148 </style>
149 <form method="POST">
150 <div id="survey-maker-welcome">
151 <div class="survey-maker-welcome-container">
152 <div class="survey-maker-welcome-intro">
153 <div class="survey-maker-welcome-logo">
154 <img src="<?php echo esc_url(SURVEY_MAKER_ADMIN_URL); ?>/images/icon-survey-128x128.png" alt="<?php echo esc_html__( 'Survey Maker Logo', "survey-maker" ); ?>">
155 </div>
156 <div class="survey-maker-welcome-block">
157 <h1><?php echo esc_html__( 'Thank you for using Survey Maker plugin !', "survey-maker" ); ?></h1>
158 <h6><?php echo esc_html__( 'To enhance the user experience of our product, we would like to request permission to track certain user interactions. Please rest assured that this tracking will be minimal and will only involve non-sensitive actions, such as specific clicks within the interface. No personal or sensitive data will be collected.', "survey-maker" ); ?></h6>
159 <h6 style="margin-top: 20px;"><?php echo esc_html__( 'Our goal is solely to improve the functionality and usability of the product based on user behavior.', "survey-maker" ); ?></h6>
160 </div>
161 <div class="survey-maker-welcome-block-buttons">
162 <div class="survey-maker-welcome-button-wrap survey-maker-clear">
163 <div class="survey-maker-welcome-left">
164 <button
165 class="survey-maker-tu-cancel"
166 type="submit"
167 name="survey_maker_cancel_terms"
168 value="cancel">
169 <?php echo esc_html__( 'Cancel', "survey-maker" ); ?>
170 </button>
171 </div>
172 <div class="survey-maker-welcome-right">
173 <button class="survey-maker-tu-agree" target="_blank" type="submit" name="survey_maker_agree_terms" value="agree">
174 <?php echo esc_html__( 'Agree & continue', "survey-maker" ); ?>
175 </button>
176 </div>
177 </div>
178 </div>
179 </div>
180 </div>
181 </div>
182 </form>
183 <?php
184 // update_option('ays_survey_maker_first_time_activation_page', false);
185 }
186
187 public function ays_survey_request($cta){
188 $curl = curl_init();
189
190 $api_url = "https://poll-plugin.com/survey-maker/";
191
192 $data = array(
193 'type' => 'survey-maker',
194 'cta' => $cta,
195 );
196
197 wp_remote_post( $api_url, array(
198 'timeout' => 30,
199 'body' => wp_json_encode(array(
200 'type' => 'survey-maker',
201 'cta' => $cta,
202 )),
203 ) );
204 }
205 }
206 //new Survey_Maker_Ays_Welcome();