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