connection = get_option( self::$connection_key, null ); if ( null === $this->connection && ( ! isset( $_GET['page'] ) || 'appsero_helper' != $_GET['page'] ) ) { add_action( 'admin_notices', [ $this, 'not_connected_notice' ] ); } add_action( 'admin_menu', [ $this, 'admin_menu' ] ); } /** * Generate the `Appsero Helper` menu * @return [type] [description] */ public function admin_menu() { add_options_page( 'Appsero Helper', 'Appsero Helper', 'manage_options', 'appsero_helper', [ $this, 'page_output' ] ); } /** * HTML output of the `Appsero Helper` page */ public function page_output() { if ( isset( $_POST['submit'] ) ) { $this->connection = $this->connect_with_appsero( $_POST ); } $token = isset( $this->connection['token'] ) ? $this->connection['token'] : ''; $action = ( $this->connection && isset( $this->connection['status'] ) && 'connected' == $this->connection['status'] ) ? 'Disconnect' : 'Connect'; ?>

Appsero Helper

error ) ) : ?>

error; ?>

success ) ) : ?>

success; ?>


Connect With AppSero

Create an API key on AppSero `API Key` page under top right navigation to connect this store with AppSero.

/>

You have not connected with AppSero in order to work Apsero Helper, Please connect using API key.

error = 'Token Is Required.'; return $form; } if ( 'Disconnect' == $form['_action'] ) { $option_value = [ 'token' => '', 'status' => 'disconnected', ]; update_option( self::$connection_key, $option_value, false ); $this->success = 'Disconnected Successfully.'; return $option_value; } $response = appsero_helper_remote_post( 'public/connect-helper', [ 'token' => $form['token'], 'url' => esc_url( home_url() ), 'api_prefix' => rest_get_url_prefix(), ] ); if ( is_wp_error( $response ) ) { $this->error = $response->get_error_message(); return $form; } $option_value = [ 'token' => $form['token'], 'status' => 'connected', ]; if ( 200 == $response['response']['code'] ) { update_option( self::$connection_key, $option_value, false ); } $response_array = json_decode( $response['body'], true ); if ( isset( $response_array['success'] ) ) { if ( $response_array['success'] ) { $this->success = $response_array['message']; return $option_value; } $this->error = $response_array['error']; return $form; } $this->error = 'Unknown Error Occurred.'; return $form; } }