This assunmes you're running wp in lando with php >= 8
services:
appserver:
build_as_root:| <?php | |
| /** | |
| * Function to resolve assets url with attached content hash. | |
| * | |
| * Browser cache mechanism is used to store locally once downloaded assets. This | |
| * improves website performance and saves network bandwidth. It may be also creating | |
| * a problem when a user visits your website and do not see the newest changes in assets | |
| * because the browser is serving an old file from cache. | |
| * |
| <?php | |
| // this snippet requires PHP 5.3+ | |
| add_action( 'wp_enqueue_scripts', function() { | |
| wp_register_style( 'atomic-blocks/ab-cta', '/path/to/atomic-blocks/css/ab-cta.css', array(), 1.0.0 ); | |
| } ); | |
| add_filter( 'render_block', function( $block_content, $block ) { | |
| if ( 'atomic-blocks/ab-cta' === $block['blockName'] ) { | |
| ob_start(); | |
| wp_print_styles( $block['blockName'] ); |
| /** | |
| * Title: Get gists | |
| * Author: Mattias Ghodsian | |
| * Description: List any users public gists | |
| * Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian | |
| * Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5 | |
| */ | |
| $profile_url = "https://api.github.com/users/mattiasghodsian/gists"; | |
| $options = array('http' => array('user_agent'=> $_SERVER['HTTP_USER_AGENT'])); |
| <?php | |
| /* | |
| * Disable Gutenberg globally | |
| * use this if you prefer one-liner | |
| * add_filter('use_block_editor_for_post', '__return_false'); | |
| */ | |
| function _thz_filter_disable_block_editor(){ | |
| return false; | |
| } | |
| add_filter( 'use_block_editor_for_post', '_thz_filter_disable_block_editor' ); |
| <?php | |
| namespace DeliciousBrains\Admin; | |
| use DeliciousBrains\DBI; | |
| class ACF { | |
| public function init() { | |
| add_filter( 'acf/settings/save_json', array( $this, 'get_local_json_path' ) ); |
| <?php | |
| /** | |
| * Set constants for Google Maps JS API key--used for ACF's backend map--and Google Maps | |
| * Embed API Key, used for generating maps on the site front end. | |
| * | |
| * @link https://developers.google.com/maps/documentation/javascript/get-api-key | |
| * @link https://developers.google.com/maps/documentation/embed/get-api-key | |
| */ | |
| const GOOGLE_MAPS_JS_API_KEY = 'MAPS-JS-API-KEY'; |
| <?php | |
| /** | |
| * Wasted half my evening trying to get this done. | |
| * Those seems to be the only settings that works for | |
| * downloading large repositories as zip/tarball | |
| * from GitHub with PHP and cURL. | |
| * | |
| * If you don't have to use PHP, then use cURL direcly: | |
| * curl -L -v -H "Authorization: token PERSONAL_ACCESS_TOKEN" https://api.github.com/repos/SOME_USER/SOME_REPO/zipball > dooone.zip | |
| */ |
WordPress Snippet
Adds the srcset and sizes attributes to ACF image uploads. Requires installation of the Advanced Custom Fields plugin.
NOTE: ACF image field must be set to return the ID.
NOTE: WordPress needs image sizes with equal aspect ratios in order to generate the srcset, and does not use srcset when images are added as "Full Size".
| <?php | |
| /** | |
| * Get the Yoast primary category from its post meta value, and displays it, with HTML markup. | |
| * If there is no primary category set, it displays the first assigned category. | |
| * | |
| * @param boolean $useCatLink Whether to link the category, if it exists | |
| * @return void | |
| */ | |
| function yourtheme_display_yoast_primary_category( $useCatLink = true ) { |