Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmudev-sls/dc66e2db1b92f0c72a2826d6a7783733 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/dc66e2db1b92f0c72a2826d6a7783733 to your computer and use it in GitHub Desktop.
[SmartCrawl] Fix conflict with Uncode theme - Issue with readability, SEO Checkup
<?php
/**
* Plugin Name: [SmartCrawl] Fix conflict with Uncode theme
* Description: [SmartCrawl] Fix conflict with Uncode theme - Issue with readability, SEO Checkup
* Task: 0/46496453944769/1164667391395617
* Author: Thobk @ WPMUDEV
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) { exit; } elseif ( defined( 'WP_CLI' ) && WP_CLI ) { return; }
add_action( 'after_setup_theme', 'wpmudev_sc_fix_conflict_uncode_theme', 100 );
function wpmudev_sc_fix_conflict_uncode_theme() {
if ( defined( 'SMARTCRAWL_VERSION' ) && SMARTCRAWL_VERSION && class_exists('Smartcrawl_Controller_Analysis_Content') && class_exists('Uncode_Install') ) {
class WPMUDEV_SM_Uncode{
public function __construct(){
add_filter( 'the_content', array( $this, 'filter_content' ), $this->priority() - 1 );
}
public function priority(){
return 99999;
}
private function is_analysis_running() {
return ! empty( $_GET['wds-frontend-check'] )
&& ! is_admin()
&& is_user_logged_in();
}
public function filter_content( $content ){
if( empty( $content ) && $this->is_analysis_running() ){
$analysis_content = Smartcrawl_Controller_Analysis_Content::get();
if( $analysis_content->get_analysis_strategy() === Smartcrawl_Controller_Analysis_Content::STRATEGY_STRICT ){
remove_filter( 'the_content', array( $analysis_content, 'wrap_post_content' ), $this->priority() );
add_filter( 'uncode_single_content', array( $analysis_content, 'wrap_post_content' ), $this->priority() );
$content .= '<i style="display:none"></i>';// strick to trigger filter uncode_single_content
}
}
return $content;
}
}
$run = new WPMUDEV_SM_Uncode;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment