Skip to content

Instantly share code, notes, and snippets.

View misfist's full-sized avatar

Pea Lutz misfist

View GitHub Profile
@misfist
misfist / find-delete-print-ds_store.sh
Last active March 15, 2023 19:09
Find, Replace and Print DS_Store
find . -name ".DS_Store" -print -delete
@misfist
misfist / find-replace-ds_store.sh
Last active March 15, 2023 19:09
Find and Delete .DS_Store files
find . -name '.DS_Store' -type f -delete
@misfist
misfist / theme.json
Created July 29, 2021 23:33
theme.json
{
"settings": {
"color": {
"custom": true,
"customGradient": false,
"gradients": [],
"link": false,
"palette": [
{
"slug": "emphasis",
@misfist
misfist / has_reusable_block.php
Created July 26, 2021 20:13
Check if post contains a specific reusable block
function has_reusable_block( $block_name, $id = false ) {
$id = (!$id) ? get_the_ID() : $id;
if( $id ) {
if ( has_block( 'block', $id ) ) {
// Check reusable blocks
$content = get_post_field( 'post_content', $id );
$blocks = parse_blocks( $content );
if ( ! is_array( $blocks ) || empty( $blocks ) ) {
return false;
@misfist
misfist / customTaxonomyRadioSelector.js
Created November 5, 2020 20:47
Gutenberg - Custom Taxonomy Selector - Radio
/**
* External dependencies
*/
import { unescape as unescapeString } from 'lodash';
function customTaxonomyRadioSelector( OriginalComponent ) {
return function( props ) {
if ( props.slug === 'my_taxonomy') {
if ( ! window.HierarchicalTermRadioSelector ) {
window.HierarchicalTermRadioSelector = class HierarchicalTermRadioSelector extends OriginalComponent {
@misfist
misfist / customTaxonomySelectControlSelector.js
Last active November 5, 2020 20:49
Gutenberg - Custom Taxonomy Selector - Select Control
const {
SelectControl,
} = wp.components;
const taxonomy = 'category';
function customTaxonomySelectControlSelector( OriginalComponent ) {
return function(props) {
if ( props.slug === 'my_taxonomy' ) {
if ( !window.HierarchicalTermSelectSelector ) {
@misfist
misfist / blocks.scss
Last active April 7, 2020 20:28
Gutenberg Base Styles
/**
* Starter styling for core blocks
* @see https://wordpress.org/support/article/blocks/
*/
//colors
$color__primary: #0073aa;
//...
$size__site-small-content: 580px;
@misfist
misfist / mixin.scss
Created March 30, 2020 21:23
clip-path Mixin
@mixin clipped-corner($corner: bottom-right, $height: 58px, $width: 52px) {
@if $corner == top-left {
clip-path: polygon(0 #{$height}, #{$width} 0, 100% 0, 100% 100%, 0 100%);
} @else if $corner == top-right {
clip-path: polygon(0 100%, 0 0, calc(100% - #{$width}) 0, 100% #{$height}, 100% 100%);
} @else if $corner == bottom-right {
clip-path: polygon(
100% calc(100% - #{$height}), /*right bottom 100% - height px*/
calc(100% - #{$width}) 100%, /* right bottom - 100% - width px */
<?php
//Change error message of AJAX submitted form.
add_filter( 'caldera_forms_render_notices', function( $notices ){
//Will NOT be set (during AJAX return) if there is no error
if( isset( $notices[ 'error' ], $notices[ 'error' ][ 'note' ] ) ){
$notices[ 'error' ][ 'note' ] = 'Form could not be submitted, please correct erorrs or give us a call.';
}
return $notices;
});
@misfist
misfist / delete-old-post.sql
Created February 14, 2018 19:39
Delete posts older than X days.
DELETE FROM wp_posts WHERE post_type = 'post' AND DATEDIFF(NOW(), post_date) > X;