Skip to content

Instantly share code, notes, and snippets.

View seothemes's full-sized avatar

SEO Themes seothemes

View GitHub Profile
@seothemes
seothemes / functions.php
Last active October 14, 2022 23:04
Randomize text content in heading block
<?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
<?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
<?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;
} );
@seothemes
seothemes / page.html
Created July 21, 2022 01:18
Header/content/footer template
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:post-content {"layout":{"inherit":true}} /-->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
@seothemes
seothemes / inline-hero-section-image.php
Created August 3, 2020 02:53
Use inline image instead of background for hero sections
<?php
// Remove hero section backgrounds.
add_action( 'after_setup_theme', function () {
remove_theme_support( 'custom-header' );
add_theme_support( 'custom-header', [
'header-selector' => false,
'default-image' => CHILD_THEME_URI . '/assets/images/hero.jpg',
'width' => 1280,
'height' => 720,
@seothemes
seothemes / functions.php
Created February 20, 2020 16:23
Auto install plugins with Genesis
<?php
add_action( 'after_switch_theme', 'startup_install_plugins' );
/**
* Install plugin dependencies.
*
* @since 1.2.0
*
* @return void
*/
@seothemes
seothemes / autoloader.php
Last active September 9, 2019 00:00
Simple PSR-4 autoloader
<?php
\spl_autoload_register( function ( $class ) {
if ( strpos( $class, __NAMESPACE__ ) !== false ) {
require_once __DIR__ . '/src' . str_replace( '\\', DIRECTORY_SEPARATOR, substr( $class, strlen( __NAMESPACE__ ) ) ) . '.php';
}
} );
@seothemes
seothemes / current-user-shortcode.php
Last active August 15, 2019 04:10
Current user shortcode
<?php
add_shortcode( 'current_user', __NAMESPACE__ . '\current_user_shortcode' );
/**
* Description of expected behavior.
*
* @since 1.0.0
*
* @param $atts
@seothemes
seothemes / genesis-plugin-tab.php
Created June 7, 2019 03:58
Add Genesis tab to plugins install screen
<?php
add_filter( 'install_plugins_tabs', __NAMESPACE__ . '\genesis_plugins_tab' );
/**
* Add Genesis to plugin tabs.
*
* @since 1.0.0
*
* @param array $tabs Default plugin tabs.
@seothemes
seothemes / functions.php
Created May 23, 2019 04:35
Set default fallback image on archives in Genesis
<?php
add_filter( 'genesis_get_image_default_args', 'prefix_set_image_fallback' );
/**
* Set default fallback image on archives.
*
* @since 1.0.0
*
* @param array $args Default image args.
*