• Harmonic Design

    (@harmonic_design)


    Hello Emre,
    First of all, thanks for this amazing plugin. I use it on all of my sites, and force all clients to use it as well ??

    I have a question about how the set_content_url() function uses the WPFC_WP_CONTENT_URL definition.

    I see that you check to see if a plugin called hide-my-wp is enabled, and if it is, you then replace the wp_content folder with what I assume is a user-defined option on that other plugin. You then define("WPFC_WP_CONTENT_URL", $content_url);

    So my problem is that left alone, cached assets always show as /wp-content/, even if you’re someone like me who may have changed the folder to something like /core/.

    I can easily fix this myself by editing the WPFC and adding $content_url = str_replace(basename(WPFC_WP_CONTENT_DIR), "core", $content_url); above the define, but this os obviously not a good solution as it would revert on every update of WPFC.

    What are your thoughts about this? In the next version, could you perhaps add a hook to set_content_url(), so that developers can override the $content_url var?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Emre Vona

    (@emrevona)

    Thank you so much.

    Can you replace it unless using wp fastest cache?

    Thread Starter Harmonic Design

    (@harmonic_design)

    Hi Emre,
    I’m not 100% sure what you mean, but it is already replaced before wpfc action. So like, the path with be domain.com/core/ and then wpfc builds the cache and the cahced objects become domain.com/wp-content/. ONLY the minified cached assets get this treatment (which I should have probably mentioned before) – normal links are still treated fine.

    Plugin Author Emre Vona

    (@emrevona)

    now I got it. Do you have an idea?

    Thread Starter Harmonic Design

    (@harmonic_design)

    I haven’t gone deep into the wpfc code yet, but I’d imagine that the easiest way would be to look for a custom definition. Something like this;

    define("WPFC_CUSTOM_WP_CONTENT", "core"); // this could be defined by developers in functions.php, wp-config.php, or other plugins
    
    public function set_content_url()
    {
        $content_url = content_url();
    
        // Hide My WP
        if ($this->isPluginActive('hide_my_wp/hide-my-wp.php')) {
            $hide_my_wp = get_option("hide_my_wp");
    
            if (isset($hide_my_wp["new_content_path"]) && $hide_my_wp["new_content_path"]) {
                $hide_my_wp["new_content_path"] = trim($hide_my_wp["new_content_path"], "/");
                $content_url = str_replace(basename(WPFC_WP_CONTENT_DIR), $hide_my_wp["new_content_path"], $content_url);
            }
        } elseif (defined('WPFC_CUSTOM_WP_CONTENT')){
    	$content_url = str_replace(basename(WPFC_WP_CONTENT_DIR), WPFC_CUSTOM_WP_CONTENT, $content_url);
        }    
    
        if (!defined('WPFC_WP_CONTENT_URL')) {
            define("WPFC_WP_CONTENT_URL", $content_url);
        }
    
        $this->content_url = $content_url;
    }
    Plugin Author Emre Vona

    (@emrevona)

    how do you replace it? with wp native functions? or with manually?

    Thread Starter Harmonic Design

    (@harmonic_design)

    I believe I am using a similar method as Hide My WP. I’m not physically renaming folders, but am instead doing this via .htaccess and rewriting the buffer to replace strings.

    Plugin Author Emre Vona

    (@emrevona)

    it means that you did not follow a native method, right?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘set_content_url() / WPFC_WP_CONTENT_URL’ is closed to new replies.