Category: Notes

  • Disable image optimisation on Pagely

    PressThumb can be disabled by renaming the pagely-pressthumb.php plugin in the mu-plugins directory to pagely-pressthumb.php.off.

    Pressthumb optimization can be re-enabled by renaming the file back to its original name.


  • Prevent WordPress image from being lazy loaded

    You need to set the loading attribute to eager.

    wp_get_attachment_image(
        $image_id,
        'full',
        false,
        [ 'loading' => 'eager' ], // Prevent image from being lazy loaded.
    );

  • Disable override of default search engine in SearchWP

    add_filter( 'searchwp\native\short_circuit', '__return_true' );

  • PHP function to detect empty index table in FacetWP

    FWP()->helper->get_row_counts();

  • Mobile menu not loading till after first user interaction on Mai Engine powered theme with WP Rocket

    Solution was to disable ‘Delay JavaScript execution’ under WP Rocket > Settings > File Optimization then clear the WP Rocket (and Cloudflare) caches.

    (Trying to exclude the Mai Engine files via the ‘Excluded JavaScript Files’ option under ‘Delay JavaScript execution’ with /wp-content/plugins/mai-engine/assets/js/min/(.*).min.js and similar didn’t work).


  • Google font not loading / broken after Pagely clone using a Mai Engine powered WordPress theme

    Not sure exactly where the fault lied, but the issue was the font was pointing to domain.com/dom12345/wp-content/fonts/ instead of domain.com/wp-content/fonts/.

    Running pagely-wp search-replace /dom12345/wp-content/fonts/ /wp-content/fonts/ was enough to solve it.


  • Get true or false from ACF field without using get_field()

    $is_enabled = (bool) get_post_meta( get_the_ID(), 'meta_key', true );
    

  • Add http basic auth to Pagely website

    http basic auth is handy when you want to add a username and password to stop anyone (including web crawlers) from accessing a website you’re working on, like a staging or development website.

    To add http basic auth in Pagely, go to to the Pagely Dashboard (atomic.pagely.com), go to Apps and choose the site you want to add http basic auth to.

    From there, choose the ARES tab and choose New Access Rule. Set the options you want – including the username and password – hit Save and then choose Deploy Changes.

    Anyone accessing the website in future will need to enter the username and password to proceed.

    Tip: if you’re on a Mac, you can save the username and password in Safari to save you having to re-enter it in future.


  • Run WP-CLI commands on Pagely without errors from PHP version

    I hit an issue on Pagely where I was running a WP-CLI command – via SSH – but I kept hitting a PHP fatal error.

    When I looked into the error it was because the site was running PHP 7.4, but WP-CLI on Pagely was running PHP 7.3 so my code was breaking on the command line.

    Turns out all you need to do is use pagely-wp instead of wp (thanks Kevin!) and the command will run at the correct version of PHP.

    So instead of:

    wp search-replace staging.website.com www.website.com
    

    Do:

    pagely-wp search-replace staging.website.com www.website.com
    

  • Fix Uncaught Error: Illegal offset type in vip-debug-bar-panels.php

    Receiving the following error when trying to add a new page in the WordPress admin on a local install of a WordPress VIP site:

    Fix Fatal error: Uncaught Error: Illegal offset type in isset or empty in mu-plugins/vip-helpers/vip-debug-bar-panels.php on line 384

    Fixed (locally) by modifying the function to return early:

    public function log_http_requests( $args, $url ) {
    	return $args;
    	/* ... */
    }