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