Skip to content

Instantly share code, notes, and snippets.

View sybrew's full-sized avatar

Sybre Waaijer sybrew

View GitHub Profile
@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 / 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' );
<?php
// don't include this php opening tag if PHP is already running in the script.
add_filter( 'the_seo_framework_focus_elements', function( $elements ) {
// Add an extra (prepending) pageContent for parsing. In this case, ACF's textarea "intro_text" and input "product_review_note".
$elements['pageContent'] = array_merge(
[ ':where(.values .acf-field, .inside.acf-fields > .acf-field)[data-name="intro_text"] .acf-input textarea' => 'append' ],
[ ':where(.values .acf-field, .inside.acf-fields > .acf-field)[data-name="product_review_note"] .acf-input input' => 'append' ],
@sybrew
sybrew / noindex-bbpress-forums-tsf.php
Last active January 17, 2023 21:26
Applies "noindex" to a forum, and all topics inside that forum.
<?php
// Don't include the PHP tag if PHP is already active.
// Request: https://wordpress.org/support/topic/exclude-specific-bbpress-forums-by-id/
add_filter(
'the_seo_framework_robots_meta_array',
function( $meta, $args, $ignore ) {
@sybrew
sybrew / tsf-noindex-all-by-category.php
Last active January 11, 2023 07:07
Applies noindex (and removes from sitemap) all posts within a certain category, and the category too.
<?php
// Do not include the PHP opening tag if PHP is already open.
add_filter(
'the_seo_framework_robots_meta_array',
function( $meta, $args, $ignore ) {
// Set the blocked term IDs yourself.
@sybrew
sybrew / 404-title-tsf.php
Created December 16, 2022 05:51
Filters 404 title for The SEO Framework
<?php
// Don't include the PHP tag if PHP is already open.
/**
* Changed the title from "404" to "Page not found".
*
* Be wary that search engines may assert from the title that a
* page isn't found, instead of only the response code (404).
* Some plugins erroneously override the response code, so keep
@sybrew
sybrew / tsf-add-seo-bar-picture-test.php
Created November 30, 2022 21:48
Adds SEO Bar picture test for The SEO Framework.
<?php
/**
* Plugin Name: The SEO Framework - Add custom image test.
* Plugin URI: https://theseoframework.com/
* Description: Adds a SEO Bar item "P" with custom image (picture) tests.
* Version: 9001.42.0
* Author: Sybre Waaijer
* Author URI: https://cyberwire.nl/
* License: GPLv3
*/
@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 / acf-tsf.php
Last active January 11, 2023 06:51
Filters Advanced Custom Fields (ACF) and The SEO Framework (TSF) description and titles
<?php
/**
* 'the_seo_framework_custom_field_description' of the filter below can be changed with:
* - the_seo_framework_title_from_custom_field
* - the_seo_framework_title_from_generation
* - the_seo_framework_generated_description
* - the_seo_framework_custom_field_description
*
* And many other filters that follow the ( $value, $args ) schema.