Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.
    airvzxf

    (@airvzxf)

    I installed the “Minify HTML” plugin and work very good with “Merge + Minify + Refresh” plugin.

    https://www.ads-software.com/plugins/minify-html-markup/

    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)

    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;
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)