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