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