Skip to content

Instantly share code, notes, and snippets.

View sybrew's full-sized avatar

Sybre Waaijer sybrew

View GitHub Profile
@sybrew
sybrew / tsf-exclude-visuals.php
Last active December 24, 2018 07:40
This class allows you to remove SEO items from view on various post types.
<?php
// Don't include the PHP tag.
/**
* Adjust $excluded_post_types : array( 'post_type' );
* Adjust $excluded_taxonomies : array( 'taxonomy' );
* Adjust $exclude_from_singular : false/true;
*/
/**
@sybrew
sybrew / remove-editor-requirement.php
Created February 9, 2018 12:46
Remove editor support requirement in TSF
<?php
//! Don't include the php tag.
add_filter( 'the_seo_framework_custom_post_type_support', function( $support ) {
return array_diff( $support, array( 'editor' ) );
} );
@sybrew
sybrew / tsf-test-relative-fontcolor.php
Last active August 20, 2018 18:12
The testing script used to find issues with the new color calcuation in TSF. Double-click the page to load the next sequence.
<!DOCTYPE html>
<html>
<head>
<style>
div {
padding: 12px 0;
font-weight: 600;
font-size: 14px;
vertical-align: middle;
display: inline-block;
@sybrew
sybrew / ifthisthenthatand.php
Created March 13, 2018 16:19
A readable if this-then-that-and-else-this-then-that-and... function wrapper.
<?php
function if_( $value ) {
return new class( (bool) $value ) {
public $run, $and;
public $cb = [];
function __construct( $run ) { $this->run = $run; }
function __destruct() {
foreach ( $this->cb as $cb ) {
$cb ? $cb() : null;
@sybrew
sybrew / disable-tsf-on-shortcode.php
Last active September 16, 2018 15:42
Work with TSF v3.0.6 or lower. Disable TSF when shortcodes are found in content.
<?php
//* Don't include the PHP tag.
add_action( 'the_seo_framework_init', function() {
//! Set shortcodes here.
function get_tsf_excluded_shortcodes() {
return array(
'my-first-shortcode',
'my-first-shortcode',
@sybrew
sybrew / disable-tsf-on-request.php
Created April 16, 2018 15:28
Disable TSF when request URL starts with any of the exclusions.
<?php
//* Don't include the PHP tag.
add_action( 'after_setup_theme', function() {
$exclusions = array(
'/sample-page',
'/forums',
'/replies',
);
@sybrew
sybrew / disable-tsf-seo-on-wpforo.php
Last active September 17, 2018 17:33
Disables The SEO Framework's SEO on wpForo pages.
<?php
// Don't include the PHP tag.
add_action( 'after_setup_theme', function() {
remove_action( 'init', 'The_SEO_Framework\\_wpforo_fix_page' );
add_action( 'the_seo_framework_init', function() {
if ( ! function_exists( 'wpforo_feature' ) || ! function_exists( 'is_wpforo_page' ) )
return;
@sybrew
sybrew / tsf-title-date-support.php
Last active April 1, 2021 21:07
Adds date support for The SEO Framework custom titles
<?php
// DO NOT USE THIS! It's condemned by Google.
// Usage: Add %%year%%, %%month%%, and/or %%day%% to custom meta titles in the SEO framework,
// and magically see them transform into their respective values.
add_filter( 'the_seo_framework_title_from_custom_field', function( $title, $args ) {
$params = [
<?php
// Ref: https://github.com/sybrew/The-SEO-Framework-Extension-Manager/blob/2d70d5a141491209340b72a8cefeb574dd00b538/extensions/essentials/focus/trunk/inc/classes/admin.class.php#L99-L128
/**
* Adds my custom fields to the Focus parser.
*
* @param array $elements
* @return array
*/
@sybrew
sybrew / title-branding.php
Created June 20, 2019 05:07
Edit TSF title branding
<?php
// Don't include the PHP tag in existing files.
// Requester: https://wordpress.org/support/topic/filter-to-remove-blogname-from-all-posts-or-other-post-type/
// Where do I place filters? See: https://tsf.fyi/docs/filters#where
/**
* Adjust The SEO Framework title branding.
*