Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/wpguppy-lite/admin/class-wp-guppy-lite-admin.php
+++ b/wpguppy-lite/admin/class-wp-guppy-lite-admin.php
@@ -44,14 +44,13 @@
* Initialize the class and set its properties.
*
* @since 1.0.0
- * @param string $plugin_name The name of this plugin.
- * @param string $version The version of this plugin.
+ * @param string $plugin_name The name of this plugin.
+ * @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
- $this->version = $version;
-
+ $this->version = $version;
}
/**
@@ -73,10 +72,9 @@
* class.
*/
- wp_enqueue_style( 'wp-color-picker' );
- wp_enqueue_style( 'wpguppy-lite-settings', plugin_dir_url( __FILE__ ) . 'css/wpguppy-admin.css',array(), $this->version, 'all');
- wp_enqueue_style( 'jquery_confirm', plugin_dir_url( __FILE__ ) . 'css/jquery-confirm.min.css',array(), $this->version, 'all');
-
+ wp_enqueue_style( 'wp-color-picker' );
+ wp_enqueue_style( 'wpguppy-lite-settings', plugin_dir_url( __FILE__ ) . 'css/wpguppy-admin.css', array(), $this->version, 'all' );
+ wp_enqueue_style( 'jquery_confirm', plugin_dir_url( __FILE__ ) . 'css/jquery-confirm.min.css', array(), $this->version, 'all' );
}
/**
@@ -98,16 +96,18 @@
* class.
*/
- wp_enqueue_script('wpguppy-lite-settings', plugin_dir_url( __FILE__ ) . 'settings/js/settings.js',array( 'wp-color-picker' ), $this->version, true);
- wp_enqueue_script('jquery_confirm', plugin_dir_url( __FILE__ ) . 'settings/js/jquery-confirm.min.js',array( 'wp-color-picker' ), $this->version, true);
-
- wp_localize_script('wpguppy-lite-settings', 'scripts_constants', array(
- 'rest_db_message' => esc_html__('Are you sure you want to reset databse?','wpguppy-lite'),
- 'is_admin' => 'no',
- 'ajaxurl' => admin_url('admin-ajax.php'),
- 'ajax_nonce' => wp_create_nonce('ajax_nonce')
- ));
+ wp_enqueue_script( 'wpguppy-lite-settings', plugin_dir_url( __FILE__ ) . 'settings/js/settings.js', array( 'wp-color-picker' ), $this->version, true );
+ wp_enqueue_script( 'jquery_confirm', plugin_dir_url( __FILE__ ) . 'settings/js/jquery-confirm.min.js', array( 'wp-color-picker' ), $this->version, true );
+ wp_localize_script(
+ 'wpguppy-lite-settings',
+ 'scripts_constants',
+ array(
+ 'rest_db_message' => esc_html__( 'Are you sure you want to reset databse?', 'wpguppy-lite' ),
+ 'is_admin' => 'no',
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
+ 'ajax_nonce' => wp_create_nonce( 'ajax_nonce' ),
+ )
+ );
}
-
}
--- a/wpguppy-lite/admin/index.php
+++ b/wpguppy-lite/admin/index.php
@@ -1 +1 @@
-<?php // Silence is golden
No newline at end of file
+<?php // Silence is golden
--- a/wpguppy-lite/admin/settings/settings.php
+++ b/wpguppy-lite/admin/settings/settings.php
@@ -1,38 +1,41 @@
<?php
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
-if (!class_exists('WPGuppy_Lite_Plugin_Options')) {
- /**
- *
- * @package WP Guppy
- */
+
+if ( ! class_exists( 'WPGuppy_Lite_Plugin_Options' ) ) {
+ /**
+ *
+ * @package WP Guppy
+ */
class WPGuppy_Lite_Plugin_Options {
- private static $_instance = null;
-
+ private static $_instance = null;
+
/**
- * PRIVATE CONSTRUCTOR
- */
+ * PRIVATE CONSTRUCTOR
+ */
public function __construct() {
- if (!is_plugin_active('wp-guppy/wp-guppy.php') ) {
- add_action('admin_menu', array(&$this, 'wpguppy_admin_menu'));
- add_action('wp_ajax_wpguppy_update_guppy_admin_status', array(&$this,'wpguppy_update_guppy_admin_status'));
- add_action('wp_ajax_get_wpguppy_whatsapp_user_info', array(&$this,'get_wpguppy_whatsapp_user_info'));
- add_action('wp_ajax_wpguppy_update_whatsapp_info', array(&$this,'wpguppy_update_whatsapp_info'));
+ if ( ! is_plugin_active( 'wp-guppy/wp-guppy.php' ) ) {
+ add_action( 'admin_menu', array( &$this, 'wpguppy_admin_menu' ) );
+ add_action( 'wp_ajax_wpguppy_update_guppy_admin_status', array( &$this, 'wpguppy_update_guppy_admin_status' ) );
+ add_action( 'wp_ajax_get_wpguppy_whatsapp_user_info', array( &$this, 'get_wpguppy_whatsapp_user_info' ) );
+ add_action( 'wp_ajax_wpguppy_update_whatsapp_info', array( &$this, 'wpguppy_update_whatsapp_info' ) );
}
}
/**
- * Call this method to get singleton
- *
- * @return
- */
- public static function instance()
- {
- if (self::$_instance === null) {
- self::$_instance = new WPGuppy_Lite_Plugin_Options();
- }
- return self::$_instance;
- }
+ * Call this method to get singleton
+ *
+ * @return
+ */
+ public static function instance() {
+ if ( self::$_instance === null ) {
+ self::$_instance = new WPGuppy_Lite_Plugin_Options();
+ }
+ return self::$_instance;
+ }
/**
* Is admin, update status
@@ -45,30 +48,30 @@
*/
function wpguppy_update_guppy_admin_status() {
global $wpdb;
- $json = array();
- $user_id = !empty($_POST['user_id']) ? intval($_POST['user_id']) : '';
- $status = !empty($_POST['status']) ? intval($_POST['status']) : '';
-
- if( !current_user_can('manage_options') || empty($user_id) ){
- $json['type'] = 'error';
- $json['message'] = esc_html__('You are not allowed to perform this action!','wpguppy-lite');
- wp_send_json($json);
- }
-
- if( !isset($_POST['security']) || empty(wp_verify_nonce( $_POST['security'], 'ajax_nonce' )) ){
- $json['type'] = 'error';
- $json['message'] = esc_html__('Invalid request, please try again later.','wpguppy-lite');
- wp_send_json($json);
- }
-
- update_user_meta($user_id, 'is_guppy_admin', $status);
-
- $json['type'] = 'success';
- $json['message'] = esc_html__('Update status','wpguppy-lite');
- wp_send_json($json);
+ $json = array();
+ $user_id = ! empty( $_POST['user_id'] ) ? intval( $_POST['user_id'] ) : '';
+ $status = ! empty( $_POST['status'] ) ? intval( $_POST['status'] ) : '';
+
+ if ( ! current_user_can( 'manage_options' ) || empty( $user_id ) ) {
+ $json['type'] = 'error';
+ $json['message'] = esc_html__( 'You are not allowed to perform this action!', 'wpguppy-lite' );
+ wp_send_json( $json );
+ }
+
+ if ( ! isset( $_POST['security'] ) || empty( wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['security'] ) ), 'ajax_nonce' ) ) ) {
+ $json['type'] = 'error';
+ $json['message'] = esc_html__( 'Invalid request, please try again later.', 'wpguppy-lite' );
+ wp_send_json( $json );
+ }
+
+ update_user_meta( $user_id, 'is_guppy_admin', $status );
+
+ $json['type'] = 'success';
+ $json['message'] = esc_html__( 'Update status', 'wpguppy-lite' );
+ wp_send_json( $json );
}
-
+
/**
* Load plugin menu
@@ -80,15 +83,16 @@
* @subpackage wp-guppy/admin
*/
public function wpguppy_admin_menu() {
- $menu_slug = 'wpguppy_options';
- $messages_page = add_menu_page(esc_html__('WP Guppy Lite','wpguppy-lite'),
- esc_html__('WP Guppy Lite','wpguppy-lite'),
- 'administrator',
- 'wpguppy_settings',
- array( &$this,'wpguppy_settings'),
- WP_GUPPY_LITE_DIRECTORY_URI.'/admin/images/guppy.svg'
- );
- add_action( "load-".$messages_page, array(&$this, 'wpguppy_load_settings') );
+ $menu_slug = 'wpguppy_options';
+ $messages_page = add_menu_page(
+ esc_html__( 'WP Guppy Lite', 'wpguppy-lite' ),
+ esc_html__( 'WP Guppy Lite', 'wpguppy-lite' ),
+ 'administrator',
+ 'wpguppy_settings',
+ array( &$this, 'wpguppy_settings' ),
+ WP_GUPPY_LITE_DIRECTORY_URI . '/admin/images/guppy.svg'
+ );
+ add_action( 'load-' . $messages_page, array( &$this, 'wpguppy_load_settings' ) );
}
/**
@@ -102,20 +106,20 @@
*/
function wpguppy_load_settings() {
global $pagenow;
- if ( isset($_POST["wpguppy_submit"]) && $_POST["wpguppy_submit"] == 'yes' ) {
- check_admin_referer( "wpguppy_options" );
- $settings = get_option( "wpguppy_settings" );
- if ($pagenow == 'admin.php' && $_GET['page'] == 'wpguppy_settings') {
- $wpguppy_settings = !empty($_POST['wpguppy_settings']) ? sanitize_text_or_array_field($_POST['wpguppy_settings']) : array();
- $updated = update_option( "wpguppy_settings", $wpguppy_settings );
+ if ( isset( $_POST['wpguppy_submit'] ) && $_POST['wpguppy_submit'] == 'yes' ) {
+ check_admin_referer( 'wpguppy_options' );
+ $settings = get_option( 'wpguppy_settings' );
+ if ( $pagenow == 'admin.php' && isset( $_GET['page'] ) && 'wpguppy_settings' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) {
+ $wpguppy_settings = ! empty( $_POST['wpguppy_settings'] ) ? wpguppy_lite_sanitize_text_or_array_field( wp_unslash( $_POST['wpguppy_settings'] ) ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized recursively by wpguppy_lite_sanitize_text_or_array_field().
+ $updated = update_option( 'wpguppy_settings', $wpguppy_settings );
}
-
- $url_params = isset($_GET['tab']) ? 'updated=true&tab='.sanitize_text_field($_GET['tab']) : 'updated=true';
- wp_redirect(admin_url('admin.php?page=wpguppy_settings&'.$url_params));
+
+ $url_params = isset( $_GET['tab'] ) ? 'updated=true&tab=' . sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'updated=true';
+ wp_safe_redirect( admin_url( 'admin.php?page=wpguppy_settings&' . $url_params ) );
exit;
}
}
-
+
/**
* Guppy settings
*
@@ -126,44 +130,44 @@
* @subpackage wp-guppy/admin
*/
public function wpguppy_settings() {
- global $wpguppy_settings;
- $tabs = array(
- 'general' => esc_html__('General','wpguppy-lite'),
- 'tabs' => esc_html__('Chat tabs','wpguppy-lite'),
- 'style' => esc_html__('Styles','wpguppy-lite'),
- 'media' => esc_html__('Media','wpguppy-lite'),
- 'real-time-chat' => esc_html__('Real time chat','wpguppy-lite'),
- 'translation' => esc_html__('Translation','wpguppy-lite'),
- );
- $wpguppy_settings = get_option( "wpguppy_settings" );
- $current_tab = !empty($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'general';
+ global $wpguppy_settings;
+ $tabs = array(
+ 'general' => esc_html__( 'General', 'wpguppy-lite' ),
+ 'tabs' => esc_html__( 'Chat tabs', 'wpguppy-lite' ),
+ 'style' => esc_html__( 'Styles', 'wpguppy-lite' ),
+ 'media' => esc_html__( 'Media', 'wpguppy-lite' ),
+ 'real-time-chat' => esc_html__( 'Real time chat', 'wpguppy-lite' ),
+ 'translation' => esc_html__( 'Translation', 'wpguppy-lite' ),
+ );
+ $wpguppy_settings = get_option( 'wpguppy_settings' );
+ $current_tab = ! empty( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'general'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only active-tab selection for display only.
?>
- <?php $this->wpguppy_settings_tabs($tabs,$current_tab);?>
+ <?php $this->wpguppy_settings_tabs( $tabs, $current_tab ); ?>
<div id="poststuff">
- <form autocomplete="off" method="post" id="gp-settings-page-form" action="<?php admin_url('admin.php?page=wpguppy_options'); ?>">
+ <form autocomplete="off" method="post" id="gp-settings-page-form" action="<?php admin_url( 'admin.php?page=wpguppy_options' ); ?>">
<?php
- foreach($tabs as $key => $tab ){
- $display_class = !empty($current_tab) && $current_tab == $key ? '' : 'hide-if-js';
- wp_nonce_field( "wpguppy_options" );
- ?>
- <div class="tab-content gb-tab-content <?php echo esc_attr($display_class);?>" id="tb-content-<?php echo esc_attr($key);?>">
+ foreach ( $tabs as $key => $tab ) {
+ $display_class = ! empty( $current_tab ) && $current_tab == $key ? '' : 'hide-if-js';
+ wp_nonce_field( 'wpguppy_options' );
+ ?>
+ <div class="tab-content gb-tab-content <?php echo esc_attr( $display_class ); ?>" id="tb-content-<?php echo esc_attr( $key ); ?>">
<div class="wrap">
- <?php require WP_GUPPY_LITE_DIRECTORY . 'admin/settings/templates/'.$key.'-options.php'; ?>
+ <?php require WP_GUPPY_LITE_DIRECTORY . 'admin/settings/templates/' . $key . '-options.php'; ?>
</div>
- <?php if( !empty($key)){?>
+ <?php if ( ! empty( $key ) ) { ?>
<input type="hidden" name="wpguppy_submit" value="yes"/>
- <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e('Save changes','wpguppy-lite');?>"></p>
- <?php } ?>
+ <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save changes', 'wpguppy-lite' ); ?>"></p>
+ <?php } ?>
</div>
<?php
- }
- echo '</div></div>';?>
+ }
+ echo '</div></div>';
+ ?>
</form>
</div>
<?php
-
}
-
+
/**
* Guppy Tabs settings
*
@@ -173,14 +177,14 @@
* @package wp-guppy
* @subpackage wp-guppy/admin
*/
- public function wpguppy_settings_tabs( $tabs,$current = '' ) {
+ public function wpguppy_settings_tabs( $tabs, $current = '' ) {
echo '<h2 class="nav-tab-wrapper">';
-
- foreach ( $tabs as $tab => $name ) {
- $class = ( $tab == $current ) ? ' nav-tab-active' : '';
- echo "<a id=".esc_attr($tab)."-settings-tab' data-tab_id=".esc_attr( $tab )." href='javascript:;' class='gp-tabs-settings nav-tab".esc_attr($class)."'>".esc_html($name)."</a>";
- }
-
+
+ foreach ( $tabs as $tab => $name ) {
+ $class = ( $tab == $current ) ? ' nav-tab-active' : '';
+ echo '<a id=' . esc_attr( $tab ) . "-settings-tab' data-tab_id=" . esc_attr( $tab ) . " href='javascript:;' class='gp-tabs-settings nav-tab" . esc_attr( $class ) . "'>" . esc_html( $name ) . '</a>';
+ }
+
echo '</h2>';
}
@@ -194,39 +198,39 @@
* @subpackage wp-guppy/admin
*/
function get_wpguppy_whatsapp_user_info() {
-
- $json = array();
- $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : '';
-
- if( !current_user_can('manage_options') || empty($user_id) ){
- $json['type'] = 'error';
- $json['message'] = esc_html__('You are not allowed to perform this action!','wpguppy-lite');
- wp_send_json($json);
- }
-
- if( !isset($_POST['security']) || empty(wp_verify_nonce( $_POST['security'], 'ajax_nonce' )) ){
- $json['type'] = 'error';
- $json['message'] = esc_html__('Invalid request, please try again later.','wpguppy-lite');
- wp_send_json($json);
- }
-
- $guppy_whatsapp_info = get_user_meta($user_id, 'guppy_whatsapp_info', true);
- $user_designation = !empty($guppy_whatsapp_info['user_designation']) ? $guppy_whatsapp_info['user_designation'] : '';
- $user_contact = !empty($guppy_whatsapp_info['user_contact']) ? $guppy_whatsapp_info['user_contact'] : '';
- $user_default_message = !empty($guppy_whatsapp_info['user_default_message']) ? $guppy_whatsapp_info['user_default_message'] : '';
- $user_offline_message = !empty($guppy_whatsapp_info['user_offline_message']) ? $guppy_whatsapp_info['user_offline_message'] : '';
- $user_availability = !empty($guppy_whatsapp_info['user_availability']) ? $guppy_whatsapp_info['user_availability'] : array();
- $user_timezone = !empty($guppy_whatsapp_info['user_timezone']) ? $guppy_whatsapp_info['user_timezone'] : '';
- $guppy_time_slots = apply_filters( 'guppy_time_slots', '' );
- $guppy_timezones_list = guppy_timezones_list();
- $available_days = array();
- $start = get_option('start_of_week');
-
- $start = $start -1; // -1 is for to start array index
- $end = $start + 6;
- for ($i = $start; $i <= $end; $i++) {
- $day = strtolower(jddayofweek($i,1));
- $available_days[$day] = $day;
+
+ $json = array();
+ $user_id = ! empty( $_POST['user_id'] ) ? sanitize_text_field( wp_unslash( $_POST['user_id'] ) ) : '';
+
+ if ( ! current_user_can( 'manage_options' ) || empty( $user_id ) ) {
+ $json['type'] = 'error';
+ $json['message'] = esc_html__( 'You are not allowed to perform this action!', 'wpguppy-lite' );
+ wp_send_json( $json );
+ }
+
+ if ( ! isset( $_POST['security'] ) || empty( wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['security'] ) ), 'ajax_nonce' ) ) ) {
+ $json['type'] = 'error';
+ $json['message'] = esc_html__( 'Invalid request, please try again later.', 'wpguppy-lite' );
+ wp_send_json( $json );
+ }
+
+ $guppy_whatsapp_info = get_user_meta( $user_id, 'guppy_whatsapp_info', true );
+ $user_designation = ! empty( $guppy_whatsapp_info['user_designation'] ) ? $guppy_whatsapp_info['user_designation'] : '';
+ $user_contact = ! empty( $guppy_whatsapp_info['user_contact'] ) ? $guppy_whatsapp_info['user_contact'] : '';
+ $user_default_message = ! empty( $guppy_whatsapp_info['user_default_message'] ) ? $guppy_whatsapp_info['user_default_message'] : '';
+ $user_offline_message = ! empty( $guppy_whatsapp_info['user_offline_message'] ) ? $guppy_whatsapp_info['user_offline_message'] : '';
+ $user_availability = ! empty( $guppy_whatsapp_info['user_availability'] ) ? $guppy_whatsapp_info['user_availability'] : array();
+ $user_timezone = ! empty( $guppy_whatsapp_info['user_timezone'] ) ? $guppy_whatsapp_info['user_timezone'] : '';
+ $guppy_time_slots = apply_filters( 'wpguppy_lite_time_slots', '' );
+ $guppy_timezones_list = wpguppy_lite_timezones_list();
+ $available_days = array();
+ $start = get_option( 'start_of_week' );
+
+ $start = $start - 1; // -1 is for to start array index
+ $end = $start + 6;
+ for ( $i = $start; $i <= $end; $i++ ) {
+ $day = strtolower( jddayofweek( $i, 1 ) );
+ $available_days[ $day ] = $day;
}
ob_start();
@@ -234,66 +238,67 @@
<form class="at-themeform" id="guppy-whatsapp-info-form">
<fieldset>
<div class="at-form-group">
- <label class="at-form-title"><?php esc_html_e('Add designation','wpguppy-lite');?></label>
+ <label class="at-form-title"><?php esc_html_e( 'Add designation', 'wpguppy-lite' ); ?></label>
<div class="at-form-field">
- <input type="text" class="at-form-control" placeholder="<?php echo esc_attr('Enter designation title');?>" name="user_designation" value="<?php echo esc_attr($user_designation);?>" required="">
+ <input type="text" class="at-form-control" placeholder="<?php echo esc_attr( 'Enter designation title' ); ?>" name="user_designation" value="<?php echo esc_attr( $user_designation ); ?>" required="">
</div>
</div>
<div class="at-form-group">
- <label class="at-form-title"><?php esc_html_e('Add contact number','wpguppy-lite');?></label>
+ <label class="at-form-title"><?php esc_html_e( 'Add contact number', 'wpguppy-lite' ); ?></label>
<div class="at-form-field">
- <input type="text" class="at-form-control" placeholder="<?php echo esc_attr('Enter contact number');?>" name="user_contact" value="<?php echo esc_attr($user_contact);?>" required="">
- <em><?php echo esc_html('Add WhatsApp contact number with a plus sign (+).', 'wpguppy-lite'); ?><a href="https://faq.whatsapp.com/general/contacts/how-to-add-an-international-phone-number" target="_blank"><?php echo esc_html('Read full detail', 'wpguppy-lite'); ?></a></em>
+ <input type="text" class="at-form-control" placeholder="<?php echo esc_attr( 'Enter contact number' ); ?>" name="user_contact" value="<?php echo esc_attr( $user_contact ); ?>" required="">
+ <em><?php echo esc_html( 'Add WhatsApp contact number with a plus sign (+).', 'wpguppy-lite' ); ?><a href="https://faq.whatsapp.com/general/contacts/how-to-add-an-international-phone-number" target="_blank"><?php echo esc_html( 'Read full detail', 'wpguppy-lite' ); ?></a></em>
</div>
</div>
<div class="at-form-group">
- <label class="at-form-title"><?php esc_html_e('Available time slots','wpguppy-lite');?></label>
+ <label class="at-form-title"><?php esc_html_e( 'Available time slots', 'wpguppy-lite' ); ?></label>
<div class="at-form-field-options">
- <?php if(!empty($available_days)){ ?>
- <?php foreach($available_days as $day=> $time){ ?>
+ <?php if ( ! empty( $available_days ) ) { ?>
+ <?php foreach ( $available_days as $day => $time ) { ?>
<?php
$day_checked = $time_disabled = '';
- if(!empty($user_availability[$day])){
+ if ( ! empty( $user_availability[ $day ] ) ) {
$day_checked = 'checked';
- }else{
+ } else {
$time_disabled = 'disabled';
}
?>
<div class="at-form-field-wrap">
<span class="db-guppy-checkbox">
- <input type="checkbox" name="available_days[]" <?php echo esc_attr($day_checked); ?> id="<?php echo esc_attr($day);?>" value="<?php echo esc_attr($day);?>">
- <label class="at-form-subtitle" for="<?php echo esc_attr($day);?>"><?php echo esc_attr(ucfirst($day));?></label>
+ <input type="checkbox" name="available_days[]" <?php echo esc_attr( $day_checked ); ?> id="<?php echo esc_attr( $day ); ?>" value="<?php echo esc_attr( $day ); ?>">
+ <label class="at-form-subtitle" for="<?php echo esc_attr( $day ); ?>"><?php echo esc_attr( ucfirst( $day ) ); ?></label>
</span>
<span class="at-select">
- <select <?php echo esc_attr($time_disabled); ?> name="start_time[<?php echo esc_attr($day)?>]" id ="start_time_<?php echo esc_attr($day)?>">
- <?php if(!empty($guppy_time_slots)){?>
- <?php foreach($guppy_time_slots as $slot=> $value){ ?>
- <?php
+ <select <?php echo esc_attr( $time_disabled ); ?> name="start_time[<?php echo esc_attr( $day ); ?>]" id ="start_time_<?php echo esc_attr( $day ); ?>">
+ <?php if ( ! empty( $guppy_time_slots ) ) { ?>
+ <?php foreach ( $guppy_time_slots as $slot => $value ) { ?>
+ <?php
$start_time_selected = '';
- $match_time = $value.':00';
- if(!empty($user_availability[$day]) && $user_availability[$day]['start_time'] == $match_time){
- $start_time_selected = 'selected';
- }
+ $match_time = $value . ':00';
+ if ( ! empty( $user_availability[ $day ] ) && $user_availability[ $day ]['start_time'] == $match_time ) {
+ $start_time_selected = 'selected';
+ }
?>
- <option value="<?php echo esc_attr($value);?>" <?php echo esc_attr($start_time_selected); ?>><?php echo esc_attr($value);?></option>
+ <option value="<?php echo esc_attr( $value ); ?>" <?php echo esc_attr( $start_time_selected ); ?>><?php echo esc_attr( $value ); ?></option>
<?php } ?>
<?php } ?>
</select>
</span>
<span class="at-select">
- <select <?php echo esc_attr($time_disabled); ?> name="end_time[<?php echo esc_attr($day)?>]" id ="end_time_<?php echo esc_attr($day)?>">
- <?php if(!empty($guppy_time_slots)){
- unset($guppy_time_slots['00:00']);
+ <select <?php echo esc_attr( $time_disabled ); ?> name="end_time[<?php echo esc_attr( $day ); ?>]" id ="end_time_<?php echo esc_attr( $day ); ?>">
+ <?php
+ if ( ! empty( $guppy_time_slots ) ) {
+ unset( $guppy_time_slots['00:00'] );
?>
- <?php foreach($guppy_time_slots as $slot=> $value){ ?>
- <?php
+ <?php foreach ( $guppy_time_slots as $slot => $value ) { ?>
+ <?php
$end_time_selected = '';
- $match_time = $value.':00';
- if(!empty($user_availability[$day]) && $user_availability[$day]['end_time'] == $match_time){
- $end_time_selected = 'selected';
- }
+ $match_time = $value . ':00';
+ if ( ! empty( $user_availability[ $day ] ) && $user_availability[ $day ]['end_time'] == $match_time ) {
+ $end_time_selected = 'selected';
+ }
?>
- <option value="<?php echo esc_attr($value);?>" <?php echo esc_attr($end_time_selected); ?>><?php echo esc_attr($value);?></option>
+ <option value="<?php echo esc_attr( $value ); ?>" <?php echo esc_attr( $end_time_selected ); ?>><?php echo esc_attr( $value ); ?></option>
<?php } ?>
<?php } ?>
</select>
@@ -304,49 +309,49 @@
</div>
</div>
<div class="at-form-group">
- <label class="at-form-title"><?php esc_html_e('Add time zone','wpguppy-lite');?></label>
+ <label class="at-form-title"><?php esc_html_e( 'Add time zone', 'wpguppy-lite' ); ?></label>
<div class="at-form-field">
<select name="user_timezone" id ="user_timezone">
- <option value=""><?php esc_html_e('Select time zone','wpguppy-lite');?></option>
- <?php if(!empty($guppy_timezones_list)){ ?>
- <?php foreach($guppy_timezones_list as $key=> $value){ ?>
- <?php
+ <option value=""><?php esc_html_e( 'Select time zone', 'wpguppy-lite' ); ?></option>
+ <?php if ( ! empty( $guppy_timezones_list ) ) { ?>
+ <?php foreach ( $guppy_timezones_list as $key => $value ) { ?>
+ <?php
$timezone_selected = '';
- $match_time = $value.':00';
- if($user_timezone == $key){
- $timezone_selected = 'selected';
- }
+ $match_time = $value . ':00';
+ if ( $user_timezone == $key ) {
+ $timezone_selected = 'selected';
+ }
?>
- <option value="<?php echo esc_attr($key);?>" <?php echo esc_attr($timezone_selected); ?>><?php echo esc_attr($value);?></option>
+ <option value="<?php echo esc_attr( $key ); ?>" <?php echo esc_attr( $timezone_selected ); ?>><?php echo esc_attr( $value ); ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
<div class="at-form-group">
- <label class="at-form-title"><?php esc_html_e('Default message','wpguppy-lite');?></label>
+ <label class="at-form-title"><?php esc_html_e( 'Default message', 'wpguppy-lite' ); ?></label>
<div class="at-form-field">
- <textarea type="text" class="at-form-control" placeholder="<?php echo esc_attr('Enter default message');?>" name="user_default_message" required=""> <?php echo ($user_default_message);?></textarea>
+ <textarea type="text" class="at-form-control" placeholder="<?php echo esc_attr( 'Enter default message' ); ?>" name="user_default_message" required=""> <?php echo esc_textarea( $user_default_message ); ?></textarea>
</div>
</div>
<div class="at-form-group">
- <label class="at-form-title"><?php esc_html_e('Offline message','wpguppy-lite');?></label>
+ <label class="at-form-title"><?php esc_html_e( 'Offline message', 'wpguppy-lite' ); ?></label>
<div class="at-form-field">
- <textarea type="text" class="at-form-control" placeholder="<?php echo esc_attr('Enter offline message');?>" name="user_offline_message" required=""> <?php echo ($user_offline_message);?></textarea>
+ <textarea type="text" class="at-form-control" placeholder="<?php echo esc_attr( 'Enter offline message' ); ?>" name="user_offline_message" required=""> <?php echo esc_textarea( $user_offline_message ); ?></textarea>
</div>
</div>
<div class="at-form-group">
<div class="at-form-field">
- <button type="button" class="update-guppy-whatsapp-info" data-id="<?php echo esc_attr($user_id);?>"><?php esc_html_e('Save & update','wpguppy-lite');?></button>
+ <button type="button" class="update-guppy-whatsapp-info" data-id="<?php echo esc_attr( $user_id ); ?>"><?php esc_html_e( 'Save & update', 'wpguppy-lite' ); ?></button>
</div>
</div>
</fieldset>
</form>
<?php
- $html = ob_get_clean();
- $json['type'] = 'success';
- $json['html'] = $html;
- wp_send_json($json);
+ $html = ob_get_clean();
+ $json['type'] = 'success';
+ $json['html'] = $html;
+ wp_send_json( $json );
}
/**
* Update whatsapp support user information
@@ -358,77 +363,78 @@
* @subpackage wp-guppy/admin
*/
function wpguppy_update_whatsapp_info() {
- $json = array();
- $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : '';
- $status = !empty($_POST['status']) ? ($_POST['status']) : '';
-
- if( !current_user_can('manage_options') || empty($user_id) ){
- $json['type'] = 'error';
- $json['message'] = esc_html__('You are not allowed to perform this action!','wpguppy-lite');
- wp_send_json($json);
- }
-
- if( !isset($_POST['security']) || empty(wp_verify_nonce( $_POST['security'], 'ajax_nonce' )) ){
- $json['type'] = 'error';
- $json['message'] = esc_html__('Invalid request, please try again later.','wpguppy-lite');
- wp_send_json($json);
- }
-
- if($status == 1){
- $user_designation = !empty($_POST['user_designation']) ? wp_strip_all_tags($_POST['user_designation']) : '';
- $user_contact = !empty($_POST['user_contact']) ? sanitize_text_field($_POST['user_contact']) : '';
- $user_default_message = !empty($_POST['user_default_message']) ? wp_strip_all_tags($_POST['user_default_message']) : '';
- $user_offline_message = !empty($_POST['user_offline_message']) ? wp_strip_all_tags($_POST['user_offline_message']) : '';
- $available_days = !empty($_POST['available_days']) ? $_POST['available_days'] : array();
- $user_timezone = !empty($_POST['user_timezone']) ? $_POST['user_timezone'] : '';
- $start_time = !empty($_POST['start_time']) ? $_POST['start_time'] : array();
- $end_time = !empty($_POST['end_time']) ? $_POST['end_time'] : array();
- $time_slots = array();
- if(empty($user_designation)
- || empty($user_contact)
- || empty($user_default_message)
- || empty($user_offline_message)
- || empty($available_days)
- || empty($user_timezone)){
- $json['type'] = 'error';
- $json['message'] = sprintf( __( 'Oops! it looks like you missed something', 'wpguppy-lite' ));
- wp_send_json($json);
+ $json = array();
+ $user_id = ! empty( $_POST['user_id'] ) ? sanitize_text_field( wp_unslash( $_POST['user_id'] ) ) : '';
+ $status = ! empty( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : '';
+
+ if ( ! current_user_can( 'manage_options' ) || empty( $user_id ) ) {
+ $json['type'] = 'error';
+ $json['message'] = esc_html__( 'You are not allowed to perform this action!', 'wpguppy-lite' );
+ wp_send_json( $json );
+ }
+
+ if ( ! isset( $_POST['security'] ) || empty( wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['security'] ) ), 'ajax_nonce' ) ) ) {
+ $json['type'] = 'error';
+ $json['message'] = esc_html__( 'Invalid request, please try again later.', 'wpguppy-lite' );
+ wp_send_json( $json );
+ }
+
+ if ( $status == 1 ) {
+ $user_designation = ! empty( $_POST['user_designation'] ) ? wp_strip_all_tags( wp_unslash( $_POST['user_designation'] ) ) : '';
+ $user_contact = ! empty( $_POST['user_contact'] ) ? sanitize_text_field( wp_unslash( $_POST['user_contact'] ) ) : '';
+ $user_default_message = ! empty( $_POST['user_default_message'] ) ? wp_strip_all_tags( wp_unslash( $_POST['user_default_message'] ) ) : '';
+ $user_offline_message = ! empty( $_POST['user_offline_message'] ) ? wp_strip_all_tags( wp_unslash( $_POST['user_offline_message'] ) ) : '';
+ $available_days = ! empty( $_POST['available_days'] ) ? array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['available_days'] ) ) : array();
+ $user_timezone = ! empty( $_POST['user_timezone'] ) ? sanitize_text_field( wp_unslash( $_POST['user_timezone'] ) ) : '';
+ $start_time = ! empty( $_POST['start_time'] ) ? array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['start_time'] ) ) : array();
+ $end_time = ! empty( $_POST['end_time'] ) ? array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['end_time'] ) ) : array();
+ $time_slots = array();
+ if ( empty( $user_designation )
+ || empty( $user_contact )
+ || empty( $user_default_message )
+ || empty( $user_offline_message )
+ || empty( $available_days )
+ || empty( $user_timezone ) ) {
+ $json['type'] = 'error';
+ $json['message'] = sprintf( __( 'Oops! it looks like you missed something', 'wpguppy-lite' ) );
+ wp_send_json( $json );
}
- if(!empty($available_days)){
- foreach($available_days as $day){
- if(!empty($start_time[$day]) && !empty($end_time[$day])){
- $start_time_slot = date('Y-m-d '.$start_time[$day].':00');
- $end_time_slot = date('Y-m-d '.$end_time[$day].':00');
- if(strtotime($start_time_slot) >= strtotime($end_time_slot)){
- $json['type'] = 'error';
- $json['message'] = sprintf( __( 'Oops! there is an issue with your <strong>%s</strong> available time slot', 'wpguppy-lite' ), ucfirst($day));
- wp_send_json($json);
- }
- $time_slots[$day] = array(
- 'start_time' => $start_time[$day].':00',
- 'end_time' => $end_time[$day].':00',
+ if ( ! empty( $available_days ) ) {
+ foreach ( $available_days as $day ) {
+ if ( ! empty( $start_time[ $day ] ) && ! empty( $end_time[ $day ] ) ) {
+ $start_time_slot = gmdate( 'Y-m-d ' . $start_time[ $day ] . ':00' );
+ $end_time_slot = gmdate( 'Y-m-d ' . $end_time[ $day ] . ':00' );
+ if ( strtotime( $start_time_slot ) >= strtotime( $end_time_slot ) ) {
+ $json['type'] = 'error';
+ /* translators: %s: day of the week, e.g. Monday. */
+ $json['message'] = sprintf( __( 'Oops! there is an issue with your <strong>%s</strong> available time slot', 'wpguppy-lite' ), ucfirst( $day ) );
+ wp_send_json( $json );
+ }
+ $time_slots[ $day ] = array(
+ 'start_time' => $start_time[ $day ] . ':00',
+ 'end_time' => $end_time[ $day ] . ':00',
);
}
}
}
$data = array(
- 'user_designation' => $user_designation,
- 'user_contact' => $user_contact,
- 'user_default_message' => $user_default_message,
- 'user_offline_message' => $user_offline_message,
- 'user_availability' => $time_slots,
- 'user_timezone' => $user_timezone,
+ 'user_designation' => $user_designation,
+ 'user_contact' => $user_contact,
+ 'user_default_message' => $user_default_message,
+ 'user_offline_message' => $user_offline_message,
+ 'user_availability' => $time_slots,
+ 'user_timezone' => $user_timezone,
);
-
- update_user_meta($user_id, 'guppy_whatsapp_info', $data);
+
+ update_user_meta( $user_id, 'guppy_whatsapp_info', $data );
}
- update_user_meta($user_id, 'is_guppy_whatsapp_user', $status);
-
- $json['type'] = 'success';
- $json['message'] = esc_html__("Wohoo! you have added user's swhatsapp details successfully",'wpguppy-lite');
- wp_send_json($json);
+ update_user_meta( $user_id, 'is_guppy_whatsapp_user', $status );
+
+ $json['type'] = 'success';
+ $json['message'] = esc_html__( "Wohoo! you have added user's swhatsapp details successfully", 'wpguppy-lite' );
+ wp_send_json( $json );
}
}
-
+
WPGuppy_Lite_Plugin_Options::instance();
}
No newline at end of file
--- a/wpguppy-lite/admin/settings/templates/general-options.php
+++ b/wpguppy-lite/admin/settings/templates/general-options.php
@@ -1,8 +1,11 @@
<?php
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
/**
* General settings
*
- *
* @link https://wp-guppy.com/
* @since 1.0.0
*
@@ -12,55 +15,55 @@
global $wpguppy_settings;
$user_rolse = array();
-if( function_exists( 'wpguppy_user_roles' ) ) {
+if ( function_exists( 'wpguppy_user_roles' ) ) {
$user_rolse = wpguppy_user_roles();
}
-$auto_invite = !empty($wpguppy_settings['auto_invite']) ? $wpguppy_settings['auto_invite'] : array();
+$auto_invite = ! empty( $wpguppy_settings['auto_invite'] ) ? $wpguppy_settings['auto_invite'] : array();
?>
-<h3><?php esc_html_e('General settings','wpguppy-lite');?></h3>
+<h3><?php esc_html_e( 'General settings', 'wpguppy-lite' ); ?></h3>
<div class="guppy-shortcode-bar">
- <label for="gp-shorcode"><span><?php esc_html_e('Shortcode','wpguppy-lite');?></span></label>
- <input type="text" id="gp-shortcode-coppy" aria-describedby="gp-shorcode-description" value="<?php echo esc_attr('[getGuppyConversation]');?>" class="regular-text code">
- <button type="button" class="gp-copy-code button">
- <span aria-hidden="true" data-code="<?php echo esc_attr('[getGuppyConversation]');?>"><?php esc_html_e('Copy code','wpguppy-lite');?></span>
- </button>
- <p class="description" id="gp-shorcode-description"><?php esc_html_e('Add shortcode to use anywhere in the PHP files. Like below code','wpguppy-lite');?></p><br>
- <code><?php echo do_shortcode('[getGuppyConversation]');?></code>
+ <label for="gp-shorcode"><span><?php esc_html_e( 'Shortcode', 'wpguppy-lite' ); ?></span></label>
+ <input type="text" id="gp-shortcode-coppy" aria-describedby="gp-shorcode-description" value="<?php echo esc_attr( '[getGuppyConversation]' ); ?>" class="regular-text code">
+ <button type="button" class="gp-copy-code button">
+ <span aria-hidden="true" data-code="<?php echo esc_attr( '[getGuppyConversation]' ); ?>"><?php esc_html_e( 'Copy code', 'wpguppy-lite' ); ?></span>
+ </button>
+ <p class="description" id="gp-shorcode-description"><?php esc_html_e( 'Add shortcode to use anywhere in the PHP files. Like below code', 'wpguppy-lite' ); ?></p><br>
+ <code><?php echo do_shortcode('[getGuppyConversation]');?></code>
</div>
-<h3 class="title"><?php esc_html_e('Role management','wpguppy-lite');?></h3>
+<h3 class="title"><?php esc_html_e( 'Role management', 'wpguppy-lite' ); ?></h3>
<div class="at-chatroles">
- <?php
- if( !empty($user_rolse) ){
- foreach($user_rolse as $key => $user_rols ) {
- $invite_checked = '';
- if(!empty($auto_invite) && in_array($key,$auto_invite)){
- $invite_checked = 'checked';
- }
- ?>
- <div class="at-chatroles_item">
- <div class="at-chatrole">
- <div class="at-chatrole_title">
- <h6><?php echo esc_html($user_rols);?></h6>
- </div>
- <div class="at-chatrole_head">
- <div class="at-roleoption">
- <div class="at-roleoption_info">
- <i class="dashicons dashicons-buddicons-pm"></i>
- <span><?php esc_html_e('You can enable auto invite for this role. This role will be able to start chat with any user from the contact list','wpguppy-lite');?></span>
- </div>
- <div class="at-roleoption_radio at-switchbtn">
- <label>
- <span><?php esc_html_e('ON','wpguppy-lite');?></span>
- <input type="checkbox" <?php echo esc_attr($invite_checked);?> type="checkbox" name="wpguppy_settings[auto_invite][]" value="<?php echo esc_attr($key);?>" >
- <i></i>
- </label>
- </div>
- </div>
- </div>
-
- </div>
- </div>
- <?php } ?>
- <?php } ?>
+ <?php
+ if ( ! empty( $user_rolse ) ) {
+ foreach ( $user_rolse as $key => $user_rols ) {
+ $invite_checked = '';
+ if ( ! empty( $auto_invite ) && in_array( $key, $auto_invite ) ) {
+ $invite_checked = 'checked';
+ }
+ ?>
+ <div class="at-chatroles_item">
+ <div class="at-chatrole">
+ <div class="at-chatrole_title">
+ <h6><?php echo esc_html( $user_rols ); ?></h6>
+ </div>
+ <div class="at-chatrole_head">
+ <div class="at-roleoption">
+ <div class="at-roleoption_info">
+ <i class="dashicons dashicons-buddicons-pm"></i>
+ <span><?php esc_html_e( 'You can enable auto invite for this role. This role will be able to start chat with any user from the contact list', 'wpguppy-lite' ); ?></span>
+ </div>
+ <div class="at-roleoption_radio at-switchbtn">
+ <label>
+ <span><?php esc_html_e( 'ON', 'wpguppy-lite' ); ?></span>
+ <input type="checkbox" <?php echo esc_attr( $invite_checked ); ?> type="checkbox" name="wpguppy_settings[auto_invite][]" value="<?php echo esc_attr( $key ); ?>" >
+ <i></i>
+ </label>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ <?php } ?>
+ <?php } ?>
</div>
--- a/wpguppy-lite/admin/settings/templates/media-options.php
+++ b/wpguppy-lite/admin/settings/templates/media-options.php
@@ -1,8 +1,11 @@
<?php
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
/**
* Media settings
*
- *
* @link https://wp-guppy.com/
* @since 1.0.0
*
@@ -10,19 +13,19 @@
* @subpackage wp-guppy/admin/templates
*/
global $wpguppy_settings;
-$default_bell_url = esc_url(WP_GUPPY_LITE_DIRECTORY_URI.'public/media/notification-bell.wav');
-$notification_bell_url = !empty($wpguppy_settings['notification_bell_url']) ? $wpguppy_settings['notification_bell_url'] : $default_bell_url;
+$default_bell_url = esc_url( WP_GUPPY_LITE_DIRECTORY_URI . 'public/media/notification-bell.wav' );
+$notification_bell_url = ! empty( $wpguppy_settings['notification_bell_url'] ) ? $wpguppy_settings['notification_bell_url'] : $default_bell_url;
- ?>
-<h3><?php esc_html_e('Media settings','wpguppy-lite');?></h3>
+?>
+<h3><?php esc_html_e( 'Media settings', 'wpguppy-lite' ); ?></h3>
<table class="form-table" role="media">
- <tbody>
- <tr>
- <th scope="row"><label for="group"><?php esc_html_e('Notification bell url','wpguppy-lite');?></label></th>
- <td>
- <input name="wpguppy_settings[notification_bell_url]" placeholder="<?php esc_attr_e('Add bell URL','wpguppy-lite');?>" type="text" value="<?php echo esc_url($notification_bell_url);?>"/>
- <p class="description"><?php esc_html_e('You can upload mp3 or wav file into WordPress media and copy that URL and add here for the ring tune.','wpguppy-lite');?>
- </td>
- </tr>
- </tbody>
+ <tbody>
+ <tr>
+ <th scope="row"><label for="group"><?php esc_html_e( 'Notification bell url', 'wpguppy-lite' ); ?></label></th>
+ <td>
+ <input name="wpguppy_settings[notification_bell_url]" placeholder="<?php esc_attr_e( 'Add bell URL', 'wpguppy-lite' ); ?>" type="text" value="<?php echo esc_url( $notification_bell_url ); ?>"/>
+ <p class="description"><?php esc_html_e( 'You can upload mp3 or wav file into WordPress media and copy that URL and add here for the ring tune.', 'wpguppy-lite' ); ?>
+ </td>
+ </tr>
+ </tbody>
</table>
No newline at end of file
--- a/wpguppy-lite/admin/settings/templates/pusher-options.php
+++ b/wpguppy-lite/admin/settings/templates/pusher-options.php
@@ -1,8 +1,11 @@
<?php
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
/**
* Pusher settings
*
- *
* @link https://wp-guppy.com/
* @since 1.0.0
*
@@ -10,56 +13,71 @@
* @subpackage wp-guppy/admin/templates
*/
global $wpguppy_settings;
-$pusher = !empty($wpguppy_settings['pusher']) ? $wpguppy_settings['pusher'] : 'disable';
-$option = !empty($wpguppy_settings['option']) ? $wpguppy_settings['option'] : array();
-$class = !empty($pusher) && $pusher == 'enable' ? '' : 'hide-if-js';
+$pusher = ! empty( $wpguppy_settings['pusher'] ) ? $wpguppy_settings['pusher'] : 'disable';
+$option = ! empty( $wpguppy_settings['option'] ) ? $wpguppy_settings['option'] : array();
+$class = ! empty( $pusher ) && $pusher == 'enable' ? '' : 'hide-if-js';
-$app_id = !empty($option['app_id']) ? $option['app_id'] : '';
-$app_key = !empty($option['app_key']) ? $option['app_key'] : '';
-$app_secret = !empty($option['app_secret']) ? $option['app_secret'] : '';
-$app_cluster = !empty($option['app_cluster']) ? $option['app_cluster'] : '';
+$app_id = ! empty( $option['app_id'] ) ? $option['app_id'] : '';
+$app_key = ! empty( $option['app_key'] ) ? $option['app_key'] : '';
+$app_secret = ! empty( $option['app_secret'] ) ? $option['app_secret'] : '';
+$app_cluster = ! empty( $option['app_cluster'] ) ? $option['app_cluster'] : '';
?>
-<h3><?php esc_html_e('Real-time chat settings','wpguppy-lite');?></h3>
+<h3><?php esc_html_e( 'Real-time chat settings', 'wpguppy-lite' ); ?></h3>
<table class="form-table" role="chat">
- <tbody>
- <tr>
- <th scope="row"><label for="group"><?php esc_html_e('Pusher settings','wpguppy-lite');?></label></th>
- <td>
- <fieldset>
- <label><input class="gp-pusher-settings" type="radio" name="wpguppy_settings[pusher]" value="enable" <?php if( !empty($pusher) && $pusher == 'enable') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Enable','wpguppy-lite');?></code></label>
- <label><input class="gp-pusher-settings" type="radio" name="wpguppy_settings[pusher]" value="disable" <?php if( !empty($pusher) && $pusher == 'disable') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Disable','wpguppy-lite');?></code></label>
- </fieldset>
- </td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($class);?>">
- <th scope="row"><label for="gp-app-id"><span></span></label></th>
- <td><p class="description"><?php echo wp_kses( __( 'We have used <a href="https://pusher.com/channels">Pusher Channel API</a> for the real-time chat experience, you must create channel API keys and add into the below settings. You may <a href="https://www.youtube.com/watch?v=70JOw13QKk8&list=PLuU227tzkYJEix0c4hOmUuo0wYf_4LWc2">check this guide</a>', 'wpguppy-lite' ), array(
- 'a' => array(
- 'href' => array(),
- 'title' => array()
- ),
- 'br' => array(),
- 'em' => array(),
- 'strong' => array(),
- ) );?></p></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($class);?>">
- <th scope="row"><label for="gp-app-id"><span><?php esc_html_e('App ID','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" placeholder="<?php esc_attr_e('Add APP Id here','wpguppy-lite');?>" name="wpguppy_settings[option][app_id]" type="text" value="<?php echo esc_attr($app_id);?>" /></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($class);?>">
- <th scope="row"><label for="gp-app-key"><span><?php esc_html_e('App Key','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" placeholder="<?php esc_attr_e('Add APP key here','wpguppy-lite');?>" name="wpguppy_settings[option][app_key]" type="text" value="<?php echo esc_attr($app_key);?>" /></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($class);?>">
- <th scope="row"><label for="gp-app-secret"><span><?php esc_html_e('App Secret','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" placeholder="<?php esc_attr_e('Add APP secret here','wpguppy-lite');?>" name="wpguppy_settings[option][app_secret]" type="text" value="<?php echo esc_attr($app_secret);?>" /></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($class);?>">
- <th scope="row"><label for="gp-app-cluster"><span><?php esc_html_e('App Cluster','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" placeholder="<?php esc_attr_e('Add APP cluster here','wpguppy-lite');?>" name="wpguppy_settings[option][app_cluster]" type="text" value="<?php echo esc_attr($app_cluster);?>" /></td>
- </tr>
- </tbody>
+ <tbody>
+ <tr>
+ <th scope="row"><label for="group"><?php esc_html_e( 'Pusher settings', 'wpguppy-lite' ); ?></label></th>
+ <td>
+ <fieldset>
+ <label><input class="gp-pusher-settings" type="radio" name="wpguppy_settings[pusher]" value="enable"
+ <?php
+ if ( ! empty( $pusher ) && $pusher == 'enable' ) {
+ ?>
+checked="checked"<?php } ?>>
+ <code><?php esc_html_e( 'Enable', 'wpguppy-lite' ); ?></code></label>
+ <label><input class="gp-pusher-settings" type="radio" name="wpguppy_settings[pusher]" value="disable"
+ <?php
+ if ( ! empty( $pusher ) && $pusher == 'disable' ) {
+ ?>
+checked="checked"<?php } ?>>
+ <code><?php esc_html_e( 'Disable', 'wpguppy-lite' ); ?></code></label>
+ </fieldset>
+ </td>
+ </tr>
+ <tr class="gp-pusher-options <?php echo esc_attr( $class ); ?>">
+ <th scope="row"><label for="gp-app-id"><span></span></label></th>
+ <td><p class="description">
+ <?php
+ echo wp_kses(
+ __( 'We have used <a href="https://pusher.com/channels">Pusher Channel API</a> for the real-time chat experience, you must create channel API keys and add into the below settings. You may <a href="https://www.youtube.com/watch?v=70JOw13QKk8&list=PLuU227tzkYJEix0c4hOmUuo0wYf_4LWc2">check this guide</a>', 'wpguppy-lite' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array(),
+ ),
+ 'br' => array(),
+ 'em' => array(),
+ 'strong' => array(),
+ )
+ );
+ ?>
+ </p></td>
+ </tr>
+ <tr class="gp-pusher-options <?php echo esc_attr( $class ); ?>">
+ <th scope="row"><label for="gp-app-id"><span><?php esc_html_e( 'App ID', 'wpguppy-lite' ); ?></span></label></th>
+ <td><input class="regular-text ltr" placeholder="<?php esc_attr_e( 'Add APP Id here', 'wpguppy-lite' ); ?>" name="wpguppy_settings[option][app_id]" type="text" value="<?php echo esc_attr( $app_id ); ?>" /></td>
+ </tr>
+ <tr class="gp-pusher-options <?php echo esc_attr( $class ); ?>">
+ <th scope="row"><label for="gp-app-key"><span><?php esc_html_e( 'App Key', 'wpguppy-lite' ); ?></span></label></th>
+ <td><input class="regular-text ltr" placeholder="<?php esc_attr_e( 'Add APP key here', 'wpguppy-lite' ); ?>" name="wpguppy_settings[option][app_key]" type="text" value="<?php echo esc_attr( $app_key ); ?>" /></td>
+ </tr>
+ <tr class="gp-pusher-options <?php echo esc_attr( $class ); ?>">
+ <th scope="row"><label for="gp-app-secret"><span><?php esc_html_e( 'App Secret', 'wpguppy-lite' ); ?></span></label></th>
+ <td><input class="regular-text ltr" placeholder="<?php esc_attr_e( 'Add APP secret here', 'wpguppy-lite' ); ?>" name="wpguppy_settings[option][app_secret]" type="text" value="<?php echo esc_attr( $app_secret ); ?>" /></td>
+ </tr>
+ <tr class="gp-pusher-options <?php echo esc_attr( $class ); ?>">
+ <th scope="row"><label for="gp-app-cluster"><span><?php esc_html_e( 'App Cluster', 'wpguppy-lite' ); ?></span></label></th>
+ <td><input class="regular-text ltr" placeholder="<?php esc_attr_e( 'Add APP cluster here', 'wpguppy-lite' ); ?>" name="wpguppy_settings[option][app_cluster]" type="text" value="<?php echo esc_attr( $app_cluster ); ?>" /></td>
+ </tr>
+ </tbody>
</table>
No newline at end of file
--- a/wpguppy-lite/admin/settings/templates/real-time-chat-options.php
+++ b/wpguppy-lite/admin/settings/templates/real-time-chat-options.php
@@ -1,8 +1,11 @@
<?php
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
/**
* Pusher settings
*
- *
* @link https://wp-guppy.com/
* @since 1.0.0
*
@@ -10,98 +13,132 @@
* @subpackage wp-guppy/admin/templates
*/
global $wpguppy_settings;
-$rt_chat_settings = !empty($wpguppy_settings['rt_chat_settings']) ? $wpguppy_settings['rt_chat_settings'] : '';
-$pusher = !empty($wpguppy_settings['pusher']) ? $wpguppy_settings['pusher'] : 'disable';
-$socket = !empty($wpguppy_settings['socket']) ? $wpguppy_settings['socket'] : 'disable';
-$option = !empty($wpguppy_settings['option']) ? $wpguppy_settings['option'] : array();
-$pusher_class = !empty($pusher) && $pusher == 'enable' ? '' : 'hide-if-js';
-$socket_class = !empty($socket) && $socket == 'enable' ? '' : 'hide-if-js';
+$rt_chat_settings = ! empty( $wpguppy_settings['rt_chat_settings'] ) ? $wpguppy_settings['rt_chat_settings'] : '';
+$pusher = ! empty( $wpguppy_settings['pusher'] ) ? $wpguppy_settings['pusher'] : 'disable';
+$socket = ! empty( $wpguppy_settings['socket'] ) ? $wpguppy_settings['socket'] : 'disable';
+$option = ! empty( $wpguppy_settings['option'] ) ? $wpguppy_settings['option'] : array();
+$pusher_class = ! empty( $pusher ) && $pusher == 'enable' ? '' : 'hide-if-js';
+$socket_class = ! empty( $socket ) && $socket == 'enable' ? '' : 'hide-if-js';
-$app_id = !empty($option['app_id']) ? $option['app_id'] : '';
-$app_key = !empty($option['app_key']) ? $option['app_key'] : '';
-$app_secret = !empty($option['app_secret']) ? $option['app_secret'] : '';
-$app_cluster = !empty($option['app_cluster']) ? $option['app_cluster'] : '';
-$socket_host_url = !empty($option['socket_host_url']) ? $option['socket_host_url'] : '';
-$socket_port_id = !empty($option['socket_port_id']) ? $option['socket_port_id'] : '81';
+$app_id = ! empty( $option['app_id'] ) ? $option['app_id'] : '';
+$app_key = ! empty( $option['app_key'] ) ? $option['app_key'] : '';
+$app_secret = ! empty( $option['app_secret'] ) ? $option['app_secret'] : '';
+$app_cluster = ! empty( $option['app_cluster'] ) ? $option['app_cluster'] : '';
+$socket_host_url = ! empty( $option['socket_host_url'] ) ? $option['socket_host_url'] : '';
+$socket_port_id = ! empty( $option['socket_port_id'] ) ? $option['socket_port_id'] : '81';
?>
-<h3><?php esc_html_e('Real-time chat settings','wpguppy-lite');?></h3>
+<h3><?php esc_html_e( 'Real-time chat settings', 'wpguppy-lite' ); ?></h3>
<table class="form-table" role="chat">
- <tbody>
- <tr>
- <th scope="row"><label for="group"><?php esc_html_e('Chat options','wpguppy-lite');?></label></th>
- <td>
- <fieldset>
- <label><input class="rt-chat-settings" type="radio" name="wpguppy_settings[rt_chat_settings]" value="pusher" <?php if( !empty($rt_chat_settings) && $rt_chat_settings == 'pusher') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Pusher channel','wpguppy-lite');?></code></label>
- <label><input class="rt-chat-settings" type="radio" name="wpguppy_settings[rt_chat_settings]" value="socket" <?php if( !empty($rt_chat_settings) && $rt_chat_settings == 'socket') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Socket-io','wpguppy-lite');?></code></label>
- </fieldset>
- </td>
- </tr>
- <tr class="rt-pusher <?php if( empty($rt_chat_settings) || $rt_chat_settings != 'pusher') { echo esc_attr($pusher_class); } ?>">
- <th scope="row"><label for="group"><?php esc_html_e('Pusher settings','wpguppy-lite');?></label></th>
- <td>
- <fieldset>
- <label><input class="gp-pusher-settings" type="radio" name="wpguppy_settings[pusher]" value="enable" <?php if( !empty($pusher) && $pusher == 'enable') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Enable','wpguppy-lite');?></code></label>
- <label><input class="gp-pusher-settings" id="pusher-setting" type="radio" name="wpguppy_settings[pusher]" value="disable" <?php if( !empty($pusher) && $pusher == 'disable') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Disable','wpguppy-lite');?></code></label>
- </fieldset>
- </td>
- </tr>
- <tr class="rt-socket <?php if( empty($rt_chat_settings) || $rt_chat_settings != 'socket') { echo esc_attr($socket_class); } ?>">
- <th scope="row"><label for="group"><?php esc_html_e('Socket io settings','wpguppy-lite');?></label></th>
- <td>
- <fieldset>
- <label><input class="gp-socket-settings" type="radio" name="wpguppy_settings[socket]" value="enable" <?php if( !empty($socket) && $socket == 'enable') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Enable','wpguppy-lite');?></code></label>
- <label><input class="gp-socket-settings" type="radio" name="wpguppy_settings[socket]" value="disable" <?php if( !empty($socket) && $socket == 'disable') {?>checked="checked"<?php } ?>>
- <code><?php esc_html_e('Disable','wpguppy-lite');?></code></label>
- </fieldset>
- </td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($pusher_class);?>">
- <td colspan="2"><p><?php echo do_shortcode('We have used <a href="https://pusher.com/channels">Pusher Channel API</a> for the real-time chat experience, you must create channel API keys and add into the below settings and need to enable client events in the pusher app settings. You may <a href="https://www.youtube.com/watch?v=70JOw13QKk8&list=PLuU227tzkYJEix0c4hOmUuo0wYf_4LWc2">check this guide</a>','wpguppy-lite');?></p></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($pusher_class);?>">
- <th scope="row"><label for="gp-app-id"><span><?php esc_html_e('App ID','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" name="wpguppy_settings[option][app_id]" type="text" value="<?php echo esc_attr($app_id);?>" /></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($pusher_class);?>">
- <th scope="row"><label for="gp-app-key"><span><?php esc_html_e('App Key','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" name="wpguppy_settings[option][app_key]" type="text" value="<?php echo esc_attr($app_key);?>" /></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($pusher_class);?>">
- <th scope="row"><label for="gp-app-secret"><span><?php esc_html_e('App Secret','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" name="wpguppy_settings[option][app_secret]" type="text" value="<?php echo esc_attr($app_secret);?>" /></td>
- </tr>
- <tr class="gp-pusher-options <?php echo esc_attr($pusher_class);?>">
- <th scope="row"><label for="gp-app-cluster"><span><?php esc_html_e('App Cluster','wpguppy-lite');?></span></label></th>
- <td><input class="regular-text ltr" name="wpguppy_settings[option][app_cluster]" type="text" value="<?php echo esc_attr($app_cluster);?>" /></td>
- </tr>
- <tr class="gp-socket-options <?php echo esc_attr($socket_class);?>">
- <th scope="row"><label for="gp-host-url"><span><?php esc_html_e('Host url','wpguppy-lite');?></span></label></th>
- <td>
- <input class="regular-