Plugin Directory

Changeset 3323935


Ignore:
Timestamp:
07/07/2025 11:13:51 PM (9 months ago)
Author:
openvideo
Message:

fixes for custom path hosting

Location:
open-video/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • open-video/trunk/OpenVideoNamespace/Channels.php

    r3321428 r3323935  
    290290            // Check if the path matches our middleton rewrite rule regex
    291291            // Use the PHP-compatible regex for preg_match
    292             if (preg_match(self::MIDDLETON_PREG_MATCH_REGEX, $path)) {
     292            if (preg_match('#' . self::openvideoplugin_get_middleton_preg_regex() . '#', $path)) {
    293293                // This is a middleton path and only difference is trailing slash, prevent redirect
    294294                return false;
  • open-video/trunk/OpenVideoNamespace/RequestUtils.php

    r3321444 r3323935  
    5151            'Referer' => $site,
    5252            'X-OpenVideo-Wp-Referer' => $site,
     53            // X-OpenVideo-Original-Path is the original path requested by user.
     54            // since we may modify $path below for proxying openvideo channel paths
     55            'X-OpenVideo-Original-Path' => $path,
    5356            'User-Agent' => !empty($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field($_SERVER['HTTP_USER_AGENT']) : '',
    5457        );
    5558
     59        // If the path starts with the custom channel path as a full segment, replace it with 'openvideo/'
     60        $channel_path = OpenVideoPlugin_Channels::openvideoplugin_get_channel_path();
     61        $path_trimmed = ltrim($path, '/');
     62        $add_proxy_header = false;
     63        if (
     64            (strpos($path_trimmed, $channel_path . '/') === 0 || $path_trimmed === $channel_path) &&
     65            strpos($path_trimmed, 'openvideo/') !== 0 && $path_trimmed !== 'openvideo'
     66        ) {
     67            $remaining = '';
     68            if ($path_trimmed === $channel_path) {
     69                $remaining = '';
     70            } else {
     71                $remaining = substr($path_trimmed, strlen($channel_path) + 1); // +1 for the slash
     72            }
     73            $path = 'openvideo/' . ltrim($remaining, '/');
     74            $add_proxy_header = true;
     75        }
     76
     77        if ($add_proxy_header) {
     78            // this header tells open.video that the custom channel path was used
     79            $request_headers['X-OV-Proxy-Channel-Request'] = $channel_path;
     80        }
     81
    5682        $method = isset($_SERVER['REQUEST_METHOD']) ? sanitize_text_field($_SERVER['REQUEST_METHOD']) : 'GET';
    5783
    58         // If the path starts with the current channel path as a full segment, replace it with 'openvideo/'
    59         $channel_path = OpenVideoPlugin_Channels::openvideoplugin_get_channel_path();
    60         $path_trimmed = ltrim($path, '/');
    61         if (strpos($path_trimmed, $channel_path . '/') === 0 || $path_trimmed === $channel_path) {
    62             $remaining = '';
    63             if ($path_trimmed === $channel_path) {
    64                 $remaining = '';
    65             } else {
    66                 $remaining = substr($path_trimmed, strlen($channel_path) + 1); // +1 for the slash
    67             }
    68             $path = 'openvideo/' . ltrim($remaining, '/');
    69         }
    7084        $url = self::OPENVIDEOPLUGIN_MIDDLETON_API_ENDPOINT . $path;
    7185
  • open-video/trunk/README.txt

    r3321444 r3323935  
    66Tested up to: 6.8
    77Requires PHP: 7.0
    8 Stable tag: 1.0.1
     8Stable tag: 1.0.2
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2727
    2828== Changelog ==
     29= 1.0.2 =
     30* Bug fixes
     31
    2932= 1.0.1 =
    3033* Bug fixes
  • open-video/trunk/open-video.php

    r3321444 r3323935  
    1616 *
    1717 * @link              https://www.open.video/
    18  * @since             1.0.1
     18 * @since             1.0.2
    1919 * @package           Open.Video
    2020 *
     
    2323 * Plugin URI:        https://wordpress.org/plugins/open-video
    2424 * Description:       Open.Video allows you to easily embed videos to your site from the Open.Video Network.
    25  * Version:           1.0.1
     25 * Version:           1.0.2
    2626 * Requires at least: 6.1
    2727 * Requires PHP: 7.0
     
    4141 * Rename this for your plugin and update it as you release new versions.
    4242 */
    43 define('OPENVIDEOPLUGIN_VERSION', '1.0.1');
     43define('OPENVIDEOPLUGIN_VERSION', '1.0.2');
    4444
    4545global $openvideoplugin_regex;
Note: See TracChangeset for help on using the changeset viewer.