version 3.3.1

This commit is contained in:
magepeopleteam 2020-07-20 10:01:44 +00:00
parent 2ce21cae27
commit afeb24ee00
19 changed files with 2541 additions and 21 deletions

View File

@ -382,10 +382,23 @@ if (!class_exists('MAGE_Events_Setting_Controls')) :
),
'email_setting_sec' => apply_filters('mep_settings_email_arr',array(
array(
'name' => 'mep_email_sending_order_status',
'label' => __( 'Email Sent on order status', 'mage-eventpress' ),
'desc' => __( 'Please Select when and which order status event confirmation email will send to customer', 'mage-eventpress' ),
'type' => 'multicheck',
'default' => array( 'completed' => 'completed' ),
'options' => array(
'processing' => 'Processing',
'completed' => 'Completed'
)
),
array(
'name' => 'mep_email_form_name',
'label' => __('Email Form Name', 'mage-eventpress'),
'desc' => __('Email Form Name', 'mage-eventpress'),
'default' => '',
'type' => 'text'
),
array(

View File

@ -1,6 +1,8 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
appsero_init_tracker_mage_eventpress();
// Language Load
add_action( 'init', 'mep_language_load');
if (!function_exists('mep_language_load')) {
@ -690,9 +692,11 @@ if (!function_exists('change_wc_event_product_status')) {
// Getting an instance of the order object
$order = wc_get_order( $order_id );
$order_meta = get_post_meta($order_id);
$email = isset($order_meta['_billing_email'][0]) ? $order_meta['_billing_email'][0] : array();
$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('completed' => 'completed'));
// mep_email_sending_order_status
foreach ( $order->get_items() as $item_id => $item_values ) {
$item_id = $item_id;
@ -702,11 +706,19 @@ if (!function_exists('change_wc_event_product_status')) {
if($order->has_status( 'processing' ) ) {
if(in_array('processing',$email_send_status)){
mep_event_confirmation_email_sent($event_id,$email);
}
change_attandee_order_status($order_id,'publish','trash','processing');
change_attandee_order_status($order_id,'publish','publish','processing');
change_extra_service_status($order_id,'publish','trash','processing');
change_extra_service_status($order_id,'publish','publish','processing');
}
if($order->has_status( 'pending' )) {
change_attandee_order_status($order_id,'publish','trash','pending');
@ -720,7 +732,11 @@ if (!function_exists('change_wc_event_product_status')) {
change_attandee_order_status($order_id,'publish','publish','on-hold');
}
if($order->has_status( 'completed' ) ) {
mep_event_confirmation_email_sent($event_id,$email);
if(in_array('completed',$email_send_status)){
mep_event_confirmation_email_sent($event_id,$email);
}
change_attandee_order_status($order_id,'publish','trash','completed');
change_attandee_order_status($order_id,'publish','publish','completed');
@ -867,20 +883,20 @@ if (!function_exists('change_wc_event_product_status')) {
?>
<form action="" method="get">
<?php
if($recurring == 'everyday'){
do_action('mep_before_attendee_list_btn',$post_id);
}else{
if($recurring == 'everyday'){
do_action('mep_before_attendee_list_btn',$post_id);
}else{
?>
<select name="ea_event_date" id="" style='font-size: 14px;border: 1px solid blue;width: 110px;display:<?php if($recurring == 'yes'){ echo 'block'; }else{ echo 'none'; } ?>'>
<option value="<?php echo get_post_meta($post_id,'event_start_date',true).' '.get_post_meta($post_id,'event_start_time',true); ?>"><?php echo get_mep_datetime(get_post_meta($post_id,'event_start_date',true),'date-text').' '.get_mep_datetime(get_post_meta($post_id,'event_start_date',true).' '.get_post_meta($post_id,'event_start_time',true),'time'); ?></option>
<option value="<?php echo date('Y-m-d H:i:s',strtotime(get_post_meta($post_id,'event_start_date',true).' '.get_post_meta($post_id,'event_start_time',true))); ?>"><?php echo get_mep_datetime(get_post_meta($post_id,'event_start_date',true),'date-text').' '.get_mep_datetime(get_post_meta($post_id,'event_start_date',true).' '.get_post_meta($post_id,'event_start_time',true),'time'); ?></option>
<?php foreach($multi_date as $multi){ ?>
<option value="<?php echo $multi['event_more_start_date'].' '.$multi['event_more_start_time']; ?>"><?php echo get_mep_datetime($multi['event_more_start_date'],'date-text').' '.get_mep_datetime($multi['event_more_start_time'],'time'); ?></option>
<option value="<?php echo date('Y-m-d H:i:s',strtotime($multi['event_more_start_date'].' '.$multi['event_more_start_time'])); ?>"><?php echo get_mep_datetime($multi['event_more_start_date'],'date-text').' '.get_mep_datetime($multi['event_more_start_time'],'time'); ?></option>
<?php } ?>
</select>
<?php } ?>
<?php } ?>
<input type="hidden" name='post_type' value='mep_events_attendees'>
<input type="hidden" name='event_id' value='<?php echo $post_id; ?>'>
<button class="button button-primary button-large">Attendees List</button>
<button class="button button-primary button-large"><?php _e('Attendees List','mage-eventpress'); ?></button>
</form>
<?php
// }else{
@ -1857,7 +1873,7 @@ if (!function_exists('mep_get_term_as_class')) {
if (!function_exists('mep_ticket_type_sold')) {
function mep_ticket_type_sold($event_id,$type,$date=''){
if($date){
if($date){
$args = array(
'post_type' => 'mep_events_attendees',
'posts_per_page' => -1,

View File

@ -380,6 +380,8 @@ function mep_event_speaker_list_shortcode_section($atts, $content = null)
ob_start();
if($event > 0){
echo mep_shortcode_speaker_list_html($event);
}else{
echo mep_shortcode_all_speaker_list_html();
}
return ob_get_clean();
}

View File

@ -119,11 +119,10 @@ $location_sts = get_post_meta($event,'mep_org_address',true);
if($location_sts){
$org_arr = get_the_terms( $event, 'mep_org' );
$org_id = $org_arr[0]->term_id;
echo "<span>".get_term_meta( $org_id, 'org_location', true )."</span>";
echo get_term_meta( $org_id, 'org_location', true );
}else{
?>
<span><?php echo get_post_meta($event,'mep_location_venue',true); ?></span>
<?php
echo get_post_meta($event,'mep_location_venue',true);
}
}
}

View File

@ -18,4 +18,22 @@ if (!function_exists('mep_display_speaker_list')) {
require(mep_template_file_path('single/speaker-list.php'));
}
}
}
}
if (!function_exists('mep_display_all_speaker_list')) {
function mep_display_all_speaker_list()
{
$args = array(
'post_type' => array('mep_event_speaker'),
'posts_per_page' => -1
);
$loop = new WP_Query($args);
echo '<ul>';
foreach ($loop->posts as $speaker) {
$speakers = $speaker->ID;
require(mep_template_file_path('all-speaker-list.php'));
}
echo '</ul>';
}
}

View File

@ -14,3 +14,14 @@ if (!function_exists('mep_shortcode_speaker_list_html')) {
<?php
}
}
if (!function_exists('mep_shortcode_all_speaker_list_html')) {
function mep_shortcode_all_speaker_list_html()
{
?>
<div class="mep-default-sidebar-speaker-list">
<?php echo mep_display_all_speaker_list(); ?>
</div>
<?php
}
}

16
lib/appsero/.gitignore vendored Executable file
View File

@ -0,0 +1,16 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vscode
/nbproject
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
.phpunit.result.cache
.DS_Store

21
lib/appsero/composer.json Executable file
View File

@ -0,0 +1,21 @@
{
"name": "appsero/client",
"description": "Appsero Client",
"keywords": ["analytics", "wordpress", "plugin", "theme"],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Tareq Hasan",
"email": "tareq@appsero.com"
}
],
"autoload": {
"psr-4": {
"Appsero\\": "src/"
}
},
"require": {
"php": ">=5.3"
}
}

216
lib/appsero/readme.md Executable file
View File

@ -0,0 +1,216 @@
# Appsero - Client
- [Installation](#installation)
- [Insights](#insights)
- [Dynamic Usage](#dynamic-usage)
## Installation
You can install AppSero Client in two ways, via composer and manually.
### 1. Composer Installation
Add dependency in your project (theme/plugin):
```
composer require appsero/client
```
Now add `autoload.php` in your file if you haven't done already.
```php
require __DIR__ . '/vendor/autoload.php';
```
### 2. Manual Installation
Clone the repository in your project.
```
cd /path/to/your/project/folder
git clone https://github.com/AppSero/client.git appsero
```
Now include the dependencies in your plugin/theme.
```php
require __DIR__ . '/appsero/src/Client.php';
```
## Insights
AppSero can be used in both themes and plugins.
The `Appsero\Client` class has *three* parameters:
```php
$client = new Appsero\Client( $hash, $name, $file );
```
- **hash** (*string*, *required*) - The unique identifier for a plugin or theme.
- **name** (*string*, *required*) - The name of the plugin or theme.
- **file** (*string*, *required*) - The **main file** path of the plugin. For theme, path to `functions.php`
### Usage Example
Please refer to the **installation** step before start using the class.
You can obtain the **hash** for your plugin for the [Appsero Dashboard](https://dashboard.appsero.com). The 3rd parameter **must** have to be the main file of the plugin.
```php
/**
* Initialize the tracker
*
* @return void
*/
function appsero_init_tracker_appsero_test() {
if ( ! class_exists( 'Appsero\Client' ) ) {
require_once __DIR__ . '/appsero/src/Client.php';
}
$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044891', 'Akismet', __FILE__ );
// Active insights
$client->insights()->init();
// Active automatic updater
$client->updater();
// Active license page and checker
$args = array(
'type' => 'options',
'menu_title' => 'Akismet',
'page_title' => 'Akismet License Settings',
'menu_slug' => 'akismet_settings',
);
$client->license()->add_settings_page( $args );
}
appsero_init_tracker_appsero_test();
```
Make sure you call this function directly, never use any action hook to call this function.
> For plugins example code that needs to be used on your main plugin file.
> For themes example code that needs to be used on your themes `functions.php` file.
## More Usage
```php
$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044892', 'Twenty Twelve', __FILE__ );
```
#### 1. Hiding the notice
Sometimes you wouldn't want to show the notice, or want to customize the notice message. You can do that as well.
```php
$client->insights()
->hide_notice()
->init();
```
#### 2. Customizing the notice message
```php
$client->insights()
->notice( 'My Custom Notice Message' )
->init();
```
#### 3. Adding extra data
You can add extra metadata from your theme or plugin. In that case, the **keys** has to be whitelisted from the Appsero dashboard.
`add_extra` method also support callback as parameter, If you need database call then callback is best for you.
```php
$metadata = array(
'key' => 'value',
'another' => 'another_value'
);
$client->insights()
->add_extra( $metadata )
->init();
```
Or if you want to run a query then pass callback, we will call the function when it is necessary.
```php
$metadata = function () {
$total_posts = wp_count_posts();
return array(
'total_posts' => $total_posts,
'another' => 'another_value'
);
};
$client->insights()
->add_extra( $metadata )
->init();
```
#### 4. Set textdomain
You may set your own textdomain to translate text.
```php
$client->set_textdomain( 'your-project-textdomain' );
```
---
### Check License Validity
Check your plugin/theme is using with valid license or not, First create a global variable of `License` object then use it anywhere in your code.
If you are using it outside of same function make sure you global the variable before using the condition.
```php
$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044892', 'Twenty Twelve', __FILE__ );
$args = array(
'type' => 'submenu',
'menu_title' => 'Twenty Twelve License',
'page_title' => 'Twenty Twelve License Settings',
'menu_slug' => 'twenty_twelve_settings',
'parent_slug' => 'themes.php',
);
global $twenty_twelve_license;
$twenty_twelve_license = $client->license();
$twenty_twelve_license->add_settings_page( $args );
if ( $twenty_twelve_license->is_valid() ) {
// Your special code here
}
Or check by pricing plan title
if ( $twenty_twelve_license->is_valid_by( 'title', 'Business' ) ) {
// Your special code here
}
```
### Use your own license form
You can easily manage license by creating a form using HTTP request. Call `license_form_submit` method from License object.
```php
global $twenty_twelve_license; // License object
$twenty_twelve_license->license_form_submit([
'_nonce' => wp_create_nonce( 'Twenty Twelve' ), // create a nonce with name
'_action' => 'active', // active, deactive
'license_key' => 'random-license-key', // no need to provide if you want to deactive
]);
if ( ! $twenty_twelve_license->error ) {
// license activated
$twenty_twelve_license->success; // Success message is here
} else {
$twenty_twelve_license->error; // has error message here
}
```
## Credits
Created and maintained by [Appsero](https://appsero.com).

238
lib/appsero/src/Client.php Executable file
View File

@ -0,0 +1,238 @@
<?php
namespace Appsero;
/**
* Appsero Client
*
* This class is necessary to set project data
*/
class Client {
/**
* The client version
*
* @var string
*/
public $version = '1.1.11';
/**
* Hash identifier of the plugin
*
* @var string
*/
public $hash;
/**
* Name of the plugin
*
* @var string
*/
public $name;
/**
* The plugin/theme file path
* @example .../wp-content/plugins/test-slug/test-slug.php
*
* @var string
*/
public $file;
/**
* Main plugin file
* @example test-slug/test-slug.php
*
* @var string
*/
public $basename;
/**
* Slug of the plugin
* @example test-slug
*
* @var string
*/
public $slug;
/**
* The project version
*
* @var string
*/
public $project_version;
/**
* The project type
*
* @var string
*/
public $type;
/**
* textdomain
*
* @var string
*/
public $textdomain;
/**
* 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
*/
public function __construct( $hash, $name, $file ) {
$this->hash = $hash;
$this->name = $name;
$this->file = $file;
$this->set_basename_and_slug();
}
/**
* Initialize insights class
*
* @return Appsero\Insights
*/
public function insights() {
if ( ! class_exists( __NAMESPACE__ . '\Insights') ) {
require_once __DIR__ . '/Insights.php';
}
return new Insights( $this );
}
/**
* Initialize plugin/theme updater
*
* @return Appsero\Updater
*/
public function updater() {
if ( ! class_exists( __NAMESPACE__ . '\Updater') ) {
require_once __DIR__ . '/Updater.php';
}
return new Updater( $this );
}
/**
* Initialize license checker
*
* @return Appsero\License
*/
public function license() {
if ( ! class_exists( __NAMESPACE__ . '\License') ) {
require_once __DIR__ . '/License.php';
}
return new License( $this );
}
/**
* API Endpoint
*
* @return string
*/
public function endpoint() {
$endpoint = apply_filters( 'appsero_endpoint', 'https://api.appsero.com' );
return trailingslashit( $endpoint );
}
/**
* Set project basename, slug and version
*
* @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 );
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin_data = get_plugin_data( $this->file );
$this->project_version = $plugin_data['Version'];
$this->type = 'plugin';
} else {
$this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );
list( $this->slug, $mainfile) = explode( '/', $this->basename );
$theme = wp_get_theme( $this->slug );
$this->project_version = $theme->version;
$this->type = 'theme';
}
$this->textdomain = $this->slug;
}
/**
* Send request to remote endpoint
*
* @param array $params
* @param string $route
*
* @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(
'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()
) );
return $response;
}
/**
* Check if the current server is localhost
*
* @return boolean
*/
public function is_local_server() {
$is_local = in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
return apply_filters( 'appsero_is_local', $is_local );
}
/**
* Translate function _e()
*/
public function _etrans( $text ) {
call_user_func( '_e', $text, $this->textdomain );
}
/**
* Translate function __()
*/
public function __trans( $text ) {
return call_user_func( '__', $text, $this->textdomain );
}
/**
* Set project textdomain
*/
public function set_textdomain( $textdomain ) {
$this->textdomain = $textdomain;
}
}

949
lib/appsero/src/Insights.php Executable file
View File

@ -0,0 +1,949 @@
<?php
namespace Appsero;
/**
* Appsero Insights
*
* This is a tracker class to track plugin usage based on if the customer has opted in.
* No personal information is being tracked by this class, only general settings, active plugins, environment details
* and admin email.
*/
class Insights {
/**
* The notice text
*
* @var string
*/
public $notice;
/**
* Wheather to the notice or not
*
* @var boolean
*/
protected $show_notice = true;
/**
* If extra data needs to be sent
*
* @var array
*/
protected $extra_data = array();
/**
* AppSero\Client
*
* @var object
*/
protected $client;
/**
* Initialize the class
*
* @param AppSero\Client
*/
public function __construct( $client, $name = null, $file = null ) {
if ( is_string( $client ) && ! empty( $name ) && ! empty( $file ) ) {
$client = new Client( $client, $name, $file );
}
if ( is_object( $client ) && is_a( $client, 'Appsero\Client' ) ) {
$this->client = $client;
}
}
/**
* Don't show the notice
*
* @return \self
*/
public function hide_notice() {
$this->show_notice = false;
return $this;
}
/**
* Add extra data if needed
*
* @param array $data
*
* @return \self
*/
public function add_extra( $data = array() ) {
$this->extra_data = $data;
return $this;
}
/**
* Set custom notice text
*
* @param string $text
*
* @return \self
*/
public function notice( $text ) {
$this->notice = $text;
return $this;
}
/**
* Initialize insights
*
* @return void
*/
public function init() {
if ( $this->client->type == 'plugin' ) {
$this->init_plugin();
} else if ( $this->client->type == 'theme' ) {
$this->init_theme();
}
}
/**
* Initialize theme hooks
*
* @return void
*/
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 );
}
/**
* Initialize plugin hooks
*
* @return void
*/
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' ) );
}
$this->init_common();
register_activation_hook( $this->client->file, array( $this, 'activate_plugin' ) );
register_deactivation_hook( $this->client->file, array( $this, 'deactivation_cleanup' ) );
}
/**
* Initialize common hooks
*
* @return void
*/
protected function init_common() {
if ( $this->show_notice ) {
// tracking notice
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
}
add_action( 'admin_init', array( $this, 'handle_optin_optout' ) );
// uninstall reason
add_action( 'wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', array( $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_action( 'admin_init', array( $this, 'send_tracking_data' ) ); // test
}
/**
* Send tracking data to AppSero server
*
* @param boolean $override
*
* @return void
*/
public function send_tracking_data( $override = false ) {
// skip on AJAX Requests
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
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' ) ) {
return;
}
$response = $this->client->send_request( $this->get_tracking_data(), 'track' );
update_option( $this->client->slug . '_tracking_last_send', time() );
}
/**
* Get the tracking data points
*
* @return array
*/
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,
) );
$admin_user = ( is_array( $users ) && ! empty( $users ) ) ? $users[0] : false;
$first_name = $last_name = '';
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(
'client_version' => $this->client->version,
'url' => esc_url( home_url() ),
'site' => $this->get_site_name(),
'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'] ),
'ip_address' => $this->get_user_ip_address(),
'project_version' => $this->client->project_version,
);
// Add metadata
if ( $extra = $this->get_extra_data() ) {
$data['extra'] = $extra;
}
return apply_filters( $this->client->slug . '_tracker_data', $data );
}
/**
* If a child class wants to send extra data
*
* @return mixed
*/
protected function get_extra_data() {
if ( is_callable( $this->extra_data ) ) {
return call_user_func( $this->extra_data );
}
if ( is_array( $this->extra_data ) ) {
return $this->extra_data;
}
return array();
}
/**
* Explain the user which data we collect
*
* @return array
*/
protected function data_we_collect() {
$data = array(
'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',
);
return $data;
}
/**
* Check if the user has opted into tracking
*
* @return bool
*/
public function tracking_allowed() {
$allow_tracking = get_option( $this->client->slug . '_allow_tracking', 'no' );
return $allow_tracking == 'yes';
}
/**
* Get the last time a tracking was sent
*
* @return false|string
*/
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
*/
public function notice_dismissed() {
$hide_notice = get_option( $this->client->slug . '_tracking_notice', null );
if ( 'hide' == $hide_notice ) {
return true;
}
return false;
}
/**
* Check if the current server is localhost
*
* @return boolean
*/
private function is_local_server() {
return false;
$is_local = in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
return apply_filters( 'appsero_is_local', $is_local );
}
/**
* Schedule the event weekly
*
* @return void
*/
private function schedule_event() {
$hook_name = $this->client->slug . '_tracker_send_event';
if ( ! wp_next_scheduled( $hook_name ) ) {
wp_schedule_event( time(), 'weekly', $hook_name );
}
}
/**
* Clear any scheduled hook
*
* @return void
*/
private function clear_schedule_event() {
wp_clear_scheduled_hook( $this->client->slug . '_tracker_send_event' );
}
/**
* Display the admin notice to users that have not opted-in or out
*
* @return void
*/
public function admin_notice() {
if ( $this->notice_dismissed() ) {
return;
}
if ( $this->tracking_allowed() ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// don't show tracking if a local server
if ( ! $this->is_local_server() ) {
$optin_url = add_query_arg( $this->client->slug . '_tracker_optin', 'true' );
$optout_url = add_query_arg( $this->client->slug . '_tracker_optout', 'true' );
if ( empty( $this->notice ) ) {
$notice = sprintf( $this->client->__trans( 'Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.' ), $this->client->name );
} else {
$notice = $this->notice;
}
$policy_url = 'https://' . 'appsero.com/privacy-policy/';
$notice .= ' (<a class="' . $this->client->slug . '-insights-data-we-collect" href="#">' . $this->client->__trans( 'what we collect' ) . '</a>)';
$notice .= '<p class="description" style="display:none;">' . implode( ', ', $this->data_we_collect() ) . '. No sensitive data is tracked. ';
$notice .= 'We are using Appsero to collect your data. <a href="' . $policy_url . '">Learn more</a> about how Appsero collects and handle your data.</p>';
echo '<div class="updated"><p>';
echo $notice;
echo '</p><p class="submit">';
echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-primary button-large">' . $this->client->__trans( 'Allow' ) . '</a>';
echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary button-large">' . $this->client->__trans( 'No thanks' ) . '</a>';
echo '</p></div>';
echo "<script type='text/javascript'>jQuery('." . $this->client->slug . "-insights-data-we-collect').on('click', function(e) {
e.preventDefault();
jQuery(this).parents('.updated').find('p.description').slideToggle('fast');
});
</script>
";
}
}
/**
* handle the optin/optout
*
* @return void
*/
public function handle_optin_optout() {
if ( isset( $_GET[ $this->client->slug . '_tracker_optin' ] ) && $_GET[ $this->client->slug . '_tracker_optin' ] == 'true' ) {
$this->optin();
wp_redirect( remove_query_arg( $this->client->slug . '_tracker_optin' ) );
exit;
}
if ( isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && $_GET[ $this->client->slug . '_tracker_optout' ] == 'true' ) {
$this->optout();
wp_redirect( remove_query_arg( $this->client->slug . '_tracker_optout' ) );
exit;
}
}
/**
* Tracking optin
*
* @return void
*/
public function optin() {
update_option( $this->client->slug . '_allow_tracking', 'yes' );
update_option( $this->client->slug . '_tracking_notice', 'hide' );
$this->clear_schedule_event();
$this->schedule_event();
$this->send_tracking_data();
}
/**
* Optout from tracking
*
* @return void
*/
public function optout() {
update_option( $this->client->slug . '_allow_tracking', 'no' );
update_option( $this->client->slug . '_tracking_notice', 'hide' );
$this->clear_schedule_event();
}
/**
* Get the number of post counts
*
* @param string $post_type
*
* @return integer
*/
public function get_post_count( $post_type ) {
global $wpdb;
return (int) $wpdb->get_var( "SELECT count(ID) FROM $wpdb->posts WHERE post_type = '$post_type' and post_status = 'publish'");
}
/**
* Get server related info.
*
* @return array
*/
private static function get_server_info() {
global $wpdb;
$server_data = array();
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
$server_data['software'] = $_SERVER['SERVER_SOFTWARE'];
}
if ( function_exists( 'phpversion' ) ) {
$server_data['php_version'] = phpversion();
}
$server_data['mysql_version'] = $wpdb->db_version();
$server_data['php_max_upload_size'] = size_format( wp_max_upload_size() );
$server_data['php_default_timezone'] = date_default_timezone_get();
$server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
$server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
$server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
return $server_data;
}
/**
* Get WordPress related data.
*
* @return array
*/
private function get_wp_info() {
$wp_data = array();
$wp_data['memory_limit'] = WP_MEMORY_LIMIT;
$wp_data['debug_mode'] = ( defined('WP_DEBUG') && WP_DEBUG ) ? 'Yes' : 'No';
$wp_data['locale'] = get_locale();
$wp_data['version'] = get_bloginfo( 'version' );
$wp_data['multisite'] = is_multisite() ? 'Yes' : 'No';
$wp_data['theme_slug'] = get_stylesheet();
$theme = wp_get_theme( $wp_data['theme_slug'] );
$wp_data['theme_name'] = $theme->get( 'Name' );
$wp_data['theme_version'] = $theme->get( 'Version' );
$wp_data['theme_uri'] = $theme->get( 'ThemeURI' );
$wp_data['theme_author'] = $theme->get( 'Author' );
return $wp_data;
}
/**
* Get the list of active and inactive plugins
*
* @return array
*/
private function get_all_plugins() {
// Ensure get_plugins function is loaded
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$active_plugins_keys = get_option( 'active_plugins', array() );
$active_plugins = array();
foreach ( $plugins as $k => $v ) {
// Take care of formatting the data how we want it.
$formatted = array();
$formatted['name'] = strip_tags( $v['Name'] );
if ( isset( $v['Version'] ) ) {
$formatted['version'] = strip_tags( $v['Version'] );
}
if ( isset( $v['Author'] ) ) {
$formatted['author'] = strip_tags( $v['Author'] );
}
if ( isset( $v['Network'] ) ) {
$formatted['network'] = strip_tags( $v['Network'] );
}
if ( isset( $v['PluginURI'] ) ) {
$formatted['plugin_uri'] = strip_tags( $v['PluginURI'] );
}
if ( in_array( $k, $active_plugins_keys ) ) {
// Remove active plugins from list so we can show active and inactive separately
unset( $plugins[$k] );
$active_plugins[$k] = $formatted;
} else {
$plugins[$k] = $formatted;
}
}
return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
}
/**
* Get user totals based on user role.
*
* @return array
*/
public function get_user_counts() {
$user_count = array();
$user_count_data = count_users();
$user_count['total'] = $user_count_data['total_users'];
// Get user count based on user role
foreach ( $user_count_data['avail_roles'] as $role => $count ) {
if ( ! $count ) {
continue;
}
$user_count[ $role ] = $count;
}
return $user_count;
}
/**
* Add weekly cron schedule
*
* @param array $schedules
*
* @return array
*/
public function add_weekly_schedule( $schedules ) {
$schedules['weekly'] = array(
'interval' => DAY_IN_SECONDS * 7,
'display' => 'Once Weekly',
);
return $schedules;
}
/**
* Plugin activation hook
*
* @return void
*/
public function activate_plugin() {
$allowed = get_option( $this->client->slug . '_allow_tracking', 'no' );
// if it wasn't allowed before, do nothing
if ( 'yes' !== $allowed ) {
return;
}
// re-schedule and delete the last sent time so we could force send again
$hook_name = $this->client->slug . '_tracker_send_event';
if ( ! wp_next_scheduled( $hook_name ) ) {
wp_schedule_event( time(), 'weekly', $hook_name );
}
delete_option( $this->client->slug . '_tracking_last_send' );
$this->send_tracking_data( true );
}
/**
* Clear our options upon deactivation
*
* @return void
*/
public function deactivation_cleanup() {
$this->clear_schedule_event();
if ( 'theme' == $this->client->type ) {
delete_option( $this->client->slug . '_tracking_last_send' );
delete_option( $this->client->slug . '_allow_tracking' );
}
delete_option( $this->client->slug . '_tracking_notice' );
}
/**
* Hook into action links and modify the deactivate link
*
* @param array $links
*
* @return array
*/
public function plugin_action_links( $links ) {
if ( array_key_exists( 'deactivate', $links ) ) {
$links['deactivate'] = str_replace( '<a', '<a class="' . $this->client->slug . '-deactivate-link"', $links['deactivate'] );
}
return $links;
}
/**
* Plugin uninstall reasons
*
* @return array
*/
private function get_uninstall_reasons() {
$reasons = array(
array(
'id' => 'could-not-understand',
'text' => $this->client->__trans( "I couldn't understand how to make it work" ),
'type' => 'textarea',
'placeholder' => $this->client->__trans( 'Would you like us to assist you?' )
),
array(
'id' => 'found-better-plugin',
'text' => $this->client->__trans( 'I found a better plugin' ),
'type' => 'text',
'placeholder' => $this->client->__trans( 'Which plugin?' )
),
array(
'id' => 'not-have-that-feature',
'text' => $this->client->__trans( "The plugin is great, but I need specific feature that you don't support" ),
'type' => 'textarea',
'placeholder' => $this->client->__trans( 'Could you tell us more about that feature?' )
),
array(
'id' => 'is-not-working',
'text' => $this->client->__trans( 'The plugin is not working' ),
'type' => 'textarea',
'placeholder' => $this->client->__trans( 'Could you tell us a bit more whats not working?' )
),
array(
'id' => 'looking-for-other',
'text' => $this->client->__trans( "It's not what I was looking for" ),
'type' => '',
'placeholder' => ''
),
array(
'id' => 'did-not-work-as-expected',
'text' => $this->client->__trans( "The plugin didn't work as expected" ),
'type' => 'textarea',
'placeholder' => $this->client->__trans( 'What did you expect?' )
),
array(
'id' => 'other',
'text' => $this->client->__trans( 'Other' ),
'type' => 'textarea',
'placeholder' => $this->client->__trans( 'Could you tell us a bit more?' )
),
);
return $reasons;
}
/**
* Plugin deactivation uninstall reason submission
*
* @return void
*/
public function uninstall_reason_submission() {
if ( ! isset( $_POST['reason_id'] ) ) {
wp_send_json_error();
}
$data = $this->get_tracking_data();
$data['reason_id'] = sanitize_text_field( $_POST['reason_id'] );
$data['reason_info'] = isset( $_REQUEST['reason_info'] ) ? trim( stripslashes( $_REQUEST['reason_info'] ) ) : '';
$this->client->send_request( $data, 'deactivate' );
wp_send_json_success();
}
/**
* Handle the plugin deactivation feedback
*
* @return void
*/
public function deactivate_scripts() {
global $pagenow;
if ( 'plugins.php' != $pagenow ) {
return;
}
$reasons = $this->get_uninstall_reasons();
?>
<div class="wd-dr-modal" id="<?php echo $this->client->slug; ?>-wd-dr-modal">
<div class="wd-dr-modal-wrap">
<div class="wd-dr-modal-header">
<h3><?php $this->client->_etrans( 'If you have a moment, please let us know why you are deactivating:' ); ?></h3>
</div>
<div class="wd-dr-modal-body">
<ul class="reasons">
<?php foreach ($reasons as $reason) { ?>
<li data-type="<?php echo esc_attr( $reason['type'] ); ?>" data-placeholder="<?php echo esc_attr( $reason['placeholder'] ); ?>">
<label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label>
</li>
<?php } ?>
</ul>
<p class="wd-dr-modal-reasons-bottom">
<?php
echo sprintf(
$this->client->__trans( 'We share your data with <a href="%1$s" target="_blank">Appsero</a> to troubleshoot problems &amp; make product improvements. <a href="%2$s" target="_blank">Learn more</a> about how Appsero handles your data.'),
esc_url( 'https://appsero.com/' ),
esc_url( 'https://appsero.com/privacy-policy' )
);
?>
</p>
</div>
<div class="wd-dr-modal-footer">
<a href="#" class="dont-bother-me"><?php $this->client->_etrans( "I rather wouldn't say" ); ?></a>
<button class="button-secondary"><?php $this->client->_etrans( 'Submit & Deactivate' ); ?></button>
<button class="button-primary"><?php $this->client->_etrans( 'Cancel' ); ?></button>
</div>
</div>
</div>
<style type="text/css">
.wd-dr-modal {
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.5);
display: none;
}
.wd-dr-modal.modal-active {
display: block;
}
.wd-dr-modal-wrap {
width: 475px;
position: relative;
margin: 10% auto;
background: #fff;
}
.wd-dr-modal-header {
border-bottom: 1px solid #eee;
padding: 8px 20px;
}
.wd-dr-modal-header h3 {
line-height: 150%;
margin: 0;
}
.wd-dr-modal-body {
padding: 5px 20px 20px 20px;
}
.wd-dr-modal-body .reason-input {
margin-top: 5px;
margin-left: 20px;
}
.wd-dr-modal-footer {
border-top: 1px solid #eee;
padding: 12px 20px;
text-align: right;
}
.wd-dr-modal-reasons-bottom {
margin: 15px 0 0 0;
}
</style>
<script type="text/javascript">
(function($) {
$(function() {
var modal = $( '#<?php echo $this->client->slug; ?>-wd-dr-modal' );
var deactivateLink = '';
$( '#the-list' ).on('click', 'a.<?php echo $this->client->slug; ?>-deactivate-link', function(e) {
e.preventDefault();
modal.addClass('modal-active');
deactivateLink = $(this).attr('href');
modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left');
});
modal.on('click', 'button.button-primary', function(e) {
e.preventDefault();
modal.removeClass('modal-active');
});
modal.on('click', 'input[type="radio"]', function () {
var parent = $(this).parents('li:first');
modal.find('.reason-input').remove();
var inputType = parent.data('type'),
inputPlaceholder = parent.data('placeholder'),
reasonInputHtml = '<div class="reason-input">' + ( ( 'text' === inputType ) ? '<input type="text" size="40" />' : '<textarea rows="5" cols="45"></textarea>' ) + '</div>';
if ( inputType !== '' ) {
parent.append( $(reasonInputHtml) );
parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
}
});
modal.on('click', 'button.button-secondary', function(e) {
e.preventDefault();
var button = $(this);
if ( button.hasClass('disabled') ) {
return;
}
var $radio = $( 'input[type="radio"]:checked', modal );
var $selected_reason = $radio.parents('li:first'),
$input = $selected_reason.find('textarea, input[type="text"]');
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: '<?php echo $this->client->slug; ?>_submit-uninstall-reason',
reason_id: ( 0 === $radio.length ) ? 'none' : $radio.val(),
reason_info: ( 0 !== $input.length ) ? $input.val().trim() : ''
},
beforeSend: function() {
button.addClass('disabled');
button.text('Processing...');
},
complete: function() {
window.location.href = deactivateLink;
}
});
});
});
}(jQuery));
</script>
<?php
}
/**
* Run after theme deactivated
* @param string $new_name
* @param object $new_theme
* @param object $old_theme
* @return void
*/
public function theme_deactivated( $new_name, $new_theme, $old_theme ) {
// Make sure this is appsero theme
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/' );
if ( is_wp_error( $response ) ) {
return '';
}
$ip = trim( wp_remote_retrieve_body( $response ) );
if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) {
return '';
}
return $ip;
}
/**
* Get site 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 = esc_url( home_url() );
}
return $site_name;
}
}

705
lib/appsero/src/License.php Executable file
View File

@ -0,0 +1,705 @@
<?php
namespace Appsero;
/**
* Appsero License Checker
*
* This class will check, active and deactive license
*/
class License {
/**
* AppSero\Client
*
* @var object
*/
protected $client;
/**
* Arguments of create menu
*
* @var array
*/
protected $menu_args;
/**
* `option_name` of `wp_options` table
*
* @var string
*/
protected $option_key;
/**
* Error message of HTTP request
*
* @var string
*/
public $error;
/**
* Success message on form submit
*
* @var string
*/
public $success;
/**
* Corn schedule hook name
*
* @var string
*/
protected $schedule_hook;
/**
* Set value for valid licnese
*
* @var boolean
*/
private $is_valid_licnese = null;
/**
* Initialize the class
*
* @param Appsero\Client
*/
public function __construct( Client $client ) {
$this->client = $client;
$this->option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license';
$this->schedule_hook = $this->client->slug . '_license_check_event';
// Run hook to check license status daily
add_action( $this->schedule_hook, array( $this, 'check_license_status' ) );
// Active/Deactive corn schedule
$this->run_schedule();
}
/**
* Check license
*
* @return boolean
*/
public function check( $license_key ) {
$route = 'public/license/' . $this->client->hash . '/check';
return $this->send_request( $license_key, $route );
}
/**
* Active a license
*
* @return boolean
*/
public function activate( $license_key ) {
$route = 'public/license/' . $this->client->hash . '/activate';
return $this->send_request( $license_key, $route );
}
/**
* Deactivate a license
*
* @return boolean
*/
public function deactivate( $license_key ) {
$route = 'public/license/' . $this->client->hash . '/deactivate';
return $this->send_request( $license_key, $route );
}
/**
* Send common request
*
* @param $license_key
* @param $route
*
* @return array
*/
protected function send_request( $license_key, $route ) {
$params = array(
'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(
'success' => false,
'error' => $response->get_error_message()
);
}
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( empty( $response ) || isset( $response['exception'] )) {
return array(
'success' => false,
'error' => 'Unknown error occurred, Please try again.'
);
}
if ( isset( $response['errors'] ) && isset( $response['errors']['license_key'] ) ) {
$response = array(
'success' => false,
'error' => $response['errors']['license_key'][0]
);
}
return $response;
}
/**
* Add settings page for license
*
* @param array $args
*
* @return void
*/
public function add_settings_page( $args = array() ) {
$defaults = array(
'type' => 'menu', // Can be: menu, options, submenu
'page_title' => 'Manage License',
'menu_title' => 'Manage License',
'capability' => 'manage_options',
'menu_slug' => $this->client->slug . '-manage-license',
'icon_url' => '',
'position' => null,
'parent_slug' => '',
);
$this->menu_args = wp_parse_args( $args, $defaults );
add_action( 'admin_menu', array( $this, 'admin_menu' ), 99 );
}
/**
* Admin Menu hook
*
* @return void
*/
public function admin_menu() {
switch ( $this->menu_args['type'] ) {
case 'menu':
$this->create_menu_page();
break;
case 'submenu':
$this->create_submenu_page();
break;
case 'options':
$this->create_options_page();
break;
}
}
/**
* License menu output
*/
public function menu_output() {
if ( isset( $_POST['submit'] ) ) {
$this->license_form_submit( $_POST );
}
$license = get_option( $this->option_key, null );
$action = ( $license && isset( $license['status'] ) && 'activate' == $license['status'] ) ? 'deactive' : 'active';
$this->licenses_style();
?>
<div class="wrap appsero-license-settings-wrapper">
<h1>License Settings</h1>
<?php
$this->show_license_page_notices();
do_action( 'before_appsero_license_section' );
?>
<div class="appsero-license-settings appsero-license-section">
<?php $this->show_license_page_card_header(); ?>
<div class="appsero-license-details">
<p>Activate <strong><?php echo $this->client->name; ?></strong> by your license key to get professional support and automatic update from your WordPress dashboard.</p>
<form method="post" action="<?php $this->formActionUrl(); ?>" 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">
<div class="license-input-key">
<svg enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path d="m463.75 48.251c-64.336-64.336-169.01-64.335-233.35 1e-3 -43.945 43.945-59.209 108.71-40.181 167.46l-185.82 185.82c-2.813 2.813-4.395 6.621-4.395 10.606v84.858c0 8.291 6.709 15 15 15h84.858c3.984 0 7.793-1.582 10.605-4.395l21.211-21.226c3.237-3.237 4.819-7.778 4.292-12.334l-2.637-22.793 31.582-2.974c7.178-0.674 12.847-6.343 13.521-13.521l2.974-31.582 22.793 2.651c4.233 0.571 8.496-0.85 11.704-3.691 3.193-2.856 5.024-6.929 5.024-11.206v-27.929h27.422c3.984 0 7.793-1.582 10.605-4.395l38.467-37.958c58.74 19.043 122.38 4.929 166.33-39.046 64.336-64.335 64.336-169.01 0-233.35zm-42.435 106.07c-17.549 17.549-46.084 17.549-63.633 0s-17.549-46.084 0-63.633 46.084-17.549 63.633 0 17.548 46.084 0 63.633z"/>
</svg>
<input type="text" value="<?php echo $this->get_input_license_value( $action, $license ); ?>"
placeholder="Enter your license key to activate" name="license_key"
<?php echo ( 'deactive' == $action ) ? 'readonly="readonly"' : ''; ?>
/>
</div>
<button type="submit" name="submit" class="<?php echo 'deactive' == $action ? 'deactive-button' : ''; ?>">
<?php echo $action == 'active' ? 'Activate License' : 'Deactivate License' ; ?>
</button>
</div>
</form>
<?php
if ( 'deactive' == $action && isset( $license['remaining'] ) ) {
$this->show_active_license_info( $license );
}
?>
</div>
</div> <!-- /.appsero-license-settings -->
<?php do_action( 'after_appsero_license_section' ); ?>
</div>
<?php
}
/**
* License form submit
*/
public function license_form_submit( $form ) {
if ( ! isset( $form['_nonce'], $form['_action'] ) ) {
$this->error = "Please add all information";
return;
}
if ( ! wp_verify_nonce( $form['_nonce'], $this->client->name ) ) {
$this->error = "You don't have permission to manage license.";
return;
}
switch ( $form['_action'] ) {
case 'active':
$this->active_client_license( $form );
break;
case 'deactive':
$this->deactive_client_license( $form );
break;
}
}
/**
* Check license status on schedule
*/
public function check_license_status() {
$license = get_option( $this->option_key, null );
if ( isset( $license['key'] ) && ! empty( $license['key'] ) ) {
$response = $this->check( $license['key'] );
if ( isset( $response['success'] ) && $response['success'] ) {
$license['status'] = 'activate';
$license['remaining'] = $response['remaining'];
$license['activation_limit'] = $response['activation_limit'];
$license['expiry_days'] = $response['expiry_days'];
$license['title'] = $response['title'];
$license['source_id'] = $response['source_identifier'];
$license['recurring'] = $response['recurring'];
} else {
$license['status'] = 'deactivate';
$license['expiry_days'] = 0;
}
update_option( $this->option_key, $license, false );
}
}
/**
* Check this is a valid license
*/
public function is_valid() {
if ( null !== $this->is_valid_licnese ) {
return $this->is_valid_licnese;
}
$license = get_option( $this->option_key, null );
if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] == 'activate' ) {
$this->is_valid_licnese = true;
} else {
$this->is_valid_licnese = false;
}
return $this->is_valid_licnese;
}
/**
* Check this is a valid license
*/
public function is_valid_by( $option, $value ) {
$license = get_option( $this->option_key, null );
if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] == 'activate' ) {
if ( isset( $license[ $option ] ) && $license[ $option ] == $value ) {
return true;
}
}
return false;
}
/**
* Styles for licenses page
*/
private function licenses_style() {
?>
<style type="text/css">
.appsero-license-section {
width: 100%;
max-width: 1100px;
min-height: 1px;
box-sizing: border-box;
}
.appsero-license-settings {
background-color: #fff;
box-shadow: 0px 3px 10px rgba(16, 16, 16, 0.05);
}
.appsero-license-settings * {
box-sizing: border-box;
}
.appsero-license-title {
background-color: #F8FAFB;
border-bottom: 2px solid #EAEAEA;
display: flex;
align-items: center;
padding: 10px 20px;
}
.appsero-license-title svg {
width: 30px;
height: 30px;
fill: #0082BF;
}
.appsero-license-title span {
font-size: 17px;
color: #444444;
margin-left: 10px;
}
.appsero-license-details {
padding: 20px;
}
.appsero-license-details p {
font-size: 15px;
margin: 0 0 20px 0;
}
.license-input-key {
position: relative;
flex: 0 0 72%;
max-width: 72%;
}
.license-input-key input {
background-color: #F9F9F9;
padding: 10px 15px 10px 48px;
border: 1px solid #E8E5E5;
border-radius: 3px;
height: 45px;
font-size: 16px;
color: #71777D;
width: 100%;
box-shadow: 0 0 0 transparent;
}
.license-input-key input:focus {
outline: 0 none;
border: 1px solid #E8E5E5;
box-shadow: 0 0 0 transparent;
}
.license-input-key svg {
width: 22px;
height: 22px;
fill: #0082BF;
position: absolute;
left: 14px;
top: 13px;
}
.license-input-fields {
display: flex;
justify-content: space-between;
margin-bottom: 30px;
max-width: 850px;
width: 100%;
}
.license-input-fields button {
color: #fff;
font-size: 17px;
padding: 8px;
height: 46px;
background-color: #0082BF;
border-radius: 3px;
cursor: pointer;
flex: 0 0 25%;
max-width: 25%;
border: 1px solid #0082BF;
}
.license-input-fields button.deactive-button {
background-color: #E40055;
border-color: #E40055;
}
.license-input-fields button:focus {
outline: 0 none;
}
.active-license-info {
display: flex;
}
.single-license-info {
min-width: 220px;
flex: 0 0 30%;
}
.single-license-info h3 {
font-size: 18px;
margin: 0 0 12px 0;
}
.single-license-info p {
margin: 0;
color: #00C000;
}
.single-license-info p.occupied {
color: #E40055;
}
</style>
<?php
}
/**
* Show active license information
*/
private function show_active_license_info( $license ) {
?>
<div class="active-license-info">
<div class="single-license-info">
<h3>Activation Remaining</h3>
<?php if ( empty( $license['activation_limit'] ) ): ?>
<p>Unlimited</p>
<?php else: ?>
<p class="<?php echo $license['remaining'] ? '' : 'occupied'; ?>">
<?php echo $license['remaining']; ?> out of <?php echo $license['activation_limit']; ?>
</p>
<?php endif; ?>
</div>
<div class="single-license-info">
<h3>Expires in</h3>
<?php
if ( $license['recurring'] && false !== $license['expiry_days'] ) {
$occupied = $license['expiry_days'] > 10 ? '' : 'occupied';
echo '<p class="' . $occupied . '">' . $license['expiry_days'] . ' days</p>';
} else {
echo '<p>Never</p>';
}
?>
</div>
</div>
<?php
}
/**
* Show license settings page notices
*/
private function show_license_page_notices() {
if ( ! empty( $this->error ) ) :
?>
<div class="notice notice-error is-dismissible appsero-license-section">
<p><?php echo $this->error; ?></p>
</div>
<?php
endif;
if ( ! empty( $this->success ) ) :
?>
<div class="notice notice-success is-dismissible appsero-license-section">
<p><?php echo $this->success; ?></p>
</div>
<?php
endif;
echo '<br />';
}
/**
* Card header
*/
private function show_license_page_card_header() {
?>
<div class="appsero-license-title">
<svg enable-background="new 0 0 299.995 299.995" version="1.1" viewBox="0 0 300 300" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path d="m150 161.48c-8.613 0-15.598 6.982-15.598 15.598 0 5.776 3.149 10.807 7.817 13.505v17.341h15.562v-17.341c4.668-2.697 7.817-7.729 7.817-13.505 0-8.616-6.984-15.598-15.598-15.598z"/>
<path d="m150 85.849c-13.111 0-23.775 10.665-23.775 23.775v25.319h47.548v-25.319c-1e-3 -13.108-10.665-23.775-23.773-23.775z"/>
<path d="m150 1e-3c-82.839 0-150 67.158-150 150 0 82.837 67.156 150 150 150s150-67.161 150-150c0-82.839-67.161-150-150-150zm46.09 227.12h-92.173c-9.734 0-17.626-7.892-17.626-17.629v-56.919c0-8.491 6.007-15.582 14.003-17.25v-25.697c0-27.409 22.3-49.711 49.711-49.711 27.409 0 49.709 22.3 49.709 49.711v25.697c7.993 1.673 14 8.759 14 17.25v56.919h2e-3c0 9.736-7.892 17.629-17.626 17.629z"/>
</svg>
<span>Activate License</span>
</div>
<?php
}
/**
* Active client license
*/
private function active_client_license( $form ) {
if ( empty( $form['license_key'] ) ) {
$this->error = 'The license key field is required.';
return;
}
$license_key = sanitize_text_field( $form['license_key'] );
$response = $this->activate( $license_key );
if ( ! $response['success'] ) {
$this->error = $response['error'] ? $response['error'] : 'Unknown error occurred.';
return;
}
$data = array(
'key' => $license_key,
'status' => 'activate',
'remaining' => $response['remaining'],
'activation_limit' => $response['activation_limit'],
'expiry_days' => $response['expiry_days'],
'title' => $response['title'],
'source_id' => $response['source_identifier'],
'recurring' => $response['recurring'],
);
update_option( $this->option_key, $data, false );
$this->success = 'License activated successfully.';
}
/**
* Deactive client license
*/
private function deactive_client_license( $form ) {
$license = get_option( $this->option_key, null );
if ( empty( $license['key'] ) ) {
$this->error = 'License key not found.';
return;
}
$response = $this->deactivate( $license['key'] );
$data = array(
'key' => '',
'status' => 'deactivate',
);
update_option( $this->option_key, $data, false );
if ( ! $response['success'] ) {
$this->error = $response['error'] ? $response['error'] : 'Unknown error occurred.';
return;
}
$this->success = 'License deactivated successfully.';
}
/**
* Add license menu page
*/
private function create_menu_page() {
call_user_func(
'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_args['icon_url'],
$this->menu_args['position']
);
}
/**
* Add submenu page
*/
private function create_submenu_page() {
call_user_func(
'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_args['position']
);
}
/**
* Add submenu page
*/
private function create_options_page() {
call_user_func(
'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_args['position']
);
}
/**
* Schedule daily sicense checker event
*/
public function schedule_cron_event() {
if ( ! wp_next_scheduled( $this->schedule_hook ) ) {
wp_schedule_event( time(), 'daily', $this->schedule_hook );
wp_schedule_single_event( time() + 20, $this->schedule_hook );
}
}
/**
* Clear any scheduled hook
*/
public function clear_scheduler() {
wp_clear_scheduled_hook( $this->schedule_hook );
}
/**
* Enable/Disable schedule
*/
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' ) );
break;
case 'theme':
add_action( 'after_switch_theme', array( $this, 'schedule_cron_event' ) );
add_action( 'switch_theme', array( $this, 'clear_scheduler' ) );
break;
}
}
/**
* Form action URL
*/
private function formActionUrl() {
echo add_query_arg(
array( 'page' => $_GET['page'] ),
admin_url( basename( $_SERVER['SCRIPT_NAME'] ) )
);
}
/**
* Get input license key
* @param $action
* @return $license
*/
private function get_input_license_value( $action, $license ) {
if ( 'active' == $action ) {
return isset( $license['key'] ) ? $license['key'] : '';
}
if ( 'deactive' == $action ) {
$key_length = strlen( $license['key'] );
return str_pad(
substr( $license['key'], 0, $key_length / 2 ), $key_length, '*'
);
}
return '';
}
}

247
lib/appsero/src/Updater.php Executable file
View File

@ -0,0 +1,247 @@
<?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_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->get_project_latest_version();
$this->set_cached_version_info( $version_info );
}
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) {
unset( $version_info->sections );
$transient_data->response[ $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() {
$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_option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license';
$license = get_option( $license_option_key, null );
$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;
}
$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;
}
/**
* 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_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->get_project_latest_version();
$this->set_cached_version_info( $version_info );
}
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) {
$transient_data->response[ $this->client->slug ] = (array) $version_info;
}
$transient_data->last_checked = time();
$transient_data->checked[ $this->client->slug ] = $this->client->project_version;
}
return $transient_data;
}
}

View File

@ -272,6 +272,14 @@ https://www.youtube.com/watch?v=F9wnlUjXa6I
[Woocommerce Events Manager](https://wordpress.org/plugins/mage-eventpress/)
## Privacy Policy
WooCommerce Event Manager uses [Appsero](https://appsero.com) SDK to collect some telemetry data upon user's confirmation. This helps us to troubleshoot problems faster & make product improvements.
Appsero SDK **does not gather any data by default.** The SDK only starts gathering basic telemetry data **when a user allows it via the admin notice**. We collect the data to ensure a great user experience for all our users.
Integrating Appsero SDK **DOES NOT IMMEDIATELY** start gathering data, **without confirmation from users in any case.**
Learn more about how [Appsero collects and uses this data](https://appsero.com/privacy-policy/).
== Installation ==
@ -568,4 +576,12 @@ New Hooks added
Event Label & Slug change settings added
PHP Warning in cart page issue fixed
More...
12 July 2020*
12 July 2020*
= 3.3.1 =
* Update Release:
Code Optimized & Improved
Location Typo fixed in event list
Event Confirmation email sending based on order status settings added
20 July 2020*

10
templates/all-speaker-list.php Executable file
View File

@ -0,0 +1,10 @@
<li>
<a href='<?php echo get_the_permalink($speakers); ?>'><?php if (has_post_thumbnail($speakers)) {
echo get_the_post_thumbnail($speakers, 'medium');
} else {
echo '<img src="' . plugins_url('../images/no-photo.jpg', __DIR__) . '"/>';
} ?>
<h6><?php echo get_the_title($speakers); ?></h6>
</a>
</li>

View File

@ -95,6 +95,7 @@
</li>
<?php }
} ?>
</ul>
</a>
<?php do_action('mep_event_list_loop_footer', $event_id); ?>

View File

@ -12,6 +12,41 @@ the_post();
<div class="mep_speaker_details">
<?php the_content(); ?>
</div>
<div class='mep_event_list'>
<div class="mep_cat-details">
<h3><?php _e('All Event Of ','mage-eventpress'); the_title(); ?></h3>
</div>
<div class='mage_grid_box'>
<?php
$paged = get_query_var("paged") ? get_query_var("paged") : 1;
$args = array(
'post_type' => array('mep_events'),
'paged' => $paged,
// 'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'event_start_datetime',
'meta_query' => array(
array(
'key' => 'mep_event_speakers_list',
'value' => get_the_id(),
'compare' => 'LIKE'
)
)
);
$loop = new WP_Query($args);
// $loop = mep_event_query(20, 'ASC', $term_id, '', '', '', 'upcoming');
while ($loop->have_posts()) {
$loop->the_post();
do_action('mep_event_list_shortcode', get_the_id(), 'three_column', 'grid');
}
wp_reset_postdata();
mep_event_pagination($loop->max_num_pages);
?>
</div>
</div>
</div>
<?php
get_footer();

View File

@ -42,7 +42,7 @@ $speaker_status = mep_get_option('mep_enable_speaker_list', 'general
<?php echo mep_get_option('mep_event_location_text', 'label_setting_sec') ? mep_get_option('mep_event_location_text', 'label_setting_sec') : _e('Event Location:', 'mage-eventpress'); ?>
</h3>
<p><?php do_action('mep_event_location_venue'); ?>
, <?php do_action('mep_event_location_city'); ?> </p>
, <?php do_action('mep_event_location_city'); ?> </p>
</div>
</div>
<?php } ?>

View File

@ -3,7 +3,7 @@
* Plugin Name: Woocommerce Events Manager
* Plugin URI: http://mage-people.com
* Description: A Complete Event Solution for WordPress by MagePeople..
* Version: 3.3.0
* Version: 3.3.1
* Author: MagePeople Team
* Author URI: http://www.mage-people.com/
* Text Domain: mage-eventpress
@ -18,6 +18,13 @@ if (!defined('ABSPATH')) {
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
if (is_plugin_active('woocommerce/woocommerce.php')) {
function appsero_init_tracker_mage_eventpress() {
if ( ! class_exists( 'Appsero\Client' ) ) {
require_once __DIR__ . '/lib/appsero/src/Client.php';
}
$client = new Appsero\Client( '08cd627c-4ed9-49cf-a9b5-1536ec384a5a', 'WooCommerce Event Manager', __FILE__ );
$client->insights()->init();
}
require_once(dirname(__FILE__) . "/inc/mep_file_include.php");
} else {
function mep_admin_notice_wc_not_active()
@ -29,4 +36,4 @@ if (is_plugin_active('woocommerce/woocommerce.php')) {
);
}
add_action('admin_notices', 'mep_admin_notice_wc_not_active');
}
}