Advertisement:

Author Topic: Question updated function in hTheme.php  (Read 546 times)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Question updated function in hTheme.php
« on: March 12, 2017, 07:38:07 pm »
Hi,

since I am doing a compare on files with regard to my current 3.6.1 production setup I notice a change/difference in my system with regard to the hTheme.php (helper file) and I wonder about the logic. This is the function latest 3.7.1:
Code: [Select]
    function osc_render_file($file = '') {
        if($file=='') {
            $file = __get('file');
        }
        // Clean $file to prevent hacking of some type
        osc_sanitize_url($file);
        $file = str_replace("../", "", str_replace("..\\", "", str_replace("://", "", preg_replace("|http([s]*)|", "", $file))));
        if(file_exists(osc_themes_path() . osc_theme() . "/plugins/" . $file)) {
            include osc_themes_path() . osc_theme() . "/plugins/" . $file;
        } else if(file_exists(osc_plugins_path() . $file)) {
            include osc_plugins_path() . $file;
        }
    }

My wondering is about the if else logic, it seems the first is meant to look for a theme file and the else for a plugin file. Which is the way I have it in my system/file at this moment. However in this code the plugins folder is added to the logic in the IF which looks as if in both cases only a plugin file is used.

What do you think? (might be something I have changed in earlier version or could be a difference added in 3.7.1, I don't remember but my version of the code looks to make more sense?


Regards,
Eric

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Question updated function in hTheme.php
« Reply #1 on: March 12, 2017, 09:38:37 pm »
No, you are reading it wrong. First, theme subfolder is used (as it allows theme developer or user to over-ride plugin's template file, usually it is meant for template/skinning), if not then fallback to plugin's original file.

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Question updated function in hTheme.php
« Reply #2 on: March 13, 2017, 02:32:28 am »
Thanks dev101, I will see what happens with my system if I change this. :)