Skip to content

Instantly share code, notes, and snippets.

View wp-seopress's full-sized avatar
😊
Coding SEOPress, best WordPress SEO plugin

Benjamin Denis wp-seopress

😊
Coding SEOPress, best WordPress SEO plugin
View GitHub Profile
@wp-seopress
wp-seopress / filter-categories-tracking-custom-dimension-with-google-analytics.php
Created February 28, 2019 18:28
Filter categories tracking custom dimension with Google Analytics
function sp_gtag_cd_categories_cf($html) {
return "'dimension2': 'cd_categories',";
}
add_filter('seopress_gtag_cd_categories_cf', 'sp_gtag_cd_categories_cf');
function sp_gtag_cd_categories_ev($html) {
return "gtag('event', '".__('Categories','wp-seopress')."', {'cd_categories': '".$get_first_category."'});";
}
add_filter('seopress_gtag_cd_categories_ev', 'sp_gtag_cd_categories_ev');
@wp-seopress
wp-seopress / filter-content-analysis-metaboxe-call-by-post-type.php
Created February 28, 2019 18:31
Filter Content Analysis Metabox call by post type
function sp_metaboxe_content_analysis($seopress_get_post_types) {
//Post types array, eg: post and page, notice the array_flip to convert values to keys
$seopress_get_post_types = array_flip(array('post','page'));
return $seopress_get_post_types;
}
add_filter('seopress_metaboxe_content_analysis', 'sp_metaboxe_content_analysis');
@wp-seopress
wp-seopress / filter-dublin-core-description.php
Created February 28, 2019 18:34
Filter Dublin Core description
function sp_dublin_core_desc($html) {
//you can add here all your conditions as if is_page(), is_category() etc..
$html = '<meta name="dc.description" content="my awesome description" /> ';
return $html;
}
add_filter('seopress_dublin_core_desc', 'sp_dublin_core_desc');
@wp-seopress
wp-seopress / filter-dublin-core-relation.php
Created February 28, 2019 18:36
Filter Dublin Core relation
function sp_dublin_core_relation($html) {
//you can add here all your conditions as if is_page(), is_category() etc..
$html = '<meta name="dc.relation" content="https://www.seopress.org/" />';
return $html;
}
add_filter('seopress_dublin_core_relation', 'sp_dublin_core_relation');
@wp-seopress
wp-seopress / filter-dublin-core-source.php
Created February 28, 2019 18:37
Filter Dublin Core source
function sp_dublin_core_source($html) {
//you can add here all your conditions as if is_page(), is_category() etc..
$html = '<meta name="dc.source" content="https://www.seopress.org/" />';
return $html;
}
add_filter('seopress_dublin_core_source', 'sp_dublin_core_source');
@wp-seopress
wp-seopress / filter-dublin-core-title.php
Created February 28, 2019 18:39
Filter Dublin Core title
function sp_dublin_core_title($html) {
//you can add here all your conditions as if is_page(), is_category() etc..
$html = '<meta name="dc.title" content="my awesome title" />';
return $html;
}
add_filter('seopress_dublin_core_title', 'sp_dublin_core_title');
@wp-seopress
wp-seopress / filter-excerpt-length-metas.php
Last active August 3, 2020 15:43
Filter excerpt length (or beginning of post content) in metas
function sp_excerpt_length($html) {
//default: 50 words
$html = 100;
return $html;
}
add_filter('seopress_excerpt_length', 'sp_excerpt_length');
@wp-seopress
wp-seopress / filter-google-analytics-affiliate-outbound-links-tracking.php
Created February 28, 2019 18:44
Filter Google Analytics affiliate / outbound links tracking
@wp-seopress
wp-seopress / filter-google-analytics-cross-domain-tracking-feature.php
Created February 28, 2019 18:45
Filter Google Analytics Cross-domain tracking feature
function sp_gtag_download_tracking_ev($html) {
return "jQuery(document).ready(function() {
jQuery('a').filter(function() {
return this.href.match(/.*\.(pdf|docx|xlsx)(\?.*)?$/); }).click(function(e) {
gtag('event', 'click', {'event_category': 'downloads','event_label' : this.href});
});
});
";
}
add_filter('seopress_gtag_download_tracking_ev', 'sp_gtag_download_tracking_ev');
@wp-seopress
wp-seopress / filter-google-analytics-cross-domain-tracking-feature.php
Created February 28, 2019 18:46
Filter Google Analytics Cross-domain tracking feature
function sp_gtag_linker($html) {
return "'linker': {'domains': ['https://www.example.com/']},";
}
add_filter('seopress_gtag_linker', 'sp_gtag_linker');