Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmudev-sls/54d0300a6a25267fa0811986ad99b4bb to your computer and use it in GitHub Desktop.
Save wpmudev-sls/54d0300a6a25267fa0811986ad99b4bb to your computer and use it in GitHub Desktop.
[SmartCrawl] - Remove author details from schema. Extend existing functionality of SmartCrawl to remove author details from schema
<?php
/**
* Plugin Name: [SmartCrawl] - Remove author details from schema
* Plugin URI: https://premium.wpmudev.org/
* Description: Extend existing functionality of SmartCrawl to remove author details from schema (as of 2.3.1)
* Author: Alessandro Kaounas @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WPMUDEV_SmartCrawl_Author_Schema' ) ) {
class WPMUDEV_SmartCrawl_Author_Schema {
private static $_instance = null;
public static function get_instance() {
if( is_null( self::$_instance ) ){
self::$_instance = new WPMUDEV_SmartCrawl_Author_Schema();
}
return self::$_instance;
}
private function __construct() {
add_filter( 'wds-schema-data', array( $this, 'wpmudev_smartcrawl_remove_author_data' ), 20, 1 );
}
function wpmudev_smartcrawl_remove_author_data( $data ){
foreach( $data as &$provider ){
if( is_array( $provider['author'] ) ){
if( isset( $provider['author']['url'] ) ) unset( $provider['author']['url'] );
}
}
return $data;
}
}
if ( ! function_exists( 'WPMUDEV_SmartCrawl_Author_Schema' ) ) {
function WPMUDEV_SmartCrawl_Author_Schema() {
return WPMUDEV_SmartCrawl_Author_Schema::get_instance();
};
add_action( 'plugins_loaded', 'WPMUDEV_SmartCrawl_Author_Schema', 99 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment