functions = new ATTO_functions(); $this->licence = new ATTO_licence(); add_action( 'init', array($this, 'options_update'), 1 ); } function admin_styles() { wp_register_style('options.css', ATTO_URL . '/css/options.css'); wp_enqueue_style( 'options.css'); } function options_update() { if (isset($_POST['atto_licence_form_submit'])) { $this->licence_form_submit(); } if (isset($_POST['atto_form_submit']) && wp_verify_nonce($_POST['atto_form_nonce'],'atto_form_submit') ) { $this->options_submit(); } } function options_interface() { $options = ATTO_functions::get_settings(); //build an array containing the user role and capability $user_roles = array(); $user_roles['Subscriber'] = apply_filters('atto_user_role_capability', 'read', __('Subscriber', 'atto')); $user_roles['Contributor'] = apply_filters('atto_user_role_capability', 'edit_posts', __('Contributor', 'atto')); $user_roles['Author'] = apply_filters('atto_user_role_capability', 'publish_posts', __('Author', 'atto')); $user_roles['Editor'] = apply_filters('atto_user_role_capability', 'publish_pages', __('Editor', 'atto')); $user_roles['Administrator'] = apply_filters('atto_user_role_capability', 'manage_options', __('Administrator', 'atto')); //allow to add custom roles $user_roles = apply_filters( 'atto/interface/options/atto_user_roles_and_capabilities', $user_roles ); ?>
licence->licence_key_verify()) { $this->licence_form(); return; } if( $this->licence->licence_key_verify()) { $this->licence_deactivate_form(); } ?>


'updated', 'text' => __('Settings Saved', 'atto')); ATTO_functions::update_settings( $options ); } function licence_form_submit() { global $atto_interface_messages; //check for de-activation if (isset($_POST['atto_licence_form_submit']) && isset($_POST['atto_licence_deactivate']) && wp_verify_nonce($_POST['atto_license_nonce'],'atto_licence')) { $licence_data = get_site_option('atto_licence'); $licence_key = $licence_data['key']; //build the request query $args = array( 'woo_sl_action' => 'deactivate', 'licence_key' => $licence_key, 'product_unique_id' => ATTO_PRODUCT_ID, 'domain' => ATTO_INSTANCE ); $request_uri = ATTO_UPDATE_API_URL . '?' . http_build_query( $args , '', '&'); $data = wp_remote_get( $request_uri ); if(is_wp_error( $data ) || $data['response']['code'] != 200) { $atto_interface_messages[] = array( 'type' => 'error', 'text' => sprintf( __('There was a problem connecting to %s', 'atto'), ATTO_UPDATE_API_URL)); return; } $response_block = json_decode($data['body']); $response_block = $response_block[count($response_block) - 1]; if(isset($response_block->status)) { if($response_block->status == 'success' && $response_block->status_code == 's201') { //the license is active and the software is active $atto_interface_messages[] = array( 'type' => 'updated', 'text' => $response_block->message); $licence_data = get_site_option('atto_licence'); //save the license $licence_data['key'] = ''; $licence_data['last_check'] = time(); update_site_option('atto_licence', $licence_data); } else //if message code is e104 force de-activation if ($response_block->status_code == 'e002' || $response_block->status_code == 'e104' || $response_block->status_code == 'e211') { $licence_data = get_site_option('atto_licence'); //save the license $licence_data['key'] = ''; $licence_data['last_check'] = time(); update_site_option('atto_licence', $licence_data); } else { $atto_interface_messages[] = array( 'type' => 'error', 'text' => sprintf(__('There was a problem deactivating the licence: %s', 'atto'), $response_block->message)); return; } } else { $atto_interface_messages[] = array( 'type' => 'error', 'text' => sprintf(__('There was a problem with the data block received from %s', 'atto'), ATTO_UPDATE_API_URL)); return; } } if (isset($_POST['atto_licence_form_submit']) && isset($_POST['atto_licence_activate']) && wp_verify_nonce($_POST['atto_license_nonce'],'atto_licence')) { $licence_key = isset($_POST['licence_key'])? sanitize_key(trim($_POST['licence_key'])) : ''; if($licence_key == '') { $atto_interface_messages[] = array( 'type' => 'error', 'text' => __("Licence Key can't be empty", 'atto')); return; } //build the request query $args = array( 'woo_sl_action' => 'activate', 'licence_key' => $licence_key, 'product_unique_id' => ATTO_PRODUCT_ID, 'domain' => ATTO_INSTANCE ); $request_uri = ATTO_UPDATE_API_URL . '?' . http_build_query( $args , '', '&'); $data = wp_remote_get( $request_uri ); if(is_wp_error( $data ) || $data['response']['code'] != 200) { $atto_interface_messages[] = array( 'type' => 'error', 'text' => sprintf( __('There was a problem connecting to %s', 'atto'), ATTO_UPDATE_API_URL )); return; } $response_block = json_decode($data['body']); //retrieve the last message within the $response_block $response_block = $response_block[count($response_block) - 1]; if(isset($response_block->status)) { if($response_block->status == 'success' && ( $response_block->status_code == 's100' || $response_block->status_code == 's101' ) ) { //the license is active and the software is active $atto_interface_messages[] = array( 'type' => 'updated', 'text' => $response_block->message); $licence_data = get_site_option('atto_licence'); //save the license $licence_data['key'] = $licence_key; $licence_data['last_check'] = time(); update_site_option('atto_licence', $licence_data); } else { $atto_interface_messages[] = array( 'type' => 'error', 'text' => sprintf(__('There was a problem activating the licence: %s', 'atto'), $response_block->message)); return; } } else { $atto_interface_messages[] = array( 'type' => 'error', 'text' => sprintf(__('There was a problem with the data block received from %s', 'atto'), ATTO_UPDATE_API_URL)); return; } } } function licence_form() { ?>


My Account.', 'atto' ), array('a' => array('href' => array(), 'target' => array())) ), esc_url('https://www.nsp-code.com/premium-plugins/my-account') ); ?>


licence->is_local_instance() ) { ?>

Local instance, no key applied.

-xxxxxxxx-xxxxxxxx    

My Account', 'atto' ), array('a' => array( 'href' => array(), 'target' => array() )) ), esc_url('https://www.nsp-code.com/premium-plugins/my-account/') ); ?>