I’m developing plugins for a wordpress application hosted with OpenShift. I can clone the git repository from openshift, and I get a structure like this
âââ .openshift
â  âââ action_hooks
â  â  âââ build
â  â  âââ deploy
â  â  âââ post_deploy
â  â  âââ pre_build
â  âââ config
â  â  âââ wp-config.php
â  âââ cron
â  â  âââ README.cron
â  â  âââ daily
â  â  âââ hourly
â  â  âââ minutely
â  â  âââ monthly
â  â  âââ weekly
â  âââ languages
â  â  âââ .gitkeep
â  â  âââ plugins
â  âââ markers
â  â  âââ README
â  âââ openshift.inc
â  âââ pear.txt
â  âââ plugins
â  â  âââ .gitkeep
â  â  âââ myplugin.php
â  â  âââ buddypress
â  âââ themes
â  âââ .gitkeep
âââ README
âââ README.md
âââ libs
â  âââ .gitkeep
âââ misc
â  âââ .gitkeep
âââ php
âââ .gitkeep
When deploying to openshift with git push
, it automatically moves things to the correct location on the server.
I want to run a development instance locally and replicate that process. How can I move the plugins, themes, etc to the correct places in wp-content locally in the same way that openshift does on the server?
If you only change
WP_CONTENT_DIR
without changinWP_CONTENT_URL
as well, chances are you will see a broken themes both in the front-end and back-end. The reason is that WordPress will still fetch the resources fromyour_domain/wp-contents/themes/your_theme/
even though now you just already point wp-content to a different folder.Inspired by @bcole, I’ve tried an approach with less burden: which is to put your openshift repo folder under local wordpress folder.
Here’s the steps:
$ cd wordpress_folder
Cloen your openshift repo from remote:
$ git clone ssh://12345678asdf123@your_app-your_domain.rhcloud.com/~/git/your_app.git/
(you may get the remote url from your openshift dashboard after login)
Initiate your WordPress application locally (you may setup a localhost server and got through classic WordPress 5 minutes start up process)
Modify your
wp-config.php
file in your WordPress folder (not the one in.openshift/config
folder!)Add these two lines BEFORE
define('ABSPATH', dirname(__FILE__) . '/');
:define('WP_CONTENT_DIR', dirname(__FILE__) . '/your_app/.openshift');
define('WP_CONTENT_URL', '/your_app/.openshift');
your_app/.openshift/
git add
,git commit
, and thengit push
to remoteThe only difference to @bcole‘s approach is that we now put the openshift INSIDE the wordpress folder, not NEXT TO it. The benefit is that now we can define
WP_CONTENT_URL
in a more decent manner.Hope this would help!
One possibility for local development could be to create an instance of WordPress that is configured to look in all the right folders of the project repository without actually moving any of the project structure around. You can achieve this with a combination of symlinks, and wp-config options.
Possible setup for your project:
1. Create a local WordPress install
Put it anywhere, perhaps next to the main project repo.
2. Create a special local wp-config.php
Put it in the wordpress directory, or one level up.
You can create a clean wp-config file just for development, or you could do this if you need to use the wp-config in the project repo:
The option
WP_CONTENT_DIR
tells WordPress to go look in the folder.openshift
and treat it as if it were thewp-content
folder. So then it will look for ‘themes’ and ‘plugins’ in the.openshift
folder instead.Here is my setup, as another example
I have a git repo for WordPress that looks a bit like this:
Note the wordpress core files are off in their own folder, and all the development stuff is in
src
andwp-config.php
lives outside of everything and is git-ignored.This line in wp-config.php tells WordPress to go look in the development folder for everything:
And then it will look in ‘src’ for folders called ‘plugins’ and ‘themes’ and it’s as if ‘src’ is now the
wp-content
directory.Some caveats I learned along the way: It’s not possible to symlink the ‘themes’ or ‘plugins’ folder because WordPress uses PHP code that checks for the presence of actual directories. It IS possible to symlink the ‘uploads’ folder though.