wordpress change themes location - wordpress

Usually all the wordpress themes are uploaded and saved over the server say http://example.com/wp-content/themes/ . I am developing a plug-in to change this path to something like http://xyz.com/themeFolder/ . So i have to develop such a functionality where my wordpress installation will be on one server and the themes and plug-ins folders will be on another server.
Any help, will be highly appreciated.
Thanks in advance to all the genius people out there :)

Since Version 2.6, you can move the wp-content directory, which holds your themes, plugins, and uploads, outside of the WordPress application directory.
Set WP_CONTENT_DIR to the full local path of this directory (no trailing slash), e.g.
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' );
Set WP_CONTENT_URL to the full URI of this directory (no trailing slash), e.g.
define( 'WP_CONTENT_URL', 'http://example/blog/wp-content');
SOURCE
Do not forget to check THIS page as well.

Related

Wordpress Default Directory Change

I am trying to change the default path of the WP default directories such as wp-content, wp-include etc to avoid wpscan.
I have tried using plugin would it possible to perform the same using manual techniques. I am using apache as a web server.
An example, I have tried:
RewriteRule ^cms_plugins/(.+) /wordpress/wp-content/plugins/$1 [L,QSA]
Thanks
Try the following steps to rename WP-Content Folder
Download the WP-Config.php file
Open and Edit the Wp-Config.php file to add the below line
define( 'WP_CONTENT_FOLDERNAME', ‘new_directry_name’ );
Change 'new_directory_name' to the name you want for your content folder.
Upload WP-Config.php file back to your server
Follow these steps to replace the WP_Content folder
Download WP-Config.php file
Open and add the below lines
define( 'WP_CONTENT_DIR', ‘new_directry_local_path’ );
define( 'WP_CONTENT_URL', 'http://new_directry_url' );
Change new_directory_local_path and http://new_directory_url to your local path and URL.
Upload back to your server

Pre-install and pre-activate wordpress plugin

I am trying to pre-install and pre-activate WordPress plugin(s) for my users.
The problem: I cannot fully setup the WordPress'es for them. Just setup database connection params, nothing more.
So using wp-cli is not possible, it requires to have the wp core to be installed.
Is there any way to pre-install and (!) pre-activate plugins using their default params?
make a folder "mu-plugins" in wp-content directory and put the plugin files in this folder you want to pre activated.
Option 1: Use Wordpress multisite, and network activate the plugins you want
Option 2: In wp-config setup a default theme define( 'WP_DEFAULT_THEME', 'twentyseventeen' );
In the default theme bundle in your plugins, and include them in your plugins folder.
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
activate_plugin( 'contact-form-7/wp-contact-form-7.php' );

How to redirect wordpress (installed inner directory) to main root address?

I've installed wordpress into a inner directory. like root/mysite . Why I didn't install it on root because there are so many addon domain installed, and I literally don't want to mess all addon domain folders with wordpress files inside root directory. My root directory is for www.example.com . And my wordpress site I've installed on root/mysite, so the url for that is www.example.com/mysites . Is there anyway to redirect www.example.com/mysites to www.example.com . As I said the only reason for not installing wordpress on my root, because I don't want to mess wordpress files, folders with other addon domain's folders on root.
So my main goal is showing a wordpress site on www.jimfahad.com that is installed on www.example.com/mysites. Is there any way?
Yes, you can leave the WordPress install and folders in mysites, but you have to copy the .htaccessfile and the index.php file to root. This will result in the visual URL of WordPress being in root (example.com), but the uploads, theme URLs, etc, being in example.com/mysites.
See the WordPress Codex > Giving WordPress Its Own Directory « Using a pre-existing subdirectory install on how to copy and edit the files:
1) Go to the General settings panel.
2) In the box for Site address (URL): change the address to the root
directory's URL. Example: http://example.com
3) Click Save Changes. (Do not worry about the error message and do
not try to see your blog at this point! You will probably get a
message about file not found.)
4) Copy (NOT MOVE!) the index.php and .htaccess files from the
WordPress (wordpress in our example) directory into the root directory
of your site—the latter is probably named something like www or
public_html. The .htaccess file is invisible, so you may have to set
your FTP client to show hidden files. If you are not using pretty
permalinks, then you may not have a .htaccess file. If you are running
WordPress on a Windows (IIS) server and are using pretty permalinks,
you'll have a web.config rather than a .htaccess file in your
WordPress directory.
5) Edit your root directory's index.php:
6) Open your root directory's index.php file in a text editor. Change
the line that says:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to the following, using your directory name for the WordPress core
files:
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
and save the file.
7) Login to your site (if you aren't still already). The URL should
still be http://example.com/wordpress/wp-admin/
8) If you have set up Permalinks, go to the Permalinks panel and
update your Permalink structure. WordPress will automatically update
your .htaccess file if it has the appropriate file permissions. If
WordPress can't write to your .htaccess file, it will display the new
rewrite rules to you, which you should manually copy into your
.htaccess file (in the same directory as the main index.php file.)

Blank Page Encountered When Moved Wp-content Directory Outside

I'm trying to install Wordpress with clean subversion repositories, as in http://codex.wordpress.org/Installing_WordPress_With_Clean_Subversion_Repositories. I have followed every step accordingly until the second last step, where it says 'You should now be able to view the site via the root URL (http://example.com)', and indeed I can see my website on, say, http://example.com.
Once I go to the final step of changing the wp-config.php though, http://example.com draws a blank page. I am quite sure the wp-config.php is the problem, i.e. Wordpress doesn't know that it should retrieve my wp-content contents from outside the core Wordpress directory. My directory structure is as such:
.htaccess
core/
custom/
wp-config.php
, where core/ holds the files checked out with Subversion, custom/ holds my themes/ and plugins/ directory, and wp-config.php contains the below lines:
define('WP_CONTENT_DIR', dirname(__FILE__) . '/custom');
define('WP_CONTENT_URL', 'http://example.com/custom');
I have tried other variations, like:
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/custom');
define('WP_CONTENT_URL', 'http://example.com/custom');
I have also tried hardcoding the local path, like:
define('WP_CONTENT_DIR', '/home/MYUSERNAME/example.com/custom');
define('WP_CONTENT_URL', 'http://example.com/custom');
, but none of the above works. Then I renamed the custom/ folder to wp-content/, but again nothing. I even went into Dreamhost to prevent redirecting http://example.com to http://www.example.com and vice versa, but again to no avail. I don't believe core/ is the problem, because I can access the Dashboard via http://example.com/core/wp-login.php, and the Dashboard says it can't detect my themes, which confirms my suspicion that WP doesn't know to retrieve the files from the custom/ folder.
By now, I have run out of ideas as to where could the problem be. Can anyone experienced in this area please give me some advice? Thanks a million.
Ensure that your statements come BEFORE the call for wp-settings.php, which is usually around line 90. Wp-settings (or more accurately default-constants.php) checks if the paths and URLs have already been defined, so you want to make sure you define them beforehand.
If that isn't the issue then check if $_SERVER['DOCUMENT_ROOT'] is returning the values you expect; you might have issues if working in a sub-directory.

WordPress Renaming Themes Folder

I'm wondering how I would rename the 'themes' folder in the wp-content. I've renamed my wp-content folder and the actual active theme folder name, but I'm after renaming the folder the themes are stored in.
/wp-content/themes/themename
the middle one lol.
Does anyone know how this would be achieved?
The following will enable the directory "t", in the root of the site, to be used as an extra Themes directory
register_theme_directory( '/www/htdocs/username/public_html/t' );
I think you'd like this thread: Steps to Take to Hide the Fact a Site is Using WordPress?
This is usefull if you want to keep plugins and uploads in ex. separate server for CDN purpose (NFS) and remove public/www permission. In this case you only deploying themes instead of plugins, uploads etc.
define('WP_CONTENT_DIR', __DIR__ . '/data/wp-content');
define('WP_CONTENT_URL', 'http://{your-url/to-blog}/wp-content');
define('WP_PLUGIN_DIR', __DIR__ . '/data/wp-content/plugins');
define('WP_PLUGIN_URL', 'http://{your-url/to-blog}/wp-content/plugins');
$wp_theme_directories = array(__DIR__ . '{/directory-to-themes}');
define('WP_DEFAULT_THEME', '{your-default-theme}');
Remember:
1. Order of lines in wp-config is important
2. Keep themes folder in wp-content (even if it will be empty)

Resources