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