Skip to content

Instantly share code, notes, and snippets.

Sybre Waaijer sybrew

Block or report user

Report or block sybrew

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sybrew
sybrew / tsf-bylines-compat.php
Created Mar 21, 2020
Disable TSF on Bylines queries
View tsf-bylines-compat.php
<?php
// Don't include this tag if PHP is already started...
add_action( 'pre_get_posts', function( $query ) {
if ( isset( $query->queried_object ) ) {
if ( $query->queried_object instanceof \Bylines\Objects\Byline ) {
add_filter( 'the_seo_framework_query_supports_seo', '__return_false', 999 );
}
@sybrew
sybrew / override-content-image-generator.php
Created Jan 8, 2020
Override content image generator to strip SVG images in TSF.
View override-content-image-generator.php
<?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';
}
@sybrew
sybrew / dynamic-tsf-tags.php
Created Nov 23, 2019
Adds sitename, month, and year generation tags for The SEO Framework. Requires PHP 7+
View dynamic-tsf-tags.php
<?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 / exclude-content-images-from-schema.php
Created Nov 10, 2019
Removes content-images for Schema-type generators in The SEO Framework. Affects Articles markup.
View exclude-content-images-from-schema.php
<?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 / tsf-custom-image-generator.php
Created Oct 11, 2019
Prepend hierarchical pages' parent social image for The SEO Framework.
View tsf-custom-image-generator.php
<?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 / tsf-custom-image-generator.php
Created Oct 11, 2019
Get hierarchical pages' parent social image for The SEO Framework.
View tsf-custom-image-generator.php
<?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 Oct 11, 2019
Example snippet to prepend and append image generators for The SEO Framework.
View tsf-custom-image-generator.php
<?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-get-description-shortcode.php
Created Sep 3, 2019
Creates a description shortcode.
View tsf-get-description-shortcode.php
<?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 / adjust-tsf-seo-bar-items.php
Last active Aug 21, 2019
Adjust and add SEO Bar item tests for The SEO Framework.
View adjust-tsf-seo-bar-items.php
<?php
// Example!
/**
* Add or adjust SEO Bar items here.
*
* @since 4.0.0
* @param string $interpreter The interpreter class name.
*/
@sybrew
sybrew / remove-tsf-seo-bar-item.php
Created Aug 21, 2019
Remove SEO Bar items for The SEO Framework.
View remove-tsf-seo-bar-item.php
<?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.
*
You can’t perform that action at this time.