Created
November 30, 2019 12:46
-
-
Save wpmudev-sls/118587dbd07f4ae73c46c43f0aacb52d to your computer and use it in GitHub Desktop.
[SmartCrawl Pro] - Add automatic links in categories. Automatic links also work on category pages and category descriptions
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
<?php | |
/** | |
* Plugin Name: [SmartCrawl Pro] - Add automatic links in categories | |
* Plugin URI: https://premium.wpmudev.org/ | |
* Description: Automatic links also work on category pages and category descriptions | |
* Author: Maciek Palmowski @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org/ | |
* License: GPLv2 or later | |
*/ | |
add_action( | |
'init', | |
function() { | |
if ( class_exists( 'Smartcrawl_Autolinks' ) ) { | |
add_filter( 'the_excerpt', 'wpmudev_add_smartcrawl_links', 100 ); | |
add_filter( 'term_description', 'wpmudev_add_smartcrawl_links', 100 ); | |
if ( ! is_single() ) { | |
add_filter( 'the_content', 'wpmudev_add_smartcrawl_links', 100 ); | |
} | |
} | |
} | |
); | |
function wpmudev_add_smartcrawl_links( $content ) { | |
$settings = Smartcrawl_Autolinks::get()->get_settings(); | |
if ( isset( $settings['onlysingle'] ) && false === $settings['onlysingle'] ) { | |
unset( $settings['onlysingle'] ); | |
Smartcrawl_Autolinks::get()->set_settings( $settings ); | |
} | |
return Smartcrawl_Autolinks::get()->the_content_filter( $content ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment