Category: WordPress
-
Remove Global Install of PHPCS
If you want to wipe the slate clean and remove all global installs of PHPCS and WordPress standards, you can follow these steps: For PHPCS (PHP CodeSniffer): For WordPress Coding Standards: Look for a line mentioning installed_paths. Replace /path/to/wpcs with the actual path you found. These commands should remove the global installations of both PHPCS…
-
PHPCS set up for just one specific WordPress project
Let’s get PHPCS set up for just one specific WordPress project. You can do this using Composer, which is a great way to manage dependencies on a per-project basis. This installs PHPCS in the project’s vendor directory. This should show WordPress among the available coding standards. By following these steps, PHPCS and the WordPress Coding…
-
Deactivate WordPress Plugins with WP-CLI
WP-CLI is a command line interface for WordPress. You can use it to manage your WordPress sites from the command line, including plugin management. Here is the command you can use to deactivate a plugin: Replace plugin-name with the actual name of the plugin you want to deactivate. If you want to deactivate all plugins,…
-
Multisite Blog URL Replacement using bash
If you have a multisite with lots and lots of blogs, updating the URL’s for each wp_{id}_options table can be difficult if you need to do it manually. Here’s how to use a bash script so you don’t bash in your head doing it table by table.
-
Disable Most Typography & Color Choices in WordPress
In your theme.json file in a Full Site Editor WordPress site, you can control and set up many settings for the site. You can even lock out choices for the site editor.
-
Output a WYSIWYG Field with ACF
To output a WYSIWYG (What You See Is What You Get) field with Advanced Custom Fields (ACF) in a WordPress template, you need to add a snippet of PHP code to your template file where you want the field’s content to appear. Firstly, you’ll need to create your WYSIWYG field using ACF. In the ACF…
-
All output should be run through an escaping function in WordPress
To escape output in PHP within WordPress, you can use the esc_html() function to convert special characters to their HTML entities. This is useful for preventing XSS (Cross-Site Scripting) attacks by ensuring that any user-provided data is properly sanitized before being outputted to the webpage
-
Translation Function for Hard-Coded String in WordPress
In WordPress, the recommended way to handle hard-coded strings that need to be translated is to use the __() function, which is a shorthand for the translate() function.
-
Allow HTML Tags while using an escaping function in WordPress
In WordPress, the esc_html() function is used to escape HTML entities in a string, which helps to prevent cross-site scripting (XSS) attacks. By default, this function will convert all HTML tags to their corresponding entities, including the <h1> tag. However, if you want to allow the <h1> tag in esc_html(), you can use the wp_kses()…