This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sp_ai_openai_alt_text($prompt_alt_text, $post_id) { | |
$language = 'English'; | |
$image_src = wp_get_attachment_image_src($post_id, 'full'); | |
$prompt_alt_text = sprintf(__('Write in less than 10 words an alternative text to improve accessibility and SEO, in this language %1$s, for this image URL: %2$s.', 'wp-seopress-pro'), esc_attr($language), esc_html($image_src[0])); | |
return $prompt_alt_text; | |
} | |
add_filter( 'seopress_ai_openai_alt_text', 'sp_ai_openai_alt_text', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('seopress_gtag_ec_single_view_details_ev', 'sp_gtag_ec_single_view_details_ev'); | |
function sp_gtag_ec_single_view_details_ev($js) { | |
$js = 'gtag("event", "view_item", { | |
currency: "USD", | |
value: 7.77, | |
items: [ | |
{ | |
item_id: "SKU_12345", | |
item_name: "Stan and Friends Tee", | |
affiliation: "Google Merchandise Store", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sp_titles_template_variables_array($array) { | |
$array[] = '%%parent_terms_title%%'; | |
return $array; | |
} | |
add_filter('seopress_titles_template_variables_array', 'sp_titles_template_variables_array'); | |
function sp_titles_template_replace_array($array) { | |
$queried_object = get_queried_object(); | |
$term_id = $queried_object->term_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('seopress_sitemaps_html_hierarchical_terms_query', 'sp_sitemaps_html_hierarchical_terms_query', 10, 2); | |
function sp_sitemaps_html_hierarchical_terms_query($cpt_key, $args_terms_query) { | |
if ($cpt_key === 'testimonials') {//replace 'testimonials' with your own post type key | |
$cats = get_terms('type', $args_terms_query); | |
return $cats; | |
} | |
return; | |
} | |
add_filter('seopress_sitemaps_html_hierarchical_tax_query', 'sp_sitemaps_html_hierarchical_tax_query', 10, 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sp_primary_category_list($cats) { | |
//default | |
//$cats = get_categories(); | |
// global $typenow; | |
// global $post; | |
// if ('product' == $typenow) { | |
// $cats = get_the_terms($post_id, 'product_cat'); | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('seopress_sitemaps_html_product_cat_slug', 'sp_sitemaps_html_product_cat_slug'); | |
function sp_sitemaps_html_product_cat_slug($product_cat_slug) { | |
$product_cat_slug = 'product_cat'; //default | |
return $product_cat_slug; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sp_sitemaps_single_query($args, $cpt_key) { | |
if ( $cpt_key == 'product' ) { | |
$args['tax_query'][] = array( | |
'taxonomy' => 'product_visibility', | |
'field' => 'slug', | |
'terms' => ['exclude-from-catalog', 'outofstock'], | |
'operator' => 'NOT IN', | |
); | |
} | |
return $args; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('seopress_rss_post_thumb_size', 'sp_rss_post_thumb_size'); | |
function sp_rss_post_thumb_size($size) { | |
//Will be used with wp_get_attachment_image_src() https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/ | |
$size = 'thumbnail'; //Accepts any registered image size name (thumbnail, medium, large, full or custom size name), or an array of width and height values in pixels (in that order). | |
return $size; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove last crumb on singular page/post | |
add_filter('seopress_pro_breadcrumbs_crumbs', 'sp_pro_breadcrumbs_crumbs'); | |
function sp_pro_breadcrumbs_crumbs($crumbs) { | |
if (is_singular()) { | |
add_filter('seopress_pro_breadcrumbs_last_item_linkable', '__return_true'); | |
end($crumbs); | |
$lastKey = key($crumbs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('seopress_titles_user_meta', 'sp_titles_user_meta', 10, 2); | |
function sp_titles_user_meta($user_meta_value, $user_meta_key) { | |
//do your stuff | |
//$user_meta_value = esc_attr(get_user_meta(get_current_user_id(), $user_meta_key, true)); | |
return $user_meta_value; | |
} |