Skip to content

Instantly share code, notes, and snippets.

View seothemes's full-sized avatar

SEO Themes seothemes

View GitHub Profile
@seothemes
seothemes / style.css
Created April 23, 2024 15:18
dark mode palette custom properties
@media (prefers-color-scheme: dark) {
body {
--wp--custom--color--body: #fff;
}
}
@seothemes
seothemes / view.tsx
Last active February 28, 2024 11:05
Slider block view script
const Splide = window.Splide;
const initSlider = () => {
const divs = document.getElementsByClassName( 'wp-block-blockify-slider' ) as HTMLCollectionOf<HTMLDivElement>;
for ( let i = 0; i < divs.length; i++ ) {
const div = divs[ i ] as HTMLDivElement;
const type = div?.getAttribute( 'data-type' ) ?? 'slider';
const perPage = parseInt( div?.getAttribute( 'data-per-page' ) || '3' );
@seothemes
seothemes / functions.php
Last active June 23, 2023 04:59
Enable link color in classic themes
<?php
add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) {
$theme_json->update_with( array_merge(
$theme_json->get_data(),
[
'settings' => [
'color' => [
'link' => true,
],
@seothemes
seothemes / index.tsx
Last active February 5, 2023 05:53
Conditionally show/hide block styles depending on the currently selected variation
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
<?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
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
<?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
<?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
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
<?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.
*