Archive for March, 2010

JQuery to remove any div with id on any web page

Tuesday, March 30th, 2010

JQuery to remove any div with id on any web page

Usually you need this kind of situation when you are using any framework or templates where header is in different file but being used as common and you need not to show anything specific from that header only on this page, where you can add this:

http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

<script type=”text/javascript”>
$(“#adTag1″).remove();
</script>

<script type=”text/javascript”>$(“#adTag1″).remove();</script>

YOU CAN ALSO USE ANY OF THESE:

To remove the element with id equal to removeme only if it is empty:

$(“#removeme:empty”).remove();

To remove all empty <div>s:

$(“div:empty”).remove();

EDIT: If it’s not empty, but has whitespace:

if($.trim($(“#removeme”).text()) == “”) {

$(“#removeme”).remove();

}

Post to Twitter Tweet This Post

  • Share/Bookmark

IE issue when using Wordpress 2.7 (IE 6, 7, 8) troubleshooting

Tuesday, March 9th, 2010
IE issue when using Wordpress 2.7 (IE 6, 7, 8)

I was running this live blog with thousands of visitors for a gaming site, the issue I noticed was that none of IE version was loading sidebar and footer when tried to visit this blog. I had rolled back all my svn changes. When I run that blog on local with empty db on local it doesn’t produce issue. When I tried using live db downloading on local I could produce the issue. Now I tried removing contents of elements as well as indented elements and made sure every tag has closing tag but did not work. I also tried Tidy an Add-on for Firefox that currently only supports Windows platform. My frustration was increasing finally I decided to go out and take an hour walk despite it was very windy and cold that my eyes were tearing and then I got back. I thought may be it’s number of posts which are so many if I reduce them and test how it reacts and finally it worked. I logged in to blog admin, clicked to Settings, Reading and changed 10 to 5 posts by the label “Blog pages show at most”. Thought people out there should not face 2 days on this type of issue and use this post to save time.

Post to Twitter Tweet This Post

  • Share/Bookmark

Wordpress Highlight comments by multiple Authors.

Monday, March 8th, 2010

<![CDATA

IN Comments.php ADD FOLLOWING RIGHT BEFORE FIRST <ol element that contains comment_author_link():

<?php

$users = get_users_of_blog();

foreach( $users as $user ) {

$role = array_pop( array_keys( unserialize($user->meta_value) ) ); // yeah, I know, looks awkward :)

$user_id = $user->user_id;

if ( $role != 'subscriber' ) // collect id of anyone whose role is greater than 'subscriber'

$roles[ $user_id ] = $role;

}

?>

<style>

#commentlist li { border:2px solid white; } /* not logged or subscriber */

#commentlist li.administrator { border:2px solid red } /* blog admin */

#commentlist li.author { border:2px solid blue } /* author */

#commentlist li.editor { border:2px solid yellow } /* editor */

</style>

NOW EDIT THE FIRST <ol ELEMENT WHICH SHOULD LOOK SIMILAR TO:

<ol id=”commentlist”>

<?php foreach ($comments as $comment) : ?>

<li>

<p>By <?php comment_author_link() ?> – <?php comment_date() ?></p>

<?php comment_text() ?>

</li>

<?php endforeach; ?>

</ol>

AFTER ADDING FOLLOWING:

<?php // The extra stuff to get commenter’s role

$user_id = $comment->user_id;

$role = ( isset( $roles[$user_id] ) ? $roles[$user_id] : ” );

?>

class=”<?php echo $role; ?>”

SHOULD LOOK LIKE THIS:

<ol id=”commentlist”>

<?php foreach ($comments as $comment) : ?>

<?php // The extra stuff to get commenter’s role

$user_id = $comment->user_id;

$role = ( isset( $roles[$user_id] ) ? $roles[$user_id] : ” );

?>

<li>

<p>By <?php comment_author_link() ?> – <?php comment_date() ?></p>

<?php comment_text() ?>

</li>

<?php endforeach; ?>

</ol>

CREATE AUTHOR AND SUSBCRIBER USERS IN WORDPRESS ADMIN, WRITE DUMMY COMMENTS AND TEST THAT.

]]>

Post to Twitter Tweet This Post

  • Share/Bookmark