• Resolved puggan

    (@puggan)


    The plugin ignores the WP_CONTENT_DIR and the UPLOADS constants.

    To get options-general.php?page=webpc_admin_page to stop complaining I made some changes:

    diff -Nurp -Z a/app/Media/Htaccess.php b/app/Media/Htaccess.php
    --- a/app/Media/Htaccess.php	2020-08-13 16:10:12.942727988 +0200
    +++ b/app/Media/Htaccess.php	2020-08-13 16:20:40.910026632 +0200
    @@ -17,7 +17,7 @@
     
         public function addRewriteRulesToWpContent($isActive)
         {
    -      $path = dirname(apply_filters('webpc_uploads_path', ''));
    +      $path = WP_CONTENT_DIR;
           if (!$isActive) return $this->saveRewritesInHtaccesss($path);
     
           $values = apply_filters('webpc_get_values', []);
    diff -Nurp -Z a/app/Settings/Paths.php b/app/Settings/Paths.php
    --- a/app/Settings/Paths.php	2020-08-13 16:10:12.942727988 +0200
    +++ b/app/Settings/Paths.php	2020-08-13 16:29:53.052319231 +0200
    @@ -4,12 +4,14 @@
     
       class Paths
       {
    -    private $pathUploads  = 'wp-content/uploads';
    -    private $pathOutput   = 'wp-content/uploads-webpc';
    +    private $pathUploads;
    +    private $pathOutput;
         private $dirsExcluded = ['.', '..', '.git', '.svn', 'node_modules'];
     
         public function __construct()
         {
    +      $this->pathUploads = wp_upload_dir()['basedir'];
    +      $this->pathOutput = $this->pathUploads . '/webpc';
           add_filter('webpc_uploads_path',   [$this, 'getUploadsPath'],  0,   2);
           add_filter('webpc_uploads_webp',   [$this, 'getOutputPath'],   0,   2);
           add_filter('webpc_uploads_path',   [$this, 'parsePath'],       100, 2);
    @@ -36,10 +38,13 @@
     
         public function parsePath($value, $skipRoot = false)
         {
    -      if ($skipRoot) return trim($value, '\/');
    +      if ($skipRoot) return trim($value, '/');
     
    +      if($value[0] === '/') {
    +          return '/' . trim($value, '\/');
    +      }
           $path = apply_filters('webpc_uploads_root', ABSPATH);
    -      return $path . '/' . trim($value, '\/');
    +      return $path . '/' . trim($value, '/');
         }
     
         public function getPrefixPath($value)
    

    In our setup we have /wp, /content, and /uploads, so the content dir isn’t the parent of uploads, and wp isn’t a parent of content.
    so the sugested filter didn’t work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter puggan

    (@puggan)

    Tha patch above dosn’t solve the invalid .htaccess-file.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @puggan,

    Thank you for your message.

    First of all, please read the plugin FAQ. There you have a question “How to change path to uploads?”. There it is explained how to change directory paths.

    Give it a try and I think you should come to a solution ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ignores upload and content paths’ is closed to new replies.