Skip to content

Instantly share code, notes, and snippets.

View crimann's full-sized avatar

Claudio Rimann crimann

View GitHub Profile
@crimann
crimann / gutenberg.txt
Created May 5, 2022 06:21 — forked from chrismccoy/gutenberg.txt
Gutenberg Resources
Turning Off Reusable Blocks
https://tomjn.com/2021/04/05/turning-off-reusable-blocks/
Turning Off The Block Directory
https://tomjn.com/2021/03/31/turning-off-the-block-directory/
How to Disable the WordPress Block Directory
https://typewheel.xyz/disable-wordpress-block-directory/
Custom previews for ACF Gutenberg Blocks
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@crimann
crimann / readme.md
Created November 5, 2021 18:20 — forked from wpmark/readme.md
An example of caching data using a WordPress transient

Caching WordPress data using Transients - Example

In this simple example we create a function for obtaining data from an external source and caching it for 24 hours. You can use the function hd_get_external_data() to get the data and work with it in your site.

If you want to force a refresh of the cache, you can pass a value of true into the function.

You can place the code into your themes functions.php file or better still in a plugin. If you are placing it in a plugin, remember to use function_exists() when using this. This ensures that the code will fail correctly if the plugin is not active.

@crimann
crimann / wp-config.php
Created August 5, 2021 21:50 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@crimann
crimann / editor-customization.js
Created June 1, 2021 17:29
Gutenberg gallery block-variation to link to media file by default
// Gallery block
wp.blocks.registerBlockVariation(
'core/gallery', {
isDefault: true,
attributes: {
linkTo: 'file',
}
}
);
// Image block
@crimann
crimann / privacy-capabilities.php
Created May 7, 2021 14:06
Allow privacy editing for all users that can edit pages
<?php
/**
* Add privacy options to the capabilities of all user
* roles that can edit pages (instead of only admins)
*/
function prefix_manage_privacy_options( $caps, $cap, $user_id, $args ) {
if ( !is_user_logged_in() ) {
return $caps;
}
@crimann
crimann / image-sizes-for-custom-post-type
Last active May 4, 2021 21:19
WordPress - Add Image Sizes for Custom Post Type
<?php
/**
* Use our custom image sizes only for our custom post type
*
*/
function custom_image_sizes_filter( $sizes ) {
// Check if a 'post_id' is set and abort otherwise
if ( !isset( $_REQUEST['post_id'] ) ) {
return $sizes;