Skip to content

Instantly share code, notes, and snippets.

VA79 vanaf1979

Block or report user

Report or block vanaf1979

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View disable-gutenberg-gradients.php
<?php
/**
* disable_editor_gradients.
*
* Disable gradient coors in the gutenberg editor.
*
* @see https://since1979.dev/snippet-011-custom-gutenberg-gradient-colors/
*
* @uses add_theme_support() https://developer.wordpress.org/reference/functions/add_theme_support/
View custom-gutenberg-gradients.css
// Light blue to white
.has-light-blue-to-white-gradient-background {
background: linear-gradient(180deg, rgba(0,101,155,0.5) 0%, rgba(255,255,255,1) 100%);
}
// Blue to white
.has-blue-to-white-gradient-background {
background: linear-gradient(180deg, rgba(0,101,155,1) 0%, rgba(255,255,255,1) 100%);
}
View custom-gutenberg-gradients.php
<?php
/**
* theme_custom_gradients.
*
* Add custom gradients to the Gutenberg editor.
*
* @see https://since1979.dev/snippet-011-custom-gutenberg-gradient-colors/
*
* @uses add_theme_support() https://developer.wordpress.org/reference/functions/add_theme_support/
View get-posts-by-multiple-meta-values.php
<?php
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'os',
'value' => array('MacOs','Linux'),
'compare' => 'IN'
)
View get-posts-by-single-meta-value.php
<?php
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'os',
'value' => 'MacOS',
'compare' => '='
)
View editor-font-sizes.css
.has-small-font-size {
font-size: 12px;
}
.has-medium-font-size {
font-size: 16px;
}
.has-large-font-size {
View disable_custom_font_sizes.php
<?php
/**
* disable_custom_font_sizes.
*
* Disable the custom font-size options in the Gutenberg editor
*
* @see https://since1979.dev/wp-snippet-002-changing-the-gutenberg-font-sizes/
*
* @uses add_theme_support() https://developer.wordpress.org/reference/functions/add_theme_support/
View json-decode-arrays.php
<?php return json_decode(wp_remote_retrieve_body($response), true) ?: []; ?>
View use-maybe-cache.php
<?php
$posts = maybeCache('remote_posts_data', 7200, function () {
return do_remote_get('https://jsonplaceholder.typicode.com/posts/');
});
foreach ($posts as $post) {
echo "<h2>{$post->title}</h2>";
}
View maybe-cache.php
<?php
/**
* maybeCache.
*
* Check if transient cache exist, else set it,
*
* @see https://since1979.dev/snippet-008-using-transients-to-cache-data/
*
* @uses get_transient() https://developer.wordpress.org/reference/functions/get_transient/
You can’t perform that action at this time.