Skip to content

Instantly share code, notes, and snippets.

View sybrew's full-sized avatar

Sybre Waaijer sybrew

View GitHub Profile
@sybrew
sybrew / tsf-add-custom-columns.php
Last active January 6, 2024 09:42
Adds The SEO Framework's Title and Description columns on the edit screen.
<?php
/**
* Plugin Name: The SEO Framework - Add custom columns
* Plugin URI: https://theseoframework.com/
* Description: Adds The SEO Framework's Title and Description columns on the edit screen.
* Version: 9001.42.1
* Author: Sybre Waaijer
* Author URI: https://cyberwire.nl/
* License: GPLv3
*/
@sybrew
sybrew / tsf-meta-render-data.php
Last active November 22, 2023 17:50
TSF meta render data filter
<?php
// This works on TSF v5.0 and later.
add_filter(
'the_seo_framework_meta_render_data',
function ( $tags_render_data ) {
// Remove og:description:
unset( $tags_render_data['og:description'] );
@sybrew
sybrew / boilerplate-tsf-cat-desc-title.php
Last active September 24, 2023 20:27
Boilerplate title and description for Categories for The SEO Framework
<?php
// Rel: https://wordpress.org/support/topic/how-to-set-custom-category-title-and-description/
add_filter(
'the_seo_framework_generated_archive_title',
function( $title, $object ) {
$object ??= get_queried_object();
if ( 'category' === ( $filterobject->taxonomy ?? '' ) ) {
@sybrew
sybrew / wp-remove-fbclid.php
Last active August 29, 2023 08:12
Removes the fbclid query parameter from the URL when someone visits your site.
<?php
// Don't include the PHP opening tag if PHP is already open in the file.
add_action(
'parse_request',
function() {
if ( isset( $_GET['fbclid'] ) ) {
wp_safe_redirect( home_url( remove_query_arg( 'fbclid' ) ), 301 );
@sybrew
sybrew / htmltimerdump.php
Created August 17, 2023 00:00
Dumps HTML timer in meta id=htmltimerdump as late as possible for you to snatch via JS.
<?php
/**
* Plugin Name: HTML Timer Dump
* Description: Dumps HTML timer in meta id=htmltimerdump as late as possible for you to snatch via JS.
* Author: Sybre Waaijer
* Author URI: https://cyberwire.nl/
* Version: 1.0.0
* License: GLPv3
*
* @package HTMLTimerDump
@sybrew
sybrew / test-php-timer.js
Created August 17, 2023 00:01
TSF's performance testing script.
// Run this script in the browser console, wait for it to complete and show you the testing results.
// You must use the following plugin to load the timings... https://gist.github.com/sybrew/f72f58394e62447d9bad61fdcc0bcb1b
// Config the constants below
const doLoggedIn = false; // whether testing logged in or out.
// NOTE: You must manually log in and out in the browser you're testing this!
const iterations = 100; // Set iterations. Fewer than 100/50 with/without Opcache is inaccurate.
const tick = false; // Whether to display every timestamp recorded on tick. Noisy.
@sybrew
sybrew / polylang-tsf-pta.php
Created June 10, 2023 22:53
Polylang Post Type Archive overwrite for TSF
<?php
// Request: https://wordpress.org/support/topic/the-seo-framework-polylang-post-type-archive-settings-not-translatable/
add_filter( 'the_seo_framework_post_type_archive_meta', 'my_custom_seo_framework_post_type_archive_meta', 10, 2 );
/**
* Filters The SEO Framework post type archive meta based on Polylang's language.
*
* @param array $meta The current post type archive meta : {
* 'doctitle' => string
@sybrew
sybrew / hide-tsf-from-all-but-super-admin.php
Created June 1, 2023 13:57
Hides TSF's admin interface from everyone but the Super Administrator (capability manage_network, or manage_options on non-multisite).
<?php
/**
* Plugin Name: TSF Headless Mode for non-super-admin.
* Plugin URI: https://theseoframework.com/
* Description: Enables Headless Mode for The SEO Framework in the admin area for non-admins.
* Version: 1.0.0
* Author: Sybre Waaijer
* Author URI: https://theseoframework.com/
* License: GPLv3
*/
@sybrew
sybrew / tsf-custom-image-generator.php
Created October 11, 2019 20:40
Example snippet to prepend and append image generators for The SEO Framework.
<?php
// Do not include this PHP opening tag if PHP is already opened...
// Ref: https://theseoframework.com/docs/using-filters/
add_filter( 'the_seo_framework_image_generation_params', 'my_tsf_custom_image_generation_args', 10, 3 );
/**
* Adjusts image generation parameters.
*
* @link https://theseoframework.com/docs/api/filters/#append-image-generators-for-social-images
@sybrew
sybrew / remove-tsf-articles-output.php
Created March 7, 2023 23:37
Disables output for Articles
<?php
// Don't include the PHP tag if PHP is already running...
add_filter( 'the_seo_framework_articles_data', '__return_empty_array' );