Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/oauth.tar
Назад
classes/route-base.php 0000644 00000002361 14721511154 0010763 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Classes; use ImageOptimization\Classes\Route; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Route_Base extends Route { const SITE_URL = 'https://my.elementor.com/connect/v1/'; protected $auth = true; protected string $path = ''; public function get_methods(): array { return []; } public function get_endpoint(): string { return 'connect/' . $this->get_path(); } public function get_path(): string { return $this->path; } public function get_name(): string { return ''; } public function get_permission_callback( \WP_REST_Request $request ): bool { $valid = $this->permission_callback( $request ); return $valid && user_can( $this->current_user_id, 'manage_options' ); } public function verify_nonce( $nonce = '', $name = '' ) { if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $nonce ) ), $name ) ) { wp_die( 'Invalid nonce', 'image-optimization' ); } } public function verify_nonce_and_capability( $nonce = '', $name = '', $capability = 'manage_options' ) { $this->verify_nonce( $nonce, $name ); if ( ! current_user_can( $capability ) ) { wp_die( 'You do not have sufficient permissions to access this page.' ); } } } classes/data.php 0000644 00000010706 14721511154 0007630 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Classes; use ImageOptimization\Modules\Oauth\Components\Connect; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Class Data */ class Data { const CONNECT_CLIENT_DATA_OPTION_NAME = 'image_optimizer_client_data'; const CONNECT_DATA_OPTION_NAME = 'image_optimizer_connect_data'; const OPTION_CONNECT_SITE_KEY = 'image_optimizer_site_key'; const OPTION_CONNECT_STATE = 'image_optimizer_connect_state'; const OPTION_ACTIVATION_STATE = 'image_optimizer_activation_state'; const OPTION_OWNER_USER_ID = 'image_optimizer_owner_user_id'; /** * set_client_data * @param $client_id * @param $auth_secret */ public static function set_client_data( $client_id, $auth_secret ) { update_option( self::CONNECT_CLIENT_DATA_OPTION_NAME, [ 'client_id' => $client_id, 'auth_secret' => $auth_secret, ], false ); } /** * get_client_data * @return array */ public static function get_client_data(): array { return get_option( self::CONNECT_CLIENT_DATA_OPTION_NAME, [ 'client_id' => '', 'auth_secret' => '', ] ); } /** * get_client_id * @return string */ public static function get_client_id(): string { return self::get_client_data()['client_id'] ?? ''; } /** * get_client_secret * @return string */ public static function get_client_secret(): string { return self::get_client_data()['auth_secret'] ?? ''; } /** * get_connect_data * * @param bool $force * * @return array|null */ public static function get_connect_data( bool $force = false ): array { static $connect_data = null; if ( $connect_data === null || $force ) { $connect_data = array_merge( [ 'access_token' => '', 'access_token_secret' => '', 'last_update' => 0, 'token_type' => 'bearer', 'user' => [], 'version' => 1, ], get_option( self::CONNECT_DATA_OPTION_NAME, [] ) ); } return $connect_data; } /** * set_connect_data * * @param array $data */ public static function set_connect_data( array $data = [] ): bool { $data['last_update'] = time(); $data['version'] = 1; update_option( self::OPTION_OWNER_USER_ID, get_current_user_id() ); return update_option( self::CONNECT_DATA_OPTION_NAME, $data ); } /** * get_access_token * @return false|mixed */ public static function get_access_token() { return self::get_connect_data()['access_token'] ?? false; } /** * get_connect_state * * @param bool $force * * @return false|mixed|null|string */ public static function get_connect_state( bool $force = false ) { $state = get_option( static::OPTION_CONNECT_STATE ); if ( ! $state || $force ) { $state = wp_generate_password( 12, false ); update_option( static::OPTION_CONNECT_STATE, $state, false ); } return $state; } /** * get_site_key * @return false|mixed|string|null */ public static function get_site_key() { $site_key = get_option( static::OPTION_CONNECT_SITE_KEY ); if ( ! $site_key ) { $site_key = md5( uniqid( wp_generate_password() ) ); update_option( static::OPTION_CONNECT_SITE_KEY, $site_key, false ); } return $site_key; } /** * delete_connect_state */ public static function delete_connect_state(): bool { return delete_option( static::OPTION_CONNECT_STATE ); } public static function get_activation_state(): string { return get_option( self::OPTION_ACTIVATION_STATE, '' ); } public static function set_activation_state( $state ): bool { return update_option( self::OPTION_ACTIVATION_STATE, $state ); } public static function delete_activation_state(): bool { return delete_option( self::OPTION_ACTIVATION_STATE ); } /** * reset connect data */ public static function reset(): void { self::delete_connect_state(); self::delete_activation_state(); delete_option( self::OPTION_OWNER_USER_ID ); delete_option( static::CONNECT_DATA_OPTION_NAME ); delete_option( self::CONNECT_CLIENT_DATA_OPTION_NAME ); delete_transient( Connect::STATUS_CHECK_TRANSIENT ); } public static function images_left(): int { $plan_data = Connect::get_connect_status(); if ( empty( $plan_data ) ) { return 0; } $quota = $plan_data->quota; $used_quota = $plan_data->used_quota; return max( $quota - $used_quota, 0 ); } public static function user_is_subscription_owner(): bool { $owner_id = (int) get_option( self::OPTION_OWNER_USER_ID ); return get_current_user_id() === $owner_id; } } rest/activate.php 0000644 00000003042 14721511154 0010032 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Rest; use ImageOptimization\Modules\Oauth\{ Classes\Route_Base, Components\Connect, }; use Throwable; use WP_REST_Request; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Activate extends Route_Base { const NONCE_NAME = 'image-optimization-activate-subscription'; protected string $path = 'activate'; public function get_name(): string { return 'activate'; } public function get_methods(): array { return [ 'POST' ]; } public function POST( WP_REST_Request $request ) { $this->verify_nonce_and_capability( $request->get_param( self::NONCE_NAME ), self::NONCE_NAME ); if ( ! Connect::is_connected() ) { return $this->respond_error_json( [ 'message' => esc_html__( 'Please connect first', 'image-optimization' ), 'code' => 'forbidden', ] ); } if ( Connect::is_activated() ) { return $this->respond_error_json( [ 'message' => esc_html__( 'Already activated', 'image-optimization' ), 'code' => 'bad_request', ] ); } if ( ! $request->get_param( 'license_key' ) ) { return $this->respond_error_json( [ 'message' => esc_html__( 'Missing license key', 'image-optimization' ), 'code' => 'bad_request', ] ); } $license_key = $request->get_param( 'license_key' ); try { Connect::activate( $license_key ); return $this->respond_success_json(); } catch ( Throwable $t ) { return $this->respond_error_json( [ 'message' => $t->getMessage(), 'code' => 'internal_server_error', ] ); } } } rest/version.php 0000644 00000001155 14721511154 0007722 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Rest; use ImageOptimization\Modules\Oauth\{ Classes\Route_Base, Components\Connect, }; use Throwable; use WP_REST_Request; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Version extends Route_Base { const NONCE_NAME = 'image-optimization-version'; protected string $path = 'version'; public function get_name(): string { return 'version'; } public function get_methods(): array { return [ 'GET' ]; } public function GET( WP_REST_Request $request ) { return $this->respond_success_json( [ 'version' => 1, ] ); } } rest/disconnect.php 0000644 00000001651 14721511154 0010367 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Rest; use ImageOptimization\Modules\Oauth\{ Classes\Data, Classes\Route_Base, Components\Connect }; use Throwable; use WP_REST_Request; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Disconnect extends Route_Base { const NONCE_NAME = 'image-optimization-disconnect'; protected string $path = 'disconnect'; public function get_name(): string { return 'disconnect'; } public function get_methods(): array { return [ 'POST' ]; } public function POST( WP_REST_Request $request ) { $this->verify_nonce_and_capability( $request->get_param( self::NONCE_NAME ), self::NONCE_NAME ); try { Connect::disconnect(); } catch ( Throwable $t ) { Data::reset(); return $this->respond_error_json( [ 'message' => $t->getMessage(), 'code' => 'internal_server_error', ] ); } return $this->respond_success_json(); } } rest/get-subscriptions.php 0000644 00000002217 14721511154 0011721 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Rest; use ImageOptimization\Modules\Oauth\{ Classes\Route_Base, Components\Connect, }; use Throwable; use WP_REST_Request; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Get_Subscriptions extends Route_Base { const NONCE_NAME = 'image-optimization-get-subscription'; protected string $path = 'get-subscriptions'; public function get_name(): string { return 'get_subscriptions'; } public function get_methods(): array { return [ 'POST' ]; } public function POST( WP_REST_Request $request ) { $this->verify_nonce_and_capability( $request->get_param( self::NONCE_NAME ), self::NONCE_NAME ); if ( ! Connect::is_connected() ) { return $this->respond_error_json( [ 'message' => esc_html__( 'Please connect first', 'image-optimization' ), 'code' => 'forbidden', ] ); } try { $subscriptions = Connect::get_subscriptions(); return $this->respond_success_json( $subscriptions ); } catch ( Throwable $t ) { return $this->respond_error_json( [ 'message' => $t->getMessage(), 'code' => 'internal_server_error', ] ); } } } rest/connect-init.php 0000644 00000002155 14721511154 0010630 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Rest; use ImageOptimization\Modules\Oauth\{ Classes\Route_Base, Components\Connect, }; use Throwable; use WP_REST_Request; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Connect_Init extends Route_Base { const NONCE_NAME = 'image-optimization-connect'; protected string $path = 'init'; public function get_name(): string { return 'connect-init'; } public function get_methods(): array { return [ 'GET' ]; } public function get( WP_REST_Request $request ) { $this->verify_nonce_and_capability( $request->get_param( self::NONCE_NAME ), self::NONCE_NAME ); if ( Connect::is_connected() ) { return $this->respond_error_json( [ 'message' => esc_html__( 'You are already connected', 'image-optimization' ), 'code' => 'forbidden', ] ); } try { $connect_url = Connect::initialize_connect(); return $this->respond_success_json( $connect_url ); } catch ( Throwable $t ) { return $this->respond_error_json( [ 'message' => $t->getMessage(), 'code' => 'internal_server_error', ] ); } } } rest/deactivate.php 0000644 00000002637 14721511154 0010354 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Rest; use ImageOptimization\Modules\Oauth\{ Classes\Data, Classes\Route_Base, Components\Connect }; use Throwable; use WP_REST_Request; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Deactivate extends Route_Base { const NONCE_NAME = 'image-optimization-deactivate-subscription'; protected string $path = 'deactivate'; public function get_name(): string { return 'deactivate'; } public function get_methods(): array { return [ 'POST' ]; } public function POST( WP_REST_Request $request ) { $this->verify_nonce_and_capability( $request->get_param( self::NONCE_NAME ), self::NONCE_NAME ); if ( ! Connect::is_connected() ) { return $this->respond_error_json( [ 'message' => esc_html__( 'Please connect first', 'image-optimization' ), 'code' => 'forbidden', ] ); } if ( ! $request->get_param( 'license_key' ) ) { return $this->respond_error_json( [ 'message' => esc_html__( 'Missing license key', 'image-optimization' ), 'code' => 'bad_request', ] ); } $license_key = $request->get_param( 'license_key' ); try { Connect::deactivate( $license_key ); return $this->respond_success_json(); } catch ( Throwable $t ) { Data::delete_activation_state(); return $this->respond_error_json( [ 'message' => $t->getMessage(), 'code' => 'internal_server_error', ] ); } } } module.php 0000644 00000001615 14721511154 0006546 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth; use ImageOptimization\Classes\Module_Base; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Class Module */ class Module extends Module_Base { /** * Get module name. * Retrieve the module name. * @access public * @return string Module name. */ public function get_name(): string { return 'oauth'; } public static function routes_list() : array { return [ 'Connect_Init', 'Disconnect', 'Get_Subscriptions', 'Activate', 'Deactivate', 'Version', ]; } public static function component_list() : array { return [ 'Connect', 'Checkpoint', 'Connect_Pointer', ]; } public static function is_active() : bool { return ! empty( get_option( 'image_optimizer_client_data' ) ); } public function __construct() { $this->register_components(); $this->register_routes(); } } components/connect.php 0000644 00000023246 14721511154 0011103 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Components; use ImageOptimization\Modules\Oauth\{ Classes\Route_Base, Components\Exceptions\Auth_Error, Classes\Data, }; use ImageOptimization\Classes\Logger; use ImageOptimization\Classes\Utils; use ImageOptimization\Modules\Settings\Module as Settings_Module; use stdClass; use Throwable; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Class Connect */ class Connect { const API_URL = 'https://my.elementor.com/api/connect/v1'; const STATUS_CHECK_TRANSIENT = 'image_optimizer_status_check'; /** * is_connected * @return bool */ public static function is_connected(): bool { return ! empty( Data::get_connect_data()['access_token'] ); } /** * is_activated * @return bool */ public static function is_activated(): bool { return ! empty( Data::get_activation_state() ); } /** * maybe_handle_admin_connect_page * @return bool */ public static function maybe_handle_admin_connect_page(): bool { if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'nonce_actionget_token' ) ) { return false; } $args = [ 'page' => 'elementor-connect', 'app' => 'library', 'action' => 'get_token', 'state' => Data::get_connect_state(), ]; foreach ( $args as $key => $value ) { if ( ! isset( $_GET[ $key ] ) || $_GET[ $key ] !== $value ) { return false; } } if ( ! isset( $_GET['nonce'] ) || ! isset( $_GET['code'] ) ) { return false; } return true; } /** * handle_elementor_connect_admin */ public function handle_elementor_connect_admin(): void { // validate args if ( ! self::maybe_handle_admin_connect_page() ) { return; } // validate nonce if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'nonce_actionget_token' ) ) { wp_die( 'Nonce verification failed', 'image-optimization' ); } $token_response = wp_remote_request( self::API_URL . '/get_token', [ 'method' => 'POST', 'body' => [ 'app' => 'library', 'grant_type' => 'authorization_code', 'client_id' => Data::get_client_id(), 'code' => sanitize_text_field( $_GET['code'] ), ], ] ); if ( is_wp_error( $token_response ) ) { wp_die( $token_response->get_error_message(), 'image-optimization' ); } $data = json_decode( wp_remote_retrieve_body( $token_response ), true ); Data::set_connect_data( $data ); do_action( Checkpoint::ON_CONNECT ); // cleanup Data::delete_connect_state(); wp_redirect( add_query_arg( [ 'page' => Settings_Module::SETTING_BASE_SLUG, 'connected' => 'true', ], admin_url( 'admin.php' ) ) ); die(); } /** * Gets required connection data from the service and generates a connect link. * * @return string User connect link * * @throws Auth_Error */ public static function initialize_connect(): string { try { $response = wp_remote_request( self::API_URL . '/library/get_client_id', [ 'method' => 'POST', 'body' => [ 'local_id' => get_current_user_id(), 'site_key' => Data::get_site_key(), 'app' => 'library', 'home_url' => trailingslashit( home_url() ), 'source' => 'image-optimizer', ], ] ); } catch ( Throwable $t ) { Logger::log( Logger::LEVEL_ERROR, 'Error while sending connection initialization request: ' . $t->getMessage() ); throw new Auth_Error( $t->getMessage() ); } $data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! isset( $data->client_id ) || ! isset( $data->auth_secret ) ) { Logger::log( Logger::LEVEL_ERROR, 'Invalid response from server: client id or auth secret are undefined' ); throw new Auth_Error( esc_html__( 'Invalid response from server', 'image-optimization' ) ); } Data::set_client_data( $data->client_id, $data->auth_secret ); return add_query_arg( [ 'utm_source' => 'image-optimizer-panel', 'utm_campaign' => 'image-optimizer', 'utm_medium' => 'wp-dash', 'source' => 'generic', 'action' => 'authorize', 'response_type' => 'code', 'client_id' => $data->client_id, 'auth_secret' => $data->auth_secret, 'state' => Data::get_connect_state( true ), 'redirect_uri' => rawurlencode( add_query_arg( [ 'page' => 'elementor-connect', 'app' => 'library', 'action' => 'get_token', 'nonce' => wp_create_nonce( 'nonce_action' . 'get_token' ), ], admin_url( 'admin.php' ) ) ), 'may_share_data' => 0, 'reconnect_nonce' => wp_create_nonce( 'nonce_action' . 'reconnect' ), ], Route_Base::SITE_URL . 'library' ); } /** * Disconnects a user and removes connection data from the DB. */ public static function disconnect() { do_action( Checkpoint::ON_DISCONNECT ); try { return wp_remote_request( self::API_URL . '/disconnect', [ 'method' => 'POST', 'body' => [ 'app' => 'library', 'home_url' => trailingslashit( home_url() ), 'client_id' => Data::get_client_id(), 'access_token' => Data::get_access_token(), ], ] ); } catch ( Throwable $t ) { Logger::log( Logger::LEVEL_ERROR, 'Error while sending disconnection request: ' . $t->getMessage() ); throw new Auth_Error( $t->getMessage() ); } finally { Data::reset(); } } /** * Sends an activation request and stores activation data in the DB. * * @param $license_key string License key to activate with. * @return mixed * * @throws Auth_Error */ public static function activate( string $license_key ) { try { $response = Utils::get_api_client()->make_request( 'POST', 'activation/activate', [], [ 'key' => $license_key ] ); } catch ( Throwable $t ) { Logger::log( Logger::LEVEL_ERROR, 'Error while sending activation request: ' . $t->getMessage() ); throw new Auth_Error( $t->getMessage() ); } if ( ! isset( $response->id ) ) { Logger::log( Logger::LEVEL_ERROR, 'Invalid response from server' ); throw new Auth_Error( esc_html__( 'Invalid response from server', 'image-optimization' ) ); } Data::set_activation_state( $license_key ); do_action( Checkpoint::ON_ACTIVATE, $license_key ); return $response; } /** * Deactivate specific license and remove activation data from the DB. * * @param $license_key string License key to deactivate. * * @return mixed * * @throws Auth_Error */ public static function deactivate( string $license_key ) { do_action( Checkpoint::ON_DEACTIVATE, $license_key ); try { $response = Utils::get_api_client()->make_request( 'POST', 'activation/deactivate', [ 'key' => $license_key, ] ); } catch ( Throwable $t ) { Logger::log( Logger::LEVEL_ERROR, 'Error while sending deactivation request: ' . $t->getMessage() ); throw new Auth_Error( $t->getMessage() ); } finally { Data::delete_activation_state(); } if ( ! isset( $response->id ) ) { Logger::log( Logger::LEVEL_ERROR, 'Invalid response from server' ); throw new Auth_Error( esc_html__( 'Invalid response from server', 'image-optimization' ) ); } return $response; } /** * Fetches and returns a list of available licenses for a specific user. * * @return array Available subscriptions or an empty array * * @throws Auth_Error */ public static function get_subscriptions(): array { try { $response = Utils::get_api_client()->make_request( 'POST', 'activation/get-subscriptions' ); } catch ( Throwable $t ) { Logger::log( Logger::LEVEL_ERROR, 'Error while fetching subscriptions: ' . $t->getMessage() ); throw new Auth_Error( $t->getMessage() ); } if ( ! isset( $response->subscriptions ) ) { Logger::log( Logger::LEVEL_ERROR, 'Invalid response from server' ); throw new Auth_Error( esc_html__( 'Invalid response from server', 'image-optimization' ) ); } return $response->subscriptions; } public static function get_connect_status() { if ( ! self::is_connected() ) { Logger::log( Logger::LEVEL_INFO, 'Status getting error. Reason: User is not connected' ); return null; } $cached_status = get_transient( self::STATUS_CHECK_TRANSIENT ); if ( $cached_status ) { return $cached_status; } $status = self::check_connect_status(); set_transient( self::STATUS_CHECK_TRANSIENT, $status, MINUTE_IN_SECONDS * 5 ); return $status; } private static function check_connect_status() { if ( ! self::is_connected() ) { Logger::log( Logger::LEVEL_INFO, 'Status check error. Reason: User is not connected' ); return null; } try { $response = Utils::get_api_client()->make_request( 'POST', 'status/check' ); } catch ( Throwable $t ) { Logger::log( Logger::LEVEL_ERROR, 'Status check error. Reason: ' . $t->getMessage() ); return null; } if ( ! isset( $response->status ) ) { Logger::log( Logger::LEVEL_ERROR, 'Invalid response from server' ); return null; } return $response; } public static function update_usage_data( stdClass $new_usage_data ) { $connect_status = self::get_connect_status(); if ( ! isset( $new_usage_data->allowed ) || ! isset( $new_usage_data->used ) ) { return; } if ( 0 === $new_usage_data->allowed - $new_usage_data->used ) { $connect_status->status = 'expired'; } $connect_status->quota = $new_usage_data->allowed; $connect_status->used_quota = $new_usage_data->used; set_transient( self::STATUS_CHECK_TRANSIENT, $connect_status, MINUTE_IN_SECONDS * 5 ); } public function __construct() { // handle connect if elementor is active add_action( 'load-elementor_page_elementor-connect', [ $this, 'handle_elementor_connect_admin' ], 9 ); // handle connect if elementor is not active add_action( '_admin_menu', [ $this, 'handle_elementor_connect_admin' ] ); } } components/connect-pointer.php 0000644 00000003417 14721511154 0012557 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Components; use ImageOptimization\Modules\Core\Components\Pointers; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Connect_Pointer { const CURRENT_POINTER_SLUG = 'image-optimization-auth-connect'; public function admin_print_script() { if ( Connect::is_connected() ) { return; } wp_enqueue_script( 'wp-pointer' ); wp_enqueue_style( 'wp-pointer' ); $pointer_content = '<h3>' . esc_html__( 'Start by connecting your license', 'image-optimization' ) . '</h3>'; $pointer_content .= '<p>' . esc_html__( 'You’re one click away from improving your site’s performance dramatically!', 'image-optimization' ) . '</p>'; ?> <script> jQuery( document ).ready( function( $ ) { console.log( $( '.image-optimization-stats-connect-button' ) ); const intervalId = setInterval( () => { if ( ! $( '.image-optimization-stats-connect-button' ).length ) { return; } clearInterval(intervalId); $( '.image-optimization-stats-connect-button' ).first().pointer( { content: '<?php echo $pointer_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>', pointerClass: 'image-optimization-auth-connect-pointer', position: { edge: 'top', align: <?php echo is_rtl() ? "'left'" : "'right'"; ?>, }, } ).pointer( 'open' ); }, 100 ); } ); </script> <style> .image-optimization-auth-connect-pointer .wp-pointer-arrow { inset-block-start: 4px; inset-inline-start: 78%; } .image-optimization-auth-connect-pointer .wp-pointer-arrow-inner { inset-block-start: 10px; } </style> <?php } public function __construct() { add_action( 'in_admin_header', [ $this, 'admin_print_script' ] ); } } components/exceptions/auth-error.php 0000644 00000000354 14721511154 0013716 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Components\Exceptions; use Exception; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Auth_Error extends Exception { protected $message = 'Auth error'; } components/checkpoint.php 0000644 00000002377 14721511154 0011603 0 ustar 00 <?php namespace ImageOptimization\Modules\Oauth\Components; use ImageOptimization\Classes\Utils; use ImageOptimization\Modules\Oauth\Classes\Data; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Class Checkpoint */ class Checkpoint { const ON_CONNECT = 'image-optimizer-connect'; const ON_DISCONNECT = 'image-optimizer-disconnect'; const ON_ACTIVATE = 'image-optimizer-activate'; const ON_DEACTIVATE = 'image-optimizer-deactivate'; /** * event * * @param array $event_data */ public static function event( array $event_data = [] ): void { $event_name = current_action(); // only allow specific events if ( ! in_array( $event_name, self::get_checkpoints() ) ) { return; } $response = Utils::get_api_client()->make_request( 'POST', 'status/checkpoint', [ 'event_name' => $event_name, 'event_data' => $event_data, ] ); } /** * get_checkpoints * @return string[] */ public static function get_checkpoints(): array { return [ self::ON_DISCONNECT, self::ON_CONNECT, self::ON_ACTIVATE, self::ON_DEACTIVATE, ]; } public function __construct() { foreach ( self::get_checkpoints() as $checkpoint ) { add_action( $checkpoint, [ __CLASS__, 'event' ], 10, 0 ); } } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка