' . esc_html__( 'Validate your theme', 'mega' ) . '
',
'
' . esc_html__( 'If you have purchased the upgrade for this theme to the professional version, please enter your email address that you used to signup for authentication, this will upgrade the theme and gain you access to restricted areas.', 'mega' ) . '
',
'
',
'',
'',
'
',
'',
'',
wp_nonce_field( 'mega_data', 'security', 1, 0 ),
'';
}
public function ajax()
{
$log = new Mega_Error();
global $mega_logs;
check_ajax_referer( 'mega_data', 'security' );
$data = $_POST;
$data = stripslashes_deep( $data );
unset( $data['security'], $data['action'] );
if ( empty( $data['email'] ))
{
$log->add_error( 'empty_email', esc_html__( 'Empty email address', 'mega' ));
echo json_encode( $log->errors );
$mega_logs->addLogs( $log->errors );
exit;
}
$api = new Mega_API_Connect( array( 'action' => 'auth-check', 'email' => $data['email'] ));
$api->data = $api->connect();
if ( isset( $api->data['status'] ) && $api->data['status'] === 'error' )
{
$log->add_error( $api->data['code'], $api->data['msg'] );
echo json_encode( $log->errors );
$mega_logs->addLogs( $log->errors );
}
else
{
global $mega_updater;
mega_set_package( 1, false, $mega_updater->update() ? true : false );
$log->add_error( 'succues', esc_html__( 'Upgraded! Authentication complete.', 'mega' ), 'notice' );
echo json_encode( $log->errors );
$mega_logs->addLogs( $log->errors );
//$api->postBack( 'auth-ok' );
//$this->redirect();
}
exit;
}
public function cron()
{
//setup cron, every 7/14 days to re-check?
}
public function upgrade()
{
global $mega_updater;
if ( $mega_updater->update() )
mega_set_package( 1, false, true );
}
public function redirect()
{
wp_redirect( admin_url( 'themes.php?page=mega' ));
}
}