-
Notifications
You must be signed in to change notification settings - Fork 0
/
disable-genesis-schema.php
88 lines (83 loc) · 2.28 KB
/
disable-genesis-schema.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* Plugin Name: Disable Genesis Schema
* Plugin URI: https://wordpress.org/plugins/disable-genesis-schema/
* Description: If you're using Yoast SEO or another plugin to output schema, use this to disable duplicate schema from Genesis
* Version: 1.0
* Author: Bill Erickson
* Author URI: https://www.billerickson.net
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume
* that you can use any other version of the GPL.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @package DisableGenesisSchema
* @version 2.0
* @author Bill Erickson <bill@billerickson.net>
* @copyright Copyright (c) 2019, Bill Erickson
* @license GPL-2.0+
*/
add_action( 'init', 'be_disable_genesis_schema' );
/**
* Disable Genesis Schema
* @author Bill Erickson
* @see https://www.billerickson.net/yoast-schema-with-genesis/
*/
function be_disable_genesis_schema() {
$elements = array(
'head',
'body',
'site-header',
'site-title',
'site-description',
'breadcrumb',
'breadcrumb-link-wrap',
'breadcrumb-link-wrap-meta',
'breadcrumb-link',
'breadcrumb-link-text-wrap',
'search-form',
'search-form-meta',
'search-form-input',
'nav-primary',
'nav-secondary',
'nav-header',
'nav-link-wrap',
'nav-link',
'entry',
'entry-image',
'entry-image-widget',
'entry-image-grid-loop',
'entry-author',
'entry-author-link',
'entry-author-name',
'entry-time',
'entry-modified-time',
'entry-title',
'entry-content',
'comment',
'comment-author',
'comment-author-link',
'comment-time',
'comment-time-link',
'comment-content',
'author-box',
'sidebar-primary',
'sidebar-secondary',
'site-footer',
);
$elements = apply_filters( 'be_remove_schema_elements', $elements );
foreach( $elements as $element ) {
add_filter( 'genesis_attr_' . $element, 'be_remove_schema_attributes', 20 );
}
}
/**
* Remove schema attributes
*
*/
function be_remove_schema_attributes( $attr ) {
unset( $attr['itemprop'], $attr['itemtype'], $attr['itemscope'] );
return $attr;
}