-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathyoast-seo.php
175 lines (139 loc) · 3.61 KB
/
yoast-seo.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* Move Yoast Meta Box to bottom
*/
add_filter(
'wpseo_metabox_prio',
function () {
return 'low';
},
10
);
/**
* Remove Yoast roles
*/
add_action(
'admin_init',
function () {
if ( get_role( 'wpseo_manager' ) ) {
remove_role( 'wpseo_manager' );
}
if ( get_role( 'wpseo_editor' ) ) {
remove_role( 'wpseo_editor' );
}
}
);
/**
* Remove Yoast settings from admin bar
*/
add_action(
'wp_before_admin_bar_render',
function () {
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'wpseo-menu' );
},
999
);
/**
* Remove Yoast 'primary' categories
*/
add_filter( 'wpseo_primary_term_taxonomies', '__return_empty_array' );
/**
* Remove Yoast post columns
*/
add_filter(
'manage_posts_columns',
function ( $columns ) {
unset(
$columns['wpseo-score'],
$columns['wpseo-title'],
$columns['wpseo-metadesc'],
$columns['wpseo-focuskw'],
$coulmns['wpseo-links']
);
return $columns;
}
);
/**
* Remove Yoast page columns
*/
add_filter(
'manage_page_columns',
function ( $columns ) {
unset(
$columns['wpseo-score'],
$columns['wpseo-title'],
$columns['wpseo-metadesc'],
$columns['wpseo-focuskw'],
$columns['wpseo-links']
);
return $columns;
}
);
/**
* Remove Yoast metabox on dashboard
*/
add_action(
'wp_dashboard_setup',
function () {
remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'side' );
}
);
/**
* Remove Yoast presentation items
* Description, robots, open graph, twitter, etc.
*
* @link https://gist.github.com/amboutwe/811e92b11e5277977047d44ea81ee9d4#file-yoast_seo_opengraph_remove_presenters-php
*/
add_filter(
'wpseo_frontend_presenter_classes',
function ( $filter ) {
$presenter_to_remove = array(
'Yoast\WP\SEO\Presenters\Meta_Description_Presenter',
'Yoast\WP\SEO\Presenters\Robots_Presenter',
'Yoast\WP\SEO\Presenters\Canonical_Presenter',
// Prev next relations
'Yoast\WP\SEO\Presenters\Rel_Prev_Presenter',
'Yoast\WP\SEO\Presenters\Rel_Next_Presenter',
// Open Graph
'Yoast\WP\SEO\Presenters\Open_Graph\Locale_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Type_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Title_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Description_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Url_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Site_Name_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Article_Publisher_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Article_Author_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Article_Published_Time_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Article_Modified_Time_Presenter',
'Yoast\WP\SEO\Presenters\Open_Graph\Image_Presenter',
// Twitter
'Yoast\WP\SEO\Presenters\Twitter\Card_Presenter',
'Yoast\WP\SEO\Presenters\Twitter\Title_Presenter',
'Yoast\WP\SEO\Presenters\Twitter\Description_Presenter',
'Yoast\WP\SEO\Presenters\Twitter\Image_Presenter',
'Yoast\WP\SEO\Presenters\Twitter\Creator_Presenter',
'Yoast\WP\SEO\Presenters\Twitter\Site_Presenter',
);
foreach ( $presenter_to_remove as $presenter ) {
if ( ( $key = array_search( $presenter, $filter ) ) !== false ) {
unset( $filter[ $key ] );
}
}
return $filter;
}
);
/**
* Remove breadcrumbs from schema
*/
add_filter( 'wpseo_schema_graph_pieces', function ($pieces, $context) {
return \array_filter( $pieces, function( $piece ) {
return ! $piece instanceof \Yoast\WP\SEO\Generators\Schema\Breadcrumb;
});
}, 11, 2 );
add_filter( 'wpseo_schema_webpage', function ($data) {
if (array_key_exists('breadcrumb', $data)) {
unset($data['breadcrumb']);
}
return $data;
}, 11, 1 );