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