Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Adrien L

    (@adrien-l)

    You nailed it. Changing the WPBruiser plugin dir did the trick (actually it’s called “goodbye-captcha”, legacy…).

    I’d check if there hasn’t been any recent ownership changes for this plugin if I were the WordPress Security team…

    Do you have any other recommendation for a no-ReCaptcha anti spam solution, BTW?

    I’m now checking Sucuri, thanks.

    EDIT: The Sucuri plugin found the remaining malicious PHP files and the corrupted core files, I have good hopes that my install is clean now. Thanks.
    Also, I put a comment about my suspicions towards WPBruiser in the plugin page, and went with Akismet for the time being (although I don’t like its data leakage). I will put a math captcha sometime, it has always done the trick for me.

    • This reply was modified 5 years, 6 months ago by Adrien L. Reason: Solved
    Thread Starter Adrien L

    (@adrien-l)

    Hello,

    So, the bug was caused by Piwik. In the plugin WP-Piwik, we can choose various ways to link WordPress to Piwik, including PHP or by URL. I chose PHP, first, which caused the bug. By URL, it works fine.

    I spent days on this issue. Plugins compatibility is a pain in the ass. I’ll do a better investigation to check which exact WP-Piwik parameter makes your plugin break when I set up the new version of the website I’m working on. For now, philosophy “it works, don’t touch anything”!

    I suggest you put a line about this issue somewhere, that kind of php being sent as xml bug is just impossible to track down…

    Thanks anyway for your plugin, which brings us hundreds of views everyday! ??
    Adrien

    Thread Starter Adrien L

    (@adrien-l)

    No input on the topic? Seeing that I’m the only one with this bug, I guess it must come from another plugin or theme, but I’d really appreciate your advice on its resolution.

    Thanks,
    Adrien

    Thread Starter Adrien L

    (@adrien-l)

    So, I answered my own question. I generate static CSS everytime a category is added or modified. This way, no PHP overload on the client side.

    In functions.php (or a different file called with require_once, to make it cleaner):

    // Function called after every category edit or creation
    function save_category_color_css( $term_id ) {
    	// URL of your css directory
    	$css_dir = get_stylesheet_directory() . '/assets/css/'; // Shorten code, save 1 call
    	ob_start(); // Capture all output (output buffering)
    
    	require($css_dir . 'category-color.css.php'); // Generate CSS
    
    	$css = ob_get_clean(); // Get generated CSS (output buffering)
    	file_put_contents($css_dir . 'category-color.css', $css, LOCK_EX); // Save it
    }
    
    function category_color_css_init() {
    	// Require the Category Color plugin
    	if( !function_exists('rl_color') ) return false;
    
    	// Only execute on admin pages
    	if ( !is_admin() )
    		return false;
    
    	// Get a list of all the categories
    	$categories = get_categories(array(
    		'hide_empty'               => 0
    	));
    
    	// attach the save_category_color_css function to each category's edited and created hook
    	foreach ( $categories  as $cat ) {
    		add_action("created_category", 'save_category_color_css', 10, 1);
    		add_action("edited_category", 'save_category_color_css', 10, 1);
    	}
    }
    add_action('admin_init', 'category_color_css_init');
    
    // Enqueue our brand new CSS
    function enqueue_category_color_css() {
    	if( function_exists('rl_color') )
    		wp_enqueue_style( 'category-color-css', get_template_directory_uri() . '/assets/css/category-color.css', array(), '', 'all' );
    }
    add_action('wp_enqueue_scripts', 'enqueue_category_color_css', 999);

    In category-color.css.php:

    <?php
    
    // remove error reporting so that we don't break the CSS in debug mode
    $reporting_level = error_reporting();
    error_reporting(0);
    
    // get all the categories
    $categories = get_categories( array(
    	'hide_empty'               => 0
    ));
    
    foreach( $categories as $category ){
    	// get the color
    	$cat_color = rl_color($category->term_id);
    
    	// create a CSS block only if the color is set
    	if( ! empty($cat_color) && $cat_color != '#' ) : ?>
    
    /* <?php echo $category->name; ?> */
    .category-<?php echo $category->term_id; ?> {
    	background-color: <?php echo $cat_color; ?> !important;
    }
    
    	<?php
    	endif;
    }
    
    // re-enable the error reporting
    error_reporting($reporting_level);
    ?>

    I think your plugin would really benefit this addition, so feel free to steal my code.

    Also, you have some notices in the category edit screen:

    Notice: Undefined property: RadLabs_Category_Colors::$js in /whatever/wp-content/plugins/category-color/rl_category_color.php on line 75
    Notice: Undefined property: RadLabs_Category_Colors::$css in /whatever//wp-content/plugins/category-color/rl_category_color.php on line 57
    Notice: Undefined index: desc in /whatever/wp-content/plugins/category-color/rl_category_color.php on line 126
Viewing 4 replies - 1 through 4 (of 4 total)