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