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