Skip to content

Instantly share code, notes, and snippets.

Avatar

SEO Themes seothemes

View GitHub Profile
@seothemes
seothemes / index.tsx
Last active February 5, 2023 05:53
Conditionally show/hide block styles depending on the currently selected variation
View index.tsx
import { addFilter } from "@wordpress/hooks";
import { createHigherOrderComponent } from "@wordpress/compose";
interface blockProps {
attributes: {
className: string;
};
isSelected: boolean;
name: string;
}
@seothemes
seothemes / functions.php
Created January 3, 2023 04:17
Insert custom content after second paragraph of content
View functions.php
<?php
declare( strict_types=1 );
namespace Blockify\Test;
use function add_filter;
use function explode;
use function implode;
use function is_singular;
@seothemes
seothemes / index.tsx
Last active November 20, 2022 00:30
Get terms by taxonomy for select control option groups
View index.tsx
import { __ } from "@wordpress/i18n";
import { InspectorControls } from "@wordpress/block-editor";
import { SelectControl } from "@wordpress/components";
import { registerBlockType } from "@wordpress/blocks";
import { useSelect } from "@wordpress/data";
import { useState } from "@wordpress/element";
interface selectOption {
value: string,
name: string
@seothemes
seothemes / functions.php
Created November 19, 2022 00:40
Add custom shortcode support to paragraph block
View functions.php
<?php
declare( strict_types=1 );
namespace Company\Project;
use function add_filter;
use function gmdate;
use function str_replace;
@seothemes
seothemes / functions.php
Last active November 3, 2022 20:08
Convert WordPress spacing scale inline styles to utility classes and load conditionally
View functions.php
<?php
declare( strict_types=1 );
namespace Blockify;
use DOMDocument;
use DOMElement;
use function add_action;
use function add_filter;
@seothemes
seothemes / style.css
Last active October 23, 2022 13:02
Gradient text WordPress heading block
View style.css
h1.has-background[class*="-gradient-background"],
h1.has-background[style*="-gradient("] {
-webkit-background-clip: text !important;
color: transparent;
padding: 0;
}
@seothemes
seothemes / functions.php
Created October 20, 2022 01:14
Merge parent theme style variation with active child theme
View functions.php
<?php
add_filter( 'theme_json_theme', 'get_parent_theme_style_variation_data' );
/**
* Merges parent theme style variation data with active theme.json.
*
* @since 1.0.0
*
* @param mixed $theme_json WP_Theme_JSON_Data | WP_Theme_JSON_Data_Gutenberg.
*
@seothemes
seothemes / functions.php
Last active October 14, 2022 23:04
Randomize text content in heading block
View functions.php
<?php
\add_filter( 'render_block_core/heading', __NAMESPACE__ . '\\randomize_h1_heading_block_on_front_page', 10, 2 );
/**
* Randomizes content of H1 heading blocks on the front page.
*
* @since 1.0.0
*
* @param string $content Block HTML content.
* @param array $block Block data.
@seothemes
seothemes / modulo-benchmark.php
Created September 19, 2022 15:52
modulo benchmark
View modulo-benchmark.php
<?php
$array = [
0 => 'X',
1 => 'Y',
2 => 'Z',
3 => 'X',
4 => 'Y',
5 => 'Z',
6 => 'X',
@seothemes
seothemes / functions.php
Last active August 19, 2022 02:15
Remove dark mode blockify
View functions.php
<?php // Do not include opening PHP tag.
// Place in child theme functions.php or custom plugin.
add_filter( 'blockify', function ( array $defaults ): array {
unset( $defaults['darkMode'] );
return $defaults;
} );