diff --git a/Admin/settings/global/admin_setting_panel.php b/Admin/settings/global/admin_setting_panel.php
index 4881087..109440b 100644
--- a/Admin/settings/global/admin_setting_panel.php
+++ b/Admin/settings/global/admin_setting_panel.php
@@ -399,12 +399,17 @@ if (!class_exists('MAGE_Events_Setting_Controls')) :
'disable' => 'Disable'
)
),
-
-
-
-
-
-
+ array(
+ 'name' => 'mep_clear_cart_after_checkout',
+ 'label' => __('Clear Cart after Checkout Order Placed?', 'mage-eventpress'),
+ 'desc' => __('By default we clear the cart after order placed, But some payment gateway need cart data after order placed. If you get any warning after order placed please disabled this and try again. Unless please do not change this settings.', 'mage-eventpress'),
+ 'type' => 'select',
+ 'default' => 'enable',
+ 'options' => array(
+ 'enable' => 'Enable',
+ 'disable' => 'Disable'
+ )
+ )
)
),
'event_list_setting_sec' => apply_filters('mep_settings_event_list_arr', array(
@@ -678,6 +683,17 @@ if (!class_exists('MAGE_Events_Setting_Controls')) :
'type' => 'wysiwyg',
'default' => 'Hi {name},
Thanks for joining the event.
Here are the event details:
Event Name: {event}
Ticket Type: {ticket_type}
Event Date: {event_date}
Start Time: {event_time}
Full DateTime: {event_datetime}
Thanks',
),
+ array(
+ 'name' => 'mep_send_confirmation_to_billing_email',
+ 'label' => __('Send Confirmation Email to Billing Email Address', 'mage-eventpress'),
+ 'desc' => __('By default Plugin sent the Event Confirmation Email to the Billing Email Address. If you want to turn off this you can disbale this setting.', 'mage-eventpress'),
+ 'type' => 'select',
+ 'default' => 'enable',
+ 'options' => array(
+ 'enable' => 'Enable',
+ 'disable' => 'Disable'
+ )
+ )
)
),
diff --git a/assets/frontend/mpwem_style.css b/assets/frontend/mpwem_style.css
index c4b5ae2..7593113 100644
--- a/assets/frontend/mpwem_style.css
+++ b/assets/frontend/mpwem_style.css
@@ -191,7 +191,13 @@ ul#mep_add_calender_links li a {
.mep-events-wrapper.wrapper {
margin: 20px auto;
}
-
+.mep-event-countdown-timer .wrapper div span {
+ display: block;
+ padding: 10px;
+}
+.mep-event-countdown-timer .wrapper div span span.label {
+ border: 0 !important;
+}
/********title***********/
.mep-default-title h2,
.section-heading h2 {
@@ -2378,31 +2384,41 @@ span.mep-more-time i {
width: max-content;
}
.mep-event-countdown-timer {
- display: flex;
+
width: 100%;
overflow: hidden;
}
-.mep-event-countdown-timer > div {
- width: 25%;
+.mep-event-countdown-timer .wrapper div {
+ width: 24%;
text-align: center;
- display: block;
+ display: inline-block !important;
+ /* display: flex; */
}
-.mep-event-countdown-timer div.wrapper {
+.mep-event-countdown-timer .wrapper {
min-height: 100px;
vertical-align: middle;
- background: #00000014;
+ /* background: #00000014; */
margin: 0 10px;
- border: 1px solid #CAC2C2;
+ /* border: 1px solid #CAC2C2; */
padding-top: 14px;
}
-.mep-event-countdown-timer div.wrapper .time {
+.mep-event-countdown-timer .wrapper .time {
display: block;
font-weight: bold;
font-size: 24px;
margin: 0;
padding: 0;
}
-.mep-event-countdown-timer div.wrapper .label {
+.mep-event-countdown-timer .wrapper div span.label {
+ display: block;
+ font-weight: bold !important;
+ margin-top:10px
+}
+
+.mep-event-countdown-timer .wrapper div {
+ font-size: 40px;
+}
+.mep-event-countdown-timer .wrapper .label {
font-size: 18px;
text-transform: capitalize;
}
@@ -2419,6 +2435,7 @@ span.mep-more-time i {
.mep-elementor-event-add-to-cart-section-widget h4.mep-cart-table-title {
display: none;
}
+
/*************************************************************
New Spring list style css added by ariful
**************************************************************/
diff --git a/inc/MPWEM_Dependencies.php b/inc/MPWEM_Dependencies.php
index 456bf6a..8b118d0 100644
--- a/inc/MPWEM_Dependencies.php
+++ b/inc/MPWEM_Dependencies.php
@@ -126,7 +126,7 @@
wp_enqueue_script('mep-calendar-scripts', MPWEM_PLUGIN_URL . '/assets/helper/calender/calendar.min.js', array('jquery', 'mep-moment-js'), 1, true);
//
wp_enqueue_script('mep-mixitup-min-js', 'https://cdnjs.cloudflare.com/ajax/libs/mixitup/3.3.0/mixitup.min.js', array(), '3.3.0', true);
- wp_enqueue_script('mep-countdown-js', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js', array(), 1, true);
+ wp_enqueue_script('mep-countdown-js', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js', array('jquery'), 1, true);
wp_enqueue_script('mep-moment-js', 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js', array(), 1, true);
//custom
wp_enqueue_style('filter_pagination', MPWEM_PLUGIN_URL . '/assets/frontend/filter_pagination.css', array(), time());
diff --git a/inc/mep_functions.php b/inc/mep_functions.php
index 0f72567..4d2202e 100755
--- a/inc/mep_functions.php
+++ b/inc/mep_functions.php
@@ -199,13 +199,14 @@ if (!function_exists('mep_get_attendee_info_query')) {
}
if (!function_exists('mep_email_dynamic_content')) {
- function mep_email_dynamic_content($email_body, $event_id, $order_id) {
+ function mep_email_dynamic_content($email_body, $event_id, $order_id, $__attendee_id = 0) {
$event_name = get_the_title($event_id);
$attendee_q = mep_get_attendee_info_query($event_id, $order_id);
foreach ($attendee_q->posts as $_attendee_q) {
- $attendee_id = $_attendee_q->ID;
+ $_attendee_id = $_attendee_q->ID;
}
+ $attendee_id = $__attendee_id > 0 ? $__attendee_id : $_attendee_id;
$attendee_name = get_post_meta($attendee_id, 'ea_name', true) ? get_post_meta($attendee_id, 'ea_name', true) : '';
$email = get_post_meta($attendee_id, 'ea_email', true) ? get_post_meta($attendee_id, 'ea_email', true) : '';
$date_time = get_post_meta($attendee_id, 'ea_event_date', true) ? get_mep_datetime(get_post_meta($attendee_id, 'ea_event_date', true), 'date-time-text') : '';
@@ -226,16 +227,16 @@ if (!function_exists('mep_email_dynamic_content')) {
// Send Confirmation email to customer
if (!function_exists('mep_event_confirmation_email_sent')) {
- function mep_event_confirmation_email_sent($event_id, $sent_email, $order_id) {
+ function mep_event_confirmation_email_sent($event_id, $sent_email, $order_id, $attendee_id=0) {
$values = get_post_custom($event_id);
- $global_email_text = mep_get_option('mep_confirmation_email_text', 'email_setting_sec', '');
- $global_email_form_email = mep_get_option('mep_email_form_email', 'email_setting_sec', '');
- $global_email_form = mep_get_option('mep_email_form_name', 'email_setting_sec', '');
- $global_email_sub = mep_get_option('mep_email_subject', 'email_setting_sec', '');
- $event_email_text = $values['mep_event_cc_email_text'][0];
- $admin_email = get_option('admin_email');
- $site_name = get_option('blogname');
+ $global_email_text = mep_get_option('mep_confirmation_email_text', 'email_setting_sec', '');
+ $global_email_form_email = mep_get_option('mep_email_form_email', 'email_setting_sec', '');
+ $global_email_form = mep_get_option('mep_email_form_name', 'email_setting_sec', '');
+ $global_email_sub = mep_get_option('mep_email_subject', 'email_setting_sec', '');
+ $event_email_text = $values['mep_event_cc_email_text'][0];
+ $admin_email = get_option('admin_email');
+ $site_name = get_option('blogname');
if ($global_email_sub) {
@@ -265,7 +266,7 @@ if (!function_exists('mep_event_confirmation_email_sent')) {
$headers[] = "From: $form_name <$form_email>";
if ($email_body) {
- $email_body = mep_email_dynamic_content($email_body, $event_id, $order_id);
+ $email_body = mep_email_dynamic_content($email_body, $event_id, $order_id, $attendee_id);
$confirmation_email_text = apply_filters('mep_event_confirmation_text', $email_body, $event_id, $order_id);
wp_mail($sent_email, $email_sub, nl2br($confirmation_email_text), $headers);
}
@@ -789,23 +790,29 @@ function mep_beta_disable_add_to_cart_if_product_is_in_cart($is_purchasable, $pr
}
}
+ $enable_clear_cart = mep_get_option('mep_clear_cart_after_checkout', 'general_setting_sec','enable');
- if(!class_exists('WC_Xendit_CC')){
- if(!class_exists( 'PaysonCheckout_For_WooCommerce' )){
- if(!class_exists( 'RP_SUB' )){
- if(!class_exists( 'Afterpay_Plugin' )){
- if(!class_exists( 'WC_Subscriptions' )){
- if ( !is_plugin_active( 'woo-juno/main.php' )){
- if ( ! class_exists( 'WC_Saferpay' ) ) {
- $woocommerce->cart->empty_cart();
- }
- }
- }
- }
- }
- }
- }
-
+ if($enable_clear_cart == 'enable'){
+ // PayplugWoocommerce
+ if ( ! class_exists( 'Payplug\PayplugWoocommerce' ) ) {
+ if(!class_exists('WC_Xendit_CC')){
+ if(!class_exists( 'PaysonCheckout_For_WooCommerce' )){
+ if(!class_exists( 'RP_SUB' )){
+ if(!class_exists( 'Afterpay_Plugin' )){
+ if(!class_exists( 'WC_Subscriptions' )){
+ if ( !is_plugin_active( 'woo-juno/main.php' )){
+ if ( ! class_exists( 'WC_Saferpay' ) ) {
+ // mep_clear_cart_after_checkout
+ $woocommerce->cart->empty_cart();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
} // end of check post type
}
@@ -1000,15 +1007,16 @@ if (!function_exists('mep_attendee_status_update')) {
$email = isset($order_meta['_billing_email'][0]) ? $order_meta['_billing_email'][0] : array();
$email_send_status = mep_get_option('mep_email_sending_order_status', 'email_setting_sec', array('disable_email' => 'disable_email'));
$email_send_status = !empty($email_send_status) ? $email_send_status : array('disable_email' => 'disable_email');
-
+ $enable_billing_email = mep_get_option('mep_send_confirmation_to_billing_email', 'email_setting_sec','enable');
// mep_email_sending_order_status
$order_status = $order->get_status();
-
+ $cn = 1;
+ $event_arr = [];
foreach ($order->get_items() as $item_id => $item_values) {
$item_id = $item_id;
$event_id = mep_event_get_order_meta($item_id, 'event_id');
-
+ $event_arr[] = $event_id;
if (get_post_type($event_id) == 'mep_events') {
@@ -1026,6 +1034,8 @@ if (!function_exists('mep_attendee_status_update')) {
change_extra_service_status($order_id, 'publish', 'trash', 'processing');
change_extra_service_status($order_id, 'publish', 'publish', 'processing');
do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id);
+ if($enable_billing_email == 'enable'){
+
if (in_array('processing', $email_send_status)) {
mep_event_confirmation_email_sent($event_id, $email, $order_id);
@@ -1033,6 +1043,7 @@ if (!function_exists('mep_attendee_status_update')) {
// mep_event_confirmation_email_sent($event_id, $org_email, $order_id);
}
}
+ }
}
if ($order->has_status('pending')) {
@@ -1084,12 +1095,12 @@ if (!function_exists('mep_attendee_status_update')) {
mep_update_event_seat_inventory($event_id,$event_ticket_info_arr);
-
-
-
- } // End of Post Type Check
+ } // End of Post Type Check
+ $cn++;
} // End order item foreach
+
+ do_action('mep_wc_order_status_change_single', $order_status, $event_id, $order_id,$cn,$event_arr);
} // End Function
}
diff --git a/lib/appsero/src/Client.php b/lib/appsero/src/Client.php
index f51b1e7..0dc3a1e 100755
--- a/lib/appsero/src/Client.php
+++ b/lib/appsero/src/Client.php
@@ -1,4 +1,5 @@
hash = $hash;
@@ -116,8 +113,7 @@ class Client {
* @return Appsero\Insights
*/
public function insights() {
-
- if ( ! class_exists( __NAMESPACE__ . '\Insights') ) {
+ if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) {
require_once __DIR__ . '/Insights.php';
}
@@ -131,35 +127,13 @@ class Client {
return $this->insights;
}
- /**
- * Initialize plugin/theme updater
- *
- * @return Appsero\Updater
- */
- public function updater() {
-
- if ( ! class_exists( __NAMESPACE__ . '\Updater') ) {
- require_once __DIR__ . '/Updater.php';
- }
-
- // if already instantiated, return the cached one
- if ( $this->updater ) {
- return $this->updater;
- }
-
- $this->updater = new Updater( $this );
-
- return $this->updater;
- }
-
/**
* Initialize license checker
*
* @return Appsero\License
*/
public function license() {
-
- if ( ! class_exists( __NAMESPACE__ . '\License') ) {
+ if ( ! class_exists( __NAMESPACE__ . '\License' ) ) {
require_once __DIR__ . '/License.php';
}
@@ -190,27 +164,26 @@ class Client {
* @return void
*/
protected function set_basename_and_slug() {
-
if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) {
$this->basename = plugin_basename( $this->file );
- list( $this->slug, $mainfile) = explode( '/', $this->basename );
+ list( $this->slug, $mainfile ) = explode( '/', $this->basename );
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin_data = get_plugin_data( $this->file );
$this->project_version = $plugin_data['Version'];
- $this->type = 'plugin';
+ $this->type = 'plugin';
} else {
$this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );
- list( $this->slug, $mainfile) = explode( '/', $this->basename );
+ list( $this->slug, $mainfile ) = explode( '/', $this->basename );
$theme = wp_get_theme( $this->slug );
$this->project_version = $theme->version;
- $this->type = 'theme';
+ $this->type = 'theme';
}
$this->textdomain = $this->slug;
@@ -219,29 +192,32 @@ class Client {
/**
* Send request to remote endpoint
*
- * @param array $params
- * @param string $route
+ * @param array $params
+ * @param string $route
*
- * @return array|WP_Error Array of results including HTTP headers or WP_Error if the request failed.
+ * @return array|WP_Error array of results including HTTP headers or WP_Error if the request failed
*/
public function send_request( $params, $route, $blocking = false ) {
$url = $this->endpoint() . $route;
- $headers = array(
+ $headers = [
'user-agent' => 'Appsero/' . md5( esc_url( home_url() ) ) . ';',
'Accept' => 'application/json',
- );
+ ];
- $response = wp_remote_post( $url, array(
- 'method' => 'POST',
- 'timeout' => 30,
- 'redirection' => 5,
- 'httpversion' => '1.0',
- 'blocking' => $blocking,
- 'headers' => $headers,
- 'body' => array_merge( $params, array( 'client' => $this->version ) ),
- 'cookies' => array()
- ) );
+ $response = wp_remote_post(
+ $url,
+ [
+ 'method' => 'POST',
+ 'timeout' => 30,
+ 'redirection' => 5,
+ 'httpversion' => '1.0',
+ 'blocking' => $blocking,
+ 'headers' => $headers,
+ 'body' => array_merge( $params, [ 'client' => $this->version ] ),
+ 'cookies' => [],
+ ]
+ );
return $response;
}
@@ -249,10 +225,10 @@ class Client {
/**
* Check if the current server is localhost
*
- * @return boolean
+ * @return bool
*/
public function is_local_server() {
- $is_local = in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
+ $is_local = isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ], true );
return apply_filters( 'appsero_is_local', $is_local );
}
@@ -260,6 +236,7 @@ class Client {
/**
* Translate function _e()
*/
+ // phpcs:ignore
public function _etrans( $text ) {
call_user_func( '_e', $text, $this->textdomain );
}
@@ -267,6 +244,7 @@ class Client {
/**
* Translate function __()
*/
+ // phpcs:ignore
public function __trans( $text ) {
return call_user_func( '__', $text, $this->textdomain );
}
diff --git a/lib/appsero/src/Insights.php b/lib/appsero/src/Insights.php
index 6b59140..8187d88 100755
--- a/lib/appsero/src/Insights.php
+++ b/lib/appsero/src/Insights.php
@@ -1,4 +1,5 @@
client = $client;
}
}
@@ -67,7 +67,8 @@ class Insights {
*
* @return \self
*/
- public function hide_notice() {
+ public function hide_notice()
+ {
$this->show_notice = false;
return $this;
@@ -78,7 +79,8 @@ class Insights {
*
* @return \self
*/
- public function add_plugin_data() {
+ public function add_plugin_data()
+ {
$this->plugin_data = true;
return $this;
@@ -91,7 +93,8 @@ class Insights {
*
* @return \self
*/
- public function add_extra( $data = array() ) {
+ public function add_extra($data = [])
+ {
$this->extra_data = $data;
return $this;
@@ -100,11 +103,12 @@ class Insights {
/**
* Set custom notice text
*
- * @param string $text
+ * @param string $text
*
* @return \self
*/
- public function notice($text='' ) {
+ public function notice($text = '')
+ {
$this->notice = $text;
return $this;
@@ -115,10 +119,11 @@ class Insights {
*
* @return void
*/
- public function init() {
- if ( $this->client->type == 'plugin' ) {
+ public function init()
+ {
+ if ($this->client->type === 'plugin') {
$this->init_plugin();
- } else if ( $this->client->type == 'theme' ) {
+ } elseif ($this->client->type === 'theme') {
$this->init_theme();
}
}
@@ -128,11 +133,12 @@ class Insights {
*
* @return void
*/
- public function init_theme() {
+ public function init_theme()
+ {
$this->init_common();
- add_action( 'switch_theme', array( $this, 'deactivation_cleanup' ) );
- add_action( 'switch_theme', array( $this, 'theme_deactivated' ), 12, 3 );
+ add_action('switch_theme', [$this, 'deactivation_cleanup']);
+ add_action('switch_theme', [$this, 'theme_deactivated'], 12, 3);
}
/**
@@ -140,17 +146,21 @@ class Insights {
*
* @return void
*/
- public function init_plugin() {
+ public function init_plugin()
+ {
// plugin deactivate popup
- if ( ! $this->is_local_server() ) {
- add_filter( 'plugin_action_links_' . $this->client->basename, array( $this, 'plugin_action_links' ) );
- add_action( 'admin_footer', array( $this, 'deactivate_scripts' ) );
- }
+ // if ( ! $this->is_local_server() ) {
+ // add_filter( 'plugin_action_links_' . $this->client->basename, [ $this, 'plugin_action_links' ] );
+ // add_action( 'admin_footer', [ $this, 'deactivate_scripts' ] );
+ // }
+
+ add_filter('plugin_action_links_' . $this->client->basename, [$this, 'plugin_action_links']);
+ add_action('admin_footer', [$this, 'deactivate_scripts']);
$this->init_common();
- register_activation_hook( $this->client->file, array( $this, 'activate_plugin' ) );
- register_deactivation_hook( $this->client->file, array( $this, 'deactivation_cleanup' ) );
+ register_activation_hook($this->client->file, [$this, 'activate_plugin']);
+ register_deactivation_hook($this->client->file, [$this, 'deactivation_cleanup']);
}
/**
@@ -158,48 +168,49 @@ class Insights {
*
* @return void
*/
- protected function init_common() {
-
- if ( $this->show_notice ) {
+ protected function init_common()
+ {
+ if ($this->show_notice) {
// tracking notice
- add_action( 'admin_notices', array( $this, 'admin_notice' ) );
+ add_action('admin_notices', [$this, 'admin_notice']);
}
- add_action( 'admin_init', array( $this, 'handle_optin_optout' ) );
+ add_action('admin_init', [$this, 'handle_optin_optout']);
// uninstall reason
- add_action( 'wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', array( $this, 'uninstall_reason_submission' ) );
+ add_action('wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', [$this, 'uninstall_reason_submission']);
// cron events
- add_filter( 'cron_schedules', array( $this, 'add_weekly_schedule' ) );
- add_action( $this->client->slug . '_tracker_send_event', array( $this, 'send_tracking_data' ) );
+ add_filter('cron_schedules', [$this, 'add_weekly_schedule']);
+ add_action($this->client->slug . '_tracker_send_event', [$this, 'send_tracking_data']);
// add_action( 'admin_init', array( $this, 'send_tracking_data' ) ); // test
}
/**
* Send tracking data to AppSero server
*
- * @param boolean $override
+ * @param bool $override
*
* @return void
*/
- public function send_tracking_data( $override = false ) {
- if ( ! $this->tracking_allowed() && ! $override ) {
+ public function send_tracking_data($override = false)
+ {
+ if (!$this->tracking_allowed() && !$override) {
return;
}
// Send a maximum of once per week
$last_send = $this->get_last_send();
- if ( $last_send && $last_send > strtotime( '-1 week' ) ) {
+ if ($last_send && $last_send > strtotime('-1 week')) {
return;
}
$tracking_data = $this->get_tracking_data();
- $response = $this->client->send_request( $tracking_data, 'track' );
+ $response = $this->client->send_request($tracking_data, 'track');
- update_option( $this->client->slug . '_tracking_last_send', time() );
+ update_option($this->client->slug . '_tracking_last_send', time());
}
/**
@@ -207,82 +218,88 @@ class Insights {
*
* @return array
*/
- protected function get_tracking_data() {
+ protected function get_tracking_data()
+ {
$all_plugins = $this->get_all_plugins();
- $users = get_users( array(
- 'role' => 'administrator',
- 'orderby' => 'ID',
- 'order' => 'ASC',
- 'number' => 1,
- 'paged' => 1,
- ) );
+ $users = get_users(
+ [
+ 'role' => 'administrator',
+ 'orderby' => 'ID',
+ 'order' => 'ASC',
+ 'number' => 1,
+ 'paged' => 1,
+ ]
+ );
- $admin_user = ( is_array( $users ) && ! empty( $users ) ) ? $users[0] : false;
- $first_name = $last_name = '';
+ $admin_user = (is_array($users) && !empty($users)) ? $users[0] : false;
+ $first_name = '';
+ $last_name = '';
- if ( $admin_user ) {
+ if ($admin_user) {
$first_name = $admin_user->first_name ? $admin_user->first_name : $admin_user->display_name;
$last_name = $admin_user->last_name;
}
- $data = array(
- 'url' => esc_url( home_url() ),
+ $data = [
+ 'url' => esc_url(home_url()),
'site' => $this->get_site_name(),
- 'admin_email' => get_option( 'admin_email' ),
+ 'admin_email' => get_option('admin_email'),
'first_name' => $first_name,
'last_name' => $last_name,
'hash' => $this->client->hash,
'server' => $this->get_server_info(),
'wp' => $this->get_wp_info(),
'users' => $this->get_user_counts(),
- 'active_plugins' => count( $all_plugins['active_plugins'] ),
- 'inactive_plugins' => count( $all_plugins['inactive_plugins'] ),
+ 'active_plugins' => count($all_plugins['active_plugins']),
+ 'inactive_plugins' => count($all_plugins['inactive_plugins']),
'ip_address' => $this->get_user_ip_address(),
'project_version' => $this->client->project_version,
'tracking_skipped' => false,
'is_local' => $this->is_local_server(),
- );
+ ];
// Add Plugins
if ($this->plugin_data) {
-
- $plugins_data = array();
+ $plugins_data = [];
foreach ($all_plugins['active_plugins'] as $slug => $plugin) {
$slug = strstr($slug, '/', true);
- if (! $slug) {
+
+ if (!$slug) {
continue;
}
- $plugins_data[ $slug ] = array(
- 'name' => isset($plugin['name']) ? $plugin['name'] : '',
- 'version' => isset($plugin['version']) ? $plugin['version'] : '',
- );
+ $plugins_data[$slug] = [
+ 'name' => isset($plugin['name']) ? $plugin['name'] : '',
+ 'version' => isset($plugin['version']) ? $plugin['version'] : '',
+ ];
}
if (array_key_exists($this->client->slug, $plugins_data)) {
unset($plugins_data[$this->client->slug]);
}
-
+
$data['plugins'] = $plugins_data;
}
- // Add metadata
- if ( $extra = $this->get_extra_data() ) {
+ // Add Metadata
+ $extra = $this->get_extra_data();
+
+ if ($extra) {
$data['extra'] = $extra;
}
// Check this has previously skipped tracking
- $skipped = get_option( $this->client->slug . '_tracking_skipped' );
+ $skipped = get_option($this->client->slug . '_tracking_skipped');
- if ( $skipped === 'yes' ) {
- delete_option( $this->client->slug . '_tracking_skipped' );
+ if ($skipped === 'yes') {
+ delete_option($this->client->slug . '_tracking_skipped');
$data['tracking_skipped'] = true;
}
- return apply_filters( $this->client->slug . '_tracker_data', $data );
+ return apply_filters($this->client->slug . '_tracker_data', $data);
}
/**
@@ -290,16 +307,17 @@ class Insights {
*
* @return mixed
*/
- protected function get_extra_data() {
- if ( is_callable( $this->extra_data ) ) {
- return call_user_func( $this->extra_data );
+ protected function get_extra_data()
+ {
+ if (is_callable($this->extra_data)) {
+ return call_user_func($this->extra_data);
}
- if ( is_array( $this->extra_data ) ) {
+ if (is_array($this->extra_data)) {
return $this->extra_data;
}
- return array();
+ return [];
}
/**
@@ -307,17 +325,18 @@ class Insights {
*
* @return array
*/
- protected function data_we_collect() {
- $data = array(
+ protected function data_we_collect()
+ {
+ $data = [
'Server environment details (php, mysql, server, WordPress versions)',
'Number of users in your site',
'Site language',
'Number of active and inactive plugins',
'Site name and URL',
'Your name and email address',
- );
+ ];
- if ($this->plugin_data) {
+ if ($this->plugin_data) {
array_splice($data, 4, 0, ["active plugins' name"]);
}
@@ -329,10 +348,11 @@ class Insights {
*
* @return bool
*/
- public function tracking_allowed() {
- $allow_tracking = get_option( $this->client->slug . '_allow_tracking', 'no' );
+ public function tracking_allowed()
+ {
+ $allow_tracking = get_option($this->client->slug . '_allow_tracking', 'no');
- return $allow_tracking == 'yes';
+ return $allow_tracking === 'yes';
}
/**
@@ -340,19 +360,21 @@ class Insights {
*
* @return false|string
*/
- private function get_last_send() {
- return get_option( $this->client->slug . '_tracking_last_send', false );
+ private function get_last_send()
+ {
+ return get_option($this->client->slug . '_tracking_last_send', false);
}
/**
* Check if the notice has been dismissed or enabled
*
- * @return boolean
+ * @return bool
*/
- public function notice_dismissed() {
- $hide_notice = get_option( $this->client->slug . '_tracking_notice', null );
+ public function notice_dismissed()
+ {
+ $hide_notice = get_option($this->client->slug . '_tracking_notice', null);
- if ( 'hide' == $hide_notice ) {
+ if ('hide' === $hide_notice) {
return true;
}
@@ -362,22 +384,23 @@ class Insights {
/**
* Check if the current server is localhost
*
- * @return boolean
+ * @return bool
*/
- private function is_local_server() {
-
- $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : 'localhost';
- $ip = isset( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1';
+ private function is_local_server()
+ {
+ $host = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : 'localhost';
+ $ip = isset($_SERVER['SERVER_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_ADDR'])) : '127.0.0.1';
$is_local = false;
- if( in_array( $ip,array( '127.0.0.1', '::1' ) )
- || ! strpos( $host, '.' )
- || in_array( strrchr( $host, '.' ), array( '.test', '.testing', '.local', '.localhost', '.localdomain' ) )
+ if (
+ in_array($ip, ['127.0.0.1', '::1'], true)
+ || !strpos($host, '.')
+ || in_array(strrchr($host, '.'), ['.test', '.testing', '.local', '.localhost', '.localdomain'], true)
) {
$is_local = true;
}
- return apply_filters( 'appsero_is_local', $is_local );
+ return apply_filters('appsero_is_local', $is_local);
}
/**
@@ -385,11 +408,12 @@ class Insights {
*
* @return void
*/
- private function schedule_event() {
- $hook_name = $this->client->slug . '_tracker_send_event';
+ private function schedule_event()
+ {
+ $hook_name = wp_unslash($this->client->slug . '_tracker_send_event');
- if ( ! wp_next_scheduled( $hook_name ) ) {
- wp_schedule_event( time(), 'weekly', $hook_name );
+ if (!wp_next_scheduled($hook_name)) {
+ wp_schedule_event(time(), 'weekly', $hook_name);
}
}
@@ -398,8 +422,9 @@ class Insights {
*
* @return void
*/
- private function clear_schedule_event() {
- wp_clear_scheduled_hook( $this->client->slug . '_tracker_send_event' );
+ private function clear_schedule_event()
+ {
+ wp_clear_scheduled_hook($this->client->slug . '_tracker_send_event');
}
/**
@@ -407,45 +432,45 @@ class Insights {
*
* @return void
*/
- public function admin_notice() {
-
- if ( $this->notice_dismissed() ) {
+ public function admin_notice()
+ {
+ if ($this->notice_dismissed()) {
return;
}
- if ( $this->tracking_allowed() ) {
+ if ($this->tracking_allowed()) {
return;
}
- if ( ! current_user_can( 'manage_options' ) ) {
+ if (!current_user_can('manage_options')) {
return;
}
// don't show tracking if a local server
- if ( $this->is_local_server() ) {
- return;
- }
+ // if ( $this->is_local_server() ) {
+ // return;
+ // }
- $optin_url = add_query_arg( $this->client->slug . '_tracker_optin', 'true' );
- $optout_url = add_query_arg( $this->client->slug . '_tracker_optout', 'true' );
+ $optin_url = wp_nonce_url(add_query_arg($this->client->slug . '_tracker_optin', 'true'), '_wpnonce');
+ $optout_url = wp_nonce_url(add_query_arg($this->client->slug . '_tracker_optout', 'true'), '_wpnonce');
- if ( empty( $this->notice ) ) {
- $notice = sprintf( $this->client->__trans( 'Want to help make %1$s even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.' ), $this->client->name );
+ if (empty($this->notice)) {
+ $notice = sprintf($this->client->__trans('Want to help make %1$s even more awesome? Allow %1$s to collect diagnostic data and usage information.'), $this->client->name);
} else {
$notice = $this->notice;
}
- $policy_url = 'https://' . 'appsero.com/privacy-policy/';
+ $policy_url = 'https://appsero.com/privacy-policy/';
- $notice .= ' (' . $this->client->__trans( 'what we collect' ) . ')';
- $notice .= '
'; - echo $notice; - echo '
'; - echo ' ' . $this->client->__trans( 'Allow' ) . ''; - echo ' ' . $this->client->__trans( 'No thanks' ) . ''; + echo $notice; + echo '
'; + echo ' ' . $this->client->__trans('Allow') . ''; + echo ' ' . $this->client->__trans('No thanks') . ''; echo '
client->__trans( 'Activate %s by your license key to get professional support and automatic update from your WordPress dashboard.' ), $this->client->name ); ?>
- show_active_license_info( $license ); - } ?> + if ( 'deactive' === $action && isset( $license['remaining'] ) ) { + $this->show_active_license_info( $license ); + } + ?> @@ -305,30 +309,37 @@ class License { /** * License form submit */ - public function license_form_submit( $form ) { - if ( ! isset( $form['_nonce'], $form['_action'] ) ) { - $this->error = $this->client->__trans( 'Please add all information' ); + public function license_form_submit( $form_data = array() ) { + if ( ! isset( $form_data['_nonce'] ) ) { + return; + } + + if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $form_data['_nonce'] ) ), $this->client->name ) ) { + $this->error = $this->client->__trans( 'Nonce vefification failed.' ); return; } - if ( ! wp_verify_nonce( $form['_nonce'], $this->client->name ) ) { - $this->error = $this->client->__trans( "You don't have permission to manage license." ); + if ( ! current_user_can( 'manage_options' ) ) { + $this->error = $this->client->__trans( 'You don\'t have permission to manage license.' ); return; } - switch ( $form['_action'] ) { + $license_key = ! empty( $form_data['license_key'] ) ? sanitize_text_field( wp_unslash( $form_data['license_key'] ) ) : ''; + $action = ! empty( $form_data['_action'] ) ? sanitize_text_field( wp_unslash( $form_data['_action'] ) ) : ''; + + switch ( $action ) { case 'active': - $this->active_client_license( $form ); + $this->active_client_license( $license_key ); break; case 'deactive': - $this->deactive_client_license( $form ); + $this->deactive_client_license(); break; case 'refresh': - $this->refresh_client_license( $form ); + $this->refresh_client_license(); break; } } @@ -369,7 +380,7 @@ class License { $license = $this->get_license(); - if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] == 'activate' ) { + if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { $this->is_valid_license = true; } else { $this->is_valid_license = false; @@ -384,8 +395,8 @@ class License { public function is_valid_by( $option, $value ) { $license = $this->get_license(); - if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] == 'activate' ) { - if ( isset( $license[ $option ] ) && $license[ $option ] == $value ) { + if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { + if ( isset( $license[ $option ] ) && $license[ $option ] === $value ) { return true; } } @@ -548,12 +559,13 @@ class License {' . $license['expiry_days'] . ' days
'; - } else { - echo '' . $this->client->__trans( 'Never' ) . '
'; - } ?> + if ( false !== $license['expiry_days'] ) { + $occupied = $license['expiry_days'] > 21 ? '' : 'occupied'; + echo '' . $license['expiry_days'] . ' days
'; + } else { + echo '' . $this->client->__trans( 'Never' ) . '
'; + } + ?>error; ?>
- success ) ) { @@ -576,7 +588,7 @@ class License {success; ?>