Created
July 24, 2023 08:52
-
-
Save danmaby/c9d4aa3aa844718ecd8ef3ae1e68359b to your computer and use it in GitHub Desktop.
A shortcode that displays the SEO description generated by the Filter Everything Pro plugin
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
/** | |
* Adds a shortcode that displays the SEO description generated by the Filter Everything Pro | |
* plugin. If no description is available, the shortcode will display the default content. An | |
* an optional 'default' attribute can be used to specify the default content. | |
* | |
* @param array $atts An array of shortcode attributes. | |
* @return string The shortcode output. | |
*/ | |
function ps_add_filters_seo_description_shortcode($atts) | |
{ | |
// Extract the attributes | |
$atts = shortcode_atts( | |
array( | |
'default' => 'No facets are currently selected.', // Default value if 'default' attribute is not provided | |
), | |
$atts, | |
'fe_seo_description' | |
); | |
if (class_exists("FilterEverything\Filter\Container")) { | |
// Get the SEO description | |
$description = flrt_get_seo_data('description'); | |
// Check if the description is available | |
if ($description !== false) { | |
// Wrap the description in the plugin's HTML and return it | |
return '<div class="wpc-page-seo-description"><p>' . $description . '</p></div>'; | |
} else { | |
// Return default content wrapped in the plugin's HTML | |
return '<div class="wpc-page-seo-description"><p>' . $atts['default'] . '</p></div>'; | |
} | |
} | |
} | |
add_shortcode('fe_seo_description', 'ps_add_filters_seo_description_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing. I shall use it for my website of motorcycle accident of a celebrity. Hope it will make my site to work smoothly. So that user and search engine love it.