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-the-sitemap-alert-arguments.php
Created January 20, 2025 14:40
Filter the XML sitemap alert arguments
add_filter('seopress_seo_alerts_sitemap_args', 'sp_seo_alerts_sitemap_args');
function sp_seo_alerts_sitemap_args($args) {
// default args
$args = [
'blocking' => true,
'timeout' => 10,
'redirection' => 1,
];
return $args;
}
@wp-seopress
wp-seopress / filter-the-robots-alert-arguments.php
Created January 20, 2025 14:31
Filter the robots.txt alert arguments
add_filter('seopress_seo_alerts_robots_args', 'sp_seo_alerts_robots_args');
function sp_seo_alerts_robots_args($args) {
// default args
$args = [
'blocking' => true,
'timeout' => 10,
'redirection' => 1,
];
return $args;
}
@wp-seopress
wp-seopress / filter-the-homepage-alert-arguments.php
Created January 20, 2025 14:12
Filter the homepage alert arguments
add_filter('seopress_seo_alerts_homepage_args', 'sp_seo_alerts_homepage_args');
function sp_seo_alerts_homepage_args($args) {
// default args
$args = [
'blocking' => true,
'timeout' => 10,
'redirection' => 1,
];
return $args;
}
@wp-seopress
wp-seopress / automatic-product-schema-seopress-pro.php
Last active February 18, 2025 10:04
Add "MerchantReturnPolicy" and "deliveryTime" to each product offer for the automatic product schema with SEOPress PRO
<?php
//Add "MerchantReturnPolicy" and "deliveryTime" to each product offer (simple and variable) for the automatic product schema with SEOPress PRO
add_filter('seopress_schemas_auto_product_json', 'sp_schemas_auto_product_json');
function sp_schemas_auto_product_json($json) {
// Returns schema as an array with 'property' => 'value'
// Check if 'offers' exists in the JSON
if (!isset($json['offers'])) {
return $json;
}
@wp-seopress
wp-seopress / kk-star-ratings-seopress-pro-schemas.php
Last active December 20, 2024 08:37
Integrate KK Star Ratings with SEOPress PRO schemas
// This snippet will retrieve the votes from the current post handled by KK Star Ratings plugin
add_filter('seopress_schemas_auto_recipe_json', 'sp_schemas_auto_recipe_json');
function sp_schemas_auto_recipe_json($json) {
$post_id = get_the_ID();
$rating_data = get_post_meta($post_id, '_kksr_avg_default', true);
$count = get_post_meta($post_id, '_kksr_count_default', true);
if (!empty($rating_data) && !empty($count)) {
$json['aggregateRating'] = [
@wp-seopress
wp-seopress / post-meta-fields-jetengine-automatic-schemas-seopress.php
Last active November 28, 2024 18:20
Add predefined dynamic variables from Jet Engine to SEOPress' schemas
<?php
add_filter('seopress_schemas_mapping_select', 'sp_schemas_mapping_select');
function sp_schemas_mapping_select($select) {
//Add the new group option + option to the list
$select['Jet Engine'] = [
'my_new_dynamic_variable_key' => __('My new dynamic variable title', 'wp-seopress-pro'),
];
return $select;
}
@wp-seopress
wp-seopress / post-meta-fields-jetengine-seopress.php
Last active November 28, 2024 18:20
Use post meta fields from a JetEngine custom table and SEOPress
<?php
function sp_titles_template_variables_array($array) {
$array[] = '%%my-custom-global-variable%%';
return $array;
}
add_filter('seopress_titles_template_variables_array', 'sp_titles_template_variables_array');
function sp_titles_template_replace_array($array) {
// Replace my_jetengine_custom_field with the name of your meta field (to be used with custom database storage)
$array[] = esc_attr(wp_strip_all_tags( jet_engine()->listings->data->get_meta( 'my_jetengine_custom_field' ) ));
return $array;
@wp-seopress
wp-seopress / run-action-after-site-audit-is-completed.php
Created October 28, 2024 09:35
Run action after site audit is completed
add_action('seopress_site_audit_after_processs', 'sp_site_audit_after_processs');
function sp_site_audit_after_processs() {
//do something
}
@wp-seopress
wp-seopress / filter-post-object-sent-automatically-to-indexnow-api.php
Last active October 10, 2024 12:49
Filter post object sent automatically to IndexNow API
add_filter('seopress_instant_indexing_permalink', 'sp_instant_indexing_permalink', 10, 2);
function sp_instant_indexing_permalink($permalink, $post) {
$cpt = get_post_type( $post ) ? get_post_type( $post ) : '';
if ($cpt === 'test') {
return false;
}
return $permalink;
}
@wp-seopress
wp-seopress / filter-the-tabs-of-the-site-overview-dashboard-block.php
Last active October 8, 2024 09:03
Filter tabs in the Dashboard Site Overview block
add_filter('seopress_dashboard_site_overview_tabs', 'sp_dashboard_site_overview_tabs');
function sp_dashboard_site_overview_tabs($tabs) {
//Default array
// $tabs = [
// 'tab_seopress_analytics' => esc_html__('Google Analytics', 'wp-seopress-pro'),
// 'tab_seopress_matomo' => esc_html__('Matomo Analytics', 'wp-seopress-pro'),
// 'tab_seopress_ps' => esc_html__('PageSpeed', 'wp-seopress-pro'),
// 'tab_seopress_gsc' => esc_html__('Search Console', 'wp-seopress-pro'),
// ];