v 4.1.3 release

This commit is contained in:
magepeopleteam 2024-01-25 07:52:44 +00:00
parent 7876a1fbcb
commit e23ff1a563
11 changed files with 748 additions and 848 deletions

View File

@ -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},<br><br>Thanks for joining the event.<br><br>Here are the event details:<br><br>Event Name: {event}<br><br>Ticket Type: {ticket_type}<br><br>Event Date: {event_date}<br><br>Start Time: {event_time}<br><br>Full DateTime: {event_datetime}<br><br>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'
)
)
)
),

View File

@ -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
**************************************************************/

View File

@ -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());

View File

@ -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
}

View File

@ -1,4 +1,5 @@
<?php
namespace Appsero;
/**
@ -13,7 +14,7 @@ class Client {
*
* @var string
*/
public $version = '1.2.0';
public $version = '2.0.1';
/**
* Hash identifier of the plugin
@ -31,6 +32,7 @@ class Client {
/**
* The plugin/theme file path
*
* @example .../wp-content/plugins/test-slug/test-slug.php
*
* @var string
@ -39,6 +41,7 @@ class Client {
/**
* Main plugin file
*
* @example test-slug/test-slug.php
*
* @var string
@ -47,6 +50,7 @@ class Client {
/**
* Slug of the plugin
*
* @example test-slug
*
* @var string
@ -68,7 +72,7 @@ class Client {
public $type;
/**
* textdomain
* Textdomain
*
* @var string
*/
@ -81,13 +85,6 @@ class Client {
*/
private $insights;
/**
* The Object of Updater Class
*
* @var object
*/
private $updater;
/**
* The Object of License Class
*
@ -95,12 +92,12 @@ class Client {
*/
private $license;
/**
/**
* Initialize the class
*
* @param string $hash hash of the plugin
* @param string $name readable name of the plugin
* @param string $file main plugin file path
* @param string $hash hash of the plugin
* @param string $name readable name of the plugin
* @param string $file main plugin file path
*/
public function __construct( $hash, $name, $file ) {
$this->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 );
}

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ class License {
/**
* Initialize the class
*
* @param Appsero\Client
* @param Client $client
*/
public function __construct( Client $client ) {
$this->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 {
<p>
<?php printf( $this->client->__trans( 'Activate <strong>%s</strong> by your license key to get professional support and automatic update from your WordPress dashboard.' ), $this->client->name ); ?>
</p>
<form method="post" action="<?php $this->form_action_url(); ?>" novalidate="novalidate" spellcheck="false">
<form method="post" novalidate="novalidate" spellcheck="false">
<input type="hidden" name="_action" value="<?php echo $action; ?>">
<input type="hidden" name="_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>">
<div class="license-input-fields">
@ -281,19 +284,20 @@ class License {
</svg>
<input type="text" value="<?php echo $this->get_input_license_value( $action, $license ); ?>"
placeholder="<?php echo esc_attr( $this->client->__trans( 'Enter your license key to activate' ) ); ?>" name="license_key"
<?php echo ( 'deactive' == $action ) ? 'readonly="readonly"' : ''; ?>
<?php echo ( 'deactive' === $action ) ? 'readonly="readonly"' : ''; ?>
/>
</div>
<button type="submit" name="submit" class="<?php echo 'deactive' == $action ? 'deactive-button' : ''; ?>">
<?php echo $action == 'active' ? $this->client->__trans( 'Activate License' ) : $this->client->__trans( 'Deactivate License' ); ?>
<button type="submit" name="submit" class="<?php echo 'deactive' === $action ? 'deactive-button' : ''; ?>">
<?php echo $action === 'active' ? $this->client->__trans( 'Activate License' ) : $this->client->__trans( 'Deactivate License' ); ?>
</button>
</div>
</form>
<?php
if ( 'deactive' == $action && isset( $license['remaining'] ) ) {
$this->show_active_license_info( $license );
} ?>
if ( 'deactive' === $action && isset( $license['remaining'] ) ) {
$this->show_active_license_info( $license );
}
?>
</div>
</div> <!-- /.appsero-license-settings -->
@ -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 {
<div class="single-license-info">
<h3><?php $this->client->_etrans( 'Expires in' ); ?></h3>
<?php
if ( false !== $license['expiry_days'] ) {
$occupied = $license['expiry_days'] > 21 ? '' : 'occupied';
echo '<p class="' . $occupied . '">' . $license['expiry_days'] . ' days</p>';
} else {
echo '<p>' . $this->client->__trans( 'Never' ) . '</p>';
} ?>
if ( false !== $license['expiry_days'] ) {
$occupied = $license['expiry_days'] > 21 ? '' : 'occupied';
echo '<p class="' . $occupied . '">' . $license['expiry_days'] . ' days</p>';
} else {
echo '<p>' . $this->client->__trans( 'Never' ) . '</p>';
}
?>
</div>
</div>
<?php
@ -568,7 +580,7 @@ class License {
<div class="notice notice-error is-dismissible appsero-license-section">
<p><?php echo $this->error; ?></p>
</div>
<?php
<?php
}
if ( ! empty( $this->success ) ) {
@ -576,7 +588,7 @@ class License {
<div class="notice notice-success is-dismissible appsero-license-section">
<p><?php echo $this->success; ?></p>
</div>
<?php
<?php
}
echo '<br />';
}
@ -594,8 +606,8 @@ class License {
</svg>
<span><?php echo $this->client->__trans( 'Activate License' ); ?></span>
<?php if ( $license && $license['key'] ) : ?>
<form method="post" class="appsero-license-right-form" action="<?php $this->form_action_url(); ?>" novalidate="novalidate" spellcheck="false">
<?php if ( $license && $license['key'] ) { ?>
<form method="post" class="appsero-license-right-form" novalidate="novalidate" spellcheck="false">
<input type="hidden" name="_action" value="refresh">
<input type="hidden" name="_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>">
<button type="submit" name="submit" class="appsero-license-refresh-button">
@ -603,7 +615,7 @@ class License {
<?php echo $this->client->__trans( 'Refresh License' ); ?>
</button>
</form>
<?php endif; ?>
<?php } ?>
</div>
<?php
@ -612,15 +624,14 @@ class License {
/**
* Active client license
*/
private function active_client_license( $form ) {
if ( empty( $form['license_key'] ) ) {
private function active_client_license( $license_key ) {
if ( empty( $license_key ) ) {
$this->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,
'*'
);
}

View File

@ -1,258 +0,0 @@
<?php
namespace Appsero;
/**
* Appsero Updater
*
* This class will show new updates project
*/
class Updater {
/**
* Appsero\Client
*
* @var object
*/
protected $client;
/**
* Initialize the class
*
* @param Appsero\Client
*/
public function __construct( Client $client ) {
$this->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;
}
}

View File

@ -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));
?>
<div class="mep-default-title mep-elementor-widget-countdown mep-event-countdown-sec">
<div id="countdown<?php echo esc_attr($event_id); ?>" class="mep-event-countdown-timer"></div>
<div id="countdown<?php echo esc_attr($event_id); ?>" class="mep-event-countdown-timer">
<div id="timer" class='wrapper'>
<div id="days"></div>
<div id="hours"></div>
<div id="minutes"></div>
<div id="seconds"></div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function($) {
jQuery('#countdown<?php echo esc_attr($event_id); ?>').countdown({
year: <?php echo esc_attr($year); ?>, // YYYY Format
month: <?php echo esc_attr($month); ?>, // 1-12
day: <?php echo esc_attr($day); ?>, // 1-31
hour: <?php echo esc_attr($hour); ?>, // 24 hour format 0-23
minute: <?php echo esc_attr($minute); ?>, // 0-59
second: <?php echo esc_attr($second); ?>, // 0-59
timezone: <?php echo esc_attr($timezone); ?>, // http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
labels: true, // Show/Hide label elements
});
jQuery(document).ready(function($) {
function makeTimer() {
var endTime = new Date("<?php echo esc_attr($day); ?> <?php echo $month_name ?> <?php echo esc_attr($year); ?> <?php echo esc_attr($hour); ?>:<?php echo esc_attr($minute); ?>:00 GMT<?php echo esc_attr($timezone); ?>");
endTime = (Date.parse(endTime) / 1000);
var now = new Date();
now = (Date.parse(now) / 1000);
var timeLeft = endTime - now;
var days = Math.floor(timeLeft / 86400);
var hours = Math.floor((timeLeft - (days * 86400)) / 3600);
var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600 )) / 60);
var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));
if (hours < "10") { hours = "0" + hours; }
if (minutes < "10") { minutes = "0" + minutes; }
if (seconds < "10") { seconds = "0" + seconds; }
jQuery("#days").html("<span>" + days + "<span class='label'>Days</span></span>");
jQuery("#hours").html("<span>" + hours + "<span class='label'>Hours</span></span>");
jQuery("#minutes").html("<span>" + minutes + "<span class='label'>Minutes</span></span>");
jQuery("#seconds").html("<span>" + seconds + "<span class='label'>Seconds</span></span>");
}
setInterval(function() { makeTimer(); }, 1000);
});
</script>
</script>
<?php
}
}
}

View File

@ -2,6 +2,7 @@
// Template Name: Default Theme
// Settings Value :::::::::::::::::::::::::::::::::::::::;
$event_id = empty($event_id) ? get_the_id() : $event_id;
$hide_date_details = mep_get_option('mep_event_hide_date_from_details', 'single_event_setting_sec', 'no');
$hide_time_details = mep_get_option('mep_event_hide_time_from_details', 'single_event_setting_sec', 'no');
$hide_location_details = mep_get_option('mep_event_hide_location_from_details', 'single_event_setting_sec', 'no');

View File

@ -3,7 +3,7 @@
* Plugin Name: Event Manager and Tickets Selling Plugin for WooCommerce - WpEvently - WordPress Plugin
* Plugin URI: http://mage-people.com
* Description: A Complete Event Solution for WordPress by MagePeople..
* Version: 4.1.2
* Version: 4.1.3
* Author: MagePeople Team
* Author URI: http://www.mage-people.com/
* Text Domain: mage-eventpress