I would like to edit the WordPress files before installation to my needs.
For each WordPress installation I am changing certain settings, pages, posts and the theme. So I would like to make these changes once and have my changes applied by the installation.
Here you can find the normal WordPress files: https://de.wordpress.org/download/#download-install
I followed this post to stop posts and pages from being created and also found some code in wp-admin/includes/upgrade.php to define pages to start out with.
How to delete the default hello world post BEFORE Wordpress install
From this post I took the info to set the starting theme, which can be found in wp-includes/default-constants.php. But that post had a warning to "NEVER EVER edit the CORE files" – kanlukasz
Set WordPress default settings before installing
So my questions are:
How to activate plugins on installation?
How to edit the settings on installation, like time format, media upload format and avatar format-> false
How to properly set the theme before installation?
Happy for every answer or pointers to other topics.
There's three main parts to a WordPress install, which I'll generally (although arbitrarily) identify as pre-work, installation, and setup.
The commands below assume you have WP-CLI installed and available on your system. They make no assumptions about your server, be it Apache, Nginx or IIS (except for rewrite which only works with Apache). At our company we actually use the Symfony CLI binary for local development server since we get a TLS cert and proxy.
As noted in the comments, you can also go down a different path using composer, and the most common one is probably the Bedrock install. I'm not going to touch on that, they've got plenty of documentation.
Pre-work
In this phase you need to get the database setup, create the directory to hold WordPress and download it, and create a wp-config.php file. You can do all of this from the CLI, too, although your commands might vary for the database depending on your version and flavor.
In this example I'm creating a database named t_low with a username and password of the same.
# Setup database
mysql -uroot -p -e "CREATE DATABASE t_low; GRANT ALL PRIVILEGES ON t_low.* TO t_low#localhost IDENTIFIED by 't_low';"
# Download WordPress
mkdir t-low
cd t-low
wp core download
# Create config
wp config create --dbname=t_low --dbuser=t_low --dbpass=t_low
Installation
This is fairly straight-forward, pretty much the options you'd see if you went through the web GUI. On development sites I don't bother with passwords because they just clog up my password manager, too, but could be provided here if you want to.
# Install WordPress
wp core install --url="https://t-low.wip" --title="Demo Site" --admin_user="person#example.com" --admin_email="person#example.com" --skip-email
Setup
At this point, WordPress is technically installed, so this is where you can change/tweak/delete things like plugins, themes and settings. Obviously don't run all of these blindly, take a moment to think through what they do and if they are applicable for you. Most of these are part of my company's default install.
# Install and optionally activate plugins
wp plugin install health-check --activate
wp plugin install one-time-login --activate
# Remove existing plugins
wp plugin delete hello
wp plugin delete akismet
# Remove extra themes
wp theme delete twentytwentyone
wp theme delete twentytwentytwo
# Turn on debugging
wp config set WP_DEBUG true
wp config set WP_DEBUG_LOG true
wp config set WP_DEBUG_DISPLAY true
# Delete sample data
wp post delete $(wp post list --post_type='post' --format=ids)
wp post delete $(wp post list --post_type='page' --format=ids)
# Set rewrite structure
wp rewrite structure '/%year%/%monthnum%/%postname%/'
# Disable avatars
wp option set show_avatars 0
# Change the time format
wp option set time_format "Y-m-d"
Your next question might be "how do I know what options to change" and that one is trickier. Sometimes you can just run wp option list and find an option that is obvious to change. Other times you might need to run that command and save the output somewhere, make the change in the GUI backend, then re-run the command to see the difference.
With all CLI commands you can append --help to get a better understanding of things. You can also find info online, but I think the CLI is more descriptive.
There's also several third-party WP CLI packages to install that you might find helpful, and some plugins even ship with their own. For instance, on most of my sites I install the one-time-login plugin wp plugin install one-time-login --activate so that I can do wp user one-time-login chris#example.com to get a magic login link and not have to worry about passwords.
Lastly, you can very easily write your own commands. There's a little bit of boilerplate stuff that you need to get down, but otherwise it is pretty straightforward WP/PHP code then.
Also, for plugins that aren't in the main directly you can still install them via a zip file or URL:
wp plugin install file.zip --activate
wp plugin install https://example.com/file.zip --activate
Some of those plugins, such as ACF, allow you to store activation keys in wp-config.php, which is really awesome. This is not universal, however, and totally up to the plugin developer.
wp config set ACF_PRO_LICENSE "XYZ"
Related
I'm using valet+ and Wordpress 5.9 on a local environment.
I have a simple task of updating some new terms of my payment module.
They are located under wp-content/plugins/my-plugin/languages/my-plugin.* where * represents .pot and -pt_BR.mo and -pt_BR.po files.
Some old terms are still working in the admin, even if I remove everything in this folder and refresh the page. The new terms are not being translated at all.
I already tried to restart valet (php, nginx, etc), and also used wp-cli cache flush command.
Am I missing something here? Or is there any other place to look for translation cache that I am leaving behind?
It turned out that wordpress was loading another file located under wpcontent/languages/plugin/my-plugin.*.
Removing those files solved the problem. No cache cleaning or restart was needed on local environment.
I have a quite strange problem with a Wordpress site. I manage a few Wordpress sites but I never experienced this problem. A plugin gets automatically installed after few days. In addition it is a maintenance plugin, called Maintenance from Webfactoryltd. But every time I delete or just deactivate this plugin, it gets reactivated / installed again and switches to maintenance mode.
This is a premium site buyed on themeforest (flatsome), but I don't think it has something to do with the premium template.
I tried following things:
Delete / Deactivate the plugin
Deactivate all plugins and reactivate only needed ones (Woocommerce)
Deactivate all caching plugins (Redis, WP Optimize)
Deactivate the automatic updater in config.php
Deactivate all automatic updates on the plugins itself
Installed Crontrol (plugin) to maybe get a cronjob which is responsible for that
Nothing worked. Has someone an idea what I can try now? Thanks in advance!
You can set limit file permission for .htaccess, wp-config.php for 444. Also, set recommended folder permissions.
You can install Wordfence & scan to see results where the file is affected & fixed it.
You can run also, virus scanner from the Cpanel account.
My site was compromised. Thanks to the link of Justinas I could take further steps to deal with this issue.
I could pinpoint the problem to a user (client) which I think run some scripts from it. The Wordfence Plugin helped with that a lot. I restricted the user and reset the password.
I also used Wordpress FAQ - My Site was hacked for orientation in this case.
Especially thanks to #Justinas for the report.
I have 2 environments for WordPress (dev && production), I'm working on dev env, when I add some new plugins, some will create tables or update
configs in DB, how can I handle all these changes and then migrate to production env's DB?
I'm using git for file changes, but I can't handle the DB changes which created by plugins. How to integrate these changes in git? Or other workarounds?
I'm using a WordPress docker image, and I mounted an existing folder to /var/www/html
I upload the mounted folder to git for version control.
Except to manage all changes in version control tool.
Update:
I'm using wordpress 5.2.2.
How can I put a database under git (version control)? This one is the same. But looks like a little difference.
As this answer says, keep both data dump and schema dump. Is data dump have a correct diff info with previous? So that I can manually add this change to something like liquibase's changeset?
My concern is just the DB changes which changed by 3rd-part plugin, and I will hardly to trace.
Here's is what we do. Any proper plug in will initialize new DB tables/fields on activation, and remove DB tables/fields when the plug-in is deactivated. In this way the plug in itself handles all DB migration functions. We write our plugins in this way, and nearly all plug-ins work in a similar fashion. We just commit plugin code to git, test in Dev, then release to production, and activate. Boom database is migrated.
Nearly all database changes are driven by new plugins installation. Let it manage the database via it's own activate /deactivate hooks.
My Problem
I manually installed WordPress on a Debian 9 VM in Virtual Box on a Windows 10 machine. When I pull up the website, this is what I get:
A WordPress site with just HTML, no formatting
The point of this install was to learn how to make a custom WordPress theme. I have built child themes before, but never a theme from scratch, so it may be I don't have everything set up yet. But there is a second issue is WordPress does not give me an option to select my second theme either.
What I did
To set up the site, I followed this tutorial on setting up WP on a Debian system. I sort of touched up on this, but I am new to WP development. I thought this was a quick and dirty route to set up a WP install. I don't have the knowledge of WordPress to know if there is an error in this setup guide.
Again, I checked the themes folder. I could not find the custom theme I started to build as an option. I can't currently download themes straight from WP because I don't have an FTP server/client currently installed on my machine. If it were just the inability to choose a WordPress theme from the WordPress theme repository, I'd suspect it's the FTP setup. But, I also can't choose my custom theme. So is there something wrong with the install?
Summary
I can't get any formatting to work on my WP development site. I suspect it's some problem with themes, but I don't know enough about the internals WordPress to know how to diagnose the problem.
Thank you for your time
It's tough to say without seeing your setup exactly, but this is often caused by URL problems.
Are you able to access wp-admin? If so, try logging in and visiting the settings > permalinks page, then just hitting the save button.
Try reloading your site. It might be fixed.. If not, a little more to try. First, I'd open your browser's Console / Inspect mode, and see if there are any console errors (showing CSS files not loading, etc). If so, post them here.
Additionally, I found a helpful article that details some other things to try when this problem pops up:
http://wphelp24.com/how-to-fix-wordpress/how-to-fix-wordpress-css-not-loading/
Embarrising enough, I created this particular plugin. Works great, but in testing, this happens:
1. Install plugin via WP Dashboard zip installer.
1a. Works great; fully functional.
2. Deactivate & delete files via WP Dashboard.
3. Reinstall plugin (#1 above).
- Issue: In the theme's plugin folder, a sequential number is appended to the plugin's folder, e.g. "my-plugin" becomes "my-plugin1"
This is a very light weight plugin, only loads a form, script, CSS file, shortcodel. - no SQL tables, no user settings, etc.
Any ideas? I've never repeatedly installed, removed, then reinstalled a plugin, so this is a new thing for me.
Thanks!