'activate_license',
'license_key' => $envatoCode,
'theme' => $theme,
'theme_id' => $theme_id,
'url' => home_url()
);
$response = get_api_response( json_encode( $api_params ));
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
if ( is_wp_error( $response ) ) {
$message = $response->get_error_message();
} else {
$message = __( 'An error occurred, please try again.', 'aleanta' );
}
} else {
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
if (is_object($license_data) && false === $license_data->success ) {
}
}
if ( isset($license_data) && isset( $license_data->license ) ) {
if ($license_data->license !== 'valid') {
update_option( $option_name, '' );
update_option( $option_name_code, $envatoCode );
return false;
}else{
update_option( $option_name, $license_data->time );
update_option( $option_name_code, $envatoCode );
return true;
}
}
return false;
}
function get_api_response( $api_params ) {
$remote_api_url = 'http://support.templines.com/keyact/';
$response = wp_remote_post( $remote_api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
return $response;
}
if ( !function_exists( 'pix_admin_notice_activation' ) ) {
function pix_admin_notice_activation() {
if(pixtheme_check_is_activated())return;
$envatoCode = get_theme_mod('pixtheme_licence_settings_code') ? get_theme_mod('pixtheme_licence_settings_code') : '';
$screen = get_current_screen();
if ( $screen->id != 'appearance_page_adminpanel' ) {
if ( 1 ) {
echo "
";
}
}
}
}
// add_action( 'init', 'pix_admin_notice_view' );
function pix_admin_notice_view() {
if (current_user_can('switch_themes')) {
add_action('admin_notices', 'pix_admin_notice_activation', 2);
}
}
if( wp_doing_ajax() ){
add_action('wp_ajax_theme_activation', 'pix_ajax_theme_activation');
add_action('wp_ajax_delete_key_activation', 'pix_ajax_delete_key_activation');
}
function pix_ajax_theme_activation() {
global $post;
if( ! wp_verify_nonce( $_POST['nonce_code'], 'pix-admin-nonce' ) ) die( 'Stop!');
$json = wp_unslash( $_POST['code']);
set_theme_mod( 'pixtheme_licence_settings_code', $json );
if($rez = pixtheme_check_is_activated()){
echo ''.$rez;
}else{
echo ''.$rez;
}
wp_die();
}
function pix_ajax_delete_key_activation() {
global $post;
if( ! wp_verify_nonce( $_POST['nonce_code'], 'pix-admin-nonce' ) ) die( 'Stop!');
$envatoCode = get_theme_mod('pixtheme_licence_settings_code', '');
$theme_id = '15911085';
$theme = 'Theme aleanta';
$api_params = array(
'edd_action' => 'delete_key',
'license_key' => $envatoCode,
'theme' => $theme,
'theme_id' => $theme_id,
'url' => home_url()
);
$response = get_api_response( json_encode( $api_params ));
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
} else {
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
if (is_object($license_data) && true == $license_data->success ) {
set_theme_mod( 'pixtheme_licence_settings_code', '' );
update_option( 'pixtheme_licence_code', '' );
echo 1 ;
}else{
echo 0;
}
}
wp_die();
}
add_action( 'admin_enqueue_scripts', 'activete_theme_ajax_data');
function activete_theme_ajax_data(){
wp_localize_script( 'jquery', 'pixAjax',
array(
'url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('pix-admin-nonce')
)
);
}
add_action('admin_print_footer_scripts', 'construct_action_javascript', 99);
function construct_action_javascript() {
?>