5

in my header and other sections I would like to use

<script src="/incs/js/script.js"></script>

While maintaining the default theme folder structure in server as below

/wp-content/themes/theme-name/incs/js/script.js

file need to be accessed via browser/html source if need be so that it hides /wp-content/themes/theme-name

http://website.com/incs/js/script.js

This is also applicable to images I may have under /incs/images/imagname.jpg

I've seen solutions where defining the directory located outside of theme folder... but need a solution that does this within.

Is this possible?

Thanks

5 Answers 5

5

The easiest way to move your theme folder is only via constant; include the wp-content folder. You can set a constant for the plugin folder and wp-content folder. Then is your plugins and themes in separete url, also in the include in the source of the frontend.

like this example for my dev installs:

define( 'WP_CONTENT_DIR',  dirname( __FILE__ ) . '/wp-content' );
define( 'WP_CONTENT_URL',  'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );
// Custom plugin directory
define( 'WP_PLUGIN_DIR',   dirname( __FILE__ ) . '/wp-plugins' );
define( 'WP_PLUGIN_URL',   'http://' . $_SERVER['HTTP_HOST'] . '/wp-plugins' );
// Custom mu plugin directory
define( 'WPMU_PLUGIN_DIR', dirname( __FILE__ ) . '/wpmu-plugins' );
define( 'WPMU_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wpmu-plugins' );
3

Nowadays I use the technique I describe in this Q: Steps to Take to Hide the Fact a Site is Using WordPress?.

Before that, I used the Roots Theme method, which is what I think you are looking for:

This post contains information on how to clean up WordPress code output. The methods described below do not prevent actual fingerprinting and shouldn’t be looked at as any sort of security measure.

Note that it doesn't work in Multisite or Child Themes.


I'll reproduce here the documentation I did for using the Roots method:

Modifying .htaccess Rewrite Rules

Large chunk of code directly from the Roots theme:
https://gist.github.com/4336843 PasteBin mirror.
The array $roots_new_non_wp_rules has to be adapted accordingly.

Refresh permalinks

Go to /wp-admin/options-permalink.php and click Save Changes.

Load scripts from CDN and not from /wp-includes/

add_action( 'wp_enqueue_scripts', 'wpse_76593_scripts_custom' );

function wpse_76593_scripts_custom() {
        wp_deregister_script('jquery');
        wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', false, '1.7.1', true);
        wp_enqueue_script( 'jquery' );
}

Search the theme for all style and script registers and enqueues.

style.css

  1. create a new file inside the folder "/css" named "style.css"
  2. open the theme's style.css
  3. select all declarations bellow the theme file header
  4. cut and paste in the file /css/style.css
  5. save both in short: /your-theme/styles.css will contain only the header information, and /your-theme/css/styles.css will contain all the styles

    • change all occurrences of url('fonts/ with url('../fonts/
    • change all occurrences of images/ with ../images/

header.php

Change the stylesheet link from

<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />

to

<link rel="stylesheet" type="text/css" media="all" href="<?php echo get_template_directory_uri(); ?>/css/style.css" /> 

All theme files

Search for:

  • get_bloginfo('template_url')
  • get_bloginfo('template_directory')

and replace with:

  • get_template_directory_uri()

Testing

Not sure about other browsers, but Safari Activity Window is perfect to check all loaded files and its URLs.

Depending on the theme complexity, extra steps have to be taken.

3

I created the Roots Plug which has the same .htaccess rewrites as the Roots Theme. But completely agree with what @brasofolio said

1

This can be easily achieved by using 'hide my wp' plugin. Please change it's permalinks and url settings as shown below:

Change theme path under Permalinks & urls to /incs Change theme path under Permalinks & urls to /incs.

Once you have changed these settings, you will notice, bloginfo('template_url') will render http://website.com/incs/ and hence

 http://website.com/incs/js/script.js

Reference: http://howtomakewebsite.ws/wordpress-plugins/how-to-hide-wordpress/731/

1
  • You forgot to mention its a paid plugin? :( Commented Oct 30, 2017 at 10:14
-1

Why dont you use bloginfo(); default wordpress functions

<?php bloginfo( $show ); ?> 

<script src="<?php bloginfo('template_directory'); ?>/incs/js/script.js"></script>

more info http://codex.wordpress.org/Function_Reference/bloginfo

1
  • 2
    He wants to hide the output of bloginfo('template_directory') - he's not asking how to use it
    – Zach
    Commented Dec 19, 2012 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.