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