Plugin Directory

Changeset 3265881


Ignore:
Timestamp:
04/02/2025 07:28:54 PM (12 months ago)
Author:
vasyltech
Message:

Official 1.3.0

Location:
aam-protected-media-files
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • aam-protected-media-files/trunk/application/Handler.php

    r3096891 r3265881  
    99
    1010namespace AAM\AddOn\ProtectedMediaFiles;
     11
     12use AAM_Service_Uri;
    1113
    1214/**
     
    127129    {
    128130        // First, let's check if URI is restricted
    129         \AAM_Service_Uri::getInstance()->authorizeUri('/' . $this->request);
     131        AAM_Service_Uri::getInstance()->authorizeUri('/' . $this->request);
    130132
    131133        $media = $this->findMedia();
     
    274276        $filename = realpath(urldecode($filename));
    275277
    276         if (is_string($filename) && $this->_isAllowed(realpath($filename))) {
     278        if (is_string($filename) && $this->_isAllowed($filename)) {
    277279            if (empty($mime)) {
    278280                if (function_exists('mime_content_type')) {
  • aam-protected-media-files/trunk/bootstrap.php

    r3096891 r3265881  
    44 * Plugin Name: AAM Protected Media Files
    55 * Description: Manage access to a physical file and prevent from a direct access
    6  * Version: 1.2.5
     6 * Version: 1.3.0
    77 * Author: Vasyl Martyniuk <vasyl@vasyltech.com>
    88 * Author URI: https://vasyltech.com
     
    1515namespace AAM\AddOn\ProtectedMediaFiles;
    1616
     17use AAM;
     18
    1719require_once __DIR__ . '/application/Handler.php';
     20require_once __DIR__ . '/application/HandlerV7.php';
    1821
    1922/**
     
    3538     *
    3639     * @var Bootstrap
     40     * @access private
    3741     *
    38      * @access private
    3942     * @version 1.0.0
    4043     */
     
    4548     *
    4649     * @return void
     50     * @access protected
    4751     *
    4852     * @since 1.1.0 Adding new setting to the AAM Settings area
    4953     * @since 1.0.0 Initial implementation of the method
    5054     *
    51      * @access protected
    5255     * @version 1.1.0
    5356     */
     
    5760            add_filter(
    5861                'aam_settings_list_filter',
    59                 array($this, 'registerContentOptions'),
    60                 10,
    61                 2
     62                function($options, $type) {
     63                    return $this->_register_additional_settings($options, $type);
     64                }, 10, 2
    6265            );
    6366        }
     
    7174     *
    7275     * @return array
     76     * @access private
    7377     *
    74      * @access public
    75      * @version 1.1.0
     78     * @version 1.3.0
    7679     */
    77     public function registerContentOptions($options, $type)
     80    private function _register_additional_settings($options, $type)
    7881    {
    7982        if ($type === 'content') {
    80             $options['addon.protected-media-files.settings.deniedRedirect'] = array(
    81                 'title'       => __('Use Access Denied Redirect For Restricted Media Items'),
    82                 'description' => __('When direct access to a physical file is restricted, the default behavior is to return HTTP 401 (Unauthorized) response. If you enable this option, the Access Denied Redirect rule applies instead.'),
    83                 'value'       => \AAM::api()->getConfig(
    84                     'addon.protected-media-files.settings.deniedRedirect', false
    85                 )
     83            if (self::is_v7()) {
     84                $key   = 'addon.protected_media_files.settings.denied_redirect';
     85                $value = AAM::api()->config->get($key, false);
     86            } else {
     87                $key   = 'addon.protected-media-files.settings.deniedRedirect';
     88                $value = AAM::api()->getConfig($key, false);
     89            }
     90
     91            $options[$key] = array(
     92                'title'       => __(
     93                    'Use Access Denied Redirect For Restricted Media Items',
     94                    'aam-protected-media-files'
     95                ),
     96                'description' => __(
     97                    'When direct access to a physical file is restricted, the default behavior is to return HTTP 401 (Unauthorized) response. If you enable this option, the Access Denied Redirect rule applies instead.',
     98                    'aam-protected-media-files'
     99                ),
     100                'value'       => $value
    86101            );
    87102        }
     
    94109     *
    95110     * @return void
     111     * @access public
    96112     *
    97      * @access public
    98      * @version 1.0.0
     113     * @since 1.3.0 Ability to handle AAM v6 & v7
     114     * @since 1.0.0 Initial implementation of the method
     115     *
     116     * @version 1.3.0
    99117     */
    100     public static function onInit()
     118    public static function on_init()
    101119    {
    102         Bootstrap::getInstance();
     120        Bootstrap::get_instance();
    103121
    104122        // Check Media Access if needed
    105123        if (filter_input(INPUT_GET, 'aam-media')) {
    106             Handler::bootstrap()->authorize();
     124            if (self::is_v7()) {
     125                HandlerV7::bootstrap()->authorize();
     126            } else {
     127                Handler::bootstrap()->authorize();
     128            }
    107129        }
     130    }
     131
     132    /**
     133     * Check if AAM is V7
     134     *
     135     * @return boolean
     136     * @access public
     137     *
     138     * @version 1.3.0
     139     */
     140    public static function is_v7()
     141    {
     142        return version_compare(AAM_VERSION, '7.0.0-alpha.1') >= 0;
    108143    }
    109144
     
    112147     *
    113148     * @return Bootstrap
     149     * @access public
    114150     *
    115      * @access public
    116151     * @version 1.0.0
    117152     */
    118     public static function getInstance()
     153    public static function get_instance()
    119154    {
    120155        if (is_null(self::$_instance)) {
     
    129164     *
    130165     * @return void
     166     * @access public
    131167     *
    132      * @access public
    133168     * @version 1.0.0
    134169     */
     
    138173
    139174        if (version_compare(PHP_VERSION, '5.6.40') === -1) {
    140             exit(__('PHP 5.6.40 or higher is required.'));
     175            exit(__('PHP 5.6.40 or higher is required.', 'aam-protected-media-files'));
    141176        } elseif (version_compare($wp_version, '5.0.0') === -1) {
    142             exit(__('WP 5.0.0 or higher is required.'));
     177            exit(__('WP 5.0.0 or higher is required.', 'aam-protected-media-files'));
     178        } elseif (!defined('AAM_KEY')) {
     179            exit(__(
     180                'Free Advanced Access Manager plugin is required to be active.',
     181                'aam-protected-media-files'
     182            ));
    143183        }
    144184    }
     
    148188if (defined('ABSPATH')) {
    149189    // Init hook
    150     add_action('init', __NAMESPACE__ . '\Bootstrap::onInit');
     190    add_action('init', __NAMESPACE__ . '\Bootstrap::on_init', PHP_INT_MAX);
    151191
    152192    // Activation hooks
  • aam-protected-media-files/trunk/readme.txt

    r3096891 r3265881  
    55Requires PHP: 5.6.0
    66License: GPLv2 or later
    7 Tested up to: 6.5.3
    8 Stable tag: 1.2.5
     7Tested up to: 6.7.2
     8Stable tag: 1.3.0
    99
    1010Add-on to the free Advanced Access Manager plugin that protects media files from direct access for visitors, roles or users
     
    3737
    3838== Changelog ==
     39
     40= 1.3.0 =
     41* Added: Introduced updated to support upcoming AAM 7 version
    3942
    4043= 1.2.5 =
Note: See TracChangeset for help on using the changeset viewer.