After setup the PHP unit test on your Windows operating system maybe you get below error:
PHP Warning: require_once(/tmp/wordpress//wp-includes/class-phpmailer.php): failed to open stream: No such file or directory in C:\Users\MaheshW\AppData\Local\Temp\wordpress-tests-lib\includes\mock-mailer.php o
n line 2
Warning: require_once(/tmp/wordpress//wp-includes/class-phpmailer.php): failed to open stream: No such file or directory in C:\Users\MaheshW\AppData\Local\Temp\wordpress-tests-lib\includes\mock-mailer.php on lin
PHP Fatal error: require_once(): Failed opening required '/tmp/wordpress//wp-includes/class-phpmailer.php' (include_path='C:\xampp\php\PEAR') in C:\Users\MaheshW\AppData\Local\Temp\wordpress-tests-lib\includes\
mock-mailer.php on line 2
Fatal error: require_once(): Failed opening required '/tmp/wordpress//wp-includes/class-phpmailer.php' (include_path='C:\xampp\php\PEAR') in C:\Users\MaheshW\AppData\Local\Temp\wordpress-tests-lib\includes\mock-
mailer.php on line 2
In file C:\Users\MaheshW\AppData\Local\Temp\wordpress-tests-lib\wp-tests-config.php line 7 has code:
Before writing about how to create a website screenshot of website with CLI command, I think, I need to share some background.
Recently, I was working on some project in which I need to set 1000+ web page screenshots and resize them and set as a featured featured image for the post.
In this article I’ll just share how to capture the website screenshot with the CLI command. I’ll create another article to share how I was resize the screenshot and set the featured images in future articles.
Research About the Right Tool
I have research about this and found some below tools.
After executing the above command below screenshot is generated.
Both are added though JS by injecting it with custom JS file while creating screenshot.
In above command the parameter --script is used. In which the script.js is set. And in this JS file I have write the below code:
Don’t forget try below parameters too. These are interesting.
--width Page width [default: 1280]
--height Page height [default: 800]
--type Image type: png|jpeg [default: png]
--quality Image quality: 0…1 (Only for JPEG) [default: 1]
--scale-factor Scale the webpage n times [default: 2]
--list-devices Output a list of supported devices to emulate
--emulate-device Capture as if it were captured on the given device
--full-page Capture the full scrollable page, not just the viewport
--no-default-background Make the default background transparent
--timeout Seconds before giving up trying to load the page. Specify 0 to disable. [default: 60]
--delay Seconds to wait after the page finished loading before capturing the screenshot [default: 0]
--wait-for-element Wait for a DOM element matching the CSS selector to appear in the page and to be visible before capturing the screenshot
--element Capture the DOM element matching the CSS selector. It will wait for the element to appear in the page and to be visible.
--hide-elements Hide DOM elements matching the CSS selector (Can be set multiple times)
--remove-elements Remove DOM elements matching the CSS selector (Can be set multiple times)
--click-element Click the DOM element matching the CSS selector
--scroll-to-element Scroll to the DOM element matching the CSS selector
--disable-animations Disable CSS animations and transitions [default: false]
--script Same as --module, but instead injects the code as a classic script
--style Inject CSS styles into the page. Can be inline code, absolute URL, and local file path with .css extension. (Can be set multiple times)
--header Set a custom HTTP header (Can be set multiple times)
--user-agent Set the user agent
--cookie Set a cookie (Can be set multiple times)
--authentication Credentials for HTTP authentication
--debug Show the browser window to see what it’s doing
--launch-options Puppeteer launch options as JSON
--overwrite Overwrite the destination file if it exists
Hope you enjoy this article. Try it yourself and let me know for any question. Some useful link:
With this option we can export the translated project translated strings in below formats:
Android XML (.xml)
Portable Object Message Catalog (.po/.pot)
Machine Object Message Catalog (.mo)
.NET Resource (.resx)
Mac OS X / iOS Strings File (.strings)
Java Properties File (.properties)
Jed 1.x (.json)
I have create a fresh WordPress setup and created a plugin wpi18n.
In this plugin I have register a post type which store the original string as a post title.
And its translated language version in post meta.
I have downloaded the .po files of all the core projects from 4.1.x to dev with the help of WP CLI command wp wpi18n download_all_core_files
We have all the translated files of each core release of each language. To process all languages it takes too much time. So, I have added the individual language support for importing the translated strings.
The CLI command wp wpi18n import_translated_strings mr download the original & translated string in Marathi language.
After importing strings, I notice that there are lot of strings which are translated as different in different core projects.
E.g. The string Leave a comment is translated as below:
टिपणी करा (4-1-x)
प्रतिक्रिया लिहा (4-2-x)
टिपणी करा (4-3-x)
टिपणी करा (4-4-x)
टिपणी करा (4-5-x)
टिपणी करा (4-6-x)
टिपणी करा (4-7-x)
टिपणी करा (4-8-x)
टिपणी करा (4-9-x-development)
So, To keep the consistency I have used most repetitive strings as a translated strings. E.g.
(8 times) टिपणी करा
(1 times) प्रतिक्रिया लिहा
So, I have used string टिपणी करा to auto translate the string Leave a comment in theme and plugin.
Some other examples:
Example 2: String – Password: have 3 variations in Marathi (mr) language as below:
WordPress multisite introduces a new database table wp_blogmeta to store metadata associated with sites. This allows for the storage of arbitrary site data relevant in a multisite/network context.
It provides an alternative to using options and can be retrieved from multiple sites in a more performant way—without calling switch_to_blog(). Sites can now also be queried by their meta with parameters supported by WP_Meta_Query.
Note: A network update is required to install the new database table.
All of these functions are ONLY available in multisite, however they work similarly to other metadata wrapper functions, such as for posts, terms, comments and users. In addition to these functions, it is now possible to use the common meta query arguments when querying sites with WP_Site_Query or its wrapper get_sites().
Provided filter wp_update_php_url for a more dynamic approach on the code level. Replacing the URL should happen in cases where a more specific guide to update PHP on the given environment exists. E.g. screenshot:
Fatal Error Protection with the so-called WSOD protection (white-screen-of-death protection), A mechanism has been implemented to detect fatal errors and, in certain designated areas of WordPress, recover from them. E.g. Screenshot.
Note that, while the primary reason for implementing the fatal error protection mechanism was making the process of updating PHP less “dangerous”, it is technically not tied to the update at all. In fact, it will be enabled permanently and discover fatal errors under any circumstances.
The functionality can also be disabled entirely if that is preferred, via a new constant WP_DISABLE_FATAL_ERROR_HANDLER or, more dynamically, a corresponding wp_fatal_error_handler_enabled filter.
WordPress 5.1 will display a warning for those plugins that require a higher PHP version than the one currently active.