PluginProbe ʕ •ᴥ•ʔ
Atarim – Visual Feedback, Review & AI Collaboration / 3.5
Atarim – Visual Feedback, Review & AI Collaboration v3.5
trunk 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 3.2.0 3.2.1 3.22 3.22.1 3.22.2 3.22.3 3.22.4 3.22.5 3.22.6 3.3.0 3.3.1 3.3.2 3.3.2.1 3.3.2.2 3.3.3 3.30 3.31 3.32 3.4 3.4.1 3.4.3 3.4.4 3.5 3.5.1 3.6 3.6.1 3.7 3.8 3.9 3.9.1 3.9.2 3.9.3 3.9.4 3.9.6 3.9.6.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2 4.2.1 4.2.2 4.3 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.4
atarim-visual-collaboration / wpfeedback.php
atarim-visual-collaboration Last commit date
cache 3 years ago css 3 years ago graphics 3 years ago images 3 years ago inc 3 years ago js 3 years ago languages 3 years ago src 3 years ago changelog.txt 3 years ago imagehelper.php 3 years ago index.php 3 years ago license.txt 3 years ago readme.txt 3 years ago uninstall.php 3 years ago wpfeedback.php 3 years ago
wpfeedback.php
2849 lines
1 <?php
2 /**
3 * Plugin Name: Atarim - Client Interface
4 * Description: Atarim is a client-focused agency management platform to help simplify collaboration and get things done fast.
5 *
6 * Version: 3.5
7 * Requires at least: 5.0
8 * Update URI: https://wordpress.org/plugins/atarim-visual-collaboration/
9 *
10 * Author: Atarim
11 * Author URI: https://atarim.io/
12 *
13 * Text Domain: atarim
14 * Domain Path: /languages/
15 *
16 * License: GPL-3.0-or-later
17 *
18 * @author Atarim <support@atarim.io>
19 * @copyright 2021 Atarim
20 * @license GPL-3.0-or-later
21 * @package Atarim
22 */
23
24 /**
25 * If this file is called directly, abort.
26 */
27 if ( ! defined( 'WPINC' ) ) {
28 die;
29 }
30 if ( ! defined( 'WPF_PLUGIN_NAME' ) ) {
31 define( 'WPF_PLUGIN_NAME', trim( dirname( plugin_basename( __FILE__ ) ), '/' ) );
32 }
33 if ( ! defined( 'WPF_PLUGIN_DIR' ) ) {
34 define( 'WPF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
35 }
36 if ( ! defined( 'WPF_PLUGIN_URL' ) ) {
37 define( 'WPF_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
38 }
39 if ( ! defined( 'WPF_VERSION' ) ) {
40 define( 'WPF_VERSION', '3.5' );
41 }
42
43 $site_url = site_url();
44
45 define( 'SCOPER_ALL_UPLOADS_EDITABLE ', true );
46
47
48 if ( ! defined( 'WPF_SITE_URL' ) ) {
49 define( 'WPF_SITE_URL', $site_url );
50 }
51
52 // this is the URL our updater / license checker pings. This should be the URL of the site with EDD installed.
53 define( 'WPF_EDD_SL_STORE_URL', 'https://atarim.io' ); // IMPORTANT: change the name of this constant to something unique to prevent conflicts with other plugins using this system.
54 // the download ID. This is the ID of your product in EDD and should match the download ID visible in your Downloads list (see example below).
55 define( 'WPF_EDD_SL_ITEM_ID', get_option( 'wpf_prod_id' ) ); // IMPORTANT: change the name of this constant to something unique to prevent conflicts with other plugins using this system.
56 define( 'WPF_EDD_FALLBACK_URL', 'https://verify.wpfeedback.co/' );
57
58 // site urls.
59 define( 'WPF_MAIN_SITE_URL', 'https://atarim.io' );
60 define( 'WPF_APP_SITE_URL', 'https://app.atarim.io' );
61 define( 'WPF_LEARN_SITE_URL', 'https://academy.atarim.io' );
62
63 /*
64 * Register hooks that are fired when the plugin is activated or deactivated.
65 * When the plugin is deleted, the uninstall.php file is loaded.
66 */
67 register_activation_hook( __FILE__, array( 'WP_Feedback', 'activate' ) );
68 register_deactivation_hook( __FILE__, array( 'WP_Feedback', 'deactivate' ) );
69
70 function wpb_admin_notice_warn() {
71 $hide = true;
72 $wpf_user_type = wpf_user_type();
73 $is_notice = get_option('wp_feedback_notice', 'true');
74 if ( ! $hide && current_user_can( 'administrator' ) && $wpf_user_type == 'advisor' && $is_notice == 'true' && ! isset( $_GET['page'] ) ) {
75 ?>
76 <div class="notice notice-warning wpf_admin_notice wpf-gftool-notice is-dismissible">
77 <div class="wpf_admin_notice_icon">
78 <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1080 1080">
79 <defs>
80 <style>
81 .cls-1 {
82 fill: #fff;
83 }
84 .cls-2 {
85 fill: #052055;
86 }
87 </style>
88 </defs>
89 <title>Atarim Logo Inverted</title>
90 <g>
91 <g>
92 <polygon class="cls-1" points="937.344 785.955 746.1 856.215 851.972 1060.257 1080 1059.991 937.344 785.955"/>
93 <polygon class="cls-1" points="539.938 19.669 0 1059.991 228.152 1059.991 539.873 458.766 652.263 675.369 843.507 605.108 539.938 19.669"/>
94 </g>
95 <polygon class="cls-2" points="227.659 1060.331 373.967 778.521 1055.074 519.371 227.659 1060.331"/>
96 </g>
97 </svg>
98 </div>
99 <div class="wpf_admin_notice_content">
100 <h4>The Graphic Feedback Tool is moving to the Atarim Dashboard!</h4>
101 <p>Please note that in the next update the ability to add new graphic items and manage your existing items is going to be removed as you will be able to add new graphic items directly inside your Atarim Dashboard - With a few cool new advances. If you already have existing designs, they will still be available through their respective direct URLs.</p>
102 <p class="admin_notice_footer"><i>* This notice is shown to you as the Webmaster.</i></p>
103 </div>
104 </div>
105 <?php
106 }
107 }
108 add_action( 'admin_notices', 'wpb_admin_notice_warn' );
109
110 function wpf_plugin_update_message( $plugin_data, $new_data ) {
111 if( isset( $plugin_data['upgrade_notice'] ) ) {
112 printf(
113 '<div class="update-message">%s
114 <br>
115 Download it from <a href="plugin-install.php?tab=plugin-information&plugin=atarim-visual-collaboration&TB_iframe=true&width=600&height=550" >here</a>
116 </div>',
117 $plugin_data['upgrade_notice']
118 );
119 }
120
121 }
122 add_action( 'in_plugin_update_message-atarim-client-interface/wpfeedback.php', 'wpf_plugin_update_message', 10, 2 );
123
124
125 add_action( 'admin_menu', 'wp_feedback_admin_menu' );
126 /**
127 * Create the admin menu.
128 * This function is used to register the admin menu for the Atarim.
129 *
130 * @input NULL
131 * @return NULL
132 */
133 function wp_feedback_admin_menu() {
134 global $current_user;
135 $wpf_powered_by = get_site_data_by_key( 'wpfeedback_powered_by' );
136
137 $selected_roles = get_site_data_by_key( 'wpf_selcted_role' );
138 $selected_roles = explode( ',', $selected_roles );
139
140 $main_menu_id = 'wpfeedback_page_tasks';
141
142 if ( array_intersect( $current_user->roles, $selected_roles ) || current_user_can( 'administrator' ) ) {
143 $wpf_user_type = wpf_user_type();
144
145 $badge = '';
146 if ( $wpf_powered_by == 'yes' ) {
147 $wpf_main_menu_label = __( 'Collaborate', 'wpfeedback' );
148 $wpf_main_menu_icon = WPF_PLUGIN_URL . 'images/atarim-whitelabel.svg';
149 } else {
150 $wpf_main_menu_label = __( 'Collaborate', 'wpfeedback' );
151 $wpf_main_menu_icon = WPF_PLUGIN_URL . 'images/atarim_favicon_white.svg';
152 }
153 add_menu_page(
154 __( $wpf_main_menu_label, 'wpfeedback' ), __( $wpf_main_menu_label, 'wpfeedback' ) . $badge, 'read', $main_menu_id, $main_menu_id, $wpf_main_menu_icon, 80
155 );
156 add_submenu_page(
157 $main_menu_id, __( 'Tasks Center', 'wpfeedback' ), __( 'Tasks Center', 'wpfeedback' ), 'read', 'wpfeedback_page_tasks', 'wpfeedback_page_tasks'
158 );
159 add_submenu_page(
160 '', __( 'Graphics', 'wpfeedback' ), __( 'Graphics', 'wpfeedback' ), 'read', 'wpfeedback_page_graphics', 'wpfeedback_page_graphics'
161 );
162 if ( $wpf_user_type == 'advisor' || ( $wpf_user_type == '' && current_user_can( 'administrator' ) ) ) {
163 add_submenu_page(
164 $main_menu_id, __( 'Settings', 'wpfeedback' ), __( 'Settings', 'wpfeedback' ), 'read', 'wpfeedback_page_settings', 'wpfeedback_page_settings'
165 );
166 }
167 if ( $wpf_user_type == 'advisor' || ( $wpf_user_type == '' && current_user_can( 'administrator' ) ) ) {
168 add_submenu_page(
169 $main_menu_id, __( 'Permissions', 'wpfeedback' ), __( 'Permissions', 'wpfeedback' ), 'read', 'wpfeedback_page_permissions', 'wpfeedback_page_permissions'
170 );
171 }
172 if ( $wpf_user_type == 'advisor' ) {
173 add_submenu_page(
174 $main_menu_id, __( 'Integrations', 'wpfeedback' ), __( 'Integrations', 'wpfeedback' ), 'read', 'wpfeedback_page_integrate', 'wpfeedback_page_integrate'
175 );
176 }
177
178 if ( $wpf_user_type == 'advisor' || ( $wpf_user_type == '' && current_user_can( 'administrator' ) ) ) {
179 add_submenu_page(
180 $main_menu_id, __( 'Support', 'wpfeedback' ), __( 'Support', 'wpfeedback' ), 'read', 'https://atarim.io/support-reachout'
181 );
182 add_submenu_page(
183 $main_menu_id, __( 'Upgrade', 'wpfeedback' ), __( 'Upgrade', 'wpfeedback' ), 'read', WPF_MAIN_SITE_URL.'/upgrade'
184 );
185 }
186 }
187 }
188
189
190 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wpf_setting_action_links' );
191 /*
192 * This function is used to set the link for the "Settings" menu item.
193 *
194 * @input Array
195 * @return Array
196 */
197 function wpf_setting_action_links( $links ) {
198 $links[] = '<a href="' . esc_url( get_admin_url( null, 'admin.php?page=wpfeedback_page_settings&wpf_setting=1' ) ) . '">' . __( 'Settings', 'wpfeedback' ) . '</a>';
199 return $links;
200 }
201
202 /*
203 * This function is used used to include the page-settings template for the settings menu if the initial onboarding is already or include wpf_backend_initial_setup if not.
204 *
205 * @input NULL
206 * @return NULL
207 */
208 function wpfeedback_page_settings() {
209 global $current_user;
210 $initial_setup = get_site_data_by_key( 'wpf_initial_setup_complete' );
211 //update_option("wpf_initial_setup_complete", 'yes');
212 if ( $initial_setup != 'yes' ) {
213 require_once( WPF_PLUGIN_DIR . 'inc/admin/wpf_backend_initial_setup.php' );
214 } else {
215 require_once( WPF_PLUGIN_DIR . 'inc/admin/page-settings.php' );
216 }
217 }
218
219 /*
220 * This function is used used to include the page-settings template for the tasks menu.
221 *
222 * @input NULL
223 * @return NULL
224 */
225 function wpfeedback_page_tasks() {
226 global $current_user;
227 require_once( WPF_PLUGIN_DIR . 'inc/admin/page-settings.php' );
228 }
229
230 /*
231 * This function is used used to include the page-settings template for the integration menu.
232 *
233 * @input NULL
234 * @return NULL
235 */
236 function wpfeedback_page_integrate() {
237 global $current_user;
238 require_once( WPF_PLUGIN_DIR . 'inc/admin/page-settings.php' );
239 }
240
241 /*
242 * This function is used used to include the page-settings template for the support menu.
243 *
244 * @input NULL
245 * @return NULL
246 */
247 function wpfeedback_page_support() {
248 global $current_user;
249 require_once( WPF_PLUGIN_DIR . 'inc/admin/page-settings.php' );
250 }
251
252 /*
253 * This function is used used to include the page-settings-permissions template for the Permissions menu.
254 *
255 * @input NULL
256 * @return NULL
257 */
258 function wpfeedback_page_permissions() {
259 global $current_user;
260 require_once( WPF_PLUGIN_DIR . 'inc/admin/page-settings-permissions.php' );
261 }
262
263 /*
264 * This function is used used to include the page-settings-graphics template for the graphics menu.
265 *
266 * @input NULL
267 * @return NULL
268 */
269 function wpfeedback_page_graphics() {
270 global $current_user;
271 require_once( WPF_PLUGIN_DIR . 'inc/admin/page-settings-graphics.php' );
272 }
273
274 /*
275 * Require admin functionality
276 */
277 require_once( WPF_PLUGIN_DIR . 'inc/wpf_ajax_functions.php' );
278 require_once( WPF_PLUGIN_DIR . 'inc/wpf_function.php' );
279 require_once( WPF_PLUGIN_DIR . 'inc/wpf_email_notifications.php' );
280 require_once( WPF_PLUGIN_DIR . 'inc/wpf_admin_functions.php' );
281 require_once( WPF_PLUGIN_DIR . 'inc/admin/wpf_admin_function.php' );
282 require_once( WPF_PLUGIN_DIR . 'inc/wpf_api.php' );
283
284 if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
285 // load our custom updater if it doesn't already exist
286 include( dirname( __FILE__ ) . '/inc/EDD_SL_Plugin_Updater.php' );
287 }
288
289 $wpf_image_cache = WPF_PLUGIN_DIR . "cache/";
290 if ( ! file_exists( $wpf_image_cache ) ) {
291 mkdir( $wpf_image_cache, 0777, true );
292 }
293
294 // retrieve our license key from the DB.
295 $wpf_license_key = trim( get_option( 'wpf_license_key' ) );
296 $wpf_decry_key = wpf_crypt_key( $wpf_license_key, 'd' );
297 // setup the updater.
298 $edd_updater = new EDD_SL_Plugin_Updater( WPF_EDD_SL_STORE_URL, __FILE__,
299 array(
300 'version' => WPF_VERSION, // current version number.
301 'license' => $wpf_decry_key, // license key (used get_option above to retrieve from DB).
302 'item_id' => WPF_EDD_SL_ITEM_ID, // id of this plugin.
303 'author' => 'Ace Digital London', // author of this plugin.
304 'url' => WPF_SITE_URL,
305 'beta' => false, // set to true if you wish customers to receive update notifications of beta releases.
306 )
307 );
308
309 add_action( 'init','new_license_activation' );
310 function new_license_activation() {
311
312 /*New license activation*/
313 if ( isset( $_GET['atarim_response'] ) ) {
314 delete_option( 'wpf_decr_checksum' );
315 delete_option( 'wpf_decr_key' );
316 delete_option( 'wpf_license_expires' );
317 delete_option( 'wpf_license' );
318 delete_option( 'wpf_prod_id' );
319 delete_option( 'wpf_license_key' );
320
321 $wpf_license_key = base64_decode( sanitize_text_field( $_GET['license_key'] ) );
322
323 update_option( 'wpf_license', base64_decode( sanitize_text_field( $_GET['atarim_response'] ) ) );
324 update_option( 'wpf_license_expires', base64_decode( sanitize_text_field( $_GET['expires'] ) ), 'no' );
325 update_option( 'wpf_prod_id', base64_decode( sanitize_text_field( $_GET['prod_id'] ) ), 'no' );
326
327 $decr = update_option( 'wpf_decr_key', base64_decode( sanitize_text_field( $_GET['payment_id'] ) ) );
328 $checksu = update_option( 'wpf_decr_checksum', base64_decode( sanitize_text_field( $_GET['checksum'] ) ), 'no' );
329 $wpf_crypt_key = wpf_crypt_key( $wpf_license_key, 'e' );
330 update_option( 'wpf_license_key', $wpf_crypt_key, 'no' );
331 update_option( 'wpf_site_id', base64_decode( sanitize_text_field( $_GET['wpf_site_id'] ) ), 'no' );
332 do_action( 'wpf_initial_sync', $wpf_license_key );
333 syncUsers();
334 get_notif_sitedata_filterdata();
335 syncPages();
336 }
337
338 // When Enable Global Settings is on, the site data will be fetched by the API.
339 $wpf_global_settings = get_option( 'wpf_global_settings' );
340 if ( $wpf_global_settings === "yes" ) {
341 get_site_data();
342 }
343 }
344
345 /*
346 * This function is used for add/update
347 * user default site data
348 */
349 function update_default_site_data() {
350 $options = array();
351 if ( get_site_data_by_key( 'wpf_tab_permission_user_client' ) == '' ) {
352 //global $current_user,$wpdb;
353 array_push( $options, ['name' => 'enabled_wpfeedback', 'value' => 'yes'] );
354 array_push( $options, ['name' => 'wpfeedback_color', 'value' => '002157'] );
355 array_push( $options, ['name' => 'wpf_selcted_role', 'value' => 'administrator'] );
356 array_push( $options, ['name' => 'wpf_website_developer', 'value' => get_current_user_id()] );
357 array_push( $options, ['name' => 'wpf_show_front_stikers', 'value' => 'yes'] );
358 array_push( $options, ['name' => 'wpf_customisations_client', 'value' => 'Client (Website Owner)'] );
359 array_push( $options, ['name' => 'wpf_customisations_webmaster', 'value' => 'Webmaster'] );
360 array_push( $options, ['name' => 'wpf_customisations_others', 'value' => 'Others'] );
361 array_push( $options, ['name' => 'wpf_from_email', 'value' => get_option( 'admin_email' )] );
362 array_push( $options, ['name' => 'wpf_tab_permission_user_client', 'value' => 'yes'] );
363 array_push( $options, ['name' => 'wpf_tab_permission_user_webmaster', 'value' => 'yes'] );
364 array_push( $options, ['name' => 'wpf_tab_permission_user_others', 'value' => 'yes'] );
365 array_push( $options, ['name' => 'wpf_tab_permission_priority_client', 'value' => 'yes'] );
366 array_push( $options, ['name' => 'wpf_tab_permission_priority_webmaster', 'value' => 'yes'] );
367 array_push( $options, ['name' => 'wpf_tab_permission_priority_others', 'value' => 'yes'] );
368 array_push( $options, ['name' => 'wpf_tab_permission_status_client', 'value' => 'yes'] );
369 array_push( $options, ['name' => 'wpf_tab_permission_status_webmaster', 'value' => 'yes'] );
370 array_push( $options, ['name' => 'wpf_tab_permission_status_others', 'value' => 'yes'] );
371 array_push( $options, ['name' => 'wpf_tab_permission_screenshot_client', 'value' => 'yes'] );
372 array_push( $options, ['name' => 'wpf_tab_permission_screenshot_webmaster', 'value' => 'yes'] );
373 array_push( $options, ['name' => 'wpf_tab_permission_screenshot_others', 'value' => 'yes'] );
374 array_push( $options, ['name' => 'wpf_tab_permission_information_client', 'value' => 'yes'] );
375 array_push( $options, ['name' => 'wpf_tab_permission_information_webmaster', 'value' => 'yes'] );
376 array_push( $options, ['name' => 'wpf_tab_permission_information_others', 'value' => 'yes'] );
377 array_push( $options, ['name' => 'wpf_tab_permission_delete_task_client', 'value' => 'no'] );
378 array_push( $options, ['name' => 'wpf_tab_permission_delete_task_webmaster', 'value' => 'yes'] );
379 array_push( $options, ['name' => 'wpf_tab_permission_delete_task_others', 'value' => 'no'] );
380 }
381
382 if ( get_site_data_by_key( 'wpf_tab_permission_user_guest' ) == '' ) {
383 array_push( $options, ['name' => 'wpf_tab_permission_user_guest', 'value' => 'no'] );
384 array_push( $options, ['name' => 'wpf_tab_permission_priority_guest', 'value' => 'no'] );
385 array_push( $options, ['name' => 'wpf_tab_permission_status_guest', 'value' => 'no'] );
386 array_push( $options, ['name' => 'wpf_tab_permission_screenshot_guest', 'value' => 'yes'] );
387 array_push( $options, ['name' => 'wpf_tab_permission_information_guest', 'value' => 'yes'] );
388 array_push( $options, ['name' => 'wpf_tab_permission_delete_task_guest', 'value' => 'no'] );
389 }
390
391 if ( get_site_data_by_key( 'wpf_tab_auto_screenshot_task_client' ) == '' ) {
392 array_push( $options, ['name' => 'wpf_tab_auto_screenshot_task_client', 'value' => 'yes'] );
393 }
394
395 if ( get_site_data_by_key( 'wpf_tab_auto_screenshot_task_webmaster' ) == '' ) {
396 array_push( $options, ['name' => 'wpf_tab_auto_screenshot_task_webmaster', 'value' => 'yes'] );
397 }
398
399 if ( get_site_data_by_key( 'wpf_tab_auto_screenshot_task_others' ) == '' ) {
400 array_push( $options, ['name' => 'wpf_tab_auto_screenshot_task_others', 'value' => 'yes'] );
401 }
402
403 if ( get_site_data_by_key( 'wpf_tab_auto_screenshot_task_guest' ) == '' ) {
404 array_push( $options, ['name' => 'wpf_tab_auto_screenshot_task_guest', 'value' => 'yes'] );
405 }
406
407 if( ! empty( $options ) ) {
408 update_site_data( $options );
409 }
410 }
411
412 /*
413 * This function is used to detect if the page builder is initialized on the current running page and deregister the Atarim of found running.
414 *
415 * @input NULL
416 * @return NULL
417 */
418 function wpfeedback_add_stylesheet_frontend() {
419 $wpf_check_page_builder_active = wpf_check_page_builder_active();
420 /* =====Start Check customize.php==== */
421 /*if ( $wpf_check_page_builder_active == 0 ) {
422 if ( is_customize_preview() ) {
423 $wpf_check_page_builder_active = 1;
424 } else {
425 $wpf_check_page_builder_active = 0;
426 }
427 }*/
428 /* =====END check customize.php==== */
429 if ( $wpf_check_page_builder_active == 0 ) {
430 $enabled_wpfeedback = wpf_check_if_enable();
431 $wpf_enabled = get_site_data_by_key( 'enabled_wpfeedback' );
432 $is_site_archived = get_site_data_by_key( 'wpf_site_archived' );
433 if ( $wpf_enabled == 'yes' && ( ! $is_site_archived ) ) {
434 if ( ! is_user_logged_in() ) {
435 /* Show the login modal only when 'wpf_login' is present => v2.0.9, v2.1.0 */
436 if ( ( get_query_var( 'is_graphic_page' ) ) || ( ! empty( $_GET['wpf_login'] ) ) ) {
437 wp_register_style( 'wpf_login_style', WPF_PLUGIN_URL . 'css/wpf-login.css', false, strtotime( "now" ) );
438 wp_enqueue_style( 'wpf_login_style' );
439 }
440 }
441
442 if ( get_query_var( 'is_graphic_page' ) ) {
443 wp_register_style( 'wpf-graphics-front-style', WPF_PLUGIN_URL . 'css/graphics-front.css', false, strtotime( "now" ) );
444 wp_enqueue_style( 'wpf-graphics-front-style' );
445 }
446
447 /* Show the login modal only when 'wpf_login' is present => v2.0.9, v2.1.0 */
448 if ( ( get_query_var( 'is_graphic_page' ) ) || ( ! empty( $_GET['wpf_login'] ) ) ) {
449 wp_register_script( 'wpf-ajax-login', WPF_PLUGIN_URL . 'js/wpf-ajax-login.js', array(), strtotime( "now" ), true );
450 wp_enqueue_script( 'wpf-ajax-login' );
451 }
452
453 wp_localize_script( 'wpf-ajax-login', 'wpf_ajax_login_object',
454 array(
455 'ajaxurl' => admin_url( 'admin-ajax.php' ),
456 'wpf_reconnect_icon' => WPF_PLUGIN_URL . 'images/wpf_reconnect.png',
457 'redirecturl' => home_url(),
458 'loadingmessage' => __( 'Sending user info, please wait...' ),
459 )
460 );
461 }
462 if ( ( get_query_var( 'is_graphic_page' ) ) || ( $enabled_wpfeedback == 1 && ! $is_site_archived ) ) {
463 wp_register_style( 'wpf_wpf-icons', WPF_PLUGIN_URL . 'css/wpf-icons.css', false, strtotime( "now" ) );
464 wp_enqueue_style( 'wpf_wpf-icons' );
465
466 wp_register_style( 'wpf_wpf-common', WPF_PLUGIN_URL . 'css/wpf-common.css', false, strtotime( "now" ) );
467 wp_enqueue_style( 'wpf_wpf-common' );
468
469 wp_register_style( 'wpf_rt_style', WPF_PLUGIN_URL . 'css/quill.css', false, strtotime( "now" ) );
470 wp_enqueue_style( 'wpf_rt_style' );
471
472 wp_register_script( 'wpf_rt_script', WPF_PLUGIN_URL . 'js/quill.js', array(), WPF_VERSION, true );
473 wp_enqueue_script( 'wpf_rt_script' );
474
475 wp_register_script( 'wpf_jquery_script', WPF_PLUGIN_URL . 'js/atarimjs.js', array(), WPF_VERSION, true );
476 wp_enqueue_script( 'wpf_jquery_script' );
477
478 //wp_register_script( 'pickr', WPF_PLUGIN_URL . 'js/pickr.min.js', null, null, true );
479 //wp_enqueue_script( 'pickr' );
480
481 //wp_register_style( 'pickr_monolith', WPF_PLUGIN_URL . 'css/monolith.min.css' );
482 //wp_enqueue_style( 'pickr_monolith' );
483 if ( $wpf_check_page_builder_active == 0 ) {
484
485 wp_register_script( 'wpf_jquery_ui_script', WPF_PLUGIN_URL . 'js/atarim-ui.js', array(), WPF_VERSION, true );
486 wp_enqueue_script( 'wpf_jquery_ui_script' );
487
488 wp_register_script( 'wpf_touch_mouse_script', WPF_PLUGIN_URL . 'js/atarim.ui.mouse.min.js', array(), WPF_VERSION, true );
489 wp_enqueue_script( 'wpf_touch_mouse_script' );
490
491 wp_register_script( 'wpf_touch_punch_script', WPF_PLUGIN_URL . 'js/jquery.ui.touch-punch.js', array(), WPF_VERSION, true );
492 wp_enqueue_script( 'wpf_touch_punch_script' );
493
494 wp_register_script( 'wpf_browser_info_script', WPF_PLUGIN_URL . 'js/wpf_browser_info.js', array(), WPF_VERSION, true );
495 wp_enqueue_script( 'wpf_browser_info_script' );
496
497 wp_register_script( 'wpf_common_functions', WPF_PLUGIN_URL . 'js/wpf_common_functions.js', array(), strtotime( "now" ), true );
498 wp_enqueue_script( 'wpf_common_functions' );
499
500 if ( get_query_var( 'is_graphic_page' ) ) {
501 wp_register_script( 'wpf-graphics-front-script', WPF_PLUGIN_URL . 'js/app_graphics.js', array(), strtotime( "now" ), true );
502 wp_enqueue_script( 'wpf-graphics-front-script' );
503
504 $upgrade_url = get_option( 'upgrade_url' );
505 wp_localize_script( 'wpf-graphics-front-script', 'upgrade_url', array( 'url' => $upgrade_url, 'plugin_url' => WPF_PLUGIN_URL ) );
506
507 $feature = array();
508 $edit = is_feature_enabled( 'edit' );
509 if ( ! $edit ) {
510 $feature[] = 'edit';
511 }
512 wp_localize_script( 'wpf-graphics-front-script', 'blocked', $feature );
513
514 wp_enqueue_media();
515 } else {
516 wp_register_script( 'wpf_app_script', WPF_PLUGIN_URL . 'js/app.js', array(), strtotime( "now" ), true );
517 wp_enqueue_script( 'wpf_app_script' );
518 $wpf_user_type = wpf_user_type();
519 $display_name = '';
520 $avatar_url = '';
521 if ( is_user_logged_in() ) {
522 $user = wp_get_current_user();
523 $display_name = $user->display_name;
524 $user_id = get_current_user_id();
525 $avatar_url = get_avatar_url( $user_id, array( 'size' => 42, 'default' => '404' ) );
526 $headers = @get_headers( $avatar_url );
527 if ( ! empty( $headers ) ) {
528 if ( $headers[0] == 'HTTP/1.1 404 Not Found' ) {
529 $avatar_url = '';
530 }
531 }
532 }
533
534 wp_localize_script( 'wpf_app_script', 'logged_user', array( 'current_user' => $wpf_user_type, 'author_img' => $avatar_url, 'author' => $display_name ) );
535
536 $theme = wp_get_theme();
537 $adjust = 'false';
538 if ( 'GeneratePress' == $theme->name || 'GeneratePress Child' == $theme->name || 'Black Bros' == $theme->name ) {
539 $adjust = 'true';
540 }
541 wp_localize_script( 'wpf_app_script', 'istheme', array( 'adjust' => $adjust ) );
542
543 $feature = array();
544 $edit = is_feature_enabled( 'edit' );
545 if ( ! $edit ) {
546 $feature[] = 'edit';
547 }
548 wp_localize_script( 'wpf_app_script', 'blocked', $feature );
549
550 $upgrade_url = get_option( 'upgrade_url' );
551 wp_localize_script( 'wpf_app_script', 'upgrade_url', array( 'url' => $upgrade_url, 'plugin_url' => WPF_PLUGIN_URL ) );
552
553 $wpf_get_user_type = esc_attr( wpf_user_type() );
554 $wpf_new_task = isset($_GET['wpf-task']) ? true : false;
555 if( $wpf_new_task && ! get_option( 'wpf_app_auto_task' ) ) {
556 update_option( 'wpf_app_auto_task', true );
557 $wpf_app_auto_task = true;
558 $wpf_new_task = true;
559 } else {
560 $wpf_app_auto_task = false;
561 $wpf_new_task = false;
562 }
563 $wpf_frontend_user = ( isset( $_GET['wpf-user-flow'] ) || isset( $_GET['wpf-existing-user-flow'] ) ) ? true : false;
564 wp_localize_script( 'wpf_app_script', 'wpf_app_script_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'wpf_app_auto_task' => $wpf_app_auto_task, 'wpf_new_task' => $wpf_new_task, 'wpf_frontend_user' => $wpf_frontend_user ) );
565 }
566
567 wp_register_script( 'wpf_html2canvas_script', WPF_PLUGIN_URL . 'js/html2canvas.js', array(), WPF_VERSION, true );
568 wp_enqueue_script( 'wpf_html2canvas_script' );
569
570 wp_register_script( 'wpf_popper_script', WPF_PLUGIN_URL . 'js/popper.min.js', array(), WPF_VERSION, true );
571 wp_enqueue_script( 'wpf_popper_script' );
572
573 wp_register_script( 'wpf_custompopover_script', WPF_PLUGIN_URL . 'js/custompopover.js', array(), WPF_VERSION, true );
574 wp_enqueue_script( 'wpf_custompopover_script' );
575
576 wp_register_script( 'wpf_selectoroverlay_script', WPF_PLUGIN_URL . 'js/selectoroverlay.js', array(), WPF_VERSION, true );
577 wp_enqueue_script( 'wpf_selectoroverlay_script' );
578
579 wp_register_script( 'wpf_xyposition_script', WPF_PLUGIN_URL . 'js/xyposition.js', array(), WPF_VERSION, true );
580 wp_enqueue_script( 'wpf_xyposition_script' );
581
582 wp_register_script( 'wpf_bootstrap_script', WPF_PLUGIN_URL . 'js/bootstrap.min.js', array(), WPF_VERSION, true );
583 wp_enqueue_script( 'wpf_bootstrap_script' );
584 }
585 }
586 }
587 }
588 add_action('wp_enqueue_scripts', 'wpfeedback_add_stylesheet_frontend');
589
590 add_filter( 'script_loader_tag', 'add_attributes_to_script', 10, 3 );
591 /**
592 *
593 * Prevent collision with the WordPress jQuery
594 */
595 function add_attributes_to_script( $tag, $handle, $src ) {
596 if ( 'wpf_jquery_script' === $handle ) {
597 if ( wp_script_is( 'jquery', 'enqueued' ) ) {
598 $tag = '<script>var jQuery_WPF = jQuery;</script>';
599 } else {
600 return;
601 }
602 }
603 return $tag;
604 }
605
606
607
608 /*
609 * This function is used to create the security nonce every time a user requests the Atarim.
610 *
611 * @input NULL
612 * @return String
613 */
614
615 function wpf_wp_create_nonce() {
616 global $post;
617 $wpf_allow_guest = get_site_data_by_key( 'wpf_allow_guest' );
618 if ( is_user_logged_in() || $wpf_allow_guest == 'yes' ) {
619 $wpf_nonce = wp_create_nonce( 'wpfeedback-script-nonce' );
620 return $wpf_nonce;
621 }
622 if ( get_query_var( 'is_graphic_page' ) && ! is_user_logged_in() && $wpf_allow_guest != 'yes' ) {
623 $wpf_nonce = wp_create_nonce( 'wpfeedback-script-nonce' );
624 return $wpf_nonce;
625 }
626 }
627
628 /* ==========All Java script for Admin footer========= */
629 /*
630 * This function is used to initial the Atarim and all related variables on the backend.
631 *
632 * @input NULL
633 * @return NULL
634 */
635 if ( isset( $_GET['page'] ) ) {
636 add_action( 'admin_footer', 'wpf_backed_scripts' );
637 }
638 function wpf_backed_scripts() {
639 global $wpdb, $post, $current_user;
640 $author_id = $current_user->ID;
641 $wpf_user_type = wpf_user_type();
642 $currnet_user_information = wpf_get_current_user_information();
643 $current_role = $currnet_user_information['role'];
644 $current_user_name = $currnet_user_information['display_name'];
645 $current_user_id = $currnet_user_information['user_id'];
646 $wpf_website_builder = get_site_data_by_key( 'wpf_website_developer' );
647 if ( $current_user_name == 'Guest' ) {
648 $wpf_website_client = get_site_data_by_key( 'wpf_website_client' );
649 $wpf_current_role = 'guest';
650 if ( $wpf_website_client ) {
651 $wpf_website_client_info = get_userdata( $wpf_website_client );
652 if ( $wpf_website_client_info ) {
653 if ( $wpf_website_client_info->display_name == '' ) {
654 $current_user_name = $wpf_website_client_info->user_nicename;
655 } else {
656 $current_user_name = $wpf_website_client_info->display_name;
657 }
658 }
659 }
660 }
661 $current_user_name = addslashes( $current_user_name );
662 $wpf_show_front_stikers = get_site_data_by_key( 'wpf_show_front_stikers' );
663 $unix_time_now = time();
664 $wpf_check_atarim_server = get_option( 'atarim_server_down_check' );
665
666 if ( $unix_time_now > $wpf_check_atarim_server ) {
667 update_option( 'atarim_server_down','false','no' );
668 }
669
670 $atarim_server_down = get_option( 'atarim_server_down' );
671 $wpfb_users = do_shortcode( '[wpf_user_list_front]' );
672 $wpf_all_pages = wpf_get_page_list();
673 $ajax_url = admin_url( 'admin-ajax.php' );
674 $plugin_url = WPF_PLUGIN_URL;
675 $wpf_comment_time = date( 'd-m-Y H:i', current_time( 'timestamp', 0 ) );
676 $wpf_nonce = wpf_wp_create_nonce();
677 $sound_file = esc_url( plugins_url( 'images/wpf-screenshot-sound.mp3', __FILE__ ) );
678 $comment_count = get_last_task_id();
679
680 echo "<script>var wpf_nonce = '$wpf_nonce', wpf_comment_time = '$wpf_comment_time', wpf_all_pages = '$wpf_all_pages', current_role = '$current_role', wpf_current_role = '$wpf_user_type', current_user_name = '$current_user_name', current_user_id = '$current_user_id', wpf_website_builder = '$wpf_website_builder', wpfb_users = '$wpfb_users', ajaxurl = '$ajax_url', wpf_screenshot_sound = '$sound_file', plugin_url = '$plugin_url', comment_count = '$comment_count', wpf_show_front_stikers = '$wpf_show_front_stikers', atarim_server_down = '$atarim_server_down';</script>";
681
682 if ( isset( $_REQUEST['page'] ) ) {
683 if ( $_REQUEST['page'] == 'wpfeedback_page_settings' || $_REQUEST['page'] == 'wpfeedback_page_tasks' || $_REQUEST['page'] == 'wpfeedback_page_integrate' || $_REQUEST['page'] == 'wpfeedback_page_upgrade' || $_REQUEST['page'] == 'wpfeedback_page_support' || $_REQUEST['page'] == 'wpfeedback_page_permissions' || $_REQUEST['page'] == 'wpfeedback_page_graphics' ) {
684 ?>
685 <script type='text/javascript'>
686 var plugin_url = '<?php echo $plugin_url ?>';
687 var current_task = 0;
688 var current_user_id = "<?php echo $author_id; ?>";
689 var wpf_user_type = "<?php echo $wpf_user_type; ?>";
690 var reloadd_task = true;
691 var pagee_no = 2;
692
693 function getParameterByName(name) {
694 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
695 var regexS = "[\\?&]" + name + "=([^&#]*)";
696 var regex = new RegExp( regexS );
697 var results = regex.exec( window.location.href );
698 if ( results == null ) {
699 return "";
700 } else {
701 return decodeURIComponent( results[1].replace(/\+/g, " ") );
702 }
703 }
704
705 /*
706 * wpf task filter code
707 */
708 function wp_feedback_filter() {
709 reloadd_task = false;
710 page_no = 0;
711 var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
712 var task_types = [];
713 var task_title = jQuery('#wpf_tasks #wpf_search_title').val();
714 var task_types_meta = [];
715 jQuery.each(
716 jQuery("#wpf_filter_form input[name='task_types']:checked"), function () {
717 task_types.push( jQuery(this).val() );
718 }
719 );
720 var selected_task_types_values = task_types.join(",");
721 var is_internal = 0;
722 jQuery.each(
723 jQuery("#wpf_filter_form input[name='task_types_meta']:checked"), function (index, element) {
724 if ( jQuery(element).attr('id') === 'wpf_task_type_internal' ) {
725 is_internal = 1;
726 } else {
727 task_types_meta.push(jQuery(this).val());
728 }
729 }
730 );
731 var selected_task_types_meta_values = task_types_meta.join(",");
732 var task_status = [];
733 jQuery.each(
734 jQuery("#wpf_filter_form input[name='task_status']:checked"), function () {
735 task_status.push(jQuery(this).val());
736 }
737 );
738 var selected_task_status_values = task_status.join(",");
739 var task_priority = [];
740 jQuery.each(
741 jQuery("#wpf_filter_form input[name='task_priority']:checked"), function () {
742 task_priority.push(jQuery(this).val());
743 }
744 );
745 var selected_task_priority_values = task_priority.join(",");
746 var author_list = [];
747 jQuery.each(
748 jQuery("#wpf_filter_form input[name='author_list']:checked"), function () {
749 author_list.push(jQuery(this).val());
750 }
751 );
752 var selected_author_list_values = author_list.join(",");
753 var wpf_display_all_taskmeta_tasktab = jQuery('#wpf_display_all_taskmeta_tasktab').prop("checked") ? 1 : 0;
754 jQuery.ajax({
755 method: "POST",
756 url: ajaxurl,
757 data: {
758 action: "wpfeedback_get_post_list_ajax",
759 wpf_nonce: wpf_nonce,
760 task_title: task_title,
761 task_types: selected_task_types_values, task_types_meta: selected_task_types_meta_values,
762 task_status: selected_task_status_values,
763 task_priority: selected_task_priority_values,
764 author_list: selected_author_list_values,
765 internal: is_internal
766 },
767 beforeSend: function () {
768 jQuery('.wpf_loader_admin').show();
769 },
770 success: function (data) {
771 //Comment
772 jQuery('#wpf_display_all_taskmeta_tasktab').prop('checked', false);
773 jQuery('.wpf_loader_admin').hide();
774 jQuery('.wpf_tasks_col .wpf_tasks-list').html(data);
775 if ( document.getElementById('wpf_task_bulk_tab').checked ) {
776 jQuery('.wpf_task_num_top').hide();
777 jQuery('#wpf_task_all_tab').removeClass('active');
778 jQuery('ul#all_wpf_list li .wpf_task_id').addClass('wpf_active');
779 jQuery('ul#all_wpf_list #wpf_bulk_select_task_checkbox').addClass('wpf_active');
780 jQuery('#wpf_bulk_select_task_checkbox').show();
781 }
782 if ( wpf_display_all_taskmeta_tasktab == 1 ) {
783 jQuery('ul#all_wpf_list li div.wpf_task_meta').addClass('wpf_active');
784 jQuery('#wpf_display_all_taskmeta_tasktab').prop("checked", true);
785 }
786 }
787 });
788 }
789
790 jQuery('.wpf_tasks-list').bind('scroll', function() {
791 if( jQuery(window).scrollTop() >= (jQuery('#all_wpf_list').offset().top + jQuery('#all_wpf_list').outerHeight() - window.innerHeight)) {
792 if ( reloadd_task == true && pagee_no > 0 ) {
793 load_task_center_all_tasks();
794 reloadd_task = false;
795 }
796 }
797 });
798
799 function load_task_center_all_tasks() {
800 jQuery.ajax({
801 method: "POST",
802 url: ajaxurl,
803 data: {
804 action: "wpfeedback_get_post_list_ajax",
805 wpf_nonce: wpf_nonce,
806 page_no: pagee_no,
807 },
808 beforeSend: function () {
809 jQuery('.wpf_loading').show();
810 },
811 success: function (data) {
812 jQuery('.wpf_loader_admin').hide();
813 if( data != '' ) {
814 jQuery('.wpf_tasks_col .wpf_tasks-list #all_wpf_list').append(data);
815 reloadd_task = true;
816 pagee_no = pagee_no + 1;
817 } else {
818 reloadd_task = false;
819 pageee_no = 0;
820 jQuery('.wpf_loading').hide();
821 }
822 }
823 });
824 }
825
826 var internal_icon_html='<span class="wpf_chevron_wrapper"><img src="' + plugin_url + 'images/eye-off-white.svg" class="wpf-internal-img"></span>';
827 function get_wpf_message_form( comment_post_ID, curren_user_id,is_internal ) {
828 let internal_button = '';
829 if ( wpf_current_role == 'advisor' ) {
830 if ( is_internal == '1' ) {
831 internal_class = "wpf_is_internal";
832 internal_button = '<button class="wpf_mark_internal wpf_mark_internal_task_center '+internal_class+'" data-id="'+comment_post_ID+'"><img src="' + plugin_url + 'images/eye-off-white.svg" class="wpf-internal-img"><span class="wpf_tooltiptext unmark_internal_tooltip_text">Switch to a normal task</span><span class="wpf_tooltiptext new_internal_tooltip_text">Add comment and create Internal task</span><span class="wpf_tooltiptext mark_internal_tooltip_text">Switch to an Internal task</span></button>';
833 } else {
834 internal_class = "";
835 internal_button = '<button class="wpf_mark_internal wpf_mark_internal_task_center '+internal_class+'" data-id="'+comment_post_ID+'"><img src="' + plugin_url + 'images/eye-off.svg" class="wpf-internal-img"><span class="wpf_tooltiptext unmark_internal_tooltip_text">Switch to a normal task</span><span class="wpf_tooltiptext new_internal_tooltip_text">Add comment and create Internal task</span><span class="wpf_tooltiptext mark_internal_tooltip_text">Switch to an Internal task</span></button>';
836 }
837 }
838 let note_button = '';
839 if ( wpf_current_role == 'advisor' || wpf_current_role == 'council' ) {
840 note_button = '<button class="wpf_mark_note wpf_mark_note_task_center" onclick="send_chat_message(true)" data-id="'+comment_post_ID+'"><img src="' + plugin_url + 'images/note.svg"><span class="wpf_tooltiptext note_tooltip_text">Create a private message that only team members can see</span></button>';
841 }
842 var html = '<div id="wpf_chat_box"><form action="" method="post" id="wpf_form" class="comment-form" enctype="multipart/form-data"><p class="comment-form-comment"><div class="wpf-tc-editor"></div><textarea placeholder="' + wpf_comment_box_placeholder + '" id="wpf_comment" name="comment" maxlength="65525" required="required"></textarea><input type="hidden" name="comment_post_ID" value="' + comment_post_ID + '" id="comment_post_ID"> <input type="hidden" name="curren_user_id" value="' + curren_user_id + '" id="curren_user_id"><p class="form-submit chat_button"><input name="submit" type="button" id="send_chat" onclick="send_chat_message()" class="submit wpf_button submit" value="' + wpf_send_message_text + '">' + note_button + internal_button + '<a href="javascript:void(0)" class="wpf_upload_button wpf_button" onchange="wpf_upload_file_admin(' + comment_post_ID + ');"><input type="file" name="wpf_uploadfile" id="wpf_uploadfile" data-elemid="' + comment_post_ID + '" class="wpf_uploadfile"><i class="gg-attachment"></i></a></p><p id="wpf_upload_error" class="wpf_hide">You are trying to upload an invalid filetype <br> Allowd File Types: JPG, PNG, GIF, PDF, DOC, DOCX and XLSX</p></form></div></div>';
843 return html;
844 }
845 function send_chat_message(note=false) {
846 jQuery("#get_masg_loader").show();
847 jQuery(".get_masg_loader").show();
848 var wpf_comment = jQuery('#wpf_comment').val();
849 var post_id = jQuery('#comment_post_ID').val();
850 var author_id = "<?php echo $author_id; ?>";
851 var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
852 var note = note;
853 var task_notify_users = [];
854 jQuery.each(
855 jQuery('#wpf_attributes_content input[name="author_list_task"]:checked'), function () {
856 task_notify_users.push(jQuery(this).val());
857 }
858 );
859 task_notify_users = task_notify_users.join(",");
860
861 if ( jQuery('#wpf_comment').val().trim().length > 0 ) {
862 jQuery.ajax({
863 method: "POST",
864 url: ajaxurl,
865 data: {
866 action: "insert_wpf_comment_func",
867 wpf_nonce: wpf_nonce,
868 post_id: post_id,
869 author_id: author_id,
870 task_notify_users: task_notify_users,
871 wpf_comment: wpf_comment,
872 note: note
873 },
874 beforeSend: function () {
875 jQuery('.wpf_loader_admin').show();
876 },
877 success: function (data) {
878 try {
879 const responseData = JSON.parse(data);
880 if ( responseData['limit'] === true ) {
881 jQuery(".wpf_locked_modal_container").show();
882 return;
883 }
884 } catch(ex){}
885
886 jQuery('.wpf_loader_admin').hide();
887 jQuery("#wpf_not_found").remove();
888 jQuery("#tag_post").html('');
889 if ( jQuery('#wpf_message_list li').length == 0 ) {
890 jQuery('ul#wpf_message_list').html(data);
891 } else {
892 jQuery('ul#wpf_message_list li.chat_author:last').after(data);
893 }
894 jQuery("#wpf_comment").val("");
895 jQuery("#addcart_loader").fadeOut();
896 jQuery("#get_masg_loader").hide();
897 jQuery(".get_masg_loader").hide();
898 // empty Task center rich text editor by Pratap
899 jQuery_WPF('.ql-editor').html('');
900 jQuery('#wpf_message_content').animate({scrollTop: jQuery('#wpf_message_content').prop("scrollHeight")}, 2000);
901 if ( jQuery("#task_task_status_attr").val() == 'complete' ) {
902 jQuery("#task_task_status_attr").val("open");
903 var obj = document.getElementById("task_task_status_attr");
904 task_status_changed(obj);
905 }
906 }
907 });
908 } else {
909 jQuery("#get_masg_loader").hide();
910 jQuery('ul#wpf_message_list').animate({scrollTop: jQuery("ul#wpf_message_list li").last().offset().top}, 1000);
911 jQuery("#wpf_comment").focus();
912 jQuery("#get_masg_loader").hide();
913 }
914 }
915
916 jQuery(document).on('click','.wpf_mark_note_task_center',function(e) {
917 e.preventDefault();
918 });
919
920 jQuery(document).on('click','.wpf_mark_internal_task_center',function(e) {
921 e.preventDefault();
922 let id=jQuery(this).data('id');
923 if( jQuery(this).hasClass('wpf_is_internal') ) {
924 mark_internal_task_center(id,'0');
925 jQuery(this).find('.wpf-internal-img').attr('src', plugin_url + 'images/eye-off.svg');
926 } else {
927 mark_internal_task_center(id,'1');
928 jQuery(this).find('.wpf-internal-img').attr('src', plugin_url + 'images/eye-off-white.svg');
929 }
930 });
931 function mark_internal_task_center( id,internal ) {
932 var task_info = [];
933 var task_notify_users = [];
934 var task_comment = jQuery_WPF('#comment-'+id).val();
935 jQuery_WPF.each(
936 jQuery_WPF('input[name=author_list_'+id+']:checked'), function(){
937 task_notify_users.push(jQuery_WPF(this).val());
938 }
939 );
940 task_info['task_id'] = id;
941 task_info['internal'] = internal;
942 var task_info_obj = jQuery_WPF.extend({}, task_info);
943 var task_info_obj = jQuery_WPF.extend({}, task_info);
944 jQuery_WPF.ajax({
945 method : "POST",
946 url : ajaxurl,
947 data : {
948 action: "wpfb_mark_as_internal",
949 wpf_nonce:wpf_nonce,
950 task_info:task_info_obj
951 },
952 beforeSend: function() {
953 jQuery_WPF('.wpf_loader_admin').show();
954 },
955 success : function(data) {
956 if ( internal == '1' ) {
957 jQuery_WPF('.wpf_mark_internal_task_center').addClass('wpf_is_internal');
958 jQuery_WPF('#wpf-task-'+id).addClass('wpfb-internal');
959 jQuery_WPF('#wpf-task-'+id).find('.wpf_task_num_top').append(internal_icon_html);
960 } else {
961 jQuery_WPF('.wpf_mark_internal_task_center').removeClass('wpf_is_internal');
962 jQuery_WPF('#wpf-task-'+id).removeClass('wpfb-internal');
963 jQuery_WPF('#wpf-task-'+id).find('.wpf_task_num_top').find('.wpf_chevron_wrapper').remove();
964 }
965 jQuery_WPF('.wpf_loader_admin').hide();
966 }
967 });
968 }
969
970 function task_status_changed( sel ) {
971 var task_info = [];
972 var task_notify_users = [];
973 jQuery.each(
974 jQuery('#wpf_attributes_content input[name="author_list_task"]:checked'), function () {
975 task_notify_users.push(jQuery(this).val());
976 }
977 );
978
979 let selected_priority = jQuery('#task_task_priority_attr').val();
980 task_notify_users = task_notify_users.join(",");
981 task_info['task_id'] = current_task;
982 task_info['task_status'] = sel.value;
983 task_info['task_notify_users'] = task_notify_users;
984 var wpf_task_id = jQuery('#wpf_task_details .wpf_task_num_top').text()
985 var task_info_obj = jQuery.extend({}, task_info);
986 let sticker_permission = wpf_tab_permission_display_stickers;
987 let task_id_permission = wpf_tab_permission_display_task_id;
988 jQuery.ajax({
989 url: '<?php echo admin_url('admin-ajax.php'); ?>',
990 type: 'POST',
991 data: {
992 action: "wpfb_set_task_status",
993 wpf_nonce: wpf_nonce,
994 task_info: task_info_obj
995 },
996 beforeSend: function () {
997 jQuery('.wpf_loader_admin').show();
998 },
999 success: function (data) {
1000 let display_span = '';
1001 let custom_class = '';
1002 if ( sticker_permission == 'yes' ) {
1003 display_span = '<span class="' + selected_priority + '_custom"></span>';
1004 custom_class = task_info['task_status'] + '_custom';
1005 }
1006 if ( task_info['task_status'] == "open" ) {
1007 var news = "Open";
1008 }
1009 if ( task_info['task_status'] == "in-progress" ) {
1010 var news = "In Progress";
1011 }
1012 if ( task_info['task_status'] == "pending-review" ) {
1013 var news = "Pending Review";
1014 }
1015 if ( task_info['task_status'] == "complete" ) {
1016 var news = "Complete";
1017 }
1018 if ( tss == "open" ) {
1019 var olss = "Open";
1020 }
1021 if ( tss == "in-progress" ) {
1022 var olss = "In Progress";
1023 }
1024 if ( tss == "pending-review" ) {
1025 var olss = "Pending Review";
1026 }
1027 if ( tss == "complete" ) {
1028 var olss="Complete";
1029 }
1030 author_img = plugin_url + 'images/bell.svg';
1031 author_html = '<img src="' + author_img + '" ></img>';
1032 jQuery("#wpf_message_list").append('<li class=" chat_author is_info " title="1 sec ago"><div class="wpf-comment-container"><div class="wpf-author-img">' + author_html + '</div><div class="wpf-comment-wrapper"><level class="wpf-author"> <span>1 sec</span></level><div class="task_text">'+current_user_name+' marked as <span class="taskStatusMsg">'+news+'</span> from '+olss+'</div></div></div></li>');
1033 jQuery("#wpf-task-" + current_task + " .wpf_task_label .task_status").removeClass().addClass("task_status wpf_" + sel.value);
1034 tss = task_info['task_status'];
1035 jQuery('.wpf_loader_admin').hide();
1036 jQuery('#wpf-task-' + current_task).data('task_status', sel.value);
1037 var view_id = jQuery(document).find("#wpf_"+current_task).attr("data-disp-id");
1038 if ( sel.value == 'complete' ) {
1039 jQuery('#all_wpf_list .post_' + current_task).addClass('complete');
1040 let display_check_mark = '';
1041 if ( task_id_permission == false ) {
1042 display_check_mark = '<i class="gg-check"></i>';
1043 } else {
1044 display_check_mark = view_id
1045 }
1046
1047 jQuery('#all_wpf_list .post_' + current_task + ' .wpf_task_num_top').html(display_check_mark);
1048 jQuery('#wpf_task_details .wpf_task_num_top').html(display_span + view_id);
1049 jQuery('#wpf_task_details .wpf_task_num_top').removeAttr('class').addClass('wpf_task_num_top ' + custom_class);
1050 jQuery('#all_wpf_list .post_' + current_task + ' .wpf_chat_top .wpf_task_num_top').html(display_span + view_id);
1051 jQuery('#all_wpf_list .post_' + current_task + ' .wpf_chat_top .wpf_task_num_top').removeAttr('class').addClass('wpf_task_num_top ' + custom_class);
1052 jQuery('#all_wpf_list li.post_' + current_task).removeClass('open').removeClass('complete').removeClass('pending-review').removeClass('in-progress').addClass(task_info['task_status']).addClass('active').addClass('wpf_list').addClass(selected_priority);
1053 } else {
1054 jQuery('#all_wpf_list .post_' + current_task).removeClass('complete');
1055 jQuery('#all_wpf_list .post_' + current_task + ' .wpf_task_num_top').html(view_id);
1056 jQuery('#wpf_task_details .wpf_task_num_top').html(display_span + view_id);
1057 jQuery('#wpf_task_details .wpf_task_num_top').removeAttr('class').addClass('wpf_task_num_top ' + custom_class);
1058 jQuery('#all_wpf_list .post_' + current_task + ' .wpf_chat_top .wpf_task_num_top').html(display_span + view_id);
1059 jQuery('#all_wpf_list .post_' + current_task + ' .wpf_chat_top .wpf_task_num_top').removeAttr('class').addClass('wpf_task_num_top ' + custom_class);
1060 jQuery('#all_wpf_list li.post_' + current_task).removeClass('open').removeClass('complete').removeClass('pending-review').removeClass('in-progress').addClass(task_info['task_status']).addClass('active').addClass('wpf_list').addClass(selected_priority);
1061 }
1062 }
1063 });
1064 }
1065
1066 function task_priority_changed( sel ) {
1067 var task_info = [];
1068 var task_priority = sel.value;
1069 task_info['task_id'] = current_task;
1070 task_info['task_priority'] = task_priority;
1071 var task_info_obj = jQuery.extend({}, task_info);
1072 let sticker_permission = wpf_tab_permission_display_stickers;
1073 jQuery.ajax({
1074 method: "POST",
1075 url: "<?php echo admin_url('admin-ajax.php'); ?>",
1076 data: {
1077 action: "wpfb_set_task_priority",
1078 wpf_nonce: wpf_nonce,
1079 task_info: task_info_obj
1080 },
1081 beforeSend: function () {
1082 jQuery('.wpf_loader_admin').show();
1083 },
1084 success: function (data) {
1085 let custom_class = '';
1086 if ( sticker_permission == 'yes' ) {
1087 custom_class = sel.value + '_custom';
1088 }
1089 if ( task_priority == "low" ){
1090 var news = "Low";
1091 }
1092 if ( task_priority == "medium" ) {
1093 var news = "Medium";
1094 }
1095 if ( task_priority == "high" ) {
1096 var news = "High";
1097 }
1098 if ( task_priority == "critical"){
1099 var news = "Critical";
1100 }
1101 if ( prr == "low" ) {
1102 var olss = "Low";
1103 }
1104 if ( prr == "medium" ) {
1105 var olss = "Medium";
1106 }
1107 if ( prr == "high" ) {
1108 var olss = "High";
1109 }
1110 if ( prr == "critical" ) {
1111 var olss = "Critical";
1112 }
1113 author_img = plugin_url + 'images/bell.svg';
1114 author_html = '<img src="' + author_img + '" ></img>';
1115 jQuery("#wpf_message_list").append('<li class=" chat_author is_info " title="1 sec ago"><div class="wpf-comment-container"><div class="wpf-author-img">' + author_html + '</div><div class="wpf-comment-wrapper"><level class="wpf-author"> <span>1 sec</span></level><div class="task_text">'+current_user_name+' marked as <span class="taskStatusMsg">'+news+'</span> from '+olss+'</div></div></div></li>');
1116 prr = task_priority;
1117 jQuery("#wpf-task-" + current_task + " .wpf_task_label .task_priority").removeClass().addClass("task_priority wpf_" + sel.value);
1118 jQuery('.wpf_loader_admin').hide();
1119 jQuery('#wpf-task-' + current_task).data('task_priority', sel.value);
1120 jQuery('#all_wpf_list .post_' + current_task + ' .wpf_chat_top .wpf_task_num_top span').removeAttr('class').addClass(custom_class);
1121 jQuery('#wpf_task_details .wpf_task_num_top span').removeAttr('class').addClass(custom_class);
1122 jQuery('#all_wpf_list li.post_' + current_task).removeClass('low').removeClass('high').removeClass('critical').removeClass('medium').addClass(task_info['task_priority']).addClass('active').addClass('wpf_list');
1123 }
1124 });
1125 }
1126
1127 function update_notify_user(user_id) {
1128 var task_info = [];
1129 var task_notify_users = [];
1130 jQuery.each(
1131 jQuery('#wpf_attributes_content input[name="author_list_task"]:checked'), function () {
1132 task_notify_users.push(jQuery(this).val());
1133 });
1134 task_notify_users = task_notify_users.join(",");
1135 task_info['task_id'] = current_task;
1136 task_info['task_notify_users'] = task_notify_users;
1137 var task_info_obj = jQuery.extend({}, task_info);
1138
1139 jQuery.ajax({
1140 method: "POST",
1141 url: "<?php echo admin_url('admin-ajax.php'); ?>",
1142 data: {
1143 action: "wpfb_set_task_notify_users",
1144 wpf_nonce: wpf_nonce,
1145 task_info: task_info_obj
1146 },
1147 beforeSend: function () {
1148 jQuery('.wpf_loader_admin').show();
1149 },
1150 success: function (data) {
1151 jQuery('.wpf_loader_admin').hide();
1152 jQuery('#wpf-task-' + current_task).data('task_notify_users', task_notify_users);
1153 }
1154 });
1155 }
1156
1157 var tss;
1158 var prr;
1159 //get chat based on WPF post select
1160 function get_wpf_chat(obj, tg, author) {
1161 jQuery("#wpf_edit_title").show();
1162 jQuery("#wpf_task_tabs_container").show();
1163 jQuery("#wpf_edit_title_box").hide();
1164 jQuery("#wpf_title_val").val();
1165 var post_id = jQuery(obj).data("postid");
1166 var view_id = jQuery(obj).data("disp-id");
1167
1168 if ( tg === undefined ) {
1169 tg = false;
1170 }
1171 jQuery("ul#all_wpf_list li.wpf_list").removeClass('active');
1172 jQuery(obj).parent().addClass('active');
1173
1174 var post_author_id = jQuery(obj).data('uid');
1175 var task_is_internal = jQuery('#wpf-task-'+post_id).hasClass('wpfb-internal');
1176 var post_task_type = jQuery(obj).data('task_type');
1177 var post_task_status = jQuery(obj).data('wpf_task_status');
1178 var post_task_no = jQuery(obj).data("task_no");
1179 var task_status = jQuery(obj).data("task_status");
1180 var task_page_url = jQuery(obj).data("task_page_url");
1181 var wpf_task_screenshot = jQuery(obj).data("wpf_task_screenshot");
1182 var task_page_title = jQuery(obj).data("task_page_title");
1183 var task_config_author_name = jQuery(obj).data("task_config_author_name");
1184 var task_author_name = jQuery(obj).data("task_author_name");
1185 let sticker_permission = new_global_sticker_permission;
1186 let title_permission = new_global_task_id_permission;
1187 var task_config_author_res = jQuery(obj).data("task_config_author_res");
1188 var task_config_author_browser = jQuery(obj).data("task_config_author_browser");
1189 var task_config_author_browserversion = jQuery(obj).data("task_config_author_browserversion");
1190 var task_notify_users = jQuery(obj).data("task_notify_users");
1191 var task_priority = jQuery(obj).data("task_priority");
1192 var click = 'yes';
1193 var additional_info_html = '<p><span class="wpf_task_ad_info_title">' + wpf_resolution + '</span> ' +''+ task_config_author_res + '</p><p><span class="wpf_task_ad_info_title">' + wpf_browser + '</span> ' + task_config_author_browser + ' ' + task_config_author_browserversion + '</p><p><span class="wpf_task_ad_info_title">' + wpf_user_name + '</span> ' + task_author_name + '</p><p><span class="wpf_task_ad_info_title">' + wpf_task_id + '</span> ' + post_id + '</p>';
1194 jQuery.ajax({
1195 method: "POST",
1196 url: ajaxurl,
1197 data: {
1198 action: "list_wpf_comment_func",
1199 wpf_nonce: wpf_nonce,
1200 post_id: post_id,
1201 post_author_id: post_author_id,
1202 click: click
1203 },
1204 beforeSend: function () {
1205 jQuery('.wpf_loader_admin').show();
1206 },
1207 success: function (data) {
1208 onload_wpfb_tasks = JSON.parse(data);
1209 if ( onload_wpfb_tasks != null && onload_wpfb_tasks != "null" ) {
1210 current_task = post_id;
1211 wpf_tag_autocomplete(document.getElementById("wpf_tags"), wpf_all_tags);
1212 jQuery('.wpf_loader_admin').hide();
1213 jQuery("#wpf_not_found").remove();
1214 jQuery("#get_masg_loader").hide();
1215 let display_span = '';
1216 let custom_class = '';
1217 if ( sticker_permission == 'yes' ) {
1218 display_span = '<span class="' + task_priority + '_custom"></span> ';
1219 custom_class = task_status + '_custom';
1220 }
1221 let task_count = '';
1222 if ( title_permission == 'yes' ) {
1223 task_count = view_id;
1224 } else {
1225 task_count = '<i class="gg-check"></i>';
1226 }
1227 let task_label = '';
1228 if ( task_status == 'complete' ) {
1229 task_label = task_count;
1230 } else {
1231 task_label = view_id;
1232 }
1233 if ( author ) {
1234 task_config_author_name_parts = task_config_author_name.split(' ');
1235 task_config_author_name_parts[1] = author;
1236 task_config_author_name = task_config_author_name_parts.join(' ');
1237 }
1238
1239 jQuery("div#wpf_task_details .wpf_task_num_top").html(display_span + task_label);
1240 jQuery('#wpf_task_details .wpf_task_num_top').removeClass('complete');
1241 jQuery('#wpf_task_details .wpf_task_num_top').removeAttr('class').addClass('wpf_task_num_top ' + task_status + ' ' + custom_class);
1242 jQuery("div#wpf_task_details .wpf_task_title_top").html(task_page_title);
1243 jQuery("div#wpf_task_details .wpf_task_details_top").html(task_config_author_name);
1244 jQuery("div#wpf_attributes_content #additional_information").html(additional_info_html);
1245 if ( current_user_id == post_author_id || wpf_user_type == 'advisor' ) {
1246 jQuery('#wpf_delete_task_container').html('<a href="javascript:void(0)" class="wpf_task_delete_btn"><i class="gg-trash"></i> ' + wpf_delete_ticket + '</a><p class="wpf_hide" id="wpf_task_delete">' + wpf_delete_conform_text2 + ' <a href="javascript:void(0);" class="wpf_task_delete" data-taskid=' + post_id + ' data-elemid=' + post_task_no + '>' + wpf_yes + '</a></p>');
1247 } else {
1248 jQuery('#wpf_delete_task_container').html('');
1249 }
1250 tss = task_status;
1251 prr = task_priority;
1252 jQuery("#task_task_status_attr").val(task_status);
1253 jQuery("#task_task_priority_attr").val(task_priority);
1254
1255 var wpf_page_url = task_page_url;
1256 if ( wpf_page_url && post_task_status == 'wpf_admin' ) {
1257 var wpf_page_url_with_and = wpf_page_url.split('&')[1];
1258 var wpf_page_url_question = wpf_page_url.split('?')[1];
1259 if ( wpf_page_url_with_and ) {
1260 var saperater = '&';
1261 }
1262 if ( wpf_page_url_question ) {
1263 var saperater = '&';
1264 } else {
1265 var saperater = '?';
1266 }
1267 } else {
1268 var saperater = '?';
1269 }
1270 if ( wpf_task_screenshot == '' ) {
1271 wpf_open_tab('wpf_message_content');
1272 }
1273 if ( post_task_type == 'general' ) {
1274 jQuery("#wpfb_attr_task_page_link").attr("href", task_page_url + saperater + "wpf_general_taskid=" + post_id);
1275 } else if ( post_task_type == 'email' ) {
1276 jQuery("#wpfb_attr_task_page_link").attr("href", task_page_url + saperater + "wpf_general_taskid=" + post_id);
1277 } else if ( post_task_type == 'graphics' ) {
1278 wpf_open_tab('wpf_message_content');
1279 jQuery("#wpfb_attr_task_page_link").attr("href", task_page_url + "&wpf_taskid=" + post_task_no);
1280 } else {
1281 jQuery("#wpfb_attr_task_page_link").attr("href", task_page_url + saperater + "wpf_taskid=" + post_task_no);
1282 }
1283 if ( typeof task_notify_users == 'string' ) {
1284 var task_notify_users_arr = task_notify_users.split(',');
1285 } else {
1286 var task_notify_users_arr = [task_notify_users.toString()];
1287 }
1288 jQuery('#wpf_attributes_content input[name="author_list_task"]').each(function () {
1289 jQuery(this).prop('checked', false);
1290 });
1291 jQuery('#wpf_attributes_content input[name="author_list_task"]').each(function () {
1292 if ( jQuery.inArray(this.value, task_notify_users_arr) != '-1' ) {
1293 jQuery(this).prop('checked', true);
1294 }
1295 });
1296
1297 chat_form = get_wpf_message_form(post_id, post_author_id,task_is_internal);
1298 jQuery('#wpf_message_form').html(chat_form);
1299
1300 if ( onload_wpfb_tasks.data == 0 ) {
1301 chat_form = get_wpf_message_form(post_id, post_author_id,task_is_internal);
1302 jQuery('#wpf_message_form').html(chat_form);
1303 } else {
1304 var chat_form = get_wpf_message_form(post_id, post_author_id,task_is_internal);
1305 jQuery('#wpf_message_form').html(chat_form);
1306 // do not convert link to URl where AWS links are present
1307 if ( onload_wpfb_tasks.data.search(/s3.us-east-2.amazonaws.com/) < 0 ) {
1308 onload_wpfb_tasks.data = onload_wpfb_tasks.data;
1309 }
1310 jQuery('ul#wpf_message_list').html(onload_wpfb_tasks.data);
1311 jQuery('#wpf_task_screenshot').attr('src', wpf_task_screenshot);
1312 jQuery('#wpf_task_screenshot_link').attr('href', wpf_task_screenshot);
1313 jQuery('#all_tag_list').html(onload_wpfb_tasks.wpf_tags);
1314 }
1315 jQuery('#wpf_message_content').animate({scrollTop: jQuery('#wpf_message_content').prop("scrollHeight")}, 2000);
1316
1317 // add rich text editor for Task center by Pratap
1318 jQuery(document).find('.wpf-tc-editor, .wpf-editor').each(function() {
1319 if ( ! jQuery_WPF(this).hasClass('activee') ) {
1320 var $this = jQuery_WPF(this);
1321 jQuery_WPF(this).addClass('activee');
1322 var quill = new Quill(this, {
1323 modules: {
1324 toolbar: [
1325 ['bold', 'italic', 'underline', 'strike'],
1326 [{ list: 'ordered' }, { list: 'bullet' }],
1327 ['link', 'code-block'],
1328 ]
1329 },
1330 placeholder: 'Leave a comment...',
1331 theme: 'bubble' // Specify theme in configuration
1332 });
1333 quill.on('text-change', function(delta, oldDelta, source) {
1334 var isempty = isQuillEmpty( quill );
1335 if ( !isempty ) {
1336 $this.parent().find('textarea').val(quill.root.innerHTML);
1337 } else {
1338 $this.parent().find('textarea').val('');
1339 }
1340 });
1341 }
1342 });
1343 }
1344 }
1345 });
1346 }
1347
1348 // Check if editor is empty before adding value to textarea.
1349 function isQuillEmpty( quill ) {
1350 if ( ( quill.getContents()['ops'] || [] ).length !== 1) {
1351 return false;
1352 }
1353 return quill.getText().trim().length === 0
1354 }
1355
1356 jQuery(document).ready(function ($) {
1357 var wpfeedback_page = getParameterByName('page');
1358 if ( wpfeedback_page == "wpfeedback_page_tasks" ) {
1359 jQuery("button.wpf_tab_item.wpf_tasks").trigger('click');
1360 }
1361 if ( wpfeedback_page == "wpfeedback_page_settings" ) {
1362 jQuery("button.wpf_tab_item.wpf_settings").trigger('click');
1363 }
1364 if ( wpfeedback_page == "wpfeedback_page_integrate" ) {
1365 jQuery("button.wpf_tab_item.wpf_addons").trigger('click');
1366 }
1367 if ( wpfeedback_page == "wpfeedback_page_support" ) {
1368 jQuery("button.wpf_tab_item.wpf_support").trigger('click');
1369 }
1370 if ( wpfeedback_page == "wpfeedback_page_permissions" ) {
1371 jQuery("button.wpf_tab_item.wpf_misc").trigger('click');
1372 }
1373 if ( wpfeedback_page == "wpfeedback_page_graphics" ) {
1374 jQuery("button.wpf_tab_item.wpf_graphics").trigger('click');
1375 }
1376 });
1377 </script>
1378 <?php
1379 }
1380 }
1381 }
1382
1383 /*
1384 * This function is used to initial the Atarim and all related variables on the frontend.
1385 *
1386 * @input NULL
1387 * @return NULL
1388 */
1389 function show_wpf_comment_button() {
1390 global $wpdb, $wp_query, $post;
1391 $wpf_current_page_url = "";
1392 $disable_for_admin = 0;
1393 $currnet_user_information = wpf_get_current_user_information();
1394 $current_role = $currnet_user_information['role'];
1395 $current_user_name = $currnet_user_information['display_name'];
1396 $current_user_id = $currnet_user_information['user_id'];
1397 $wpf_website_builder = get_site_data_by_key( 'wpf_website_developer' );
1398 if ( $current_user_name == 'Guest' ) {
1399 $wpf_website_client = get_site_data_by_key( 'wpf_website_client' );
1400 $wpf_current_role = 'guest';
1401 if ( $wpf_website_client ) {
1402 $wpf_website_client_info = get_userdata( $wpf_website_client );
1403 if ( $wpf_website_client_info ) {
1404 if ( $wpf_website_client_info->display_name == '' ) {
1405 $current_user_name = $wpf_website_client_info->user_nicename;
1406 } else {
1407 $current_user_name = $wpf_website_client_info->display_name;
1408 }
1409 }
1410 }
1411 } else {
1412 $wpf_current_role = wpf_user_type();
1413 }
1414
1415 $current_user_name = addslashes( $current_user_name );
1416 $selected_roles = get_site_data_by_key( 'wpf_selcted_role' );
1417 $selected_roles = explode( ',', $selected_roles );
1418 if ( $wpf_current_role == 'advisor' ) {
1419 $wpf_tab_permission_user = get_site_data_by_key( 'wpf_tab_permission_user_webmaster' );
1420 $wpf_tab_permission_priority = get_site_data_by_key( 'wpf_tab_permission_priority_webmaster' );
1421 $wpf_tab_permission_status = get_site_data_by_key( 'wpf_tab_permission_status_webmaster' );
1422 $wpf_tab_permission_screenshot = get_site_data_by_key( 'wpf_tab_permission_screenshot_webmaster' );
1423 $wpf_tab_permission_information = get_site_data_by_key( 'wpf_tab_permission_information_webmaster' );
1424 $wpf_tab_permission_delete_task = get_site_data_by_key( 'wpf_tab_permission_delete_task_webmaster' );
1425 $wpf_tab_permission_auto_screenshot = get_site_data_by_key( 'wpf_tab_auto_screenshot_task_webmaster' );
1426 $wpf_tab_permission_display_stickers = ( get_site_data_by_key( 'wpf_tab_permission_display_stickers_webmaster' ) != 'no' ) ? 'yes' : 'no';
1427 $wpf_tab_permission_display_task_id = ( get_site_data_by_key( 'wpf_tab_permission_display_task_id_webmaster' ) != 'no' ) ? 'yes' : 'no';
1428 $wpf_tab_permission_keyboard_shortcut = ( get_site_data_by_key( 'wpf_tab_permission_keyboard_shortcut_webmaster' ) != 'no' ) ? 'yes' : 'no';
1429 } else if ( $wpf_current_role == 'king' ) {
1430 $wpf_tab_permission_user = get_site_data_by_key( 'wpf_tab_permission_user_client' );
1431 $wpf_tab_permission_priority = get_site_data_by_key( 'wpf_tab_permission_priority_client' );
1432 $wpf_tab_permission_status = get_site_data_by_key( 'wpf_tab_permission_status_client' );
1433 $wpf_tab_permission_screenshot = get_site_data_by_key( 'wpf_tab_permission_screenshot_client' );
1434 $wpf_tab_permission_information = get_site_data_by_key( 'wpf_tab_permission_information_client' );
1435 $wpf_tab_permission_delete_task = get_site_data_by_key( 'wpf_tab_permission_delete_task_client' );
1436 $wpf_tab_permission_auto_screenshot = get_site_data_by_key( 'wpf_tab_auto_screenshot_task_client' );
1437 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_client' );
1438 $wpf_tab_permission_keyboard_shortcut = get_site_data_by_key( 'wpf_tab_permission_keyboard_shortcut_client' );
1439 $wpf_tab_permission_display_task_id = ( get_site_data_by_key( 'wpf_tab_permission_display_task_id_webmaster' ) != 'no' ) ? 'yes' : 'no';
1440 } else if ( $wpf_current_role == 'council' ) {
1441 $wpf_tab_permission_user = get_site_data_by_key( 'wpf_tab_permission_user_others' );
1442 $wpf_tab_permission_priority = get_site_data_by_key( 'wpf_tab_permission_priority_others' );
1443 $wpf_tab_permission_status = get_site_data_by_key( 'wpf_tab_permission_status_others' );
1444 $wpf_tab_permission_screenshot = get_site_data_by_key( 'wpf_tab_permission_screenshot_others' );
1445 $wpf_tab_permission_information = get_site_data_by_key( 'wpf_tab_permission_information_others' );
1446 $wpf_tab_permission_delete_task = get_site_data_by_key( 'wpf_tab_permission_delete_task_others' );
1447 $wpf_tab_permission_auto_screenshot = get_site_data_by_key( 'wpf_tab_auto_screenshot_task_others' );
1448 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_others' );
1449 $wpf_tab_permission_keyboard_shortcut = get_site_data_by_key( 'wpf_tab_permission_keyboard_shortcut_others' );
1450 $wpf_tab_permission_display_task_id = ( get_site_data_by_key( 'wpf_tab_permission_display_task_id_webmaster' ) != 'no' ) ? 'yes' : 'no';
1451 } else {
1452 $wpf_tab_permission_user = get_site_data_by_key( 'wpf_tab_permission_user_guest' );
1453 $wpf_tab_permission_priority = get_site_data_by_key( 'wpf_tab_permission_priority_guest' );
1454 $wpf_tab_permission_status = get_site_data_by_key( 'wpf_tab_permission_status_guest' );
1455 $wpf_tab_permission_screenshot = get_site_data_by_key( 'wpf_tab_permission_screenshot_guest' );
1456 $wpf_tab_permission_information = get_site_data_by_key( 'wpf_tab_permission_information_guest' );
1457 $wpf_tab_permission_delete_task = get_site_data_by_key( 'wpf_tab_permission_delete_task_guest' );
1458 $wpf_tab_permission_auto_screenshot = get_site_data_by_key( 'wpf_tab_auto_screenshot_task_guest' );
1459 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_guest' );
1460 $wpf_tab_permission_keyboard_shortcut = get_site_data_by_key( 'wpf_tab_permission_keyboard_shortcut_guest' );
1461 $wpf_tab_permission_display_task_id = ( get_site_data_by_key( 'wpf_tab_permission_display_task_id_webmaster' ) != 'no' ) ? 'yes' : 'no';
1462 }
1463
1464 $wpf_disable_for_admin = get_site_data_by_key( 'wpf_disable_for_admin' );
1465 if ( $wpf_disable_for_admin == 'yes' && $current_role == 'administrator' ) {
1466 $disable_for_admin = 1;
1467 } else {
1468 $disable_for_admin = 0;
1469 }
1470
1471 $current_page_id = '';
1472 if ( is_admin() ) {
1473 $current_page_id = get_the_ID();
1474 }
1475 if ( $current_page_id == '' ) {
1476 if ( isset( $wp_query->post->ID ) ) {
1477 $current_page_id = $wp_query->post->ID;
1478 }
1479 }
1480
1481 $current_page_title = addslashes( get_the_title( $current_page_id ) );
1482 $page_type = "default";
1483
1484 if ( class_exists( 'WooCommerce' ) ) {
1485 if ( is_category() ) {
1486 $page_type = "archive";
1487 $category = get_queried_object();
1488 $current_page_id = $category->term_id;
1489 $current_page_url = get_category_link( $current_page_id );
1490 $current_page_title = addslashes( get_cat_name( $current_page_id ) );
1491 } else if ( is_archive() && ( ! is_shop() ) && ( ! is_category() ) ) {
1492 if ( ! is_wp_error( get_term_link( get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) ) ) {
1493 $current_page_url = get_term_link( get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
1494 } else {
1495 $current_page_url = "";
1496 }
1497 } else if ( is_shop() ) {
1498 $current_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
1499 } else if ( is_home() ) {
1500 $current_page_url = get_permalink( get_option( 'page_for_posts' ) );
1501 } else {
1502 $current_page_url = get_permalink( $current_page_id );
1503 }
1504 } else {
1505 if ( is_category() ) {
1506 $page_type = "archive";
1507 $category = get_queried_object();
1508 $current_page_id = $category->term_id;
1509 $current_page_url = get_category_link( $current_page_id );
1510 $current_page_title = addslashes( get_cat_name( $current_page_id ) );
1511 } else if ( is_tag() ) { // tag archieve page
1512 $category = get_queried_object();
1513 $current_page_id = $category->term_id;
1514 $current_page_url = get_category_link( $current_page_id );
1515 $current_page_title = $category->name;
1516 } else if ( is_tax() ) { // taxonomy archieve page
1517 $category = get_queried_object();
1518 $current_page_id = $category->term_id;
1519 $current_page_url = get_category_link( $current_page_id );
1520 $current_page_title = $category->name;
1521 } else if ( is_home() ) {
1522 if ( get_query_var( 'is_graphic_page' ) ) { // for graphic page
1523 $current_page_id = '';
1524 $current_page_title = '';
1525 $current_page_url = '';
1526 } else {
1527 $current_page_url = get_permalink( get_option( 'page_for_posts' ) );
1528 }
1529 } else if ( is_archive() && ( ! is_category() ) ) {
1530 $current_page_url = "";
1531 } else {
1532 $current_page_url = get_permalink( $current_page_id );
1533 }
1534 }
1535 //fallback if URL is not in the database
1536 $fallback_link = 0;
1537 if ( $current_page_id == '' || $current_page_id == 0 || $current_page_url == "" ) {
1538 $fallback_link = 1;
1539 $current_page_id = 0;
1540 $current_page_url = "";
1541 }
1542 $wpf_show_front_stikers = get_site_data_by_key( 'wpf_show_front_stikers' );
1543 $unix_time_now = time();
1544 $wpf_check_atarim_server = get_option( 'atarim_server_down_check' );
1545 if ( $unix_time_now > $wpf_check_atarim_server ) {
1546 update_option( 'atarim_server_down', 'false', 'no' );
1547 }
1548 $atarim_server_down = get_option( 'atarim_server_down' );
1549 $wpfb_users = do_shortcode( '[wpf_user_list_front]' );
1550 $ajax_url = admin_url( 'admin-ajax.php' );
1551 $plugin_url = WPF_PLUGIN_URL;
1552 $sound_file = esc_url( plugins_url( 'images/wpf-screenshot-sound.mp3', __FILE__ ) );
1553 $wpf_tag_enter_img = esc_url( plugins_url( 'images/enter.png', __FILE__ ) );
1554 $bubble_and_db_id = get_last_task_id( true );
1555 $comment_count = $bubble_and_db_id['Dbid'];
1556 $bubble_comment_count = $bubble_and_db_id['Bubbleid'];
1557 $wpf_check_page_builder_active = wpf_check_page_builder_active();
1558
1559 /* =====Start Check customize.php==== */
1560 /*if ( $wpf_check_page_builder_active == 0 ) {
1561 if ( is_customize_preview() ) {
1562 $wpf_check_page_builder_active = 1;
1563 } else {
1564 $wpf_check_page_builder_active = 0;
1565 }
1566 }*/
1567 /* =====END check customize.php==== */
1568
1569 /* =====Start filter sidebar HTML Structure==== */
1570 if ( get_query_var( 'is_graphic_page' ) && $wpf_show_front_stikers == 'yes' ) {
1571 $checkbox_checked = "checked";
1572 } else {
1573 $checkbox_checked = "";
1574 }
1575 $wpf_active = wpf_check_if_enable();
1576 $is_site_archived = get_site_data_by_key( 'wpf_site_archived' );
1577 $backend_btn = '';
1578 $wpf_go_to_cloud_dashboard_btn_tab = '';
1579 if ( $current_user_id > 0 ) {
1580 if ( $wpf_current_role == 'advisor' ) {
1581 $wpf_go_to_cloud_dashboard_btn_tab = '<a href="' . WPF_APP_SITE_URL . '/login" target="_blank" class="wpf_filter_tab_btn cloud_dashboard_btn" title="' . __("Atarim Dashboard", "wpfeedback") . '">'.get_wpf_icon().'</a>';
1582 }
1583 $sidebar_col = "wpf_col3";
1584 $backend_btn = ' <button class="wpf_tab_sidebar wpf_backend" onclick="openWPFTab(\'wpf_backend\')" >' . __('Backend', 'wpfeedback') . '</button>';
1585 if ( get_query_var( 'is_graphic_page' ) ) {
1586 $wpf_current_page_url = site_url() . '/graphic?id=' . sanitize_text_field( $_GET['id'] ) . '?wpf_login=1';
1587 } else {
1588 $wpf_current_page_url = get_permalink() . '?wpf_login=1';
1589 }
1590 } else {
1591 $sidebar_col = "wpf_col2";
1592 }
1593
1594 $wpf_nonce = wpf_wp_create_nonce();
1595 $wpf_admin_bar = 0;
1596 if ( is_admin_bar_showing() ) {
1597 $wpf_admin_bar = 1;
1598 }
1599
1600 $restrict_plugin = get_option( 'restrict_plugin' );
1601 if ( $wpf_active == 1 && $wpf_check_page_builder_active == 0 && ( ! $is_site_archived ) ) {
1602 require_once( WPF_PLUGIN_DIR . 'inc/wpf_popup_string.php' );
1603 echo "<style>li#wp-admin-bar-wpfeedback_admin_bar {display: none !important;}</style>";
1604 if ( $current_page_id == 0 ) {
1605 echo "<script>var fallback_link_check = '$fallback_link', page_type = '$page_type', wpf_tag_enter_img = '$wpf_tag_enter_img', disable_for_admin = '$disable_for_admin', wpf_nonce = '$wpf_nonce', current_role = '$current_role', wpf_current_role = '$wpf_current_role', current_user_name = '$current_user_name', current_user_id = '$current_user_id', wpf_website_builder = '$wpf_website_builder', wpfb_users = '$wpfb_users', ajaxurl = '$ajax_url', current_page_url = window.location.href.split('?')[0], current_page_title = '$current_page_title', current_page_id = '$current_page_id', wpf_screenshot_sound = '$sound_file', plugin_url = '$plugin_url', comment_count = '$comment_count', bubble_comment_count = '$bubble_comment_count', wpf_show_front_stikers = '$wpf_show_front_stikers', wpf_tab_permission_user = '$wpf_tab_permission_user', wpf_tab_permission_priority = '$wpf_tab_permission_priority', wpf_tab_permission_status = '$wpf_tab_permission_status', wpf_tab_permission_screenshot = '$wpf_tab_permission_screenshot', wpf_tab_permission_information = '$wpf_tab_permission_information', wpf_tab_permission_delete_task = '$wpf_tab_permission_delete_task', wpf_tab_permission_auto_screenshot = '$wpf_tab_permission_auto_screenshot', wpf_admin_bar = '$wpf_admin_bar', wpf_tab_permission_display_stickers = '$wpf_tab_permission_display_stickers', wpf_tab_permission_display_task_id = '$wpf_tab_permission_display_task_id', wpf_tab_permission_keyboard_shortcut = '$wpf_tab_permission_keyboard_shortcut', restrict_plugin = '$restrict_plugin', atarim_server_down = '$atarim_server_down';</script>";
1606 } else {
1607 echo "<script>var fallback_link_check = '$fallback_link', page_type = '$page_type', wpf_tag_enter_img = '$wpf_tag_enter_img', disable_for_admin = '$disable_for_admin', wpf_nonce = '$wpf_nonce', current_role = '$current_role', wpf_current_role = '$wpf_current_role', current_user_name = '$current_user_name', current_user_id = '$current_user_id', wpf_website_builder = '$wpf_website_builder', wpfb_users = '$wpfb_users', ajaxurl = '$ajax_url', current_page_url = '$current_page_url', current_page_title = '$current_page_title', current_page_id = '$current_page_id', wpf_screenshot_sound = '$sound_file', plugin_url = '$plugin_url', comment_count = '$comment_count', bubble_comment_count = '$bubble_comment_count', wpf_show_front_stikers = '$wpf_show_front_stikers', wpf_tab_permission_user = '$wpf_tab_permission_user', wpf_tab_permission_priority = '$wpf_tab_permission_priority', wpf_tab_permission_status = '$wpf_tab_permission_status', wpf_tab_permission_screenshot = '$wpf_tab_permission_screenshot', wpf_tab_permission_information = '$wpf_tab_permission_information', wpf_tab_permission_delete_task = '$wpf_tab_permission_delete_task', wpf_tab_permission_auto_screenshot = '$wpf_tab_permission_auto_screenshot', wpf_admin_bar = $wpf_admin_bar, wpf_tab_permission_display_stickers = '$wpf_tab_permission_display_stickers', wpf_tab_permission_display_task_id = '$wpf_tab_permission_display_task_id', wpf_tab_permission_keyboard_shortcut = '$wpf_tab_permission_keyboard_shortcut', restrict_plugin = '$restrict_plugin', atarim_server_down = '$atarim_server_down';</script>";
1608 }
1609 $wpf_sidebar_closeicon = '<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 357 357" enable-background="new 0 0 357 357" xml:space="preserve"><g><g id="close"><polygon fill="#F5325C" points="357,35.7 321.3,0 178.5,142.8 35.7,0 0,35.7 142.8,178.5 0,321.3 35.7,357 178.5,214.2 321.3,357 357,321.3 214.2,178.5 "/></g></g></svg>';
1610 if ( $disable_for_admin == 0 ) {
1611 if ( get_query_var( 'is_graphic_page' ) ) {
1612 $wpf_sidebar_style = "";
1613 $wpf_sidebar_active = "wpf_graphics active";
1614 } else {
1615 $wpf_sidebar_active = "";
1616 $wpf_sidebar_style = "opacity: 0; margin-right: -380px";
1617 }
1618
1619 $wpf_site_id = get_option( 'wpf_site_id' );
1620 $bottom_panel_db = get_option( 'bottom_panel', 1 );
1621 $bottom_style = "";
1622 $bottom_button_style = 'bottom: -67px;';
1623 if ( isset( $bottom_panel_db ) && $bottom_panel_db == '0' ) {
1624 $bottom_button_style = 'bottom: 3px;';
1625 }
1626
1627 /* ================filter Tabs Content HTML================ */
1628 $wpf_task_status_filter_btn = '<div id="wpf_filter_taskstatus" class=""><label class="wpf_filter_title">' . get_wpf_status_icon() . ' ' . __('Filter by Status:', 'wpfeedback') . '</label>' . wp_feedback_get_texonomy_filter("task_status") . '</div>';
1629 $wpf_task_priority_filter_btn = '<div id="wpf_filter_taskpriority" class=""><label class="wpf_filter_title">' . get_wpf_priority_icon() . ' ' . __("Filter by Priority:", "wpfeedback") . '</label>' . wp_feedback_get_texonomy_filter("task_priority") . '</div>';
1630
1631 /* If compact mode enabled, load it and don't load the bottom bar => v2.1.0 */
1632 $enable_compact_mode = get_site_data_by_key('wpf_enabled_compact_mode');
1633 if ( is_feature_enabled( 'bottom_bar_enabled' ) && $enable_compact_mode !== 'yes' ) {
1634 $wpf_sidebar_header = '';
1635 if ( get_query_var( 'is_graphic_page' ) ) {
1636 $wpf_sidebar_header = '<div class="wpf_sidebar_header ' . $sidebar_col . '">
1637 <!-- =================Top Tabs================-->
1638 <div class="top_tabs">
1639 <button class="wpf_tab_sidebar wpf_thispage wpf_active" onclick="openWPFTab(\'wpf_thispage\')" >' . __('This Page', 'wpfeedback') . '</button>
1640 </div>
1641 <div id="sidebar_filters">
1642 <ul class="icons-block">
1643 <li class="status">
1644 <a class="wpf_filter_tab_btn_bottom wpf_btm_withside" data-tag="wpf_task_status_filter_btn" href="javascript:void(0);" title="'.__("Filter By Status", "wpfeedback").'" id="wpf_filter_btn_bottom_status">'
1645 . get_wpf_status_icon().'
1646 </a>
1647 </li>
1648 <li class="priority"> <a id="wpf_filter_btn_bottom_priority" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_task_priority_filter_btn" title="'.__("Filter By Priority", "wpfeedback").'">'. get_wpf_priority_icon().'</a></li>
1649 <li class="search">
1650 <a id="wpf_filter_btn_bottom_search" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_search_filter_btn" title="'.__("Search by task title", "wpfeedback").'">
1651
1652 <svg class="svg-icon search-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16pt" height="16pt" viewBox="0 0 16 16" version="1.1">
1653 <g id="surface1">
1654 <path style=" stroke:none;fill-rule:nonzero;fill:rgb(29.019608%,33.333333%,40.784314%);fill-opacity:1;" d="M 15.386719 13.554688 L 12.101562 10.269531 C 12.78125 9.246094 13.175781 8.023438 13.175781 6.707031 C 13.171875 3.132812 10.277344 0.238281 6.707031 0.234375 C 3.132812 0.238281 0.238281 3.132812 0.234375 6.707031 C 0.238281 10.277344 3.132812 13.171875 6.707031 13.175781 C 8.023438 13.175781 9.246094 12.78125 10.269531 12.101562 L 13.554688 15.386719 C 14.0625 15.890625 14.882812 15.890625 15.386719 15.386719 C 15.890625 14.882812 15.890625 14.0625 15.386719 13.558594 Z M 2.175781 6.707031 C 2.175781 4.207031 4.207031 2.175781 6.707031 2.175781 C 9.203125 2.175781 11.234375 4.207031 11.234375 6.707031 C 11.234375 9.203125 9.203125 11.234375 6.707031 11.234375 C 4.207031 11.234375 2.175781 9.203125 2.175781 6.707031 Z M 2.175781 6.707031 "/>
1655 </g>
1656 </svg>
1657 </a>
1658 </li>
1659 </ul>
1660 </div>
1661 </div>';
1662 } else {
1663 $wpf_sidebar_header = '<div class="wpf_sidebar_header ' . $sidebar_col . '">
1664 <!-- =================Top Tabs================-->
1665 <div class="top_tabs">
1666 <button class="wpf_tab_sidebar wpf_thispage wpf_active" onclick="openWPFTab(\'wpf_thispage\')" >' . __('This Page', 'wpfeedback') . '</button>
1667 <button class="wpf_tab_sidebar wpf_allpages" onclick="openWPFTab(\'wpf_allpages\')" >' . __('All Pages', 'wpfeedback') . '</button>' . $backend_btn . '<span id="close_sidebar" class="close_sidebar" onclick="expand_sidebar()">' . $wpf_sidebar_closeicon . '</span>' . '
1668 </div>
1669 <div id="sidebar_filters">
1670 <ul class="icons-block">
1671 <li class="status">
1672 <a class="wpf_filter_tab_btn_bottom wpf_btm_withside" data-tag="wpf_task_status_filter_btn" href="javascript:void(0);" title="'.__("Filter By Status", "wpfeedback").'" id="wpf_filter_btn_bottom_status">'
1673 . get_wpf_status_icon().'
1674 </a>
1675 </li>
1676 <li class="priority"> <a id="wpf_filter_btn_bottom_priority" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_task_priority_filter_btn" title="'.__("Filter By Priority", "wpfeedback").'">'. get_wpf_priority_icon().'</a></li>
1677 <li class="search">
1678 <a id="wpf_filter_btn_bottom_search" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_search_filter_btn" title="'.__("Search by task title", "wpfeedback").'">
1679
1680 <svg class="svg-icon search-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16pt" height="16pt" viewBox="0 0 16 16" version="1.1">
1681 <g id="surface1">
1682 <path style=" stroke:none;fill-rule:nonzero;fill:rgb(29.019608%,33.333333%,40.784314%);fill-opacity:1;" d="M 15.386719 13.554688 L 12.101562 10.269531 C 12.78125 9.246094 13.175781 8.023438 13.175781 6.707031 C 13.171875 3.132812 10.277344 0.238281 6.707031 0.234375 C 3.132812 0.238281 0.238281 3.132812 0.234375 6.707031 C 0.238281 10.277344 3.132812 13.171875 6.707031 13.175781 C 8.023438 13.175781 9.246094 12.78125 10.269531 12.101562 L 13.554688 15.386719 C 14.0625 15.890625 14.882812 15.890625 15.386719 15.386719 C 15.890625 14.882812 15.890625 14.0625 15.386719 13.558594 Z M 2.175781 6.707031 C 2.175781 4.207031 4.207031 2.175781 6.707031 2.175781 C 9.203125 2.175781 11.234375 4.207031 11.234375 6.707031 C 11.234375 9.203125 9.203125 11.234375 6.707031 11.234375 C 4.207031 11.234375 2.175781 9.203125 2.175781 6.707031 Z M 2.175781 6.707031 "/>
1683 </g>
1684 </svg>
1685 </a>
1686 </li>
1687 </ul>
1688 </div>
1689 </div>';
1690 }
1691
1692 $bottom_bar_html = '<div id="wpf_already_comment" class="wpf_hide"><div class="wpf_notice_title">' . __("Task already exist for this element.", "wpfeedback") . '</div><div class="wpf_notice_text">' . __("Write your message in the existing thread. <br>Here, we opened it for you.", "wpfeedback") . '</div></div><div id="pushed_to_media" class="wpf_hide"><div class="wpf_notice_title">' . __("Pushed to Media Folder.", "wpfeedback") . '</div><div class="wpf_notice_text">' . __("The file was added to the website's media folder, you can now use it from the there.", "wpfeedback") . '</div></div><div id="wpf_reconnecting_task" class="wpf_hide" style="display: none;"><div class="wpf_notice_title">' . __("Remapping task....", "wpfeedback") . '</div><div class="wpf_notice_text">' . __("Give it a few seconds. <br>Then, refresh the page to see the task in the new position.", "wpfeedback") . '</div></div><div id="wpf_reconnecting_enabled" class="wpf_hide" style="display: none;"><div class="wpf_notice_title">' . __("Remap task", "wpfeedback") . '</div><div class="wpf_notice_text">' . __("Place the task anywhere on the page to pinpoint the location of the request.", "wpfeedback") . '</div></div><div id="wpf_launcher" data-html2canvas-ignore="true" ><div class="wpf_launch_buttons" style="'.$bottom_button_style.'"><div class="wpf_start_comment"><a href="javascript:enable_comment();" title="' . __('Click to give your feedback!', 'wpfeedback') . '" data-placement="left" class="comment_btn"><i class="gg-math-plus"></i></a></div>
1693 <div class="wpf_expand"><a href="javascript:expand_bottom_bar()" id="wpf_expand_btn" title="' . __("Panel", "wpfeedback") . '"><img title="Panel" src="'. get_wpf_favicon().'" style="width:65px" /></a></div></div>
1694 <div class="wpf_sidebar_container ' . $wpf_sidebar_active . '" style="' . $wpf_sidebar_style . '";>
1695 '. $wpf_sidebar_header .'
1696 <div class="filter_ui_content">
1697 <div id="wpf_side_filter">
1698 <div class="wpf_list wpf_hide" id="wpf_task_status_filter_btn">' . $wpf_task_status_filter_btn . '</div>
1699 <div class="wpf_list wpf_hide" id="wpf_task_priority_filter_btn">' . $wpf_task_priority_filter_btn . '</div>
1700 <div class="wpf_list wpf_hide" id="wpf_search_filter_btn"><div id="sidebar_search" class="wpf_search_box"><span class="wpf_search_box">
1701 <svg onclick="hide_search_from_sidebar()" class="svg-icon search-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16pt" height="16pt" viewBox="0 0 16 16" version="1.1">
1702 <g id="surface1">
1703 <path style=" stroke:none;fill-rule:nonzero;fill:rgb(29.019608%,33.333333%,40.784314%);fill-opacity:1;" d="M 15.386719 13.554688 L 12.101562 10.269531 C 12.78125 9.246094 13.175781 8.023438 13.175781 6.707031 C 13.171875 3.132812 10.277344 0.238281 6.707031 0.234375 C 3.132812 0.238281 0.238281 3.132812 0.234375 6.707031 C 0.238281 10.277344 3.132812 13.171875 6.707031 13.175781 C 8.023438 13.175781 9.246094 12.78125 10.269531 12.101562 L 13.554688 15.386719 C 14.0625 15.890625 14.882812 15.890625 15.386719 15.386719 C 15.890625 14.882812 15.890625 14.0625 15.386719 13.558594 Z M 2.175781 6.707031 C 2.175781 4.207031 4.207031 2.175781 6.707031 2.175781 C 9.203125 2.175781 11.234375 4.207031 11.234375 6.707031 C 11.234375 9.203125 9.203125 11.234375 6.707031 11.234375 C 4.207031 11.234375 2.175781 9.203125 2.175781 6.707031 Z M 2.175781 6.707031 "/>
1704 </g>
1705 </svg>
1706 <input onkeyup="wp_feedback_cat_filter(event, this)" type="text" name="wpf_search_title" class="wpf_search_title" value="" id="wpf_search_title" placeholder="'.__("Search by task title", "wpfeedback").'"></span></div></div>
1707 </div>
1708 </div>
1709 <div class="wpf_sidebar_content">
1710 <div class="wpf_sidebar_loader wpf_hide"></div>
1711 <div id="wpf_thispage" class="wpf_thispage_tab wpf_container wpf_active_filter"><!--<div class="custom_today">today</div>--><ul id="wpf_thispage_container_today"></ul><!--<div class="custom_yesterday">yesterday</div> --> <ul id="wpf_thispage_container_yesterday"></ul><!-- <div class="custom_Weekly">Weekly</div> --> <ul id="wpf_thispage_container_this_week"></ul><!-- <div class="custom_this_month">This Month</div> --> <ul id="wpf_thispage_container_this_month"></ul><!-- <div class="custom_year">This Year</div> --> <ul id="wpf_thispage_container_year"></ul> <!-- <div class="custom_other">Other</div> --> <ul id="wpf_thispage_container_other"></ul></div>
1712 <div id="wpf_allpages" class="wpf_allpages_tab wpf_container" style="display:none";><!--<div class="custom_today">today</div>--><ul id="wpf_allpages_container_today"></ul><!--<div class="custom_yesterday">yesterday</div> --> <ul id="wpf_allpages_container_yesterday"></ul><!-- <div class="custom_Weekly">Weekly</div> --> <ul id="wpf_allpages_container_this_week"></ul><!-- <div class="custom_this_month">This Month</div> --> <ul id="wpf_allpages_container_this_month"></ul><!-- <div class="custom_year">This Year</div> --> <ul id="wpf_allpages_container_year"></ul> <!-- <div class="custom_other">Other</div> --> <ul id="wpf_allpages_container_other"></ul></div>
1713 <div class="wpf_loading">Loading...</div>
1714 <div id="wpf_backend" class="wpf_backend_tab wpf_container" style="display:none";><!--<div class="custom_today">today</div>--><ul id="wpf_backend_container_today"></ul><!--<div class="custom_yesterday">yesterday</div> --> <ul id="wpf_backend_container_yesterday"></ul><!-- <div class="custom_Weekly">Weekly</div> --> <ul id="wpf_backend_container_this_week"></ul><!-- <div class="custom_this_month">This Month</div> --> <ul id="wpf_backend_container_this_month"></ul><!-- <div class="custom_year">This Year</div> --> <ul id="wpf_backend_container_year"></ul> <!-- <div class="custom_other">Other</div> --> <ul id="wpf_backend_container_other"></ul></div>
1715 </div>
1716 </div>'.generate_bottom_part_html().'
1717 </div>';
1718 } else {
1719 $wpf_graphics_page_class = '';
1720 $wpf_sidebar_header = '';
1721 if ( get_query_var( 'is_graphic_page' ) ) {
1722 $wpf_graphics_page_class = 'graphic_page_compact_buttons';
1723 $wpf_sidebar_header = '<div class="wpf_sidebar_header ' . $sidebar_col . '">
1724 <!-- =================Top Tabs================-->
1725 <div class="top_tabs">
1726 <button class="wpf_tab_sidebar wpf_thispage wpf_active" onclick="openWPFTab(\'wpf_thispage\')" >' . __('This Page', 'wpfeedback') . '</button>
1727 </div>
1728 <div id="sidebar_filters">
1729 <ul class="icons-block">
1730 <li class="status">
1731 <a class="wpf_filter_tab_btn_bottom wpf_btm_withside" data-tag="wpf_task_status_filter_btn" href="javascript:void(0);" title="'.__("Filter By Status", "wpfeedback").'" id="wpf_filter_btn_bottom_status">'
1732 . get_wpf_status_icon().'
1733 </a>
1734 </li>
1735 <li class="priority"> <a id="wpf_filter_btn_bottom_priority" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_task_priority_filter_btn" title="'.__("Filter By Priority", "wpfeedback").'">'. get_wpf_priority_icon().'</a></li>
1736 <li class="search">
1737 <a id="wpf_filter_btn_bottom_search" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_search_filter_btn" title="'.__("Search by task title", "wpfeedback").'">
1738 <svg class="svg-icon search-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16pt" height="16pt" viewBox="0 0 16 16" version="1.1">
1739 <g id="surface1">
1740 <path style=" stroke:none;fill-rule:nonzero;fill:rgb(29.019608%,33.333333%,40.784314%);fill-opacity:1;" d="M 15.386719 13.554688 L 12.101562 10.269531 C 12.78125 9.246094 13.175781 8.023438 13.175781 6.707031 C 13.171875 3.132812 10.277344 0.238281 6.707031 0.234375 C 3.132812 0.238281 0.238281 3.132812 0.234375 6.707031 C 0.238281 10.277344 3.132812 13.171875 6.707031 13.175781 C 8.023438 13.175781 9.246094 12.78125 10.269531 12.101562 L 13.554688 15.386719 C 14.0625 15.890625 14.882812 15.890625 15.386719 15.386719 C 15.890625 14.882812 15.890625 14.0625 15.386719 13.558594 Z M 2.175781 6.707031 C 2.175781 4.207031 4.207031 2.175781 6.707031 2.175781 C 9.203125 2.175781 11.234375 4.207031 11.234375 6.707031 C 11.234375 9.203125 9.203125 11.234375 6.707031 11.234375 C 4.207031 11.234375 2.175781 9.203125 2.175781 6.707031 Z M 2.175781 6.707031 "/>
1741 </g>
1742 </svg>
1743 </a>
1744 </li>
1745 </ul>
1746 </div>
1747 </div>';
1748 } else {
1749 $wpf_sidebar_header = '<div class="wpf_sidebar_header ' . $sidebar_col . '">
1750 <!-- =================Top Tabs================-->
1751 <div class="top_tabs">
1752 <button class="wpf_tab_sidebar wpf_thispage wpf_active" onclick="openWPFTab(\'wpf_thispage\')" >' . __('This Page', 'wpfeedback') . '</button>
1753 <button class="wpf_tab_sidebar wpf_allpages" onclick="openWPFTab(\'wpf_allpages\')" >' . __('All Pages', 'wpfeedback') . '</button>' . $backend_btn . '<span id="close_sidebar" class="close_sidebar" onclick="expand_compact_sidebar()">' . $wpf_sidebar_closeicon . '</span>' . '
1754 </div>
1755 <div id="sidebar_filters">
1756 <ul class="icons-block">
1757 <li class="status">
1758 <a class="wpf_filter_tab_btn_bottom wpf_btm_withside" data-tag="wpf_task_status_filter_btn" href="javascript:void(0);" title="Filter By Status" id="wpf_filter_btn_bottom_status">'
1759 . get_wpf_status_icon().'
1760 </a>
1761 </li>
1762 <li class="priority"> <a id="wpf_filter_btn_bottom_priority" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_task_priority_filter_btn" title="Filter By Priority">'. get_wpf_priority_icon().'</a></li>
1763 <li class="search">
1764 <a id="wpf_filter_btn_bottom_search" class="wpf_filter_tab_btn_bottom wpf_btm_withside" href="javascript:void(0);" data-tag="wpf_search_filter_btn" title="'.__("Search by task title", "wpfeedback").'">
1765 <svg class="svg-icon search-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16pt" height="16pt" viewBox="0 0 16 16" version="1.1">
1766 <g id="surface1">
1767 <path style=" stroke:none;fill-rule:nonzero;fill:rgb(29.019608%,33.333333%,40.784314%);fill-opacity:1;" d="M 15.386719 13.554688 L 12.101562 10.269531 C 12.78125 9.246094 13.175781 8.023438 13.175781 6.707031 C 13.171875 3.132812 10.277344 0.238281 6.707031 0.234375 C 3.132812 0.238281 0.238281 3.132812 0.234375 6.707031 C 0.238281 10.277344 3.132812 13.171875 6.707031 13.175781 C 8.023438 13.175781 9.246094 12.78125 10.269531 12.101562 L 13.554688 15.386719 C 14.0625 15.890625 14.882812 15.890625 15.386719 15.386719 C 15.890625 14.882812 15.890625 14.0625 15.386719 13.558594 Z M 2.175781 6.707031 C 2.175781 4.207031 4.207031 2.175781 6.707031 2.175781 C 9.203125 2.175781 11.234375 4.207031 11.234375 6.707031 C 11.234375 9.203125 9.203125 11.234375 6.707031 11.234375 C 4.207031 11.234375 2.175781 9.203125 2.175781 6.707031 Z M 2.175781 6.707031 "/>
1768 </g>
1769 </svg>
1770 </a>
1771 </li>
1772 </ul>
1773 </div>
1774 </div>';
1775 }
1776 $bottom_bar_html = '<div id="wpf_launcher" class="wpf-compact-launcher" data-html2canvas-ignore="true" style="user-select: auto;">
1777
1778 <div id="wpf_launch_buttons_wrapper">
1779 <div class="wpf_launch_buttons ' . $wpf_graphics_page_class . '" style="user-select: auto; left: -56px;">
1780 <div class="wpf_start_comment" style="user-select: auto;">
1781 <a href="javascript:enable_comment();" title="Click to leave a comment" data-placement="left" class="comment_btn" style="user-select: auto; cursor: pointer;">
1782 <i class="gg-math-plus" style="user-select: auto;"></i>
1783 </a>
1784 </div>
1785
1786 <div class="wpf_expand" style="user-select: auto;">
1787 <a href="javascript:expand_compact_sidebar()" id="wpf_expand_btn" title="Collaboration Sidebar" style="user-select: auto; cursor: pointer;" class="tasks-btn">
1788 <img src="' . get_wpf_favicon() . '" />
1789 </a>
1790 </div>
1791
1792 <div class="wpf_general_comment">
1793 <a class="wpf_green_btn wpf_general_btn wpf_comment_mode_general_task active_comment" id="wpf_comment_mode_general_task" href="javascript:void(0)" onclick="wpf_new_general_task(0)" title="Click to create a generic request" style="user-select: auto; cursor: crosshair;">
1794 '. get_wpf_exclamation_icon() .'
1795 <span style="user-select: auto;">'. __('General', 'wpfeedback') .'</span>
1796 </a>
1797 </div>
1798 </div>
1799 </div>
1800
1801 <div class="wpf_sidebar_container ' . $wpf_sidebar_active . '" style="' . $wpf_sidebar_style . '";>
1802 ' . $wpf_sidebar_header . '
1803 <div class="filter_ui_content">
1804 <div id="wpf_side_filter">
1805 <div class="wpf_list wpf_hide" id="wpf_task_status_filter_btn">' . $wpf_task_status_filter_btn . '</div>
1806 <div class="wpf_list wpf_hide" id="wpf_task_priority_filter_btn">' . $wpf_task_priority_filter_btn . '</div>
1807 <div class="wpf_list wpf_hide" id="wpf_search_filter_btn"><div id="sidebar_search" class="wpf_search_box"><span class="wpf_search_box">
1808 <svg onclick="hide_search_from_sidebar()" class="svg-icon search-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16pt" height="16pt" viewBox="0 0 16 16" version="1.1">
1809 <g id="surface1">
1810 <path style=" stroke:none;fill-rule:nonzero;fill:rgb(29.019608%,33.333333%,40.784314%);fill-opacity:1;" d="M 15.386719 13.554688 L 12.101562 10.269531 C 12.78125 9.246094 13.175781 8.023438 13.175781 6.707031 C 13.171875 3.132812 10.277344 0.238281 6.707031 0.234375 C 3.132812 0.238281 0.238281 3.132812 0.234375 6.707031 C 0.238281 10.277344 3.132812 13.171875 6.707031 13.175781 C 8.023438 13.175781 9.246094 12.78125 10.269531 12.101562 L 13.554688 15.386719 C 14.0625 15.890625 14.882812 15.890625 15.386719 15.386719 C 15.890625 14.882812 15.890625 14.0625 15.386719 13.558594 Z M 2.175781 6.707031 C 2.175781 4.207031 4.207031 2.175781 6.707031 2.175781 C 9.203125 2.175781 11.234375 4.207031 11.234375 6.707031 C 11.234375 9.203125 9.203125 11.234375 6.707031 11.234375 C 4.207031 11.234375 2.175781 9.203125 2.175781 6.707031 Z M 2.175781 6.707031 "/>
1811 </g>
1812 </svg>
1813 <input onkeyup="wp_feedback_cat_filter(event, this)" type="text" name="wpf_search_title" class="wpf_search_title" value="" id="wpf_search_title" placeholder="'.__("Search by task title", "wpfeedback").'"></span></div></div>
1814 </div>
1815 </div>
1816 <div class="wpf_sidebar_content">
1817 <div class="wpf_sidebar_loader wpf_hide"></div>
1818 <div id="wpf_thispage" class="wpf_thispage_tab wpf_container wpf_active_filter"><!--<div class="custom_today">today</div>--><ul id="wpf_thispage_container_today"></ul><!--<div class="custom_yesterday">yesterday</div> --> <ul id="wpf_thispage_container_yesterday"></ul><!-- <div class="custom_Weekly">Weekly</div> --> <ul id="wpf_thispage_container_this_week"></ul><!-- <div class="custom_this_month">This Month</div> --> <ul id="wpf_thispage_container_this_month"></ul><!-- <div class="custom_year">This Year</div> --> <ul id="wpf_thispage_container_year"></ul> <!-- <div class="custom_other">Other</div> --> <ul id="wpf_thispage_container_other"></ul></div>
1819 <div id="wpf_allpages" class="wpf_allpages_tab wpf_container" style="display:none";><!--<div class="custom_today">today</div>--><ul id="wpf_allpages_container_today"></ul><!--<div class="custom_yesterday">yesterday</div> --> <ul id="wpf_allpages_container_yesterday"></ul><!-- <div class="custom_Weekly">Weekly</div> --> <ul id="wpf_allpages_container_this_week"></ul><!-- <div class="custom_this_month">This Month</div> --> <ul id="wpf_allpages_container_this_month"></ul><!-- <div class="custom_year">This Year</div> --> <ul id="wpf_allpages_container_year"></ul> <!-- <div class="custom_other">Other</div> --> <ul id="wpf_allpages_container_other"></ul></div>
1820 <div class="wpf_loading">Loading...</div>
1821 <div id="wpf_backend" class="wpf_backend_tab wpf_container" style="display:none";><!--<div class="custom_today">today</div>--><ul id="wpf_backend_container_today"></ul><!--<div class="custom_yesterday">yesterday</div> --> <ul id="wpf_backend_container_yesterday"></ul><!-- <div class="custom_Weekly">Weekly</div> --> <ul id="wpf_backend_container_this_week"></ul><!-- <div class="custom_this_month">This Month</div> --> <ul id="wpf_backend_container_this_month"></ul><!-- <div class="custom_year">This Year</div> --> <ul id="wpf_backend_container_year"></ul> <!-- <div class="custom_other">Other</div> --> <ul id="wpf_backend_container_other"></ul></div>
1822 </div>
1823 </div>'.generate_side_part_html().'
1824 </div>';
1825 }
1826
1827 echo $bottom_bar_html;
1828 $wpf_get_user_type = get_user_meta( $current_user_id, 'wpf_user_initial_setup', true );
1829 if ( $wpf_get_user_type == '' && $current_user_id && in_array( $current_role, $selected_roles ) ) {
1830 $wpf_get_user_typpe = get_user_meta( $current_user_id, 'wpf_user_initial_setup', true );
1831 $wpf_get_user_type = esc_attr( wpf_user_type() );
1832 $wpf_user_flow = isset( $_GET['wpf-user-flow'] ) ? true : false;
1833 if ( ! $wpf_get_user_type ) {
1834 delete_option( 'wpf_app_user_flow' );
1835 }
1836 if ( isset( $_GET['wpf-user-flow'] ) && ! get_option( 'wpf_app_user_flow' ) ) {
1837 update_option( 'wpf_app_user_flow', true );
1838 $wpf_app_user_flow = true;
1839 $wpf_user_flow = true;
1840 } else if ( isset( $_GET['wpf-existing-user-flow'] ) ) {
1841 $wpf_app_user_flow = false;
1842 $wpf_user_flow = false;
1843 } else {
1844 $wpf_app_user_flow = true;
1845 $wpf_user_flow = true;
1846 }
1847 if ( $wpf_get_user_typpe == '' && $current_user_id && in_array( $current_role, $selected_roles ) && ( $wpf_app_user_flow && $wpf_user_flow ) ) {
1848 require_once( WPF_PLUGIN_DIR . 'inc/frontend/wpf_frontend_initial_setup.php' );
1849 }
1850 }
1851 require_once( WPF_PLUGIN_DIR . 'inc/frontend/wpf_general_task_modal.php' );
1852 require_once( WPF_PLUGIN_DIR . 'inc/frontend/wpf_approve_page_modal.php' );
1853 require_once( WPF_PLUGIN_DIR . 'inc/frontend/wpf_responsive_page_modal.php' );
1854 require_once( WPF_PLUGIN_DIR . 'inc/frontend/wpf_restrictions_modal.php' );
1855 }
1856 }
1857 $wpf_enabled = get_site_data_by_key( 'enabled_wpfeedback' );
1858
1859 if ( ! is_user_logged_in() && ( $wpf_enabled == 'yes' && ( ! $is_site_archived ) ) ) {
1860 require_once( WPF_PLUGIN_DIR . 'inc/frontend/wpf_login_modal.php' );
1861 }
1862 }
1863
1864 add_action( 'wp_footer', 'show_wpf_comment_button' );
1865 function wpf_check_permission() {
1866 $currnet_user_information = wpf_get_current_user_information();
1867 $current_role = $currnet_user_information['role'];
1868 $current_user_name = $currnet_user_information['display_name'];
1869 $current_user_id = $currnet_user_information['user_id'];
1870 $wpf_website_builder = get_site_data_by_key( 'wpf_website_developer' );
1871 if ( $current_user_name == 'Guest' ) {
1872 $wpf_website_client = get_site_data_by_key( 'wpf_website_client' );
1873 $wpf_current_role = 'guest';
1874 if ( $wpf_website_client ) {
1875 $wpf_website_client_info = get_userdata( $wpf_website_client );
1876 if ( $wpf_website_client_info ) {
1877 if ( $wpf_website_client_info->display_name == '' ) {
1878 $current_user_name = $wpf_website_client_info->user_nicename;
1879 } else {
1880 $current_user_name = $wpf_website_client_info->display_name;
1881 }
1882 }
1883 }
1884 } else {
1885 $wpf_current_role = wpf_user_type();
1886 }
1887
1888 $current_user_name = addslashes($current_user_name);
1889 if ( $wpf_current_role == 'advisor' ) {
1890 $wpf_tab_permission_display_stickers = ( get_site_data_by_key( 'wpf_tab_permission_display_stickers_webmaster' ) != 'no' ) ? 'yes' : 'no';
1891 $wpf_tab_permission_display_task_id = ( get_site_data_by_key( 'wpf_tab_permission_display_task_id_webmaster' ) != 'no' ) ? 'yes' : 'no';
1892 } else if ( $wpf_current_role == 'king' ) {
1893 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_client' );
1894 $wpf_tab_permission_display_task_id = get_site_data_by_key( 'wpf_tab_permission_display_task_id_client' );
1895 } else if ( $wpf_current_role == 'council' ) {
1896 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_others' );
1897 $wpf_tab_permission_display_task_id = get_site_data_by_key( 'wpf_tab_permission_display_task_id_others' );
1898 } else {
1899 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_guest' );
1900 $wpf_tab_permission_display_task_id = get_site_data_by_key( 'wpf_tab_permission_display_task_id_guest' );
1901 }
1902 }
1903
1904 function add_sticker_permission_to_head() {
1905 $currnet_user_information = wpf_get_current_user_information();
1906 $current_role = $currnet_user_information['role'];
1907 $current_user_name = $currnet_user_information['display_name'];
1908 $current_user_id = $currnet_user_information['user_id'];
1909 $wpf_website_builder = get_site_data_by_key( 'wpf_website_developer' );
1910 if ( $current_user_name == 'Guest' ) {
1911 $wpf_website_client = get_site_data_by_key( 'wpf_website_client' );
1912 $wpf_current_role = 'guest';
1913 if ( $wpf_website_client ) {
1914 $wpf_website_client_info = get_userdata( $wpf_website_client );
1915 if ( $wpf_website_client_info ) {
1916 if ( $wpf_website_client_info->display_name == '' ) {
1917 $current_user_name = $wpf_website_client_info->user_nicename;
1918 } else {
1919 $current_user_name = $wpf_website_client_info->display_name;
1920 }
1921 }
1922 }
1923 } else {
1924 $wpf_current_role = wpf_user_type();
1925 }
1926 $current_user_name = addslashes( $current_user_name );
1927
1928 if ( $wpf_current_role == 'advisor' ) {
1929 $wpf_tab_permission_display_stickers = ( get_site_data_by_key( 'wpf_tab_permission_display_stickers_webmaster' ) != 'no' ) ? 'yes' : 'no';
1930 $wpf_tab_permission_display_task_id = ( get_site_data_by_key( 'wpf_tab_permission_display_task_id_webmaster' ) != 'no' ) ? 'yes' : 'no';
1931 } elseif ( $wpf_current_role == 'king' ) {
1932 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_client' );
1933 $wpf_tab_permission_display_task_id = get_site_data_by_key( 'wpf_tab_permission_display_task_id_client' );
1934 } elseif ( $wpf_current_role == 'council' ) {
1935 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_others' );
1936 $wpf_tab_permission_display_task_id = get_site_data_by_key( 'wpf_tab_permission_display_task_id_others' );
1937 } else {
1938 $wpf_tab_permission_display_stickers = get_site_data_by_key( 'wpf_tab_permission_display_stickers_guest' );
1939 $wpf_tab_permission_display_task_id = get_site_data_by_key( 'wpf_tab_permission_display_task_id_guest' );
1940 }
1941
1942 echo '<script>var new_global_sticker_permission = "' . $wpf_tab_permission_display_stickers . '", new_global_task_id_permission = "' . $wpf_tab_permission_display_task_id . '"</script>';
1943 }
1944 add_filter( 'admin_head', 'add_sticker_permission_to_head' );
1945
1946
1947 /*
1948 * This function is used to remove the backend menu for the wpfeedback post type so they are not accessible by backend users.
1949 *
1950 * @input NULL
1951 * @return NULL
1952 */
1953 function wpf_disable_comments_admin_menu() {
1954 remove_menu_page( 'edit.php?post_type=wpfeedback' );
1955 }
1956 add_action( 'admin_menu', 'wpf_disable_comments_admin_menu' );
1957
1958
1959 /*
1960 * This function is used to disabled the Atarim features on Atarim pages.
1961 *
1962 * @input NULL
1963 * @return NULL
1964 */
1965 function wpf_exclude_comments( $query ) {
1966 if ( $query->query_vars['type'] !== 'wp_feedback' ) {
1967 $query->query_vars['type__not_in'] = array_merge( (array) $query->query_vars['type__not_in'], array('wp_feedback') );
1968 }
1969 }
1970 add_action( 'pre_get_comments', 'wpf_exclude_comments' );
1971
1972
1973 /*
1974 * This function is used to set the redirect of Upgrade menu item.
1975 *
1976 * @input NULL
1977 * @return NULL
1978 */
1979 function wpf_upgrade_menu_page_redirect() {
1980 $wpf_license = get_option( 'wpf_license' );
1981 $wpf_user_type = wpf_user_type();
1982 if ( $wpf_license != 'valid' ) {
1983 ?>
1984 <style type="text/css">
1985 div#wpf_tasks {
1986 position: relative;
1987 }
1988 </style>
1989 <?php
1990 }
1991 if ( $wpf_user_type == 'advisor' ) {
1992 ?>
1993 <script type="text/javascript">
1994 jQuery(document).ready(function ($) {
1995 jQuery('#toplevel_page_wp_feedback ul li').last().find('a').attr('target', '_blank');
1996 });
1997 </script>
1998 <?php
1999 }
2000 }
2001 add_action( 'admin_head', 'wpf_upgrade_menu_page_redirect' );
2002
2003 require_once( WPF_PLUGIN_DIR . 'inc/wpf_class.php' );
2004
2005 /*
2006 * This function is used to redirect the users to the settings page on the activation of the plugin.
2007 *
2008 * @input String
2009 * @return Redirect
2010 */
2011 function wpf_activation_redirect( $plugin ) {
2012 if ( $plugin == plugin_basename( __FILE__ ) ) {
2013 $url = admin_url( 'admin.php?page=wpfeedback_page_settings' );
2014 wp_redirect( $url );
2015 exit;
2016 }
2017 }
2018 add_action( 'activated_plugin', 'wpf_activation_redirect', 10, 1 );
2019
2020 /*
2021 * This function is used to detect if the page builder is active on the current running page.
2022 *
2023 * @input NULL
2024 * @return Boolean
2025 */
2026 function wpf_check_page_builder_active() {
2027 $page_builder = 0;
2028 /* ========Check Divi editor Active======== */
2029 if ( isset( $_GET['et_fb'] ) || ( is_admin() && function_exists( 'et_pb_is_pagebuilder_used' ) && et_pb_is_pagebuilder_used() ) ) {
2030 $page_builder = 1;
2031 } else if ( isset( $_GET['page'] ) ) {
2032 if ( $_GET['page'] == 'et_theme_builder' ) {
2033 $page_builder = 1;
2034 }
2035 } else if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_active() ) { /* ------Check wpbeaver editor Active------- */
2036 $page_builder = 1;
2037 } else if ( isset( $_GET['brizy-edit'] ) || isset( $_GET['brizy-edit-iframe'] ) || isset( $_GET['brizy_post'] ) ) { /* ========Check brizy editor Active======== */
2038 $page_builder = 1;
2039 } else if ( isset( $_GET['ct_builder'] ) || isset( $_GET['ct_template'] ) ) { /* =======Check oxygen editor Active======== */
2040 $page_builder = 1;
2041 } else if ( isset( $_POST['cs_preview_state'] ) ) { /* =======Check Cornerstone editor Active======== */
2042 $page_builder = 1;
2043 } else if ( isset( $_GET['vc_editable'] ) ) { /* ------Check Visual Composer Active======== */
2044 $page_builder = 1;
2045 } else if ( isset( $_GET['action'] ) && $_GET['action'] == 'edit' && isset( $_GET['vcv-action'] ) && $_GET['vcv-action'] == 'frontend' ) {
2046 $page_builder = 1;
2047 } else if ( isset( $_GET['bricks'] ) ) { /* ------Check Bricks editor Active======== */
2048 $page_builder = 1;
2049 } else if ( ! empty( $_GET ) && array_key_exists( 'is-editor-iframe', $_GET ) && $_GET['is-editor-iframe'] != '' ) { /* ------Check Generate Press editor Active======== */
2050 $page_builder = 1;
2051 } else if ( defined( 'ELEMENTOR_VERSION' ) ) { /* ------Check elementor editor Active======== */
2052 if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
2053 $page_builder = 1;
2054 } else {
2055 $page_builder = 0;
2056 }
2057 } else if ( is_customize_preview() ) {
2058 $page_builder = 1;
2059 } else {
2060 $page_builder = 0;
2061 }
2062 return $page_builder;
2063 }
2064
2065
2066 /**
2067 * Load the plugin text domain for translation.
2068 *
2069 */
2070 function wpf_load_plugin_textdomain() {
2071 $domain = 'wpfeedback';
2072 if ( is_user_logged_in() ) {
2073 $get_locale = get_user_locale( $user_id = 0 );
2074 } else {
2075 $get_locale = get_locale();
2076 }
2077 $locale = apply_filters( 'plugin_locale', $get_locale, $domain );
2078 load_textdomain( $domain, trailingslashit( WPF_PLUGIN_DIR . '/languages/' ) . $domain . '-' . $locale . '.mo' );
2079 load_plugin_textdomain( $domain, FALSE, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages/' );
2080 }
2081 add_action( 'init', 'wpf_load_plugin_textdomain', 10 );
2082
2083
2084 /*
2085 * This function is used to identify if certain themes/plugins are so that jquery UI can be de registered.
2086 *
2087 * @input NULL
2088 * @return Boolean
2089 */
2090 function wpf_remove_ui_script() {
2091 $response = 1;
2092 if ( function_exists( 'get_field' ) ) {
2093 $response = 0;
2094 }
2095 if ( class_exists( 'PMXI_Plugin' ) ) {
2096 $response = 0;
2097 }
2098 if ( class_exists( 'Avada' ) ) {
2099 $response = 0;
2100 }
2101 if ( class_exists( 'WooCommerce' ) ) {
2102 $response = 0;
2103 }
2104 if ( class_exists( 'The7_Less_Functions' ) ) {
2105 $response = 0;
2106 }
2107 if ( class_exists( 'iHomefinderAutoloader' ) ) {
2108 $response = 0;
2109 }
2110 return $response;
2111 }
2112
2113
2114 /*
2115 * function is used to get last task no
2116 */
2117 function get_last_task_id( $returnBubbleId = false ) {
2118 $url = WPF_CRM_API . 'wp-api/site/taskCount';
2119 $sendarr = array();
2120 $sendarr["wpf_site_id"] = get_option( 'wpf_site_id' );
2121 $sendtocloud = json_encode( $sendarr );
2122 $response = wpf_send_remote_post( $url, $sendtocloud );
2123 $last_id = 1;
2124 $bubble_id = 1;
2125 if ( isset( $response['data'] ) ) {
2126 $last_id = $response['data'] + 1;
2127 $bubble_id = $response['sitetaskid'] + 1;
2128 }
2129 if ( $returnBubbleId == true ) {
2130 $res = array();
2131 $res['Dbid'] = $last_id;
2132 $res['Bubbleid'] = $bubble_id;
2133 return $res;
2134 }
2135 return $last_id;
2136 }
2137
2138
2139 /*
2140 * function is used to get site settings data
2141 * and stored in session
2142 */
2143 function get_site_data() {
2144 $ret = 0;
2145 if ( ! is_user_logged_in() ) {
2146 if ( ! get_option( 'enabled_wpfeedback' ) == 'yes' ) {
2147 $ret = 1;
2148 } else {
2149 if ( ! get_option( 'wpf_allow_guest' ) == 'yes' ) {
2150 $ret = 1;
2151 } else {
2152 $ret = 0;
2153 }
2154 }
2155 }
2156
2157 if ( $ret == 1 ) {
2158 return;
2159 }
2160
2161 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { /* it's an Ajax call */
2162 } else if( get_option( 'wpf_license' ) != 'valid' ) {
2163 } else {
2164 $wpf_site_id = get_option('wpf_site_id');
2165 $args = array(
2166 'wpf_site_id' => $wpf_site_id
2167 );
2168 $url = WPF_CRM_API . 'get-site-data';
2169 $sendtocloud = json_encode( $args );
2170 $res_data = wpf_send_remote_post( $url, $sendtocloud );
2171 if ( isset( $res_data['status'] ) && $res_data['status'] == '200' && isset( $res_data['data'] ) ) {
2172 $site_data = $res_data['data'];
2173 foreach ( $site_data as $key => $sdata ) {
2174 if ( ( $sdata == 0 || ! empty( $sdata ) ) && ( $key != 'wpf_license' ) ) {
2175 update_option( $key, $sdata, 'no' );
2176 }
2177 }
2178 } else {
2179 }
2180 }
2181 }
2182
2183
2184 /*
2185 * function is used to get site notify user
2186 * and stored in session
2187 */
2188 function get_notify_users() {
2189 $ret = 0;
2190 if ( ! is_user_logged_in() ) {
2191 if ( ! get_option( 'enabled_wpfeedback' ) == 'yes' ) {
2192 $ret = 1;
2193 } else {
2194 if ( ! get_option( 'wpf_allow_guest' ) == 'yes' ) {
2195 $ret = 1;
2196 } else {
2197 $ret = 0;
2198 }
2199 }
2200 }
2201
2202 if ( $ret == 1 ) {
2203 return;
2204 }
2205
2206 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { /* it's an Ajax call */
2207 } else if ( get_option( 'wpf_license' ) != 'valid' ) {
2208 } else {
2209 $wpf_site_id = get_option( 'wpf_site_id' );
2210 $args = array(
2211 'wpf_site_id' => $wpf_site_id
2212 );
2213
2214 $url = WPF_CRM_API . 'wp-api/wpfuser/getNotifiedUsers';
2215 $sendtocloud = json_encode( $args );
2216 $filterData = wpf_send_remote_post( $url, $sendtocloud );
2217
2218 if ( isset( $filterData['status'] ) && $filterData['status'] == '200' ) {
2219 $notify_users = $filterData['data'];
2220 if ( ! empty( $notify_users ) ) {
2221 update_option( 'notify_users', $notify_users, "no" );
2222 } else {
2223 update_option( 'notify_users', '', "no" );
2224 }
2225 }else{
2226 }
2227 }
2228 }
2229
2230 /**
2231 * function is used to get notify user, site data, filter data
2232 * combination of 3 CURL requests into one:-
2233 * get-wp-filter-data
2234 * get-site-data
2235 * wp-api/wpfuser/getNotifiedUsers
2236 */
2237 function get_notif_sitedata_filterdata() {
2238 $ret = 0;
2239 if ( ! is_user_logged_in() ) {
2240 if ( ! get_option( 'enabled_wpfeedback' ) == 'yes' ) {
2241 $ret = 1;
2242 } else {
2243 if ( ! get_option( 'wpf_allow_guest' ) == 'yes' ) {
2244 $ret = 1;
2245 } else {
2246 $ret = 0;
2247 }
2248 }
2249 }
2250
2251 if ( $ret == 1 ) {
2252 return;
2253 }
2254
2255 if ( get_option( 'wpf_license' ) != 'valid' ) {
2256 } else {
2257 $wpf_site_id = get_option( 'wpf_site_id' );
2258 $args = array(
2259 'wpf_site_id' => $wpf_site_id
2260 );
2261
2262 $url = WPF_CRM_API . 'wp-api/site/get-meta-data';
2263 $sendtocloud = json_encode( $args );
2264 $allData = wpf_send_remote_post( $url, $sendtocloud );
2265 if ( isset( $allData['status'] ) && $allData['status'] == '200' ) {
2266 $notify_users = $allData['data']['getNotifiedUsers']['data'];
2267 $res_data = $allData['data']['get-site-data'];
2268 $fil_data = $allData['data']['wp-filter-data'];
2269 $restrict_plugin = $allData['data']['limit'];
2270 $wpf_user_plan = $allData['data']['plan'];
2271
2272 if ( ! empty( $notify_users ) ) {
2273 update_option( 'notify_users', $notify_users, "no" );
2274 }
2275 if ( ! empty( $wpf_user_plan['upgrade_path'] ) ) {
2276 update_option( 'upgrade_url', $wpf_user_plan['upgrade_path'], "no" );
2277 }
2278 if ( !empty($fil_data['data']) ) {
2279 update_option( 'filter_data', $fil_data['data'], 'no' );
2280 }
2281 // update the limit
2282 //update_option( 'restrict_plugin', $restrict_plugin, 'no' );
2283
2284 if ( isset( $res_data['status'] ) && $res_data['status'] == '200' && isset( $res_data['data'] ) ) {
2285 $site_data = $res_data['data'];
2286 /* ---- UPDATE BY SHAWN ON VERSION 2.0.9 ---- */
2287 foreach ( $site_data as $key => $sdata ) {
2288 if ( ( $sdata == 0 || ! empty( $sdata ) ) && ( $key != 'wpf_license' ) ) {
2289 update_option( $key, $sdata, 'no' );
2290 }
2291 }
2292
2293 // override old data by checking the old API URL => 2.1.1
2294 if ( ! empty( $site_data ) ) {
2295 $pattern = '/api.wpfeedback.co/';
2296
2297 // check for the logo
2298 if ( preg_match( $pattern, $site_data['wpfeedback_logo'] ) != false ) {
2299 update_option( 'wpfeedback_logo', 'https://api.atarim.io/Atarim.svg', 'no' );
2300 }
2301
2302 // check for the fav icon
2303 if ( preg_match( $pattern, $site_data['wpfeedback_favicon'] ) != false ) {
2304 update_option( 'wpfeedback_favicon', 'https://api.atarim.io/atarim_icon.svg', 'no' );
2305 }
2306 }
2307
2308 // add the site archive settings
2309 if ( ! empty( $allData['site_archived'] ) && $allData['site_archived'] !== 0 ) {
2310 update_option( 'wpf_site_archived', 0, 'no' );
2311 } else if ( ! empty( $allData['site_archived'] ) ) {
2312 update_option( 'wpf_site_archived', 0, 'no' );
2313 }
2314 }
2315 // update the plan data
2316 update_option( 'wpf_user_plan', serialize( $wpf_user_plan ), 'no' );
2317 }
2318 }
2319 }
2320
2321 /*
2322 * function is used to get site settings data
2323 * and stored in session
2324 */
2325 function get_user_data() {
2326 if ( ! session_id() ) {
2327 session_start();
2328 }
2329
2330 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { /* it's an Ajax call */
2331 } else if ( get_option( 'wpf_license' ) != 'valid' ) {
2332 } else {
2333 $wpf_site_id = get_option( 'wpf_site_id' );
2334 if ( is_user_logged_in() ) {
2335 $userid = get_current_user_id();
2336 $args = array(
2337 'wpf_site_id' => $wpf_site_id,
2338 'wpf_user_id' => $userid
2339 );
2340 $url = WPF_CRM_API . 'wp-api/wpfuser/getWpfUser';
2341 $sendtocloud = json_encode( $args );
2342 $res_data = wpf_send_remote_post( $url, $sendtocloud );
2343 if ( isset( $res_data['status'] ) && $res_data['status'] == '200' && isset( $res_data['data'] ) ) {
2344 $user_data = $res_data['data'];
2345 if ( isset( $_SESSION['site_' . $wpf_site_id]["user_data"] ) ) {
2346 unset( $_SESSION['site_'.$wpf_site_id]["user_data"] );
2347 }
2348 $_SESSION['site_'.$wpf_site_id]['user_data'] = $user_data;
2349 } else {
2350 if ( isset( $_SESSION['site_'.$wpf_site_id]["user_data"] ) ) {
2351 unset( $_SESSION['site_'.$wpf_site_id]["user_data"] );
2352 }
2353 }
2354 } else {
2355 if ( isset( $_SESSION['site_' . $wpf_site_id]["user_data"] ) ) {
2356 unset( $_SESSION['site_'.$wpf_site_id]["user_data"] );
2357 }
2358 }
2359 }
2360 }
2361
2362 /*
2363 * function is used to get site filter
2364 * data and store in session
2365 */
2366 function get_site_filter_data() {
2367 $ret = 0;
2368 if ( ! is_user_logged_in() ) {
2369 if( ! get_option( 'enabled_wpfeedback' ) == 'yes' ) {
2370 $ret = 1;
2371 } else {
2372 if ( ! get_option( 'wpf_allow_guest' ) == 'yes' ) {
2373 $ret = 1;
2374 } else {
2375 $ret = 0;
2376 }
2377 }
2378 }
2379
2380 if ( $ret == 1 ) {
2381 return;
2382 }
2383
2384 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { /* it's an Ajax call */
2385 } else if( get_option( 'wpf_license' ) != 'valid' ) {
2386 } else {
2387 $wpf_site_id = get_option( 'wpf_site_id' );
2388 $url = WPF_CRM_API . 'wp-api/site/get-wp-filter-data';
2389 $sendarr = array();
2390 $sendarr["wpf_site_id"] = $wpf_site_id;
2391 $sendtocloud = json_encode( $sendarr );
2392 $response = wpf_send_remote_post( $url, $sendtocloud );
2393 if ( isset( $response['status'] ) && $response['status'] == '1' ) {
2394 update_option( 'filter_data', $response['data'], 'no' );
2395 }
2396 }
2397 }
2398
2399 /*
2400 * function is used to clear the session
2401 */
2402 function clear_session() {
2403 $wpf_site_id = get_option( 'wpf_site_id' );
2404 if ( isset( $_SESSION['site_' . $wpf_site_id]["site_data"] ) ) {
2405 unset( $_SESSION['site_' . $wpf_site_id]["site_data"] );
2406 }
2407
2408 if ( isset( $_SESSION['site_' . $wpf_site_id]["notify_users"] ) ) {
2409 unset( $_SESSION['site_' . $wpf_site_id]["notify_users"] );
2410 }
2411
2412 if ( isset( $_SESSION['site_' . $wpf_site_id]["user_data"] ) ) {
2413 unset( $_SESSION['site_' . $wpf_site_id]["user_data"] );
2414 }
2415 }
2416
2417 /*
2418 * function is used to get site settings data by key
2419 */
2420 function get_site_data_by_key( $key ) {
2421 $str = get_option( $key );
2422 return $str;
2423 }
2424
2425 function get_site_data_by_key_api( $option_name ) {
2426 $args = array(
2427 'wpf_site_id' => get_option( 'wpf_site_id' ),
2428 'option_name' => $option_name
2429 );
2430 $url = WPF_CRM_API . 'get-site-data-by-key';
2431 $sendtocloud = json_encode( $args );
2432 $res_data = wpf_send_remote_post( $url, $sendtocloud );
2433 $str = '';
2434 if ( $res_data['status'] == '200' && isset( $res_data['data'] ) ) {
2435 $str = $res_data['data'];
2436 }
2437 return $str;
2438 }
2439
2440 /*
2441 * function is used to update site settings data
2442 */
2443 function update_site_data( $options ) {
2444 $args = array(
2445 'wpf_site_id' => get_option( 'wpf_site_id' ),
2446 'options' => $options
2447 );
2448 $url = WPF_CRM_API . 'update-site-data';
2449 $sendtocloud = json_encode( $args );
2450 $myposts = wpf_send_remote_post( $url, $sendtocloud );
2451 if ( $myposts['status'] == 200 ) {
2452 get_notif_sitedata_filterdata();
2453 return 1;
2454 } else {
2455 return 0;
2456 }
2457 }
2458
2459 /*
2460 * register new route for graphic page
2461 */
2462 add_action( 'init', 'wpf_graphic_add_rewrite_rule' );
2463 function wpf_graphic_add_rewrite_rule(){
2464 add_rewrite_rule( '^collaborate/graphic?', 'index.php?is_graphic_page=1', 'top' );
2465 flush_rewrite_rules();
2466 }
2467
2468 add_action( 'query_vars', 'wpf_graphic_set_query_var' );
2469 function wpf_graphic_set_query_var( $vars ) {
2470 array_push( $vars, 'is_graphic_page' );
2471 return $vars;
2472 }
2473
2474 add_filter( 'template_include', 'wpf_graphic_include_template', 1000, 1 );
2475 function wpf_graphic_include_template( $template ) {
2476 if ( get_query_var( 'is_graphic_page' ) ) {
2477 $new_template = WPF_PLUGIN_DIR . '/graphics/wpf_graphics.php';
2478 if ( file_exists( $new_template ) ) {
2479 $template = $new_template;
2480 }
2481 }
2482 return $template;
2483 }
2484
2485 function get_task_time_type( $date ) {
2486 $current = strtotime( date( 'Y-m-d' ) );
2487 $datediff = $date - $current;
2488 $difference = floor( $datediff / (60 * 60 * 24) );
2489 if ( $difference == 0 ) {
2490 return 'today';
2491 } else if ( $difference > 1 ) {
2492 return 'Future Date';
2493 } else if ( $difference > 0 ) {
2494 return 'tomorrow';
2495 } else if ( $difference < -1 ) {
2496 return 'Long Back';
2497 } else {
2498 return 'yesterday';
2499 }
2500 }
2501
2502
2503 function formatTimeString( $time ) {
2504 $monday = strtotime( "last monday" );
2505 $monday = date( 'w', $monday ) == date( 'w' ) ? $monday + 7*86400 : $monday;
2506 $sunday = strtotime( date( "Y-m-d 23:59:59", $monday ) . " +6 days" );
2507 $this_week_sd = strtotime( date( "Y-m-d 00:00:01", $monday ) . " -7 days" );
2508 $this_week_ed = strtotime( date( "Y-m-d 23:59:59", $sunday ) . " -7 days" );
2509 $number_of_days_in_this_month = date( 't' );
2510 $first_day_this_month = strtotime( date( 'Y-m-01 00:00:01' ) . " -${number_of_days_in_this_month} days" ); // hard-coded '01' for first day
2511 $last_day_this_month = strtotime( date( 'Y-m-t 23:59:59' ) . " -${number_of_days_in_this_month} days" );
2512 $first_day_of_year = strtotime( 'first day of january this year' );
2513 $last_day_of_year = strtotime('last day of december this year');
2514
2515 if ( $time >= strtotime( date( 'Y-m-d 00:00:01' ) ) && $time <= strtotime( date( 'Y-m-d 23:59:59' ) ) ) {
2516 return "today";
2517 }
2518
2519 if ( $time >= strtotime( date( "Y-m-d 00:00:01" ) . " -1 days" ) && $time <= strtotime( date( 'Y-m-d 23:59:59' ) . " -1 days" ) ) {
2520 return 'yesterday';
2521 }
2522
2523 if ( $time >= $this_week_sd && $time <= $this_week_ed ) {
2524 return "this_week";
2525 }
2526
2527 if ( $time >= $first_day_this_month && $time <= $last_day_this_month ) {
2528 return "this_month";
2529 }
2530
2531 if ( $time >= $first_day_of_year && $time <= $last_day_of_year ) {
2532 return "year";
2533 }
2534 return "other";
2535 }
2536
2537 /*
2538 * Move the site data to wpf when
2539 * plugin 2.0 updated
2540 */
2541 function move_all_old_data_api_call() {
2542 if( isset( $_GET['move_wpf_data'] ) && $_GET['move_wpf_data'] == 1 ) {
2543 echo "Data moved!!";
2544 exit;
2545 }
2546 }
2547
2548
2549 /*function prefix_plugin_update_message( $data, $response ) {
2550 if( isset( $data['upgrade_notice'] ) ) {
2551 printf(
2552 '<div class="update-message">%s</div>',
2553 wpautop( $data['upgrade_notice'] )
2554 );
2555 }
2556 }
2557 add_action( 'atarim-client-interface-plugin/wpfeedback.php', 'prefix_plugin_update_message', 10, 2 );*/
2558
2559
2560 /*function prefix_plugin_update_message_fallback( $data, $response ) {
2561 if ( ! function_exists( 'prefix_plugin_update_message' ) ) {
2562 printf(
2563 '<div class="update-message"><p><strong>%s</strong></p></div>',
2564 __( 'Version 2.0 is a major update. You should take a backup before you upgrade.', 'text-domain' )
2565 );
2566 }
2567 }
2568 add_action( 'atarim-client-interface-plugin/wpfeedback.php', 'prefix_plugin_update_message_fallback', 10, 2 );*/
2569
2570 /*
2571 * This function is used to register the taxonomy "Task Status" on the website where it is installed.
2572 *
2573 * @input NULL
2574 * @return NULL
2575 */
2576 if ( ! function_exists( 'wp_feedback_task_status_taxonomy' ) ) {
2577 // Register Task status Custom Taxonomy
2578 function wp_feedback_task_status_taxonomy() {
2579 $labels = array(
2580 'name' => _x( 'Task status', 'Taxonomy General Name', 'wp_feedback' ),
2581 'singular_name' => _x( 'Task status', 'Taxonomy Singular Name', 'wp_feedback' ),
2582 'menu_name' => __( 'Task status', 'wp_feedback' ),
2583 'all_items' => __( 'All Task status', 'wp_feedback' ),
2584 'parent_item' => __( 'Parent Item', 'wp_feedback' ),
2585 'parent_item_colon' => __( 'Parent Item:', 'wp_feedback' ),
2586 'new_item_name' => __( 'New Task status', 'wp_feedback' ),
2587 'add_new_item' => __( 'New Task status', 'wp_feedback' ),
2588 'edit_item' => __( 'Edit Task status', 'wp_feedback' ),
2589 'update_item' => __( 'Update Task status', 'wp_feedback' ),
2590 'view_item' => __( 'View Task status', 'wp_feedback' ),
2591 'separate_items_with_commas' => __( 'Separate items with commas', 'wp_feedback' ),
2592 'add_or_remove_items' => __( 'Add or remove Task status', 'wp_feedback' ),
2593 'choose_from_most_used' => __( 'Choose from the most used', 'wp_feedback' ),
2594 'popular_items' => __( 'Popular Task status', 'wp_feedback' ),
2595 'search_items' => __( 'Search Task status', 'wp_feedback' ),
2596 'not_found' => __( 'Not Found Task status', 'wp_feedback' ),
2597 'no_terms' => __( 'No Task status', 'wp_feedback' ),
2598 'items_list' => __( 'Task status list', 'wp_feedback' ),
2599 'items_list_navigation' => __( 'Task status list navigation', 'wp_feedback' ),
2600 );
2601 $args = array(
2602 'labels' => $labels,
2603 'hierarchical' => true,
2604 'public' => false,
2605 'show_ui' => true,
2606 'show_admin_column' => true,
2607 'show_in_nav_menus' => false,
2608 'show_tagcloud' => true,
2609 );
2610 register_taxonomy( 'task_status', array('wpfeedback'), $args );
2611
2612 }
2613 add_action( 'init', 'wp_feedback_task_status_taxonomy', 0 );
2614 }
2615
2616
2617 /**
2618 * This function is used to register the taxonomy "Task Urgency" on the website where it is installed.
2619 *
2620 * @input NULL
2621 * @return NULL
2622 */
2623 if ( ! function_exists( 'wp_feedback_task_priority_taxonomy' ) ) {
2624 // Register Task urgency Custom Taxonomy
2625 function wp_feedback_task_priority_taxonomy() {
2626 $labels = array(
2627 'name' => _x( 'Task urgency', 'Taxonomy General Name', 'wp_feedback' ),
2628 'singular_name' => _x( 'Task urgency', 'Taxonomy Singular Name', 'wp_feedback' ),
2629 'menu_name' => __( 'Task urgency', 'wp_feedback' ),
2630 'all_items' => __( 'All Task urgency', 'wp_feedback' ),
2631 'parent_item' => __( 'Parent Item', 'wp_feedback' ),
2632 'parent_item_colon' => __( 'Parent Item:', 'wp_feedback' ),
2633 'new_item_name' => __( 'New Task urgency', 'wp_feedback' ),
2634 'add_new_item' => __( 'New Task urgency', 'wp_feedback' ),
2635 'edit_item' => __( 'Edit Task urgency', 'wp_feedback' ),
2636 'update_item' => __( 'Update Task urgency', 'wp_feedback' ),
2637 'view_item' => __( 'View Task urgency', 'wp_feedback' ),
2638 'separate_items_with_commas' => __( 'Separate items with commas', 'wp_feedback' ),
2639 'add_or_remove_items' => __( 'Add or remove Task urgency', 'wp_feedback' ),
2640 'choose_from_most_used' => __( 'Choose from the most used', 'wp_feedback' ),
2641 'popular_items' => __( 'Popular Task urgency', 'wp_feedback' ),
2642 'search_items' => __( 'Search Task urgency', 'wp_feedback' ),
2643 'not_found' => __( 'Not Found Task urgency', 'wp_feedback' ),
2644 'no_terms' => __( 'No Task urgency', 'wp_feedback' ),
2645 'items_list' => __( 'Task urgency list', 'wp_feedback' ),
2646 'items_list_navigation' => __( 'Task urgency list navigation', 'wp_feedback' ),
2647 );
2648 $args = array(
2649 'labels' => $labels,
2650 'hierarchical' => true,
2651 'public' => false,
2652 'show_ui' => true,
2653 'show_admin_column' => true,
2654 'show_in_nav_menus' => false,
2655 'show_tagcloud' => true,
2656 );
2657 register_taxonomy( 'task_priority', array('wpfeedback'), $args );
2658 }
2659 add_action( 'init', 'wp_feedback_task_priority_taxonomy', 0 );
2660 }
2661
2662
2663 /**
2664 * This function is used to register the terms for taxonomy "Task Priority" on the website where it is installed.
2665 *
2666 * @input NULL
2667 * @return NULL
2668 */
2669 if ( ! function_exists( 'wp_feedback_register_task_priority_terms' ) ) {
2670 function wp_feedback_register_task_priority_terms() {
2671 $taxonomy = 'task_priority';
2672 $terms = array(
2673 '0' => array(
2674 'name' => 'Low',
2675 'slug' => 'low',
2676 'description' => '',
2677 ),
2678 '1' => array(
2679 'name' => 'Medium',
2680 'slug' => 'medium',
2681 'description' => '',
2682 ),
2683 '2' => array(
2684 'name' => 'High',
2685 'slug' => 'high',
2686 'description' => '',
2687 ),
2688 '3' => array(
2689 'name' => 'Critical',
2690 'slug' => 'critical',
2691 'description' => '',
2692 ),
2693 );
2694
2695 foreach ( $terms as $term_key => $term ) {
2696 if ( ! term_exists( $term['slug'], 'task_priority' ) ) {
2697 wp_insert_term(
2698 $term['name'],
2699 $taxonomy,
2700 array(
2701 'description' => $term['description'],
2702 'slug' => $term['slug'],
2703 )
2704 );
2705 }
2706 }
2707 }
2708 }
2709 add_action( 'wp_loaded', 'wp_feedback_register_task_priority_terms', 0 );
2710
2711 /*
2712 * This function is used to register the terms for taxonomy "Task Status" on the website where it is installed.
2713 *
2714 * @input NULL
2715 * @return NULL
2716 */
2717 if ( ! function_exists( 'wp_feedback_register_task_status_terms' ) ) {
2718 function wp_feedback_register_task_status_terms() {
2719 $taxonomy = 'task_status';
2720 $terms = array(
2721 '0' => array(
2722 'name' => 'Open',
2723 'slug' => 'open',
2724 'description' => '',
2725 ),
2726 '1' => array(
2727 'name' => 'In Progress',
2728 'slug' => 'in-progress',
2729 'description' => '',
2730 ),
2731 '2' => array(
2732 'name' => 'Pending Review',
2733 'slug' => 'pending-review',
2734 'description' => '',
2735 ),
2736 '3' => array(
2737 'name' => 'Complete',
2738 'slug' => 'complete',
2739 'description' => '',
2740 ),
2741 );
2742
2743 foreach ( $terms as $term_key => $term ) {
2744 if ( ! term_exists( $term['slug'], 'task_status' ) ) {
2745 wp_insert_term(
2746 $term['name'],
2747 $taxonomy,
2748 array(
2749 'description' => $term['description'],
2750 'slug' => $term['slug'],
2751 )
2752 );
2753 }
2754 }
2755 }
2756 }
2757 add_action( 'wp_loaded', 'wp_feedback_register_task_status_terms', 0 );
2758
2759 /*
2760 * This function is used to show notice if the license is not active.
2761 *
2762 * @input NULL
2763 * @return NULL
2764 */
2765 function licence_invalid_notice() {
2766 if( get_option( 'wpf_license' ) != 'valid' && ( wpf_user_type() === 'advisor' ) ) {
2767 echo '<div class="notice notice-warning wpf_admin_notice">
2768 <div class="wpf_admin_notice_icon">
2769 <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1080 1080">
2770 <defs>
2771 <style>
2772 .cls-1 {
2773 fill: #fff;
2774 }
2775 .cls-2 {
2776 fill: #052055;
2777 }
2778 </style>
2779 </defs>
2780 <title>Atarim Logo Inverted</title>
2781 <g>
2782 <g>
2783 <polygon class="cls-1" points="937.344 785.955 746.1 856.215 851.972 1060.257 1080 1059.991 937.344 785.955"/>
2784 <polygon class="cls-1" points="539.938 19.669 0 1059.991 228.152 1059.991 539.873 458.766 652.263 675.369 843.507 605.108 539.938 19.669"/>
2785 </g>
2786 <polygon class="cls-2" points="227.659 1060.331 373.967 778.521 1055.074 519.371 227.659 1060.331"/>
2787 </g>
2788 </svg>
2789 </div>
2790 <div class="wpf_admin_notice_content">
2791 <div class="wpf_admin_notice_title">Welcome to Atarim 👋</div>
2792 Please activate your license to continue using the platform.
2793 <p class="admin_notice_footer"><i>* This notice is shown to you as the Webmaster.</i></p>
2794 </div>
2795 <div class="wpf_admin_notice_button_col"><a class="wpf_admin_notice_button" href="'. admin_url() .'admin.php?page=wpfeedback_page_permissions"><span class="dashicons dashicons dashicons-update"></span> Activate & Connect</a></div>
2796 </div>';
2797 }
2798 }
2799 add_action( 'admin_notices', 'licence_invalid_notice' );
2800
2801
2802 /**
2803 * This notice will show on the admin when wpf_site_archived = 1 on the wp_options table
2804 */
2805 function site_archived_notice()
2806 {
2807 if ( get_site_data_by_key( 'wpf_site_archived' ) && ( wpf_user_type() === 'advisor' ) ) { ?>
2808 <div class="notice notice-warning wpf_admin_notice">
2809 <div class="wpf_admin_notice_icon">
2810 <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1080 1080">
2811 <defs>
2812 <style>
2813 .cls-1 {
2814 fill: #fff;
2815 }
2816 .cls-2 {
2817 fill: #052055;
2818 }
2819 </style>
2820 </defs>
2821 <title>Atarim Logo Inverted</title>
2822 <g>
2823 <g>
2824 <polygon class="cls-1" points="937.344 785.955 746.1 856.215 851.972 1060.257 1080 1059.991 937.344 785.955"/>
2825 <polygon class="cls-1" points="539.938 19.669 0 1059.991 228.152 1059.991 539.873 458.766 652.263 675.369 843.507 605.108 539.938 19.669"/>
2826 </g>
2827 <polygon class="cls-2" points="227.659 1060.331 373.967 778.521 1055.074 519.371 227.659 1060.331"/>
2828 </g>
2829 </svg>
2830 </div>
2831 <div class="wpf_admin_notice_content">
2832 Atarim is disabled because this website has been archived on the Agency Dashboard. To re-enable the plugin,
2833 please go to the <a href="https://app.atarim.io/websites" target=_blank >Websites</a> screen in your Agency
2834 Dashboard and <strong>unarchive this website</strong>
2835 <p class="admin_notice_footer"><i>* This notice is shown to you as the Webmaster.</i></p>
2836 </div>
2837 </div>
2838 <?php
2839 }
2840 }
2841 add_action( 'admin_notices', 'site_archived_notice' );
2842
2843 add_action('init', 'add_custom_cookie_admin');
2844 function add_custom_cookie_admin() {
2845 global $current_user;
2846 $wpf_user_id = get_current_user_id();
2847 // save user id in the cookie to use it on react side
2848 setcookie( 'wpf_manage_ip', $wpf_user_id, time() + 86400, '/');
2849 }