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