I realize this is a bit of a strange question, but to put a long story short, we have a few Wordpress installs whose files are loaded through a symbolic link (the symlink is in the document root whereas Wordpress is not).
For this to work, I need to have a list of all Wordpress files that are usually loaded directly from the web browser (either by the user or through AJAX), such as: index.php, wp-login.php, (all theme files)* ...
An example of files that are not loaded directly: wp-load.php, wp-config.php, wp-blog-header.php...
[*] Theme files are an exception; they actually exist in the document root.
Edit: You might wonder, what is the point of this? It is so that we can cut down on the extra files on the server; it's useless to have thousands of identical files from each Wordpress website. The wp-content directory has been left there since it's what changes between websites. Am I aware of the consequences of such a set up? I believe I am.
Edit 2:
http://codex.wordpress.org/WordPress_Files
Here is a list of entry points based on require( 'wp-load.php' );
https://github.com/szepeviktor/WPHW/blob/master/wp-entry-points.md
And a Trac ticket about their deficiencies
https://core.trac.wordpress.org/ticket/28364
So far, the following fixes my issue:
ln -s /var/www/vhosts/mainsite/httpdocs/index.php /var/www/vhosts/subsite/httpdocs/index.php
ln -s /var/www/vhosts/mainsite/httpdocs/wp-login.php /var/www/vhosts/subsite/httpdocs/wp-login.php
ln -s /var/www/vhosts/mainsite/httpdocs/wp-admin /var/www/vhosts/subsite/httpdocs/wp-admin
ln -s /var/www/vhosts/mainsite/httpdocs/wp-includes /var/www/vhosts/subsite/httpdocs/wp-includes
Related
I'm working on a wordpress site hosted on an AWS Lightsail instance (Bitnami) and i'd like to have version control to work on our site themes with a coworker.
I like the idea of just having to git pull to make changes to the site.
In the wordpress folder (that contains wp-admin, licences, wp-config.php, etc...), there is the wp-content folder but it's a symbolic link that points outside the wordpress folder to root/bitnami/wordpress/wp-content. I can't use git in the wordpress folder but I can set it up in the root/bitnami/wordpress/wp-content but it feels like bad practice since it asks me for admin privileges for every command line.
Is there a reason the wp-content folder is a symbolic link that points to outside the wordpress folder or is it just a mistake from the person who set things up?
Is it okay to use git to bypass an ftp client in this case?
So I just had this same issue today, and I resolved this by moving the directories for .../wp-content to the location of the symlinks and deleting the symlinks.
This was my process (though you could delete the symlinks first):
Move wp-content mv /bitnami/wordpress/wp-content /location/of/wordpress/temporary-directory-name
Delete symlinks rm -f /location/of/wordpress/
Rename temporary-directory-name using move mv /location/of/wordpress/temporary-directory-name /location/of/wordpress/wp-content
You can then repeat the same steps for the wp-config.php file. Once this was done I was able to verify Wordpress was still working on my LightSail instance. Hope this helps
This might be a stupid question but I am not able to locate the "views" directory inside my WordPress install!
I need to do some work in media-views.js, which is located in wp/includes/js directory. At line 2291, it has the entry:
media.view.AttachmentFilters = require( './views/attachment-filters.js');
I tried
sudo find ~/ -type f -name 'attachment-filters.js'
sudo find / -type f -name 'attachment-filters.js'
(staying at WordPress installation root) but did not find the file.
When I tried to search views directory with
sudo find . -type d -name "views"`
it only fetched
./wp-content/plugins/akismet/views!
Please help!
General answer
As I understood, the wp-includes/js/media is only in the source code (in github). Those are js modules that are then concatenated and transformed by their build pipeline.
See this issue: https://core.trac.wordpress.org/ticket/28510
Split javascript files in media into modules: This will only affect the src/ directory in the develop repository, which will use our build process to concatenate into the build/ directory, so nothing will change for developers using the build/ directory or the core repo.
We'll start this effort with media, and end up with a standardized way of doing this going forward.
To better understand how all of this works, I suggest this article https://make.wordpress.org/core/2015/01/22/the-case-for-js-modules/, which explains the WordPress Backbone more in depth.
As for your specifiy need
In WordPress, you use themes, plugins, hooks and filters to customize your site. You don't alter the source code directly !
If your need is to define custom attachment filters, you need to use filters, they are there precisely for that. Have a look at https://code.tutsplus.com/articles/quick-tip-add-extra-media-type-filters-to-the-wordpress-media-manager--wp-25998 for an example.
I'm currently trying to use VVV to develop and test my plugins. My host OS is Win10.
My plugins are in D:\Workshop\projects\vendor\module. I've used this folder structure for a long time, and it is really convenient, especially for use with Composer and friends.
Now I've installed VVV, created a site with VV. I want to test a plugin, the source code of which is in D:\Workshop\projects\XedinUnknown\my-project. So, I create a symlink in D:\Workshop\projects\XedinUnknown\vvv-local\www\my-test-site\htdocs\wp-content\plugins that points to that project's folder. Alas, it doesn't work. If I SSH into VVV and ls /srv/www/my-test-site/htdocs/wp-content/plugins, I can see my-project there, but it points to ../../../../../../../XedinUnknown/my-project, which, of course, doesn't exist. If instead of symlink I create a junction, it's just an empty file.
I suspect that this has to do with how the Linux environment handles Windows symlinks, but I'm not entirely sure. Is it possible to make this work somehow? I really don't wanna copy the whole project folder into VVV.
This is also addressed here.
So, it would seem like I've found somewhat of a solution. I added a synched folder, which maps to my projects home. I then create a symlink to that folder from the WP plugins directory, inside the VM.
Step 1 - Add Shared Folder
This should be done in a Customfile as explained here. This file should go into the same directory as the Vagrantfile, e.g. it will become the Vagrantfile's sibling. In my case, if you're following along from my question, it is in D:\Workshop\projects\XedinUnknown\vvv-local. Anything put here becomes global for the whole of VVV. This also gives you the ability to use different combinations of your projects in different websites. Add these contents to your Customfile, creating it if it does not exist.
config.vm.synced_folder "D:/Workshop/projects", "/srv/projects", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]
Of course, you should replace D:/Workshop/projects with the path to where you store your projects. Note the forward slashes (/). This works on Win/Nix. For a Windows-only configuration, I suspect you'd have to replace them with \\, because this is an escape sequence.
Step 2 - Add Link to Project
This should be done in your site's vvv-init.sh file. In my case, this file was in D:\Workshop\projects\XedinUnknown\vvv-local\www\my-test-site\, because I want to create this symlink specifically for the my-test-site site. Please note that your VVV path will probably be different, and it doesn't have to be inside the projects directory. It's wherever you cloned VVV into. Add the below lines to your site's vvv-init.sh file.
if [ ! -f "htdocs/wp-content/plugins/my-project" ]; then
echo 'Creating symlink to plugin project...'
cd ./htdocs/wp-content/plugins
ln -s /srv/projects/XedinUnknown/my-project my-project
cd -
fi
In the above snippet, change the path to your desired project path, keeping in mind that /srv/projects/ now maps live to the projects root in your host OS. You can also replace the second occurrence (last word) of my-project in ln -s /srv/projects/XedinUnknown/my-project my-project with whatever you want. As long as you don't change it later, your plugin should not suddenly get de-activated.
Also, from what I understood, vvv-init.sh runs during provisioning, not every time the machine is brought up. So, if you want to run the code in there, you have to run vagrant up --provision from the VVV directory. If you don't want to provision, you can run it manually. SSH into VVV with vagrant ssh, then cd /srv/www/my-test-site (replace my-test-site with name of your site), and run . vvv-init.sh.
Afterword
I am quite new to Bash scripting, and I don't know if my solution is the best one, so please feel free to suggest better versions of the Bash script. I also don't know Ruby, and am new to Vagrant, so please feel free to suggest improvements to the Customfile - this is in essence the same as the Vagrantfile.
One possible issue that I can anticipate with this solution (and this is inherently by design of the filesystem architecture) is that if WordPress decides to make changes to your plugin, e.g. if you run a WP update, it will effectively delete all files in your project, including the repository. So, on the testing site I would recommend using something like this. I am in no way associated with this plugin.
Hi and thanks for reading my question.
Its my first so please be gentle as im not a programmer but a barge captain, and curious ))
The situation:
I run a small website and we want to serve more languages, the website is based on Wordpress multisite.
After trying various translation solution we decided to go with transposh.
That plugin enables us to translate content easily and it becomes available at domain.com/en domain.com/fr etcetera those directory´s are virtual.
As we have different domain names for different languages i needed a solution to have the content of domain.com/en on domain2.com
What i did was to set the cache directory (static html) of domain.com as webroot of domain2.com. A fairly simple solution and it works like a charm.
The only problem i face is that the menu items link back to the domain.com and not domain2.com
I tried to make urls relative via wp core and two plugins but as the trailing /en or /fr is virtual making the urls relative just links back to domain.com
I have spend two days googling and im realy out of ideas. I tried different php script for search and replace, cgi scripts, perl scripts but none seem to do the job. I dont have shell access.
I was wondering if its posible to do smth like that with mod rewrite and if posible then how?
simply put:
static html site with wrong links
can i change the links via htaccess or other method which is easy (relatively) to understand and maintain?
The cache gets rebuild now and then of course
This is solved by an other approach:
Instead of using the cache i creatd a cronjob with wget:
/usr/bin/wget -np -P /destination-eg-yourwebroot/ --html-extension -nH -p -k -r http://domain.com
This creates a html copy of your website in the webroot of the new domain
For some reason wget does not always update the links in the copy, so they will point to original domain
We can run the command again but then prepend it with /usr/bin/wget -nc -k
/usr/bin/wget -nc -k -np -P /destination-eg-yourwebroot/ --html-extension -nH -p -k -r http://domain.com
It will update the links correctly, including css urls
U now have a clean copy of your website on a different domain
I inside my httpdocs(www), i created a folder called "bin", i put an "test.html" just to display "Hello Stackoverflow", but when I go access the page, i.e http://domain.com/bin/test.html, it says Page Cannot Be Found. But when I move the file to test folder, it display what it should be. Why?
In general, the default config, as part of generally good security practice won't be configured to do anything that isnt normal (like doing stuff other than executing stuff in the bin directory, or stuff that wouldnt normally happen in the base directory). In general, I'd say you should be trying to fit in with this, rather than going against the grain.
Possibly permissions.
chmod 755 /Path/To/Bin/
chmod 644 /Path/To/Bin/test.html
Apart from the evident "check permissions" answer and asuming you are using Apache server you may need to add a .htaccess file with the right permissions in each folder.
Look for .httaccess in other folders and remember to use ls -a ( file begining with dot are hidden by default -a = All )
By the way, it may be a bad practice to put html files in a binary folder.