From e23ff1a56384501a54925acea3069d92ba0b8cbe Mon Sep 17 00:00:00 2001 From: magepeopleteam Date: Thu, 25 Jan 2024 07:52:44 +0000 Subject: [PATCH] v 4.1.3 release --- Admin/settings/global/admin_setting_panel.php | 28 +- assets/frontend/mpwem_style.css | 37 +- inc/MPWEM_Dependencies.php | 2 +- inc/mep_functions.php | 79 +- lib/appsero/src/Client.php | 98 +-- lib/appsero/src/Insights.php | 769 ++++++++++-------- lib/appsero/src/License.php | 206 ++--- lib/appsero/src/Updater.php | 258 ------ support/elementor/widget/event-countdown.php | 116 +-- templates/themes/default-theme.php | 1 + woocommerce-event-press.php | 2 +- 11 files changed, 748 insertions(+), 848 deletions(-) delete mode 100755 lib/appsero/src/Updater.php 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 '

'; - 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 '

'; echo " - get_template() == $this->client->slug ) { - $this->client->send_request( $this->get_tracking_data(), 'deactivate' ); + if ($old_theme->get_template() === $this->client->slug) { + $this->client->send_request($this->get_tracking_data(), 'deactivate'); } } /** * Get user IP Address */ - private function get_user_ip_address() { - $response = wp_remote_get( 'https://icanhazip.com/' ); + private function get_user_ip_address() + { + $response = wp_remote_get('https://icanhazip.com/'); - if ( is_wp_error( $response ) ) { + if (is_wp_error($response)) { return ''; } - $ip = trim( wp_remote_retrieve_body( $response ) ); + $ip = trim(wp_remote_retrieve_body($response)); - if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) { + if (!filter_var($ip, FILTER_VALIDATE_IP)) { return ''; } @@ -988,16 +1069,17 @@ class Insights { /** * Get site name */ - private function get_site_name() { - $site_name = get_bloginfo( 'name' ); + private function get_site_name() + { + $site_name = get_bloginfo('name'); - if ( empty( $site_name ) ) { - $site_name = get_bloginfo( 'description' ); - $site_name = wp_trim_words( $site_name, 3, '' ); + if (empty($site_name)) { + $site_name = get_bloginfo('description'); + $site_name = wp_trim_words($site_name, 3, ''); } - if ( empty( $site_name ) ) { - $site_name = esc_url( home_url() ); + if (empty($site_name)) { + $site_name = esc_url(home_url()); } return $site_name; @@ -1006,28 +1088,30 @@ class Insights { /** * Send request to appsero if user skip to send tracking data */ - private function send_tracking_skipped_request() { - $skipped = get_option( $this->client->slug . '_tracking_skipped' ); + private function send_tracking_skipped_request() + { + $skipped = get_option($this->client->slug . '_tracking_skipped'); - $data = array( + $data = [ 'hash' => $this->client->hash, 'previously_skipped' => false, - ); + ]; - if ( $skipped === 'yes' ) { + if ($skipped === 'yes') { $data['previously_skipped'] = true; } else { - update_option( $this->client->slug . '_tracking_skipped', 'yes' ); + update_option($this->client->slug . '_tracking_skipped', 'yes'); } - $this->client->send_request( $data, 'tracking-skipped' ); + $this->client->send_request($data, 'tracking-skipped'); } /** * Deactivation modal styles */ - private function deactivation_modal_styles() { - ?> + private function deactivation_modal_styles() + { + ?> - client = $client; @@ -71,10 +71,10 @@ class License { $this->schedule_hook = $this->client->slug . '_license_check_event'; // Creating WP Ajax Endpoint to refresh license remotely - add_action( "wp_ajax_appsero_refresh_license_" . $this->client->hash, array( $this, 'refresh_license_api' ) ); + add_action( 'wp_ajax_appsero_refresh_license_' . $this->client->hash, [ $this, 'refresh_license_api' ] ); // Run hook to check license status daily - add_action( $this->schedule_hook, array( $this, 'check_license_status' ) ); + add_action( $this->schedule_hook, [ $this, 'check_license_status' ] ); // Active/Deactive corn schedule $this->run_schedule(); @@ -111,10 +111,10 @@ class License { /** * Check license * - * @return bool + * @return array */ public function check( $license_key ) { - $route = 'public/license/' . $this->client->hash . '/check'; + $route = 'public/license/' . $this->client->hash . '/check'; return $this->send_request( $license_key, $route ); } @@ -122,10 +122,10 @@ class License { /** * Active a license * - * @return bool + * @return array */ public function activate( $license_key ) { - $route = 'public/license/' . $this->client->hash . '/activate'; + $route = 'public/license/' . $this->client->hash . '/activate'; return $this->send_request( $license_key, $route ); } @@ -133,10 +133,10 @@ class License { /** * Deactivate a license * - * @return bool + * @return array */ public function deactivate( $license_key ) { - $route = 'public/license/' . $this->client->hash . '/deactivate'; + $route = 'public/license/' . $this->client->hash . '/deactivate'; return $this->send_request( $license_key, $route ); } @@ -144,41 +144,38 @@ class License { /** * Send common request * - * @param $license_key - * @param $route - * * @return array */ protected function send_request( $license_key, $route ) { - $params = array( + $params = [ 'license_key' => $license_key, 'url' => esc_url( home_url() ), 'is_local' => $this->client->is_local_server(), - ); + ]; $response = $this->client->send_request( $params, $route, true ); if ( is_wp_error( $response ) ) { - return array( + return [ 'success' => false, - 'error' => $response->get_error_message() - ); + 'error' => $response->get_error_message(), + ]; } $response = json_decode( wp_remote_retrieve_body( $response ), true ); - if ( empty( $response ) || isset( $response['exception'] )) { - return array( + if ( empty( $response ) || isset( $response['exception'] ) ) { + return [ 'success' => false, 'error' => $this->client->__trans( 'Unknown error occurred, Please try again.' ), - ); + ]; } if ( isset( $response['errors'] ) && isset( $response['errors']['license_key'] ) ) { - $response = array( + $response = [ 'success' => false, - 'error' => $response['errors']['license_key'][0] - ); + 'error' => $response['errors']['license_key'][0], + ]; } return $response; @@ -190,10 +187,10 @@ class License { public function refresh_license_api() { $this->check_license_status(); - return wp_send_json( - array( - 'message' => 'License refreshed successfully.' - ), + wp_send_json_success( + [ + 'message' => 'License refreshed successfully.', + ], 200 ); } @@ -205,8 +202,8 @@ class License { * * @return void */ - public function add_settings_page( $args = array() ) { - $defaults = array( + public function add_settings_page( $args = [] ) { + $defaults = [ 'type' => 'menu', // Can be: menu, options, submenu 'page_title' => 'Manage License', 'menu_title' => 'Manage License', @@ -215,11 +212,11 @@ class License { 'icon_url' => '', 'position' => null, 'parent_slug' => '', - ); + ]; $this->menu_args = wp_parse_args( $args, $defaults ); - add_action( 'admin_menu', array( $this, 'admin_menu' ), 99 ); + add_action( 'admin_menu', [ $this, 'admin_menu' ], 99 ); } /** @@ -247,12 +244,18 @@ class License { * License menu output */ public function menu_output() { - if ( isset( $_POST['submit'] ) ) { - $this->license_form_submit( $_POST ); + // process form data if submitted + if ( isset( $_POST['_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), $this->client->name ) ) { + $form_data = [ + '_nonce' => sanitize_key( wp_unslash( $_POST['_nonce'] ) ), + '_action' => isset( $_POST['_action'] ) ? sanitize_text_field( wp_unslash( $_POST['_action'] ) ) : '', + 'license_key' => isset( $_POST['license_key'] ) ? sanitize_text_field( wp_unslash( $_POST['license_key'] ) ) : '', + ]; + $this->license_form_submit( $form_data ); } $license = $this->get_license(); - $action = ( $license && isset( $license['status'] ) && 'activate' == $license['status'] ) ? 'deactive' : 'active'; + $action = ( $license && isset( $license['status'] ) && 'activate' === $license['status'] ) ? 'deactive' : 'active'; $this->licenses_style(); ?> @@ -271,7 +274,7 @@ class License {

client->__trans( 'Activate %s by your license key to get professional support and automatic update from your WordPress dashboard.' ), $this->client->name ); ?>

-
+
@@ -281,19 +284,20 @@ class License { + />
-
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 {

client->_etrans( 'Expires in' ); ?>

21 ? '' : 'occupied'; - echo '

' . $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; ?>

- '; } @@ -594,8 +606,8 @@ class License { client->__trans( 'Activate License' ); ?> - -
+ +
- + error = $this->client->__trans( 'The license key field is required.' ); return; } - $license_key = sanitize_text_field( $form['license_key'] ); - $response = $this->activate( $license_key ); + $response = $this->activate( $license_key ); if ( ! $response['success'] ) { $this->error = $response['error'] ? $response['error'] : $this->client->__trans( 'Unknown error occurred.' ); @@ -628,7 +639,7 @@ class License { return; } - $data = array( + $data = [ 'key' => $license_key, 'status' => 'activate', 'remaining' => $response['remaining'], @@ -637,7 +648,7 @@ class License { 'title' => $response['title'], 'source_id' => $response['source_identifier'], 'recurring' => $response['recurring'], - ); + ]; update_option( $this->option_key, $data, false ); @@ -647,7 +658,7 @@ class License { /** * Deactive client license */ - private function deactive_client_license( $form ) { + private function deactive_client_license() { $license = $this->get_license(); if ( empty( $license['key'] ) ) { @@ -658,10 +669,10 @@ class License { $response = $this->deactivate( $license['key'] ); - $data = array( + $data = [ 'key' => '', 'status' => 'deactivate', - ); + ]; update_option( $this->option_key, $data, false ); @@ -677,11 +688,12 @@ class License { /** * Refresh Client License */ - private function refresh_client_license( $form = null ) { + private function refresh_client_license() { $license = $this->get_license(); - if( !$license || ! isset( $license['key'] ) || empty( $license['key'] ) ) { - $this->error = $this->client->__trans( "License key not found" ); + if ( ! $license || ! isset( $license['key'] ) || empty( $license['key'] ) ) { + $this->error = $this->client->__trans( 'License key not found' ); + return; } @@ -695,12 +707,12 @@ class License { */ private function create_menu_page() { call_user_func( - 'add_' . 'menu' . '_page', + 'add_menu_page', $this->menu_args['page_title'], $this->menu_args['menu_title'], $this->menu_args['capability'], $this->menu_args['menu_slug'], - array( $this, 'menu_output' ), + [ $this, 'menu_output' ], $this->menu_args['icon_url'], $this->menu_args['position'] ); @@ -711,13 +723,13 @@ class License { */ private function create_submenu_page() { call_user_func( - 'add_' . 'submenu' . '_page', + 'add_submenu_page', $this->menu_args['parent_slug'], $this->menu_args['page_title'], $this->menu_args['menu_title'], $this->menu_args['capability'], $this->menu_args['menu_slug'], - array( $this, 'menu_output' ), + [ $this, 'menu_output' ], $this->menu_args['position'] ); } @@ -727,12 +739,12 @@ class License { */ private function create_options_page() { call_user_func( - 'add_' . 'options' . '_page', + 'add_options_page', $this->menu_args['page_title'], $this->menu_args['menu_title'], $this->menu_args['capability'], $this->menu_args['menu_slug'], - array( $this, 'menu_output' ), + [ $this, 'menu_output' ], $this->menu_args['position'] ); } @@ -761,46 +773,34 @@ class License { private function run_schedule() { switch ( $this->client->type ) { case 'plugin': - register_activation_hook( $this->client->file, array( $this, 'schedule_cron_event' ) ); - register_deactivation_hook( $this->client->file, array( $this, 'clear_scheduler' ) ); + register_activation_hook( $this->client->file, [ $this, 'schedule_cron_event' ] ); + register_deactivation_hook( $this->client->file, [ $this, 'clear_scheduler' ] ); break; case 'theme': - add_action( 'after_switch_theme', array( $this, 'schedule_cron_event' ) ); - add_action( 'switch_theme', array( $this, 'clear_scheduler' ) ); + add_action( 'after_switch_theme', [ $this, 'schedule_cron_event' ] ); + add_action( 'switch_theme', [ $this, 'clear_scheduler' ] ); break; } } - /** - * Form action URL - */ - private function form_action_url() { - $url = add_query_arg( - $_GET, - admin_url( basename( $_SERVER['SCRIPT_NAME'] ) ) - ); - - echo apply_filters( 'appsero_client_license_form_action', $url ); - } - /** * Get input license key * - * @param $action - * * @return $license */ private function get_input_license_value( $action, $license ) { - if ( 'active' == $action ) { + if ( 'active' === $action ) { return isset( $license['key'] ) ? $license['key'] : ''; } - if ( 'deactive' == $action ) { + if ( 'deactive' === $action ) { $key_length = strlen( $license['key'] ); return str_pad( - substr( $license['key'], 0, $key_length / 2 ), $key_length, '*' + substr( $license['key'], 0, $key_length / 2 ), + $key_length, + '*' ); } diff --git a/lib/appsero/src/Updater.php b/lib/appsero/src/Updater.php deleted file mode 100755 index 33b1cef..0000000 --- a/lib/appsero/src/Updater.php +++ /dev/null @@ -1,258 +0,0 @@ -client = $client; - $this->cache_key = 'appsero_' . md5( $this->client->slug ) . '_version_info'; - - // Run hooks. - if ( $this->client->type == 'plugin' ) { - $this->run_plugin_hooks(); - } elseif ( $this->client->type == 'theme' ) { - $this->run_theme_hooks(); - } - } - - /** - * Set up WordPress filter to hooks to get update. - * - * @return void - */ - public function run_plugin_hooks() { - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_plugin_update' ) ); - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); - } - - /** - * Set up WordPress filter to hooks to get update. - * - * @return void - */ - public function run_theme_hooks() { - add_filter( 'pre_set_site_transient_update_themes', array( $this, 'check_theme_update' ) ); - } - - /** - * Check for Update for this specific project - */ - public function check_plugin_update( $transient_data ) { - global $pagenow; - - if ( ! is_object( $transient_data ) ) { - $transient_data = new \stdClass; - } - - if ( 'plugins.php' == $pagenow && is_multisite() ) { - return $transient_data; - } - - if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->basename ] ) ) { - return $transient_data; - } - - $version_info = $this->get_version_info(); - - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { - - unset( $version_info->sections ); - - // If new version available then set to `response` - if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) { - $transient_data->response[ $this->client->basename ] = $version_info; - } else { - // If new version is not available then set to `no_update` - $transient_data->no_update[ $this->client->basename ] = $version_info; - } - - $transient_data->last_checked = time(); - $transient_data->checked[ $this->client->basename ] = $this->client->project_version; - } - - return $transient_data; - } - - /** - * Get version info from database - * - * @return Object or Boolean - */ - private function get_cached_version_info() { - global $pagenow; - - // If updater page then fetch from API now - if ( 'update-core.php' == $pagenow ) { - return false; // Force to fetch data - } - - $value = get_transient( $this->cache_key ); - - if( ! $value && ! isset( $value->name ) ) { - return false; // Cache is expired - } - - // We need to turn the icons into an array - if ( isset( $value->icons ) ) { - $value->icons = (array) $value->icons; - } - - // We need to turn the banners into an array - if ( isset( $value->banners ) ) { - $value->banners = (array) $value->banners; - } - - if ( isset( $value->sections ) ) { - $value->sections = (array) $value->sections; - } - - return $value; - } - - /** - * Set version info to database - */ - private function set_cached_version_info( $value ) { - if ( ! $value ) { - return; - } - - set_transient( $this->cache_key, $value, 3 * HOUR_IN_SECONDS ); - } - - /** - * Get plugin info from Appsero - */ - private function get_project_latest_version() { - - $license = $this->client->license()->get_license(); - - $params = array( - 'version' => $this->client->project_version, - 'name' => $this->client->name, - 'slug' => $this->client->slug, - 'basename' => $this->client->basename, - 'license_key' => ! empty( $license ) && isset( $license['key'] ) ? $license['key'] : '', - ); - - $route = 'update/' . $this->client->hash . '/check'; - - $response = $this->client->send_request( $params, $route, true ); - - if ( is_wp_error( $response ) ) { - return false; - } - - $response = json_decode( wp_remote_retrieve_body( $response ) ); - - if ( ! isset( $response->slug ) ) { - return false; - } - - if ( isset( $response->icons ) ) { - $response->icons = (array) $response->icons; - } - - if ( isset( $response->banners ) ) { - $response->banners = (array) $response->banners; - } - - if ( isset( $response->sections ) ) { - $response->sections = (array) $response->sections; - } - - return $response; - } - - /** - * Updates information on the "View version x.x details" page with custom data. - * - * @param mixed $data - * @param string $action - * @param object $args - * - * @return object $data - */ - public function plugins_api_filter( $data, $action = '', $args = null ) { - - if ( $action != 'plugin_information' ) { - return $data; - } - - if ( ! isset( $args->slug ) || ( $args->slug != $this->client->slug ) ) { - return $data; - } - - return $this->get_version_info(); - } - - /** - * Check theme upate - */ - public function check_theme_update( $transient_data ) { - global $pagenow; - - if ( ! is_object( $transient_data ) ) { - $transient_data = new \stdClass; - } - - if ( 'themes.php' == $pagenow && is_multisite() ) { - return $transient_data; - } - - if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->slug ] ) ) { - return $transient_data; - } - - $version_info = $this->get_version_info(); - - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { - - // If new version available then set to `response` - if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) { - $transient_data->response[ $this->client->slug ] = (array) $version_info; - } else { - // If new version is not available then set to `no_update` - $transient_data->no_update[ $this->client->slug ] = (array) $version_info; - } - - $transient_data->last_checked = time(); - $transient_data->checked[ $this->client->slug ] = $this->client->project_version; - } - - return $transient_data; - } - - /** - * Get version information - */ - private function get_version_info() { - $version_info = $this->get_cached_version_info(); - - if ( false === $version_info ) { - $version_info = $this->get_project_latest_version(); - $this->set_cached_version_info( $version_info ); - } - - return $version_info; - } - -} diff --git a/support/elementor/widget/event-countdown.php b/support/elementor/widget/event-countdown.php index 8691395..4b91efb 100644 --- a/support/elementor/widget/event-countdown.php +++ b/support/elementor/widget/event-countdown.php @@ -77,14 +77,14 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'label' => __( 'Display?', 'mage-eventpress' ), 'type' => Controls_Manager::SELECT, - 'default' => 'block', + 'default' => 'inline-block', 'options' => [ - 'block' => __( 'Yes', 'mage-eventpress' ), + 'inline-block' => __( 'Yes', 'mage-eventpress' ), 'none' => __( 'No', 'mage-eventpress' ) ], 'separator' => 'none', 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days' => 'display: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days' => 'display: {{VALUE}} !important;', ], ] ); @@ -101,7 +101,7 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'name' => 'mep_event_cd_day_border', 'label' => __( 'Border', 'plugin-domain' ), - 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days .wrapper', + 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days span', ] ); @@ -114,7 +114,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Background Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days .wrapper' => 'background: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days span' => 'background: {{VALUE}};', ], ] ); @@ -124,7 +124,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Time Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days .time' => 'color: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days span' => 'color: {{VALUE}};', ], ] ); @@ -148,7 +148,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days .wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -159,7 +159,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days .wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -168,7 +168,7 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'name' => 'mep_event_cd_day_box_shadow', 'label' => __( 'Box Shadow', 'plugin-domain' ), - 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days .wrapper', + 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#days span', ] ); @@ -189,9 +189,9 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'label' => __( 'Display?', 'mage-eventpress' ), 'type' => Controls_Manager::SELECT, - 'default' => 'block', + 'default' => 'inline-block', 'options' => [ - 'block' => __( 'Yes', 'mage-eventpress' ), + 'inline-block' => __( 'Yes', 'mage-eventpress' ), 'none' => __( 'No', 'mage-eventpress' ) ], 'separator' => 'none', @@ -213,7 +213,7 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'name' => 'mep_event_cd_hours_border', 'label' => __( 'Border', 'plugin-domain' ), - 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours .wrapper', + 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours span', ] ); $this->add_control( @@ -222,7 +222,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Background Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours .wrapper' => 'background: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours span' => 'background: {{VALUE}};', ], ] ); @@ -232,7 +232,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Time Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours .time' => 'color: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours span' => 'color: {{VALUE}};', ], ] ); @@ -253,7 +253,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours .wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -264,7 +264,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours .wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -273,7 +273,7 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'name' => 'mep_event_cd_hours_box_shadow', 'label' => __( 'Box Shadow', 'plugin-domain' ), - 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours .wrapper', + 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#hours span', ] ); $this->end_controls_section(); @@ -291,9 +291,9 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'label' => __( 'Display?', 'mage-eventpress' ), 'type' => Controls_Manager::SELECT, - 'default' => 'block', + 'default' => 'inline-block', 'options' => [ - 'block' => __( 'Yes', 'mage-eventpress' ), + 'inline-block' => __( 'Yes', 'mage-eventpress' ), 'none' => __( 'No', 'mage-eventpress' ) ], 'separator' => 'none', @@ -324,7 +324,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Background Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes .wrapper' => 'background: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes span' => 'background: {{VALUE}};', ], ] ); @@ -334,7 +334,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Time Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes .time' => 'color: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes span' => 'color: {{VALUE}};', ], ] ); @@ -355,7 +355,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes .wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -366,7 +366,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes .wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -375,7 +375,7 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'name' => 'mep_event_cd_minutes_box_shadow', 'label' => __( 'Box Shadow', 'plugin-domain' ), - 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes .wrapper', + 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#minutes span', ] ); $this->end_controls_section(); @@ -392,9 +392,9 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'label' => __( 'Display?', 'mage-eventpress' ), 'type' => Controls_Manager::SELECT, - 'default' => 'block', + 'default' => 'inline-block', 'options' => [ - 'block' => __( 'Yes', 'mage-eventpress' ), + 'inline-block' => __( 'Yes', 'mage-eventpress' ), 'none' => __( 'No', 'mage-eventpress' ) ], 'separator' => 'none', @@ -416,7 +416,7 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'name' => 'mep_event_cd_seconds_border', 'label' => __( 'Border', 'plugin-domain' ), - 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds .wrapper', + 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds span', ] ); $this->add_control( @@ -425,7 +425,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Background Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds .wrapper' => 'background: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds span' => 'background: {{VALUE}};', ], ] ); @@ -435,7 +435,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'label' => __( 'Time Color', 'mage-eventpress' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds .time' => 'color: {{VALUE}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds span' => 'color: {{VALUE}};', ], ] ); @@ -456,7 +456,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds .wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -467,7 +467,7 @@ class MEPEventCountdownWidget extends Widget_Base { 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%', 'rem' ], 'selectors' => [ - '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds .wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); @@ -476,7 +476,7 @@ class MEPEventCountdownWidget extends Widget_Base { [ 'name' => 'mep_event_cd_seconds_box_shadow', 'label' => __( 'Box Shadow', 'plugin-domain' ), - 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds .wrapper', + 'selector' => '{{WRAPPER}} .mep-elementor-widget-countdown .mep-event-countdown-timer div#seconds span', ] ); $this->end_controls_section(); @@ -498,25 +498,49 @@ class MEPEventCountdownWidget extends Widget_Base { $minute = get_mep_datetime($event_datetime,'minute'); $second = get_mep_datetime($event_datetime,'second'); $timezone = get_mep_datetime($event_datetime,'timezone'); + + $month_name = date('F',strtotime($event_datetime)); ?>
-
+
+
+
+
+
+
+
+
+