What should be disabled to run on an internal network with no access to the Internet?

After more fruitless searching, I stumbled across this article from WP Tavern which mentioned a plugin then called “WP Local Dev Environment,” now called Airplane Mode. The plugin blocks a long list of things that WordPress does which require checking something from the Internet. While it is intended to be toggled on or off depending … Read more

Using Multiple Queries of “home_url” vs. Calling a Variable Multiple Times

If you look at the source for the home_url() function, you’ll note a small series of function calls eventually invoking get_option(). As explained in this WPSE Answer, the get_option() function is cached, meaning that if an option’s value is already in memory, get_option() returns that value instead of querying the database again. As a result, … Read more

Hardcoding and WordPress Performance

This is a PHP question not related at all to WP, but since it was upvoted…. TL;Dr version – Compilres do this kind of micro optimizations much better then you, no point in even trying. lets look at what compilers will do with your question code // is this less efficient $meta = get_post_meta($post->ID,’meta’); $permalink … Read more

WordPress performance issue. Can I debug it?

You need to check the actual access logs, such as web, SSH, etc., and if you can access it, the MySQL log, too. That will show you what is possibly hitting the site at that time and let you differentiate between a huge unexplained web traffic spike from a bot and something that is happening … Read more

Disable Outbound Web Requests

Defining WP_HTTP_BLOCK_EXTERNAL constant (wp-config.php is good place to do this) would kill all outgoing network requests, other than those for hostnames, defined in WP_ACCESSIBLE_HOSTS. See source for details, doesn’t seem to be documented in Codex.

Performance impact of using functions in WordPress?

The overhead of PHP function as a mechanism is minimal. After all nearly everything going on is function calls. On a reasonable hardware you will have to ramp up function calls into thousands and tens of thousands to generate significant overhead (as opposed to doing same things with less function calls involved). Worth noting that … Read more

How to properly insert a stylesheet in wp_head

You can do it like this, put it in your functions.php : This is the correct way of doing it “the WordPress way”. <?php // Check if function exisits if (!function_exists(‘rg_templateScriptSetup’)) { // if not, create one function rg_templateScriptSetup() { // Register styles in WordPress wp_register_style(‘prefix-basic-css’, get_template_directory_uri(). ‘/css/basic-style.css’); // Register styles in WordPress wp_register_style(‘first-css’, get_template_directory_uri(). … Read more

Speeding Up Bulk Post Creation – wp_insert_post & update_post_meta

Siteground has WP-CLI installed and when you have WooCommerce installed it adds its own set of WP-CLI commands. See this: https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Overview With this your solution would be cleaner as it would go though WC’s API. Maybe you can also check for ideas how WC does it. I remember in the add/edit product UI there was … Read more

What is a reasonable get_num_queries() result?

Depends on the use case. But 100 def. says there’s something gone wrong. If you got a lot of custom tables and a lot of different stuff from different tables that you need to display on one page/request, then I’d say 40 is higher than usual. My personal framework does around 10-15(?) queries for a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)