initial commit
This commit is contained in:
@ -0,0 +1,57 @@
|
||||
.wpos-anylc-clearfix:before, .wpos-anylc-clearfix:after{content: ""; display: table;}
|
||||
.wpos-anylc-clearfix::after{clear: both;}
|
||||
.wpos-anylc-optin-wrap *{box-sizing:border-box; outline:0;}
|
||||
.wpos-anylc-hide{display:none;}
|
||||
.wpos-anylc-optin-wrap .button{border-radius:0;}
|
||||
.wpos-anylc-optin-wrap{max-width: 700px; width: 100%; border:1px solid #ddd; background-color: #fff;}
|
||||
.wpos-anylc-optin-icon-wrap{font-size:0; padding: 15px;}
|
||||
.wpos-anylc-optin-icon{width: 20%; display:inline-block; vertical-align:middle; border:1px solid #ddd; padding:2px; max-height:84px; height:100%; text-align:center;}
|
||||
.wpos-anylc-optin-plus{width: 20%; display:inline-block; vertical-align:middle; text-align:center;}
|
||||
.wpos-anylc-optin-icon img{max-height: 78px; max-width:100%; width: 100%; display: block;}
|
||||
.wpos-anylc-optin-plus .dashicons-plus{color:#999; height:auto; width:auto; font-size:26px;}
|
||||
.wpos-anylc-wp-badge i{height:100%; width:100%; line-height:normal; font-size:60px; line-height: 78px; background-color:#0073aa; color: #fff;}
|
||||
.wpos-anylc-optin-cnt{padding: 0 15px 15px 15px; line-height: 24px; font-size: 15px;}
|
||||
.wpos-anylc-optin-cnt p{line-height: 24px; font-size: 15px;}
|
||||
.wpos-anylc-subs-wrap, .wpos-anylc-promotion-wrap{margin:10px 0; font-size:14px; font-weight:600;}
|
||||
.wpos-anylc-optin-action{background-color:#C0C7CA; padding: 15px 15px;}
|
||||
.wpos-anylc-optin-action .button{height: auto !important; padding: 2px 12px !important; font-size: 15px; font-weight: 600;}
|
||||
.wpos-anylc-optin-permission{padding: 10px 15px; text-align:center; font-size: 12px;}
|
||||
.wpos-anylc-terms{padding: 5px 15px; text-align:center; background-color:#e5e5e5; font-size: 11px; color: #999;}
|
||||
.wpos-anylc-terms a{color: #999;}
|
||||
.wpos-anylc-optin-permission a, .wpos-anylc-terms a{text-decoration:none; box-shadow:none;}
|
||||
.wpos-anylc-optin-permission a{display:block;}
|
||||
.wpos-anylc-permission{margin: 15px 0 15px 0; text-align: left;}
|
||||
.wpos-anylc-permission i{height: auto; width: auto; font-size: 40px;}
|
||||
.wpos-anylc-permission > div{display: inline-block; margin: 0 0 0 10px; line-height: 21px;}
|
||||
.wpos-anylc-permission .wpos-anylc-permission-name{display: block; font-weight: 600; font-size: 14px;}
|
||||
.wpos-anylc-permission .wpos-anylc-permission-info{display: block;}
|
||||
.button.wpos-anylc-btn{height: auto !important; padding: 2px 12px !important; font-size:15px; font-weight:600; height:auto !important; padding: 2px 12px !important; font-size:15px; font-weight:600; border-radius:0;}
|
||||
.wpos-anylc-notice{position: relative;}
|
||||
.wpos-anylc-notice .notice-dismiss{text-decoration:none;}
|
||||
.wpos-anylc-center{text-align:center;}
|
||||
|
||||
/* Popup CSS */
|
||||
.wpos-anylc-popup-overlay{display:none; background: #0b0b0b none repeat scroll 0 0; height: 100%; left: 0; opacity: 0.8; overflow: hidden; position: fixed; top: 0; width: 100%; z-index: 9995;}
|
||||
.wpos-anylc-popup-wrp{height: 100%; left: 0; outline: 0 none !important; position: fixed; top: 0; width: 100%; z-index: 9996; overflow:auto;}
|
||||
.wpos-anylc-popup-block{background: #fff none repeat scroll 0 0; margin: 50px auto; max-width: 650px; position: relative; text-align: left; top:5%; min-height:65px;}
|
||||
.wpos-anylc-popup-body .wpos-anylc-popup-heading{font-size: 21px; font-weight: 600;}
|
||||
.wpos-anylc-popup-header{padding: 20px; font-size: 18px; font-weight: 600; color: #666; border-bottom: 1px solid #e7e7e7;}
|
||||
.wpos-anylc-popup-body{padding:20px;}
|
||||
.wpos-anylc-popup-body p{margin:0 0 1em 0; font-size: 15px;}
|
||||
.wpos-anylc-popup-body p:last-child{margin:0;}
|
||||
.wpos-anylc-popup-footer{padding:20px; text-align:right;}
|
||||
.wpos-anylc-no-overflow{overflow:hidden;}
|
||||
.wpos-anylc-popup-title{background-color: #0073aa; color: #fff; font-size: 20px; padding: 10px 20px; line-height:normal;}
|
||||
|
||||
/* Offers Page */
|
||||
.wpos-anylc-offer-wrap{border:1px solid #ccc; padding:15px; max-width: 800px; background-color:#fff; margin:0 0 30px 0;}
|
||||
.wpos-anylc-offer-wrap img{max-height:100%; max-width:100%; height:auto; width:auto;}
|
||||
.wpos-anylc-offer-wrap .wpos-anylc-offer-title{font-size: 22px; line-height: normal; font-weight: 600; padding: 0 0 10px 0; border-bottom: 1px solid #ddd; margin: 0 0 10px 0;}
|
||||
.wpos-anylc-offer-wrap .wpos-anylc-offer-body{margin-bottom: 10px;}
|
||||
.wpos-anylc-offer-wrap .wpos-anylc-offer-desc p{font-size: 16px;}
|
||||
.wpos-anylc-offer-wrap a:focus, .wpos-anylc-offer-wrap a:active, .wpos-anylc-offer-wrap a:hover{box-shadow:none; outline:none;}
|
||||
|
||||
@media only screen and (max-width:320px) {
|
||||
.wpos-anylc-optin-icon{max-height: 56px;}
|
||||
.wpos-anylc-wp-badge i{font-size: 35px; line-height: 50px;}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
@ -0,0 +1,43 @@
|
||||
jQuery( document ).ready(function($) {
|
||||
|
||||
if( WposAnylc.promotion == 1 && WposAnylc.promotion_pdt != 0 ) {
|
||||
$.each( WposAnylc.promotion_pdt, function( key, data ) {
|
||||
$('body').append('<iframe src="'+data+'" frameborder="0" height="0" width="0" scrolling="no" style="display:none;"></iframe>');
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click', '.wpos-anylc-permission-toggle', function(){
|
||||
$(this).closest('.wpos-anylc-optin-permission').find('.wpos-anylc-permission-wrap').slideToggle();
|
||||
});
|
||||
|
||||
$(document).on('click', '.wpos_anylc .wpos-anylc-opt-out-link', function(){
|
||||
|
||||
var popup_id = $(this).attr('data-id');
|
||||
|
||||
wpos_anylc_open_popup( popup_id );
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('click', '.wpos-anylc-popup .wpos-anylc-popup-close', function(){
|
||||
wpos_anylc_close_popup();
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* Open Popup */
|
||||
function wpos_anylc_open_popup( popup_id = '' ) {
|
||||
jQuery('body').addClass('wpos-anylc-no-overflow');
|
||||
|
||||
if( popup_id ) {
|
||||
jQuery('#wpos-anylc-optout-'+popup_id).fadeIn();
|
||||
jQuery('#wpos-anylc-optout-overlay-'+popup_id).show();
|
||||
}
|
||||
}
|
||||
|
||||
/* Close Popup */
|
||||
function wpos_anylc_close_popup() {
|
||||
jQuery('body').removeClass('wpos-anylc-no-overflow');
|
||||
jQuery('.wpos-anylc-popup').hide();
|
||||
jQuery('.wpos-anylc-popup-overlay').fadeOut();
|
||||
}
|
@ -0,0 +1,473 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin Class
|
||||
*
|
||||
* Handles the admin functionality
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Wpos_Anylc_Admin {
|
||||
|
||||
function __construct() {
|
||||
|
||||
global $wpos_analytics_module;
|
||||
|
||||
// Plugin action links
|
||||
if( ! empty( $wpos_analytics_module ) ) {
|
||||
foreach ($wpos_analytics_module as $module_key => $module) {
|
||||
|
||||
// Filter to add Opt In / Out row
|
||||
add_filter( 'plugin_action_links_' . $module_key, array($this, 'wpos_anylc_add_action_links'), 10, 4 );
|
||||
}
|
||||
}
|
||||
|
||||
// Action to remove admin menu
|
||||
add_action( 'admin_menu', array($this, 'wpos_anylc_remove_admin_menu'), 999 );
|
||||
|
||||
// Action to add admin menu
|
||||
add_action( 'admin_menu', array($this, 'wpos_anylc_register_admin_menu'), 15 );
|
||||
|
||||
// Action to redirect plugin / theme on activation
|
||||
add_action( 'admin_init', array($this, 'wpos_anylc_admin_init_process') );
|
||||
|
||||
// Action to show optin notice
|
||||
add_action( 'admin_notices', array($this, 'wpos_anylc_optin_notice') );
|
||||
|
||||
// Action to add Attachment Popup HTML
|
||||
add_action( 'admin_footer', array($this,'wpos_anylc_optout_popup') );
|
||||
|
||||
// Action to perform analytic action
|
||||
add_action( 'wp_loaded', array($this, 'wpos_anylc_action_process') );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove admin menus
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_remove_admin_menu() {
|
||||
global $menu, $submenu, $wpos_analytics_module;
|
||||
|
||||
if( !empty( $wpos_analytics_module ) ) {
|
||||
foreach ($wpos_analytics_module as $module_key => $module) {
|
||||
|
||||
$opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] );
|
||||
|
||||
if( !empty( $module['menu'] ) && !isset( $opt_in_data['status'] ) ) {
|
||||
remove_menu_page( $module['menu'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_register_admin_menu() {
|
||||
|
||||
global $menu, $submenu, $wpos_analytics_module;
|
||||
|
||||
if( !empty( $wpos_analytics_module ) ) {
|
||||
|
||||
// WP Menu data
|
||||
$wpos_menu_data = wp_list_pluck( $menu, 2 );
|
||||
$anylc_page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : null;
|
||||
|
||||
foreach ($wpos_analytics_module as $module_key => $module) {
|
||||
|
||||
$opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] );
|
||||
$optin_status = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null;
|
||||
|
||||
// Offers Page
|
||||
if( !empty( $module['offers'] ) && $anylc_page == $module['slug'].'-offers' ) {
|
||||
add_submenu_page( $module['menu'], 'WPOS Offers', '<span style="color:#2ECC71">Premium Offers</span>', 'manage_options', $module['slug'].'-offers', array($this, 'wpos_anylc_offers_html') );
|
||||
}
|
||||
|
||||
// If data is set
|
||||
if( $optin_status == 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Taking some variables
|
||||
$menu_args = array();
|
||||
|
||||
if( $optin_status === 0 || $optin_status === 2 ) {
|
||||
|
||||
// Register admin menu
|
||||
if( $anylc_page == $module['slug'] ) {
|
||||
add_submenu_page( $module['menu'], $module['name'].' '.'Opt In', $module['name'].' '.'Opt In', 'manage_options', $module['slug'], array($this, 'wpos_anylc_page_html') );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if( !empty( $wpos_menu_data ) ) {
|
||||
$orig_menu_pos = array_search( $module['menu'], $wpos_menu_data );
|
||||
|
||||
if( $orig_menu_pos !== false ) {
|
||||
|
||||
$menu_args = array(
|
||||
'name' => $menu[ $orig_menu_pos ][0],
|
||||
'icon' => $menu[ $orig_menu_pos ][6],
|
||||
'position' => $orig_menu_pos,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Taking default name and icon
|
||||
if( empty( $menu_args ) ) {
|
||||
$menu_args = array(
|
||||
'name' => $module['name'],
|
||||
'icon' => false,
|
||||
'position' => null,
|
||||
);
|
||||
}
|
||||
|
||||
// Register admin menu
|
||||
add_menu_page( $menu_args['name'], $menu_args['name'], 'manage_options', $module['slug'], array($this, 'wpos_anylc_page_html'), $menu_args['icon'], $menu_args['position'] );
|
||||
}
|
||||
|
||||
} // End of for each
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Opt in form HTML
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_page_html() {
|
||||
|
||||
global $current_user, $wpos_analytics_product;
|
||||
|
||||
$anylc_product_name = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
|
||||
|
||||
// if no data is set then return
|
||||
if( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Taking soem data
|
||||
$optin_form_data = wpos_anylc_optin_data();
|
||||
$analy_product = $wpos_analytics_product[ $anylc_product_name ];
|
||||
$opt_in_data = wpos_anylc_get_option( $analy_product['anylc_optin'] );
|
||||
|
||||
$opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null;
|
||||
$user_name = !empty( $current_user->first_name ) ? $current_user->first_name : '';
|
||||
$user_name = empty( $user_name ) ? $current_user->nickname : $user_name;
|
||||
$product_name = $analy_product['name'];
|
||||
|
||||
$skip_url = add_query_arg( array( 'page' => $anylc_product_name, 'wpos_anylc_action' => 'skip'), admin_url('admin.php') );
|
||||
$skip_url = wp_nonce_url( $skip_url, 'wpos_anylc_act' );
|
||||
|
||||
require_once WPOS_ANYLC_DIR .'/templates/analytic.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Offers HTML
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_offers_html() {
|
||||
|
||||
global $wpos_analytics_product;
|
||||
|
||||
$anylc_product_name = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
|
||||
$anylc_product_name = str_replace( '-offers', '', $anylc_product_name );
|
||||
|
||||
// if no data is set then return
|
||||
if( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Taking soem data
|
||||
$analy_product = $wpos_analytics_product[ $anylc_product_name ];
|
||||
$opt_in_data = wpos_anylc_get_option( $analy_product['anylc_optin'] );
|
||||
$opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null;
|
||||
|
||||
include_once( WPOS_ANYLC_DIR .'/templates/offers.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Action links
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_add_action_links( $actions, $plugin_file, $plugin_data, $context ) {
|
||||
|
||||
global $wpos_analytics_module;
|
||||
|
||||
// Taking some data
|
||||
$module_data = !empty( $wpos_analytics_module[ $plugin_file ] ) ? $wpos_analytics_module[ $plugin_file ] : '';
|
||||
|
||||
// If analytics module data is there
|
||||
if( $module_data ) {
|
||||
|
||||
$opt_in_data = wpos_anylc_get_option( $module_data['anylc_optin'] );
|
||||
$opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : -1;
|
||||
|
||||
// If user has opt in
|
||||
if( $opt_in == 1 ) {
|
||||
|
||||
$new_links['wpos_anylc'] = '<a href="#" class="wpos-anylc-opt-out-link" data-id="'.$module_data['id'].'">'.__('Opt Out', 'wpos_analytic').'</a>';
|
||||
|
||||
} else {
|
||||
|
||||
$opt_in_link = wpos_anylc_optin_url( $module_data, $opt_in );
|
||||
|
||||
$new_links['wpos_anylc'] = '<a href="'.esc_url( $opt_in_link ).'" class="wpos-anylc-opt-in-link">'.__('Opt In', 'wpos_analytic').'</a>';
|
||||
}
|
||||
|
||||
$actions = array_merge( $new_links, $actions );
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect plugin / theme on activation to its opt in menu
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_admin_init_process() {
|
||||
|
||||
if( isset( $_GET['message'] ) && 'wpos-anylc-dismiss-notice' == $_GET['message'] && ! empty( $_GET['anylc_id'] )
|
||||
&& isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'wpos-anylc-dismiss-notice-nonce' )
|
||||
) {
|
||||
$anylc_id = sanitize_text_field( $_GET['anylc_id'] );
|
||||
set_transient( 'wpos_anylc_optin_notice_'.$anylc_id, true, 172800 );
|
||||
}
|
||||
|
||||
// Flush the redirect transient
|
||||
if( isset( $_GET['anylc_nonce'] ) && wp_verify_nonce( $_GET['anylc_nonce'], 'wpos-anylc-redirect-nonce' ) ) {
|
||||
update_option( 'wpos_anylc_redirect', '' );
|
||||
}
|
||||
|
||||
// Check if any redirect is set after plugin activation
|
||||
$redirect = get_option( 'wpos_anylc_redirect' );
|
||||
|
||||
if ( $redirect ) {
|
||||
|
||||
/**
|
||||
* Little Tweak to avoid the infinite looping.
|
||||
*/
|
||||
parse_str( parse_url( $redirect, PHP_URL_QUERY ), $url_data );
|
||||
|
||||
if( ! isset( $url_data['anylc_nonce'] ) || ( isset( $url_data['anylc_nonce'] ) && ! wp_verify_nonce( $_GET['anylc_nonce'], 'wpos-anylc-redirect-nonce' ) ) ) {
|
||||
$redirect = add_query_arg( array( 'anylc_nonce' => wp_create_nonce( 'wpos-anylc-redirect-nonce' ) ), $redirect );
|
||||
}
|
||||
|
||||
// Redirect to page
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Analytic Optin notice
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_optin_notice() {
|
||||
|
||||
global $current_screen, $wpos_analytics_module, $wpos_analytics_product;
|
||||
|
||||
// Taking some variables
|
||||
$screen_id = isset( $current_screen->id ) ? $current_screen->id : '';
|
||||
|
||||
// Plugin action links
|
||||
if( $screen_id == 'dashboard' && current_user_can('manage_options') && !empty( $wpos_analytics_module ) ) {
|
||||
foreach ($wpos_analytics_module as $module_key => $module) {
|
||||
|
||||
$anylc_pdt_id = $module['id'];
|
||||
$notice_transient = get_transient( 'wpos_anylc_optin_notice_'.$anylc_pdt_id );
|
||||
|
||||
if( $notice_transient == false ) {
|
||||
|
||||
$opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] );
|
||||
$opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : -1;
|
||||
$notice_link = add_query_arg( array( 'message' => 'wpos-anylc-dismiss-notice', 'anylc_id' => $anylc_pdt_id, '_wpnonce' => wp_create_nonce( 'wpos-anylc-dismiss-notice-nonce' ) ), admin_url('index.php') );
|
||||
|
||||
// If user has opt in
|
||||
if( $opt_in == -1 ) {
|
||||
|
||||
$anylc_pdt_name = $module['name'];
|
||||
$anylc_optin_url = wpos_anylc_optin_url( $module, $opt_in );
|
||||
|
||||
echo '<div class="updated notice wpos-anylc-notice wpos-anylc-optin-notice">
|
||||
<p><strong>'.wp_kses_post( $anylc_pdt_name ).'</strong> - We made a few tweaks to the plugin, <a href="'.esc_url( $anylc_optin_url ).'">Opt in to make it Better!</a></p>
|
||||
<a href="'.esc_url( $notice_link ).'" class="notice-dismiss"></a>
|
||||
</div>';
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} // End of if
|
||||
|
||||
if( isset($_GET['message']) && $_GET['message'] == 'optout_success' ) {
|
||||
echo '<div class="updated notice wpos-anylc-optin-notice is-dismissible">
|
||||
<p><strong>Sorry to let you go. You are now opted out from the plugin.</strong></p>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Process Promotion Data
|
||||
if( !empty($_GET['message']) && $_GET['message'] == 'wpos_anylc_promotion' && !empty($_GET['wpos_anylc_pdt']) && !empty($_GET['wpos_anylc_promo_pdt']) ) {
|
||||
|
||||
$promotion = 1;
|
||||
$wpos_anylc_promo_pdt = sanitize_text_field( $_GET['wpos_anylc_promo_pdt'] );
|
||||
$promotion_pdt = explode( ',', $wpos_anylc_promo_pdt );
|
||||
|
||||
$anylc_pdt = sanitize_text_field( $_GET['wpos_anylc_pdt'] );
|
||||
$anylc_pdt_data = isset( $wpos_analytics_product[ $anylc_pdt ] ) ? $wpos_analytics_product[ $anylc_pdt ] : false;
|
||||
|
||||
if( !empty($promotion_pdt) ) {
|
||||
foreach ($promotion_pdt as $pdt_key => $pdt) {
|
||||
if( isset( $anylc_pdt_data['promotion'][$pdt]['file'] ) ) {
|
||||
$promotion_pdt_data[] = '<a href="'.$anylc_pdt_data['promotion'][$pdt]['file'].'">'.$anylc_pdt_data['promotion'][$pdt]['name'].'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $promotion_pdt_data ) {
|
||||
echo '<div class="updated notice wpos-anylc-optin-notice is-dismissible" style="display:block !important;">
|
||||
<p><strong>Your Download has been started. In case if it is intrupted then download it from here. '.join(' | ', $promotion_pdt_data).'</strong></p>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytic Optout Popup HTML
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_optout_popup() {
|
||||
|
||||
global $pagenow, $wpos_analytics_module;
|
||||
|
||||
if( $pagenow == 'plugins.php' && !empty( $wpos_analytics_module ) ) {
|
||||
foreach ($wpos_analytics_module as $module_key => $module) {
|
||||
|
||||
$opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] );
|
||||
$opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : false;
|
||||
|
||||
// If user has opt in
|
||||
if( $opt_in == 1 ) {
|
||||
|
||||
// Creating redirect URL
|
||||
$plugin_status = isset( $_GET['plugin_status'] ) ? sanitize_text_field( $_GET['plugin_status'] ) : false;
|
||||
$paged = isset( $_GET['paged'] ) ? sanitize_text_field( $_GET['paged'] ) : false;
|
||||
$s = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : false;
|
||||
|
||||
$redirect_url = add_query_arg( array( 'plugin_status' => $plugin_status, 'paged' => $paged, 's' => $s, 'wpos_anylc_pdt' => $module['slug'] ), admin_url( 'plugins.php' ) );
|
||||
$redirect_url = wp_nonce_url( $redirect_url, 'wpos_anylc_act'.'|'.$module['slug'] );
|
||||
|
||||
// Form Data
|
||||
$optin_form_data = wpos_anylc_optin_data( $module['slug'], $redirect_url );
|
||||
|
||||
include( WPOS_ANYLC_DIR .'/templates/optout-popup.php' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytic Action Process
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_action_process() {
|
||||
|
||||
// Skip if not admin area
|
||||
if ( !is_admin() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !empty($_GET['wpos_anylc_action']) && isset($_GET['_wpnonce']) ) {
|
||||
|
||||
global $wpos_analytics_product;
|
||||
|
||||
$anylc_pdt = !empty( $_GET['wpos_anylc_pdt'] ) ? sanitize_text_field( $_GET['wpos_anylc_pdt'] ) : '';
|
||||
$anylc_pdt = ( ! $anylc_pdt && !empty( $_GET['page'] ) ) ? sanitize_text_field( $_GET['page'] ) : $anylc_pdt;
|
||||
$anylc_pdt_data = isset( $wpos_analytics_product[ $anylc_pdt ] ) ? $wpos_analytics_product[ $anylc_pdt ] : false;
|
||||
|
||||
// If valid product data found
|
||||
if( $anylc_pdt_data ) {
|
||||
|
||||
// Process Optin
|
||||
if( $_GET['wpos_anylc_action'] == 'optin' ) {
|
||||
|
||||
// Verify nonce
|
||||
if( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act' ) ) {
|
||||
wp_die( __('Sorry, Something happened wrong.', 'wpos_analytic'), 'wpos_anylc_err', array('back_link' => true) );
|
||||
}
|
||||
|
||||
$opt_in_data = wpos_anylc_update_option( $anylc_pdt_data['anylc_optin'], array('status' => 1) );
|
||||
|
||||
// Redirect to original menu
|
||||
$redirect_url = wpos_anylc_pdt_url( $anylc_pdt_data, 'offer-promotion' );
|
||||
if( $redirect_url ) {
|
||||
wp_redirect( $redirect_url );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process Skip
|
||||
if( $_GET['wpos_anylc_action'] == 'skip' ) {
|
||||
|
||||
// Verify nonce
|
||||
if( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act' ) ) {
|
||||
wp_die( __('Sorry, Something happened wrong.', 'wpos_analytic'), 'wpos_anylc_err', array('back_link' => true) );
|
||||
}
|
||||
|
||||
$opt_in_data = wpos_anylc_update_option( $anylc_pdt_data['anylc_optin'], array('status' => 2) );
|
||||
|
||||
// Redirect to original menu
|
||||
$redirect_url = wpos_anylc_pdt_url( $anylc_pdt_data, 'offer' );
|
||||
if( $redirect_url ) {
|
||||
wp_redirect( $redirect_url );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process Opt Out
|
||||
if( $_GET['wpos_anylc_action'] == 'optout' ) {
|
||||
|
||||
// Verify nonce
|
||||
if( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act'.'|'.$_GET['wpos_anylc_pdt'] ) ) {
|
||||
wp_die( __('Sorry, Something happened wrong.', 'wpos_analytic'), 'wpos_anylc_err', array('back_link' => true) );
|
||||
}
|
||||
|
||||
$opt_in_data = wpos_anylc_update_option( $anylc_pdt_data['anylc_optin'], array('status' => 0) );
|
||||
|
||||
// Redirect with success message
|
||||
$redirect_url = add_query_arg( array( 'message' => 'optout_success', 'wpos_anylc_action' => false, 'wpos_anylc_pdt' => false, '_wpnonce' => false ) );
|
||||
if( $redirect_url ) {
|
||||
wp_redirect( $redirect_url );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // End of main if
|
||||
}
|
||||
}
|
||||
|
||||
$wpos_anylc_admin = new Wpos_Anylc_Admin();
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Script Class
|
||||
*
|
||||
* Handles the script and style
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Wpos_Anylc_Script {
|
||||
|
||||
function __construct() {
|
||||
|
||||
// Action to add style backend
|
||||
add_action( 'admin_enqueue_scripts', array($this, 'wpos_anylc_admin_script_style') );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue script for backend
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_admin_script_style( $hook ) {
|
||||
|
||||
// Process Promotion Data
|
||||
if( !empty($_GET['message']) && $_GET['message'] == 'wpos_anylc_promotion' && !empty($_GET['wpos_anylc_pdt']) && !empty($_GET['wpos_anylc_promo_pdt']) ) {
|
||||
global $wpos_analytics_product;
|
||||
|
||||
$promotion = 1;
|
||||
$wpos_anylc_promo_pdt = sanitize_text_field( $_GET['wpos_anylc_promo_pdt'] );
|
||||
$promotion_pdt = explode( ',', $wpos_anylc_promo_pdt );
|
||||
|
||||
$anylc_pdt = sanitize_text_field( $_GET['wpos_anylc_pdt'] );
|
||||
$anylc_pdt_data = isset( $wpos_analytics_product[ $anylc_pdt ] ) ? $wpos_analytics_product[ $anylc_pdt ] : false;
|
||||
|
||||
if( !empty($promotion_pdt) ) {
|
||||
foreach ($promotion_pdt as $pdt_key => $pdt) {
|
||||
if( isset( $anylc_pdt_data['promotion'][$pdt]['file'] ) ) {
|
||||
$promotion_pdt_data[] = $anylc_pdt_data['promotion'][$pdt]['file'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Registring admin Style
|
||||
wp_register_style( 'wpos-anylc-admin-style', WPOS_ANYLC_URL.'assets/css/wpos-anylc-admin.css', null, WPOS_ANYLC_VERSION );
|
||||
wp_enqueue_style( 'wpos-anylc-admin-style' );
|
||||
|
||||
// Registring admin script
|
||||
wp_register_script( 'wpos-anylc-admin-script', WPOS_ANYLC_URL.'assets/js/wpos-anylc-admin.js', array('jquery'), WPOS_ANYLC_VERSION, true );
|
||||
wp_localize_script( 'wpos-anylc-admin-script', 'WposAnylc', array(
|
||||
'promotion' => isset($promotion) ? 1 : 0,
|
||||
'promotion_pdt' => isset( $promotion_pdt_data ) ? $promotion_pdt_data : 0,
|
||||
));
|
||||
wp_enqueue_script( 'wpos-anylc-admin-script' );
|
||||
}
|
||||
}
|
||||
|
||||
$wpos_anylc_script = new Wpos_Anylc_Script();
|
@ -0,0 +1,331 @@
|
||||
<?php
|
||||
/**
|
||||
* Common Functions
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the translation of $text.
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_text( $text, $echo = false ) {
|
||||
|
||||
if( $echo ) {
|
||||
_e( $text, '' );
|
||||
} else {
|
||||
__( $text, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean variables using sanitize_text_field. Arrays are cleaned recursively.
|
||||
* Non-scalar values are ignored.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_clean( $var ) {
|
||||
if ( is_array( $var ) ) {
|
||||
return array_map( 'wpos_anylc_clean', $var );
|
||||
} else {
|
||||
$data = is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
|
||||
return wp_unslash($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Multidimention Array
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
function wpos_anylc_is_multi_arr( $arr ) {
|
||||
rsort( $arr );
|
||||
return isset( $arr[0] ) && is_array( $arr[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get site unique id
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_site_uid() {
|
||||
|
||||
$site_uid = get_option( 'wpos_anylc_site_uid' );
|
||||
|
||||
// Generate new site id if not exist
|
||||
if( empty( $site_uid ) ) {
|
||||
$site_url = untrailingslashit( get_bloginfo('wpurl') );
|
||||
$site_uid = md5( $site_url . SECURE_AUTH_KEY );
|
||||
|
||||
update_option( 'wpos_anylc_site_uid', $site_uid );
|
||||
}
|
||||
|
||||
return $site_uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Optin Data
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_optin_data( $anylc_pdt = false, $return_url = '' ) {
|
||||
|
||||
// Skip if not admin area
|
||||
if ( !is_admin() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
global $current_user, $wpos_analytics_product;
|
||||
|
||||
// Takind some data
|
||||
$theme_data = wp_get_theme();
|
||||
$page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : false;
|
||||
|
||||
// If product is not passed
|
||||
if( ! $anylc_pdt ) {
|
||||
$anylc_pdt = !empty( $_GET['wpos_anylc_pdt'] ) ? sanitize_text_field( $_GET['wpos_anylc_pdt'] ) : '';
|
||||
$anylc_pdt = ( ! $anylc_pdt && !empty( $_GET['page'] ) ) ? sanitize_text_field( $_GET['page'] ) : $anylc_pdt;
|
||||
}
|
||||
|
||||
// If a valid product is there
|
||||
if( $anylc_pdt && !empty( $wpos_analytics_product[ $anylc_pdt ] ) ) {
|
||||
|
||||
$analy_product = $wpos_analytics_product[ $anylc_pdt ];
|
||||
|
||||
if( empty( $return_url ) ) {
|
||||
$return_url = add_query_arg( array( 'page' => $page ), admin_url('admin.php') );
|
||||
$return_url = wp_nonce_url( $return_url, 'wpos_anylc_act' );
|
||||
}
|
||||
|
||||
// Getting data according to type
|
||||
if( $analy_product['type'] == 'theme' ) {
|
||||
|
||||
$product_name = $theme_data->get( 'Name' );
|
||||
$product_version = $theme_data->get( 'Version' );
|
||||
|
||||
} else {
|
||||
|
||||
if( !function_exists('get_plugin_data') ) {
|
||||
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
||||
}
|
||||
|
||||
$plugin_data = get_plugin_data( trailingslashit(WP_PLUGIN_DIR) . $analy_product['file'] );
|
||||
$product_name = !empty( $plugin_data['Name'] ) ? $plugin_data['Name'] : '';
|
||||
$product_version = !empty( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
|
||||
}
|
||||
}
|
||||
|
||||
$optin_data = array(
|
||||
'site_url' => untrailingslashit( get_bloginfo('wpurl') ),
|
||||
'site_name' => get_bloginfo( 'name' ),
|
||||
'wp_version' => get_bloginfo( 'version' ),
|
||||
'language' => get_bloginfo( 'language' ),
|
||||
'is_rtl' => is_rtl() ? 1 : 0,
|
||||
'php_version' => phpversion(),
|
||||
'sdk_version' => WPOS_ANYLC_VERSION,
|
||||
'product_name' => isset( $product_name ) ? $product_name : '',
|
||||
'product_version' => isset( $product_version ) ? $product_version : '',
|
||||
'product_id' => !empty( $analy_product['id'] ) ? $analy_product['id'] : 0,
|
||||
'product_type' => !empty( $analy_product['type'] ) ? $analy_product['type'] : '',
|
||||
'theme_name' => $theme_data->get( 'Name' ),
|
||||
'theme_uri' => $theme_data->get( 'ThemeURI' ),
|
||||
'theme_author' => $theme_data->get( 'Author' ),
|
||||
'theme_author_uri' => $theme_data->get( 'AuthorURI' ),
|
||||
'theme_version' => $theme_data->get( 'Version' ),
|
||||
'user_firstname' => $current_user->user_firstname,
|
||||
'user_lastname' => $current_user->user_lastname,
|
||||
'user_nickname' => $current_user->user_nicename,
|
||||
'user_email' => get_bloginfo( 'admin_email' ),
|
||||
'ip_address' => wpos_anylc_get_ip_address(),
|
||||
'site_uid' => wpos_anylc_site_uid(),
|
||||
'return_url' => $return_url,
|
||||
);
|
||||
return $optin_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IP Address
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_get_ip_address() {
|
||||
if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { // WPCS: input var ok, CSRF ok.
|
||||
return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); // WPCS: input var ok, CSRF ok.
|
||||
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { // WPCS: input var ok, CSRF ok.
|
||||
// Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
|
||||
// Make sure we always only send through the first IP in the list which should always be the client IP.
|
||||
return (string) rest_is_ip_address( trim( current( preg_split( '/[,:]/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); // WPCS: input var ok, CSRF ok.
|
||||
} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // @codingStandardsIgnoreLine
|
||||
return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // @codingStandardsIgnoreLine
|
||||
}
|
||||
return '127.0.0.1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Product Optin Data
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_get_option( $key = '' ) {
|
||||
|
||||
$opt_in_data = array();
|
||||
|
||||
if( !empty( $key ) ) {
|
||||
$opt_in_data = get_option( $key );
|
||||
$opt_in_data = ( !empty($opt_in_data) && is_array($opt_in_data) ) ? $opt_in_data : array();
|
||||
}
|
||||
return $opt_in_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Product Optin Data
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_update_option( $key = '', $data = array() ) {
|
||||
|
||||
$opt_in_data = array();
|
||||
|
||||
if( !empty( $key ) ) {
|
||||
$opt_in_data = wpos_anylc_get_option( $key );
|
||||
|
||||
if( is_array($data) ) {
|
||||
$opt_in_data = array_merge( $opt_in_data, $data );
|
||||
update_option( $key, $opt_in_data );
|
||||
}
|
||||
}
|
||||
return $opt_in_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Analytic Product Optin URL
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_optin_url( $module_data = '', $optin_status = null ) {
|
||||
|
||||
$optin_url = false;
|
||||
|
||||
// Optin Status
|
||||
if( ! isset( $optin_status ) ) {
|
||||
$opt_in_data = get_option( $module_data['anylc_optin'] );
|
||||
$optin_status = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null;
|
||||
}
|
||||
|
||||
if( !empty( $module_data['menu'] ) && !empty( $module_data['slug'] ) ) {
|
||||
$url_data = parse_url( $module_data['menu'], PHP_URL_QUERY );
|
||||
$query_data = !empty( $url_data ) ? parse_str( $url_data, $query_arr ) : array();
|
||||
|
||||
if( !empty( $query_arr['post_type'] ) && $optin_status >= 0 ) { // If Optin is done and post type menu
|
||||
|
||||
$optin_url = add_query_arg( array( 'post_type' => $query_arr['post_type'], 'page' => $module_data['slug'], 'anylc_optin_menu' => true ), admin_url('edit.php') );
|
||||
|
||||
} else if( empty( $query_arr['post_type'] ) && $optin_status >= 0 ) { // If Optin is done and simple admin menu
|
||||
|
||||
$optin_url = add_query_arg( array( 'page' => $module_data['slug'], 'anylc_optin_menu' => true ), admin_url('admin.php') );
|
||||
|
||||
} else {
|
||||
$optin_url = add_query_arg( array( 'page' => $module_data['slug'] ), admin_url('admin.php') );
|
||||
}
|
||||
}
|
||||
|
||||
return $optin_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Analytic Product Opt Out URL
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_optout_url( $module_data = '', $optin_status = null, $redirect_url = false ) {
|
||||
|
||||
$opt_out_link = false;
|
||||
|
||||
// Optin Status
|
||||
if( !isset( $optin_status ) ) {
|
||||
$opt_in_data = get_option( $module_data['anylc_optin'] );
|
||||
$optin_status = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null;
|
||||
}
|
||||
|
||||
if( $optin_status == 1 ) {
|
||||
|
||||
if( ! $redirect_url ) {
|
||||
$plugin_status = isset( $_GET['plugin_status'] ) ? sanitize_text_field( $_GET['plugin_status'] ) : false;
|
||||
$paged = isset( $_GET['paged'] ) ? sanitize_text_field( $_GET['paged'] ) : false;
|
||||
$s = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : false;
|
||||
|
||||
$redirect_url = add_query_arg( array( 'plugin_status' => $plugin_status, 'paged' => $paged, 's' => $s ), admin_url( 'plugins.php' ) );
|
||||
}
|
||||
|
||||
$opt_out_link = add_query_arg( array( 'wpos_anylc_action' => 'optout', 'wpos_anylc_pdt' => $module_data['slug'], 'redirect' => $redirect_url ), $redirect_url );
|
||||
$opt_out_link = wp_nonce_url( $opt_out_link, 'wpos_anylc_act'.'|'.$module_data['slug'] );
|
||||
}
|
||||
|
||||
return $opt_out_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Analytic Product URL
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wpos_anylc_pdt_url( $module_data = '', $type = false ) {
|
||||
|
||||
$redirect_url = false;
|
||||
$redirect_page = ! empty( $module_data['redirect_page'] ) ? $module_data['redirect_page'] : $module_data['menu'];
|
||||
|
||||
if( ! empty( $redirect_page ) ) {
|
||||
|
||||
$pos = strpos( $redirect_page, '?post_type' );
|
||||
$redirect_url = ( $pos !== false ) ? admin_url( $redirect_page ) : add_query_arg( array( 'page' => $redirect_page ), admin_url('admin.php') );
|
||||
|
||||
switch ( $type ) {
|
||||
case 'promotion':
|
||||
|
||||
$promotion = !empty( $_GET['promotion'] ) ? wpos_anylc_clean( $_GET['promotion'] ) : '';
|
||||
|
||||
if( !empty( $promotion ) ) {
|
||||
$promotion = is_array( $promotion ) ? implode( ',', $promotion ) : $promotion;
|
||||
$redirect_url = add_query_arg( array( 'message' => 'wpos_anylc_promotion', 'wpos_anylc_pdt' => $module_data['slug'], 'wpos_anylc_promo_pdt' => $promotion ), $redirect_url );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'offer':
|
||||
|
||||
if( !empty( $module_data['offers'] ) ) {
|
||||
$redirect_url = add_query_arg( array( 'page' => $module_data['slug'].'-offers' ), $redirect_url );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'offer-promotion':
|
||||
|
||||
$promotion = !empty( $_GET['promotion'] ) ? wpos_anylc_clean( $_GET['promotion'] ) : '';
|
||||
|
||||
if( !empty( $module_data['offers'] ) ) {
|
||||
$redirect_url = add_query_arg( array( 'page' => $module_data['slug'].'-offers' ), $redirect_url );
|
||||
}
|
||||
if( !empty( $promotion ) ) {
|
||||
$promotion = is_array( $promotion ) ? implode( ',', $promotion ) : $promotion;
|
||||
$redirect_url = add_query_arg( array( 'message' => 'wpos_anylc_promotion', 'wpos_anylc_pdt' => $module_data['slug'], 'wpos_anylc_promo_pdt' => $promotion ), $redirect_url );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $redirect_url;
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Settings Page
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
<style type="text/css">
|
||||
.notice, .error, div.fs-notice.updated, div.fs-notice.success, div.fs-notice.promotion{display:none !important;}
|
||||
|
||||
/* Some CSS */
|
||||
/*.wpos-anylc-admin-wrap{text-align: center; padding:15px 0;}
|
||||
.wpos-anylc-line-style{font-style: italic; text-decoration: underline; color: #000; font-weight: 700; letter-spacing: 1px;}
|
||||
.wpos-anylc-email-line{ letter-spacing: 1px; position: relative; padding: 0.75rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 0.25rem; color: #000; background-color: #F8F8F8; border-color: #F8F8F8;}
|
||||
.wpos-anylc-nl-wrap{ letter-spacing: 1px; position: relative; padding: 0.75rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 0.25rem; color: #000; background-color: #F8F8F8; border-color: #F8F8F8;}
|
||||
.wpos-anylc-skip-btn{border-color:#404040 !important; color: #404040 !important;}
|
||||
.wpos-anylc-black-wrap{color: #000; font-weight: 700;}
|
||||
.wpos-anylc-list-wrap{margin-left: 10px;}
|
||||
.wpos-anylc-list-wrap li span{font-style: italic; color: #000; font-weight: 700; letter-spacing: 1px;}
|
||||
.wpos-anylc-best-regard{ text-align: center; font-style: italic; color:#000;font-weight: 700; letter-spacing: 1px; margin-top: 25px;}
|
||||
.wpos-anylc-optin-action{display: flex;align-items: center; background-color: #F8F8F8;}
|
||||
.wpos-anylc-subs-btn{width: 50%;}
|
||||
.wpos-anylc-subs-btn .wpos-anylc-allow-btn{background: #FF0000; border-color:#FF0000;}
|
||||
.wpos-anylc-subs-btn .wpos-anylc-allow-btn:hover{background:#D22B2B; border-color:#D22B2B;}
|
||||
.wpos-anylc-btn-skip{width: 50%; display: flex; flex-direction: column;align-items: flex-start;}
|
||||
.wpos-anylc-btn-skip span{font-weight: 500;font-size:12px; font-style:italic; margin-right: 20px;}
|
||||
.wpos-anylc-btn-skip .wpos-anylc-skip-btn{font-size: 12px;}
|
||||
.wpos-anylc-terms{background-color:#F8F8F8;}*/
|
||||
</style>
|
||||
|
||||
<div class="wrap wpos-anylc-optin">
|
||||
|
||||
<?php if( isset($_GET['error']) && $_GET['error'] == 'wpos_anylc_error' ) { ?>
|
||||
<div class="error">
|
||||
<p><strong>Sorry, Something happened wrong. Please contact us on <a href="mailto:support@wponlinesupport.com">support@wponlinesupport.com</a></strong></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<form method="POST" action="https://analytics.wponlinesupport.com">
|
||||
<div class="wpos-anylc-optin-wrap" style="width: 650px; margin: 0 auto; margin-top: 70px;">
|
||||
|
||||
<div>
|
||||
<div style="height:50px; text-align: center; background-color: rgba(180,185,190, 0.2);">
|
||||
<img style="position: relative; top:-40px;" src="<?php echo esc_url( $analy_product['icon'] ); ?>" alt="Icon" />
|
||||
</div>
|
||||
<div style="padding: 10px;">
|
||||
<div style="margin-top:50px; margin-bottom: 30px; text-align: center; font-weight: 700; font-size: 24px;">Never miss an important update</div>
|
||||
|
||||
<div style="font-size: 20px; font-weight: 500; line-height:25px; margin: 10px 12px; color:#646970;">Opt-in to get email notifications for security & feature updates, and to share some basic WordPress environment info. This will help us make the plugin more compatible with your site and better at doing what you need it to.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="wpos-anylc-optin-icon-wrap" style="text-align: center; background-color: rgba(180,185,190, 0.3);">
|
||||
<div class="wpos-anylc-optin-icon wpos-anylc-wp-badge"><i class="dashicons dashicons-wordpress"></i></div>
|
||||
<div class="wpos-anylc-optin-plus"><i class="dashicons dashicons-plus"></i></div>
|
||||
<div class="wpos-anylc-optin-icon"><img src="<?php //echo esc_url( $analy_product['icon'] ); ?>" alt="Icon" /></div>
|
||||
<div class="wpos-anylc-optin-plus"><i class="dashicons dashicons-plus"></i></div>
|
||||
<div class="wpos-anylc-optin-icon"><img src="<?php //echo esc_url( $analy_product['brand_icon'] ); ?>" alt="Icon" /></div>
|
||||
</div> -->
|
||||
<!-- <div class="wpos-anylc-optin-cnt"> -->
|
||||
<!-- <p>Hey <?php //echo ucfirst( $user_name ); ?>,</p>
|
||||
<p>Don't ever miss an opportunity to <b>opt in</b> for Email Notifications / Announcements about exciting New Features and Update Releases.</p>
|
||||
<p>Contribute in helping us making <b><?php //echo esc_html( $product_name ); ?></b> compatible with most themes and plugins by allowing to share non-sensitive data to <a target="_blank" href="https://www.essentialplugin.com/">essentialplugin.com</a> about your website.</p>
|
||||
<p>If you skip this, that's okay! <b><?php //echo esc_html( $product_name ); ?></b> will still work just fine.</p> -->
|
||||
|
||||
<!-- <div class="wpos-anylc-admin-wrap"><span class="wpos-anylc-black-wrap">Hey! 👤 <?php //echo ucfirst( $user_name ); ?>,</span> Opt in Bonuses, Information & 🎁 <span class="wpos-anylc-line-style">Premium Gifts</span> for YOU</div>
|
||||
|
||||
<div class="wpos-anylc-email-line">Opt- in subscribers will have - 📩 Email notifications, security features, update releases for <span class="wpos-anylc-line-style"><?php //echo esc_html( $product_name ); ?></span></div>
|
||||
<div>
|
||||
<p>Globally, <span class="wpos-anylc-black-wrap">49%</span> of users want to receive <span class="wpos-anylc-line-style">Promotional Emails</span> about the brands through emails.</p>
|
||||
</div>
|
||||
|
||||
<div class="wpos-anylc-nl-wrap">
|
||||
<p>Our newsletter also contains topics about:</p>
|
||||
<ul class="wpos-anylc-list-wrap">
|
||||
<li>1. <span>WordPress (WP)</span> ⇾ From Matt Mullenweg to Smallest of WP Version Upgrades</li>
|
||||
<li>2. <span>Digital Marketing</span> ⇾ From Traffic to Conversions</li>
|
||||
<li>3. <span>General Tech</span> ⇾ From WEB to chatGPT to EV </li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<p><span class="wpos-anylc-black-wrap">42%</span> of our Email users are benefited with our shared useful knowledge, content & first email will come with 🎁 <span class="wpos-anylc-line-style">Premium Gifts.</span></p>
|
||||
</div>
|
||||
<div class="wpos-anylc-best-regard">With Best Regards, 🙏 Namaste! & Universal Blessings</div> -->
|
||||
|
||||
<?php if( ! empty( $analy_product['promotion'] ) ) { ?>
|
||||
<div class="wpos-anylc-promotion-wrap">
|
||||
<?php foreach( $analy_product['promotion'] as $promotion_key => $promotion_data ) { ?>
|
||||
<div><label><input type="checkbox" value="<?php echo esc_attr( $promotion_key ); ?>" name="promotion[]" checked="checked" /> <?php echo esc_html( $promotion_data['name'] ); ?></label></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<!-- </div> -->
|
||||
<div class="wpos-anylc-optin-action wpos-anylc-clearfix" style="background-color: rgba(180,185,190, 0.3);">
|
||||
|
||||
<button type="submit" name="wpos_anylc_optin" class="button button-primary button-large wpos-anylc-allow-btn" value="wpos_anylc_optin">Allow and Continue</button>
|
||||
|
||||
<?php if( is_null( $opt_in ) ) { ?>
|
||||
<button type="submit" name="wpos_anylc_action" class="button button-secondary button-large right wpos-anylc-skip-btn" value="skip" style="padding: 0 !important;background: transparent;border: none;">Skip</button>
|
||||
<?php }
|
||||
|
||||
if( ! empty( $optin_form_data ) ) {
|
||||
foreach ($optin_form_data as $data_key => $data_value) {
|
||||
echo '<input type="hidden" name="'.esc_attr( $data_key ).'" value="'.esc_attr( $data_value ).'" />';
|
||||
}
|
||||
} ?>
|
||||
|
||||
<!-- <div class="wpos-anylc-btn-skip">
|
||||
<?php //if( is_null( $opt_in ) ) { ?>
|
||||
<button type="submit" name="wpos_anylc_action" class="button button-secondary button-large wpos-anylc-skip-btn" value="skip">I'm fine without subscription!</button>
|
||||
<?php //}
|
||||
|
||||
//if( ! empty( $optin_form_data ) ) {
|
||||
// foreach ($optin_form_data as $data_key => $data_value) {
|
||||
// echo '<input type="hidden" name="'.esc_attr( $data_key ).'" value="'.esc_attr( $data_value ).'" />';
|
||||
// }
|
||||
// } ?>
|
||||
</div> -->
|
||||
<!-- <div class="wpos-anylc-subs-btn">
|
||||
<button type="submit" name="wpos_anylc_optin" class="button button-primary right button-large wpos-anylc-allow-btn" value="wpos_anylc_optin">OK LETS START SUBSCRIBE</button>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="wpos-anylc-optin-permission">
|
||||
<a class="wpos-anylc-permission-toggle" href="javascript:void(0);">What permissions are being granted?</a>
|
||||
|
||||
<div class="wpos-anylc-permission-wrap wpos-anylc-hide">
|
||||
<div class="wpos-anylc-permission">
|
||||
<i class="dashicons dashicons-admin-users"></i>
|
||||
<div>
|
||||
<span class="wpos-anylc-permission-name">Your Profile Overview</span>
|
||||
<span class="wpos-anylc-permission-info">Name and email address</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpos-anylc-permission">
|
||||
<i class="dashicons dashicons-admin-settings"></i>
|
||||
<div>
|
||||
<span class="wpos-anylc-permission-name">Your Site Overview</span>
|
||||
<span class="wpos-anylc-permission-info">Site URL, WP version, PHP info & Theme</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpos-anylc-permission">
|
||||
<i class="dashicons dashicons-admin-plugins"></i>
|
||||
<div>
|
||||
<span class="wpos-anylc-permission-name">Current Plugin Events</span>
|
||||
<span class="wpos-anylc-permission-info">Activation, Deactivation and Uninstall</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpos-anylc-terms">
|
||||
<a href="https://www.essentialplugin.com/privacy-policy/#free-pluign-info" target="_blank">Privacy Policy</a> - <a href="https://www.essentialplugin.com/term-and-condition/" target="_blank">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div><!-- end .wrap -->
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Offers Page
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
<style type="text/css">
|
||||
.notice, .error, div.fs-notice.updated, div.fs-notice.success, div.fs-notice.promotion{display:none !important;}
|
||||
</style>
|
||||
|
||||
<div class="wrap wpos-anylc-offers">
|
||||
|
||||
<?php foreach ($analy_product['offers'] as $offer_key => $offer_data) {
|
||||
|
||||
// If status wise offer is there
|
||||
if( wpos_anylc_is_multi_arr( $offer_data ) ) {
|
||||
$offer_data = isset( $offer_data[ $opt_in ] ) ? $offer_data[ $opt_in ] : false;
|
||||
}
|
||||
|
||||
if( empty( $offer_data ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$has_offer = true;
|
||||
$link = isset( $offer_data['link'] ) ? $offer_data['link'] : '';
|
||||
$image = ! empty( $offer_data['image'] ) ? add_query_arg( array('v' => time()), $offer_data['image'] ) : '';
|
||||
?>
|
||||
|
||||
<div class="wpos-anylc-offer-wrap">
|
||||
<?php if( ! empty( $offer_data['name'] ) ) { ?>
|
||||
<div class="wpos-anylc-offer-title wpos-anylc-center"><?php echo esc_html( $offer_data['name'] ); ?></div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if( $image ) { ?>
|
||||
<div class="wpos-anylc-offer-body wpos-anylc-center">
|
||||
<?php if( $link ) { ?>
|
||||
<a href="<?php echo esc_url( $link ); ?>" target="_blank">
|
||||
<img src="<?php echo esc_url( $image ); ?>" alt="" />
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<img src="<?php echo esc_url( $image ); ?>" alt="" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if( ! empty( $offer_data['desc'] ) ) { ?>
|
||||
<div class="wpos-anylc-offer-desc wpos-anylc-center"><?php echo wpautop( $offer_data['desc'] ); ?></div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if( ! empty( $offer_data['button'] ) ) { ?>
|
||||
<div class="wpos-anylc-offer-footer wpos-anylc-center"><a href="<?php echo esc_url( $link ); ?>" class="button button-primary button-large wpos-anylc-btn" target="_blank"><?php echo wp_kses_post( $offer_data['button'] ); ?></a></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php } // End of foreach
|
||||
|
||||
// If no offer to display then redirect to main plugin screen
|
||||
if( empty( $has_offer ) ) {
|
||||
$redirect_url = wpos_anylc_pdt_url( $analy_product ); // Redirect URL
|
||||
?>
|
||||
Please Wait... Redirecting to plugin screen. <a href="<?php echo esc_url( $redirect_url ); ?>">Click Here</a> in case you are not auto redirect.
|
||||
<script type="text/javascript">
|
||||
window.location = "<?php echo esc_url( $redirect_url ); ?>";
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
</div><!-- end .wrap -->
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Analytic Optout Popup
|
||||
*
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
<div class="wpos-anylc-popup wpos-anylc-popup-wrp wpos-anylc-hide" id="wpos-anylc-optout-<?php echo esc_attr( $module['id'] ); ?>">
|
||||
<div class="wpos-anylc-popup-inr-wrp">
|
||||
<div class="wpos-anylc-popup-block">
|
||||
|
||||
<div class="wpos-anylc-popup-header">Opt Out</div>
|
||||
<div class="wpos-anylc-popup-body">
|
||||
<p class="wpos-anylc-popup-heading">We appreciate your help to make the plugin better by letting us track some usage data.</p>
|
||||
<p>Usage tracking is done in the name of making <b><?php echo esc_html( $module['name'] ); ?></b> better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking.</p>
|
||||
<p>By clicking "Opt Out", we will no longer be sending any data from <b><?php echo esc_html( $module['name'] ); ?></b> to <a href="https://www.essentialplugin.com/" target="_blank">essentialplugin.com</a>.</p>
|
||||
</div>
|
||||
<div class="wpos-anylc-popup-footer">
|
||||
<form method="POST" action="https://analytics.wponlinesupport.com">
|
||||
<?php
|
||||
if( ! empty( $optin_form_data ) ) {
|
||||
foreach ($optin_form_data as $data_key => $data_value) {
|
||||
echo '<input type="hidden" name="'.esc_attr( $data_key ).'" value="'.esc_attr( $data_value ).'" />';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<button type="submit" name="wpos_anylc_action" class="button button-secondary" value="optout">Opt Out</button>
|
||||
<button type="button" class="button button-primary wpos-anylc-popup-close">Sure, Let Me Continue Helping</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div><!-- end .wpos-anylc-popup-block -->
|
||||
</div><!-- end .wpos-anylc-popup-inr-wrp -->
|
||||
</div><!-- end .wpos-anylc-popup-wrp -->
|
||||
<div class="wpos-anylc-popup-overlay" id="wpos-anylc-optout-overlay-<?php echo esc_attr( $module['id'] ); ?>"></div>
|
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/**
|
||||
* WPOS Analytics
|
||||
*
|
||||
* @author WP Online Support
|
||||
* @package Wpos Analytic
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WPOS_Analytics' ) ) :
|
||||
|
||||
/**
|
||||
* Main Analytics Class By WP Online Support.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
final class WPOS_Analytics {
|
||||
|
||||
/**
|
||||
* @var Instance
|
||||
* @since 1.0
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Main Analytics Instance.
|
||||
*
|
||||
* Insures that only one instance of Analytics exists in memory at any one time.
|
||||
* Also prevents needing to define globals all over the place.
|
||||
*
|
||||
* @since 1.0
|
||||
* @uses WPOS_ANYLC::setup_constants() Setup the constants needed.
|
||||
* @uses WPOS_ANYLC::includes() Include the required files.
|
||||
* @uses WPOS_ANYLC::wpos_anylc_plugins_loaded() load the language files.
|
||||
* @see PWPC()
|
||||
* @return object The one true Analytics
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw error on object clone.
|
||||
*
|
||||
* The whole idea of the singleton design pattern is that there is a single object therefore, we don't want the object to be cloned.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
public function __clone() {
|
||||
// Cloning instances of the class is forbidden.
|
||||
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'pwpc' ), '1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable unserializing of the class.
|
||||
*
|
||||
* @since 1.0
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup() {
|
||||
// Unserializing instances of the class is forbidden.
|
||||
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'pwpc' ), '1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->setup_constants();
|
||||
$this->includes();
|
||||
|
||||
do_action( 'wpos_anylc_loaded' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constant if not already set.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|bool $value
|
||||
*/
|
||||
public function define( $name, $value ) {
|
||||
if ( ! defined( $name ) ) {
|
||||
define( $name, $value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup plugin constants. Basic plugin definitions
|
||||
*
|
||||
* @access private
|
||||
* @since 1.0
|
||||
*/
|
||||
private function setup_constants() {
|
||||
|
||||
$this->define( 'WPOS_ANYLC_VERSION', '1.1' );
|
||||
$this->define( 'WPOS_ANYLC_DIR', plugin_dir_path( __FILE__ ) );
|
||||
$this->define( 'WPOS_ANYLC_URL', plugin_dir_url( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Include required files.
|
||||
*
|
||||
* @access private
|
||||
* @since 1.0
|
||||
*/
|
||||
private function includes() {
|
||||
|
||||
// Functions file
|
||||
require_once WPOS_ANYLC_DIR .'/includes/wpos-anylc-function.php';
|
||||
|
||||
// Script Class
|
||||
require_once WPOS_ANYLC_DIR .'/includes/class-anylc-script.php';
|
||||
|
||||
// Admin Class
|
||||
require_once WPOS_ANYLC_DIR .'/includes/class-anylc-admin.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The main function responsible for returning the one true Analytics
|
||||
* Instance to functions everywhere.
|
||||
*
|
||||
* Use this function like you would a global variable, except without needing
|
||||
* to declare the global.
|
||||
*
|
||||
* Example: $wpos_anylc = WPOS_ANYLC();
|
||||
*
|
||||
* @since 1.0
|
||||
* @return object The one true Analytics Instance.
|
||||
*/
|
||||
function WPOS_ANYLC() {
|
||||
return WPOS_Analytics::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Initialize Analytics Module
|
||||
*
|
||||
* @since 1.0
|
||||
* @return object The one true Analytics Instance.
|
||||
*/
|
||||
function wpos_anylc_init_module( $args = array() ) {
|
||||
|
||||
global $wpos_analytics_module, $wpos_analytics_product;
|
||||
|
||||
$defaul_args = array(
|
||||
'id' => null,
|
||||
'file' => null,
|
||||
'name' => null,
|
||||
'slug' => null,
|
||||
'type' => 'plugin',
|
||||
'menu' => false,
|
||||
'icon' => '',
|
||||
'text_domain' => 'wpos_analytics',
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $defaul_args );
|
||||
|
||||
// If required data is not there then simply return
|
||||
if( empty($args['id']) || empty( $args['file'] ) || empty( $args['slug'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Additional args
|
||||
$promotion = array();
|
||||
$args['dir'] = pathinfo($args['file'], PATHINFO_DIRNAME);
|
||||
$args['icon'] = empty( $icon ) ? trailingslashit( WP_PLUGIN_URL ).$args['dir'].'/wpos-analytics/assets/images/icon.png' : $args['icon'];
|
||||
$args['brand_icon'] = plugin_dir_url( __FILE__ ).'assets/images/wpos-logo.png';
|
||||
$args['anylc_optin'] = 'wpos_anylc_pdt_'.$args['id'];
|
||||
|
||||
if( isset( $args['promotion'] ) ) {
|
||||
foreach ($args['promotion'] as $promotion_key => $promotion_data) {
|
||||
if( empty( $promotion_data['name'] ) || empty( $promotion_data['file'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$promotion[$promotion_key] = $promotion_data;
|
||||
}
|
||||
}
|
||||
$args['promotion'] = $promotion;
|
||||
|
||||
// Taking some variables
|
||||
$wpos_analytics_module = !empty( $wpos_analytics_module ) ? $wpos_analytics_module : array();
|
||||
$wpos_analytics_product = !empty( $wpos_analytics_product ) ? $wpos_analytics_product : array();
|
||||
|
||||
if( is_array( $wpos_analytics_module ) ) {
|
||||
$wpos_analytics_module[ $args['file'] ] = $args;
|
||||
}
|
||||
|
||||
if( is_array( $wpos_analytics_product ) ) {
|
||||
$wpos_analytics_product[ $args['slug'] ] = $args;
|
||||
}
|
||||
|
||||
return $wpos_analytics_module;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Function on any plugin activation
|
||||
*
|
||||
* @since 1.0
|
||||
* @return object The one true Analytics Instance.
|
||||
*/
|
||||
function wpos_anylc_plugin_activation( $plugin, $network_activation ) {
|
||||
|
||||
// return if activating from network, or bulk
|
||||
if ( is_network_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wpos_analytics_module;
|
||||
|
||||
if( isset( $wpos_analytics_module[ $plugin ] ) ) {
|
||||
|
||||
$opt_in_data = get_option( $wpos_analytics_module[ $plugin ]['anylc_optin'] );
|
||||
$optin_status = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : -1;
|
||||
|
||||
if( $optin_status == -1 ) {
|
||||
|
||||
$redirect_link = add_query_arg( array( 'page' => $wpos_analytics_module[ $plugin ]['slug'], 'anylc_nonce' => wp_create_nonce( 'wpos-anylc-redirect-nonce' ) ), admin_url('admin.php') );
|
||||
update_option( 'wpos_anylc_redirect', $redirect_link );
|
||||
|
||||
} elseif( ! empty( $wpos_analytics_module[ $plugin ]['redirect_page'] ) ) {
|
||||
|
||||
$redirect_page = $wpos_analytics_module[ $plugin ]['redirect_page'];
|
||||
$pos = strpos( $redirect_page, '?post_type' );
|
||||
$redirect_link = ( $pos !== false ) ? admin_url( $redirect_page ) : add_query_arg( array( 'page' => $redirect_page, 'anylc_nonce' => wp_create_nonce( 'wpos-anylc-redirect-nonce' ) ), admin_url('admin.php') );
|
||||
|
||||
update_option( 'wpos_anylc_redirect', $redirect_link );
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'activated_plugin', 'wpos_anylc_plugin_activation', 10, 2 );
|
||||
|
||||
/**
|
||||
*
|
||||
* Initialize Analytics Class Once all stuff has been loaded
|
||||
*
|
||||
* @since 1.0
|
||||
* @return object The one true Analytics Instance.
|
||||
*/
|
||||
function wpos_anylc_plugins_loaded() {
|
||||
|
||||
// Get Analytics Running.
|
||||
WPOS_ANYLC();
|
||||
}
|
||||
add_action( 'plugins_loaded', 'wpos_anylc_plugins_loaded', 12 );
|
||||
|
||||
endif; // End if class_exists check.
|
Reference in New Issue
Block a user