Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
Building cool stuff for WordPress

SEO Themes seothemes

😀
Building cool stuff for WordPress
View GitHub Profile
@seothemes
seothemes / inline-hero-section-image.php
Created Aug 3, 2020
Use inline image instead of background for hero sections
View inline-hero-section-image.php
<?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 Feb 20, 2020
Auto install plugins with Genesis
View functions.php
<?php
add_action( 'after_switch_theme', 'startup_install_plugins' );
/**
* Install plugin dependencies.
*
* @since 1.2.0
*
* @return void
*/
@seothemes
seothemes / autoloader.php
Last active Sep 9, 2019
Simple PSR-4 autoloader
View autoloader.php
<?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 Aug 15, 2019
Current user shortcode
View current-user-shortcode.php
<?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 Jun 7, 2019
Add Genesis tab to plugins install screen
View genesis-plugin-tab.php
<?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
Set default fallback image on archives in Genesis
View functions.php
<?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.
*
@seothemes
seothemes / functions.php
Last active May 25, 2019
Dynamic CSS in WordPress
View functions.php
<?php
/**
* Load dynamic CSS stylesheet in WordPress. There are 4 steps:
*
* 1. Enqueue dynamic stylesheet on front end or add inline CSS if in Customizer.
* 2. Get the dynamic CSS with AJAX calls.
* 3. Generate CSS using PHP variables.
* 4. Minify CSS after before loading.
*/
@seothemes
seothemes / style.scss
Created May 22, 2019
Gravity Forms SCSS
View style.scss
/* ## Gravity Forms
--------------------------------------------- */
.gform_heading,
.gform_body,
.gform_footer {
clear: both;
}
.gform_heading {
@seothemes
seothemes / functions.php
Created Apr 26, 2019
Add hook after title area
View functions.php
<?php
add_filter( 'genesis_markup_title-area_close', 'prefix_after_title_area', 10, 2 );
/**
* Appends HTML to the closing markup for .title-area.
*
* Adding something between the title + description and widget area used to require
* re-building genesis_do_header(). However, since the title-area closing markup
* now goes through genesis_markup(), it means we now have some extra filters
* to play with. This function makes use of this and adds in an extra hook
@seothemes
seothemes / functions.php
Created Apr 2, 2019
Simple Pricing Table - open links in new window
View functions.php
<?php
// Do NOT include the opening php tag.
add_filter( 'spt_markup_link_open', 'prefix_spt_button_markup' );
/**
* Open Simple Pricing Table links in new tab.
*
* @since 1.0.0
*
* @return string