• airvzxf

    (@airvzxf)


    Merge + Minify + Refresh
    Version 1.6.12 | Por Launch Interactive
    Wordpress version: 4.6.1

    Error: WP was installed in subfolder
    The error is in file: merge-minify-refresh.php on line 440.
    The problem: The file_get_contents not found the file.

    Warning: file_get_contents(/home/alfaunif/public_html/wp-includes/js/jquery/jquery.js): failed to open stream: No such file or directory in /home/alfaunif/public_html/wp/wp-content/plugins/merge-minify-refresh/merge-minify-refresh.php on line 440

    In my case the WP was installed in /home/alfaunif/public_html/wp/wp-includes/ directory.

    I solve this problem and if you want you could add this lines to the core plugin to nobody has this problem again.

    Add lines to solve:

    class MergeMinifyRefresh
    Close to the line 40

    
    	private $wordpressdir = '';
    	private $wordpressdirWithSlash = ''; //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    

    public function __construct() {
    Close to the line 80

    
    	$this->root = $_SERVER["DOCUMENT_ROOT"];
    	$this->wordpressdir = parse_url(get_site_url(), PHP_URL_PATH);
    	$this->wordpressdirWithSlash = $this->wordpressdir . "/"; //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    

    public function inspect_scripts() {
    Close to the line 350

    
    				$script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    				if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    					$script_path = $this->wordpressdir . $script_path;
    				}
    				
    				//Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    				if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    					$script_path = $this->wordpressdir . $script_path;
    				}
    
    

    public function inspect_scripts() {
    Close to the line 418

    
    							$script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    							if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    								$script_path = $this->wordpressdir . $script_path;
    							}
    						
    							if(substr($script_path, -7) == '.min.js') {
    								$nomin_path = substr($script_path, 0, -7) . '.js';
    								if(is_file($this->root.$nomin_path)) {
    									$script_path = $nomin_path;
    									$log .= " - unminified version used";
    								}
    							}
    							
    							//Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    							if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    								$script_path = $this->wordpressdir . $script_path;
    							}
    

    public function inspect_stylescripts_footer() {
    Close to the line 510

    
    				$script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    				if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    					$script_path = $this->wordpressdir . $script_path;
    				}
    				
    				//Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    				if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    					$script_path = $this->wordpressdir . $script_path;
    				}
    

    public function inspect_stylescripts_footer() {
    Close to the line 540

    
    							$script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    							if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    								$script_path = $this->wordpressdir . $script_path;
    							}
    
    							if(substr($script_path, -7) == '.min.js') {
    								$nomin_path = substr($script_path, 0, -7) . '.js';
    								if(is_file($this->root.$nomin_path)) {
    									$script_path = $nomin_path;
    									$log .= " - unminified version used";
    								}
    							}
    							
    							//Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    							if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    								$script_path = $this->wordpressdir . $script_path;
    							}
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter airvzxf

    (@airvzxf)

    Sorry my code was a disaster, I re-comment with a great style code.

    class MergeMinifyRefresh
    Close to the line 40

    private $wordpressdir = '';
    private $wordpressdirWithSlash = ''; //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    

    public function __construct() {
    Close to the line 80

    $this->root = $_SERVER["DOCUMENT_ROOT"];
    $this->wordpressdir = parse_url(get_site_url(), PHP_URL_PATH);
    $this->wordpressdirWithSlash = $this->wordpressdir . "/"; //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    

    public function inspect_scripts() {
    Close to the line 350

    $script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    
    

    public function inspect_scripts() {
    Close to the line 418

    $script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    
    if(substr($script_path, -7) == '.min.js') {
    	$nomin_path = substr($script_path, 0, -7) . '.js';
    	if(is_file($this->root.$nomin_path)) {
    		$script_path = $nomin_path;
    		$log .= " - unminified version used";
    	}
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    

    public function inspect_stylescripts_footer() {
    Close to the line 510

    $script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    

    public function inspect_stylescripts_footer() {
    Close to the line 540

    $script_path = parse_url($this->ensure_scheme($wp_scripts->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($script_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    
    if(substr($script_path, -7) == '.min.js') {
    	$nomin_path = substr($script_path, 0, -7) . '.js';
    	if(is_file($this->root.$nomin_path)) {
    		$script_path = $nomin_path;
    		$log .= " - unminified version used";
    	}
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$script_path = $this->wordpressdir . $script_path;
    }
    
    Thread Starter airvzxf

    (@airvzxf)

    Oh! In some pages I have the same problem but right now with CSS.
    That could solve it if you add this lines.

    public function inspect_stylescripts_footer() {
    Close to the line 650

    $style_path = parse_url($this->ensure_scheme($wp_styles->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($style_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($style_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    

    public function inspect_stylescripts_footer() {
    Close to the line 700

    $style_path = parse_url($this->ensure_scheme($wp_styles->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($style_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($style_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    

    public function inspect_styles() {
    Close to the line 790

    $style_path = parse_url($this->ensure_scheme($wp_styles->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($style_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($style_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    

    public function inspect_styles() {
    Close to the line 850

    $style_path = parse_url($this->ensure_scheme($wp_styles->registered[$handle]->src), PHP_URL_PATH);
    if($this->wordpressdir != '' && substr($style_path, 0, strlen($this->wordpressdir)) != $this->wordpressdir) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    
    //Added by Israel Roldan @airvzxf on November 12, 2016. Solve the problem when the main WP directory is in subfolder.
    if(substr($style_path, 0, strlen($this->wordpressdirWithSlash)) != $this->wordpressdirWithSlash) {
    	$style_path = $this->wordpressdir . $style_path;
    }
    
    Thread Starter airvzxf

    (@airvzxf)

    We can improve this code and delete the variable wordpressdirWithSlash

    class MergeMinifyRefresh
    Close to the line 40
    DELETE THE LINE: private $wordpressdirWithSlash = ”;

    private $wordpressdir = '';
    // Doesn't add this line: private $wordpressdirWithSlash = '';

    public function __construct() {
    Close to the line 80
    DELETE THE LINE: $this->wordpressdirWithSlash = $this->wordpressdir . “/”;

    $this->root = $_SERVER["DOCUMENT_ROOT"];
    $this->wordpressdir = parse_url(get_site_url(), PHP_URL_PATH);
    // Doesn't add this line: $this->wordpressdirWithSlash = $this->wordpressdir . "/";

    And REPLACE all occurrences for this line to script_path:
    if(substr($script_path, 0, strlen($this->wordpressdirWithSlash)) != $this>wordpressdirWithSlash) {
    if(substr($script_path, 0, strlen($this->wordpressdir."/")) != $this->wordpressdir."/") {

    And REPLACE all occurrences for this line to style_path:
    if(substr($style_path, 0, strlen($this->wordpressdirWithSlash)) != $this>wordpressdirWithSlash) {
    if(substr($style_path, 0, strlen($this->wordpressdir."/")) != $this->wordpressdir."/") {

    • This reply was modified 8 years ago by airvzxf.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error: WP was installed in subfolder file_get_contents merge-minify-refresh.php’ is closed to new replies.