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