Blog

Advertisement

wp cli arguments vs associated arguments

In a recent article, we learn about the $assoc_args and $args in the WP CLI program. Now, Let’s try some examples of $args and $assoc_args. Note: If you read some recent articles then you can skip some below steps. Create Empty Plugin Create a new folder wordpress-examples into plugins directory /wp-content/plugins/ Create a file wordpress-examples.php

How to use the wp_parse_url() and wp_parse_str() functions

wp_parse_url() wp_parse_url() is wrapper function for PHP’s parse_url() function that handles consistency in the return values across PHP versions. Example 1: Let’s extract the scheme, host, and path from the URL https://maheshwaghmare.com/ by using the wp_parse_url(). The output of the above code is below: array (size=3) ‘scheme’ => string ‘https’ (length=5) ‘host’ => string ‘maheshwaghmare.com’

Understanding the WP CLI arguments

In a recent article, we learn about creating the first WP CLI Hello World program. If you read that article then you can skip some below steps. Now, We are going to understand the WP CLI arguments or $args parameter from the WP CLI command. First, we’ll create a simple plugin and then understand the

Advertisement

Create a first WP CLI Hello World Program

We learn how to install the WP CLI. Now, Let’s create a simple WP CLI hello world program. We are going to create a new plugin that contains the WP CLI hello world program. Create Empty Plugin Create a new folder wordpress-examples into plugins directory /wp-content/plugins/ Create a file wordpress-examples.php and add the below code

Adding image sizes with add_image_size() in WordPress

Introduction We can add custom image sizes with function add_image_size(). But, First, let’s discuss why we need custom images in WordPress? By default, WordPress provides 3 image sizes. Means, When we upload any image in WordPress media library then WordPress creates 3 image sizes for us. These image sizes are: Thumbnail (150×150) Medium (300×300) Large

How to fix error: To perform the requested action WordPress needs to access your web server

Overview WordPress will prompt you for FTP credentials If it does not have permission to write the files it needs to. Whenever this happens we can see the error: To perform the requested action, WordPress needs to access your web server. Please enter your FTP information to continue. If you do not remember your information,

Advertisement

Avoid Automatic Redirection or Canonical Redirection

Overview WordPress redirects the incoming links to the proper URL based on the site url. Search engines consider the link http://www.somedomain.com and somedomain.com to be two different URLs when they both go to the same location. This SEO enhancement prevents penalties for duplicate content by redirecting all incoming links to one or the other. Prevents

Enable allow_url_fopen from the php.ini file

we are going to see: Introduction allow_url_fopen is a filesystem and streams configuration option. Which enables the URL-aware fopen() wrappers that enable accessing URL objects like files. If allow_url_fopen() is enabled then by default we can access remote files using the FTP or HTTP protocol. Also, extensions like zlib may register additional wrappers. Issue We

How to Fix the ERROR: the “PHPCompatibilityWP” coding standard is not installed.

How to Check PHPCompatibilityWP exist? To check the PHPCompatibilityWP coding standard is installed on your system use command phpcs -i E.g. phpcs -i You can see the result like below: The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz, Zend, WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra and PHPCompatibility Maybe you have some additional coding standards

Advertisement

FIXED: PHP Unit test issue PHP Warning/Fatal error: Failed to open stream: No such file (mock-mailer.php) for windows

After setup the PHP unit test on your Windows operating system maybe you get below error: In file C:\Users\MaheshW\AppData\Local\Temp\wordpress-tests-lib\wp-tests-config.php line 7 has code: Here, ABSPATH return the invalid path. You can simply change the above code with below: NOTE: Here change the {USERNAME} with your own user name. To know the user name just open