Page 2 of 3

Re: hide closed comments even for Intense Debate

Posted: 14 May 2010, 11:39
by sayontan
I took a look at the plugin. Unfortunately there is not much I can do about it, since it is all handled in an AJAX call and the message is generated from the IntenseDebate site itself. There may be an alternative, however. You can probably control this using JQuery. You create a custom JavaScript file and put in this content:

Code: Select all

		$j = jQuery.noConflict();
		$j(document).ready(function() {
			var inner_html = $j('div.idc-message').html();
			if (inner_html != null && inner_html.indexOf('Commenting Disabled') > -1) {
				$j('div.idc-message').hide();
			}
		});
Try if this works, because I have my doubts. The thing is, the "idc-message" div is not a part of the document, so the JQuery variable might not be able to return anything. However, if anything works, this is the only one that has a chance.

Re: hide closed comments even for Intense Debate

Posted: 14 May 2010, 11:49
by marcnyc
where would I put this code?

is it not possible for Suffusion to remove their Ajax/JS query altogether from the code if comments are disabled?
I assume that Suffusion parses the contents returned by WP and removed the "comments are closed" text issued by the WP comments, and if so couldn't Suffusion just add the Intense Debate ajax/jsquery to the things to search for which then are removed/replaced by space?

Re: hide closed comments even for Intense Debate

Posted: 14 May 2010, 11:57
by sayontan
I mentioned it in my previous post - create a custom JS file. You can include that in the custom includes section, in the footer.
is it not possible for Suffusion to remove their Ajax/JS query altogether from the code if comments are disabled?
No.
I assume that Suffusion parses the contents returned by WP and removed the "comments are closed" text issued by the WP comments, and if so couldn't Suffusion just add the Intense Debate ajax/jsquery to the things to search for which then are removed/replaced by space?
While your assumption is correct, the conclusion is not. I don't think I can add the AJAX call at my side without recreating the whole plugin.

Re: hide closed comments even for Intense Debate

Posted: 14 May 2010, 12:24
by marcnyc
I tried adding your code to the custom header include section of Suffusion and as you expected it didn't work...

I don't know the inner workings of Suffusion but if you parse the content returned by WP before outputting it and you do some kind of search/replace function on that variable to remove the "comments are disabled" text, then I'd think a preg_replace() would take care of intense debate as well, but maybe I am wrong or don't understand how it's done internally...

Re: hide closed comments even for Intense Debate

Posted: 14 May 2010, 13:36
by sayontan
Marc,
As I said, the conclusion you are drawing is not correct. There is no PHP call that I can make or wrap for that plugin - it is all JS and there are no hooks I can use. The code I had provided was the only way I could think of, and as I suspected, it doesn't work. I don't plan to invest any more time on this plugin unless they change their inner workings.

Sayontan.

Re: hide closed comments even for Intense Debate

Posted: 16 May 2010, 07:48
by marcnyc
ok thanks for letting me know

Re: hide closed comments even for Intense Debate

Posted: 20 May 2010, 16:52
by marcnyc
Connie wrote:why not identify the CSS of that "comments are closed" and set that to visibility:hidden, display:none in the Custom CSS?

I think you should try that first and not put all burden on Sayontan's shoulder.
It can be easily acchieved by custom CSS, I guess
I am still working on this problem and revisiting this idea of Connie, however I am not sure I know how to check whether I am on a post or a page... Is there a PHP function or variable that I can interrogate to see if I am on a page or a post so that if I am on a page I can hide the comments via CSS?

Re: hide closed comments even for Intense Debate

Posted: 20 May 2010, 17:00
by sayontan
The PHP function is "is_page()". See here: http://codex.wordpress.org/Conditional_Tags. Let me know what you work out.

Re: hide closed comments even for Intense Debate

Posted: 20 May 2010, 19:18
by marcnyc
Thanks, got it!

I still don't understand the inner workings of WordPress and the hooks and functions, so I just modified the function that you posted to remove the rounded corners and it worked:

Code: Select all

<?php
// this function was posted by Sayontan at http://www.aquoid.com/forum/viewtopic.php?f=4&t=1443&p=6547
// I modified it to hide the Intense Debate comments from all the pages
remove_action('suffusion_document_header', 'suffusion_include_skin');
add_action('suffusion_document_header', 'suffusion_my_custom_skin', 11);

function suffusion_my_custom_skin() {
   global $suf_color_scheme;
   $skin = "dark-green.css";
   if (substr($suf_color_scheme, 0, 10) == "dark-theme") {
      $skin = "dark-".substr($suf_color_scheme, 11).".css";
   }
   else {
      $skin = substr($suf_color_scheme, 12).".css";
   }
?>
   <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/style.css" type="text/css" media="all"/>
   <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/<?php echo $skin;?>" type="text/css" media="all"/>
   <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/plugins.css" type="text/css" media="all"/>
<?php
   if (($rtl = get_locale_stylesheet_uri()) != '') {
?>
      <link rel="stylesheet" href="<?php echo $rtl; ?>" type="text/css" media="all" />
<?php
   }
   
	// #############################################################################################
	// modification to Sayontan's function to hide all the closed comment forms
	// #############################################################################################
   	// wp_reset_query();
	if ( is_page() ) {
		echo '
	<style type="text/css"> 
		#idc-container {
			display:none;
			visibility:hidden;
		}
	</style>
		';
	}
	// #############################################################################################

}
?>

Re: hide closed comments even for Intense Debate

Posted: 20 May 2010, 19:33
by sayontan
Interesting fix - the only drawback is that it will hide your message for all pages (sometimes the message might be relevant, I believe). I can make life quite a lot easier for you if you want to hide this for all pages. In a subsequent release very soon I am going to be switching full-scale to the WP PHP function post_class for all pages. When I do that, pages will have a class "page" associated with them - currently they have the class "post" associated. Then this will be a simple CSS include:

Code: Select all

.page #idc-container {
    display: none;
    visibility: hidden;
}
Of course, there is another way that your approach brings forth. Each page has a post id associated with it and that becomes the id of the HTML element, e.g. "post-113". So you could do this:

Code: Select all

#post-113 #idc-container {
    display: none;
    visibility: hidden;
}
Now, if am to include your fix in my code and hide this element only for pages where you have excluded comments, I can add this code to the file called custom-styles.php. I can loop through the pages you have excluded, then create the above CSS based on individual page ids.

Thanks for posting the fix - with the modifications I suggested I can make it a part of the standard code.