文件操作 - Api.php
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/ionos-security/inc/Controllers/ActivationNotification/Api.php
编辑文件内容
<?php namespace Ionos\Security\Controllers\ActivationNotification; use WP_Error; use WP_HTTP_Response; use WP_REST_Response; /** * The REST API endpoints. */ class Api { /** * The Base URL for the API endpoints. */ const REST_BASE = 'ionos/activation-notification/v1'; /** * The user meta-key used to store the timestamp of the last update. */ const KEY = 'wordpress-security_activation-notification'; /** * Registers all APIs of this plugin */ public static function create_rest_routes() { register_rest_route( self::REST_BASE, '/set_timestamp', [ 'methods' => 'POST', 'callback' => [ __CLASS__, 'set_timestamp' ], 'permission_callback' => '__return_true', ] ); register_rest_route( self::REST_BASE, '/set_cookie', [ 'methods' => 'POST', 'callback' => [ __CLASS__, 'set_cookie' ], 'permission_callback' => '__return_true', ] ); } /** * Stores the timestamp into the user meta of the current user. * * @param array $req Request data. * * @return WP_Error|WP_HTTP_Response|WP_REST_Response */ public static function set_timestamp( $req ) { $state = false; if ( isset( $req['timestamp'] ) ) { $state = update_user_meta( get_current_user_id(), self::KEY, $req['timestamp'] ); } return rest_ensure_response( [ 'state' => (bool) $state ] ); } /** * Sets a cookie so that the warning is not displayed every time. * * @return WP_Error|WP_HTTP_Response|WP_REST_Response */ public static function set_cookie() { $url = parse_url( get_site_url() ); $cookie = setcookie( self::KEY, rand(), 0, '/wp-admin/', $url['host'], true, true ); return rest_ensure_response( [ 'state' => $cookie ] ); } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件