Skip to content

Instantly share code, notes, and snippets.

View sybrew's full-sized avatar

Sybre Waaijer sybrew

View GitHub Profile
@sybrew
sybrew / disable-rich-pins.php
Created August 13, 2019 10:31
Disable Pinterest Rich Pins for your WordPress site.
<?php
/**
* Plugin Name: Disable Pinterest rich pins.
* Description: This plugin adds a meta tag to your site header that tells Pinterest to disable rich pins for your WordPress site.
* Version: 1.0.0
* Author: Sybre Waaijer
* Author URI: https://theseoframework.com/
* License: GPLv3
*/
@sybrew
sybrew / remove-tsf-seo-bar-item.php
Created August 21, 2019 04:58
Remove SEO Bar items for The SEO Framework.
<?php
// Example!
/**
* Adjust SEO Bar interpreter and builder items here.
*
* The only use we can think of here is removing items from `$builder::$tests`,
* and reading `$interpreter::$query`. Do not add tests here. Do not alter the query.
*
@sybrew
sybrew / adjust-tsf-seo-bar-items.php
Last active August 21, 2019 05:23
Adjust and add SEO Bar item tests for The SEO Framework.
<?php
// Example!
/**
* Add or adjust SEO Bar items here.
*
* @since 4.0.0
* @param string $interpreter The interpreter class name.
*/
@sybrew
sybrew / tsf-get-description-shortcode.php
Created September 3, 2019 13:17
Creates a description shortcode.
<?php
// The PHP tag starts PHP. Don't implement it if it's already there.
/**
* Get the current query description: [tsf-description]
* Get another query description, page: [tsf-description id=42]
* Get another query description, term: [tsf-description id=42 taxonomy=category]
*/
add_shortcode( 'tsf-description', function( $atts ) {
@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 / tsf-custom-image-generator.php
Created October 11, 2019 21:21
Get hierarchical pages' parent social image 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 / tsf-custom-image-generator.php
Created October 11, 2019 21:28
Prepend hierarchical pages' parent social image for The SEO Framework.
<?php
// Do not include this PHP opening tag if PHP is already opened...
// Ref: https://theseoframework.com/docs/using-filters/
// Ref: https://gist.github.com/sybrew/938092feb87f821b054a59c72c1d3daa
add_filter( 'the_seo_framework_image_generation_params', 'my_tsf_custom_image_generation_args', 10, 3 );
/**
* Adjusts image generation parameters.
*
@sybrew
sybrew / exclude-content-images-from-schema.php
Created November 10, 2019 18:34
Removes content-images for Schema-type generators in The SEO Framework. Affects Articles markup.
<?php
// Don't include the PHP tag if PHP is already active...
/**
* Adjusts image generation parameters to exclude content-images for Schema-type generators.
*
* @param array $params : [
* string size: The image size to use.
* boolean multi: Whether to allow multiple images to be returned.
@sybrew
sybrew / dynamic-tsf-tags.php
Created November 23, 2019 13:13
Adds sitename, month, and year generation tags for The SEO Framework. Requires PHP 7+
<?php
// Don't include the PHP tag is PHP is already running.
add_filter( 'the_seo_framework_title_from_custom_field', 'my_transform_dynamic_tags' );
add_filter( 'the_seo_framework_custom_field_description', 'my_transform_dynamic_tags' );
function my_transform_dynamic_tags( $tag ) {
// Cache keys, for this method is inefficient.
static $keys = null;
@sybrew
sybrew / override-content-image-generator.php
Created January 8, 2020 21:37
Override content image generator to strip SVG images in TSF.
<?php
// Don't include the PHP tag is PHP is already active
add_filter( 'the_seo_framework_image_generation_params', function( $args ) {
if ( isset( $args['cbs']['content'] ) ) {
$args['cbs']['content'] = 'my_content_image_generator';
}