IS301 practices safe browsing
IS301.com on Twitter
-
Recent Posts
Recent Comments
- Dr. D. on A major change for the site
- Dr. D. on A major change for the site
- Chris Rodiilosso on It’s time for me to say farewell
- Chris Rodiilosso on It’s time for me to say farewell
- Chris Rodiilosso on The call to ban autonomous weapons grows louder
Ars Technica’s I.T. News Feed
- Yearlong supply-chain attack targeting security pros steals 390K credentials
- Twirling body horror in gymnastics video exposes AI’s flaws
- Critical WordPress plugin vulnerability under active exploit threatens thousands
- OpenAI introduces “Santa Mode” to ChatGPT for ho-ho-ho voice chats
- Russia takes unusual route to hack Starlink-connected devices in Ukraine
AnandTech’s Hardcore Hardware News Feed
- End of the Road: An AnandTech Farewell
- The Corsair iCUE LINK TITAN 360 RX RGB AIO Cooler Review: Meticulous, But Pricey
- The iBUYPOWER AW4 360 AIO Cooler Review: A Good First Effort
- The Cougar Poseidon Ultra 360 ARGB AIO Cooler Review: Bright Lights, Average Cooling
- Sabrent Rocket nano V2 External SSD Review: Phison U18 in a Solid Offering
Recent Videos
Running Windows 10 in VirtualBox
Ripping Media
PLEX
XBMC
Tag Cloud
Alan Turing Amazon Apple Bing Comcast Copyright Cox Design Drone Facebook FCC Firefox Futurama Google history HTC Intel iWatch John Oliver Malware Microsoft Movies Music Netflix Net Neutrality Oculus Passwords Radio Shack Samsung Security Simpsons Steam Stephen Hawking Steve Jobs Tom Wheeler Twitter UCI Valve Virtual Reality Vive VR Windows Windows 10 Wordpress YouTube
Darren
Lecturer in the Informatics department at the University of California, Irvine. Previously on the faculty of Nevada State College's School of Arts and Sciences, the University of Nevada, Las Vegas' Lee Business School, and The University of Maryland, Baltimore County's School of Information Technology and Engineering. I'm the creator of IS301.com which you are reading right now, co-founder of and regular contributor to theexperiencebar.com, and all-around fun guy.
A small update to the site’s functionality (and learn some PHP!)
There has been so much to write about, however I have been beyond busy especially with the quarter drawing to a close. There is a showcase to plan and schedule for, and industry people will be there so I want my students to shine. From what I’ve seen, they will. On top of that I’m mentoring a group for a business competition and of course there’s the regular teaching, grading, meetings and other stuff that goes on.
Nevertheless, it had been nagging at me that the site’s comment functionality never worked quite right. I’ve been made aware of it before, so why it started to gnaw at me two weeks ago I’m not certain, but it did. What I wanted it to do was give visitors an option of commenting via WordPress login, Facebook, Twitter, or other social media accounts they may prefer rather than having to sign up specifically with WordPress. Normally on a WordPress site there is an option for this, however for whatever reason – and I never understand why WP themes do this – my theme overrode this, forcing visitors to log in through WordPress if they wanted to comment (hence one of the reasons for the dearth of comments). You can see how it should look in the header image. Luckily, the fix was beyond easy, but shows the lengths the theme designer went through to ensure a broken commenting system.
Here’s what I had to do to fix it. You aren’t going to believe it, but here we go:
WordPress uses a file called ‘comments.php’ to provide comment functionality. Here’s what my original comment.php file looked like:
<?php if ( post_password_required() ) { ?>
<p><?php _e( ‘This post is password protected. Enter the password to view any comments.’, ‘themater’ ); ?></p>
<?php return; } ?>
<?php if ( have_comments() ) { ?>
<div id=”comments”>
<h3 id=”comments-title”><?php
printf( _n( ‘One Response to %2$s’, ‘%1$s Responses to %2$s’, get_comments_number(), ‘themater’ ),
number_format_i18n( get_comments_number() ), ‘<em>’ . get_the_title() . ‘</em>’ );
?></h3>
<ol class=”commentlist”>
<?php wp_list_comments(); ?>
</ol>
<?php if ( get_comment_pages_count() > 1 ) { ?>
<div class=”navigation clearfix”>
<div class=”alignleft”><?php previous_comments_link( __( ‘<span class=”meta-nav”>←</span> Older Comments’, ‘themater’ ) ); ?></div>
<div class=”alignright”><?php next_comments_link( __( ‘Newer Comments <span class=”meta-nav”>→</span>’, ‘themater’ ) ); ?></div>
</div><!– .navigation .clearfix –>
<?php } ?>
</div><!– #comments –>
<?php } ?>
<?php comment_form(); ?>
A lot there, yes? You may be wondering if the comments functionality needs all that PHP, and the answer is no. Actually, it’s because it was all there that the comment functionality was broken in the first place. In fact, to INCREASE the functionality of the comment system and allow people to comment using any social media login they prefer, I had to make the following changes. Be sure to pay very close attention, because the change is subtle and hard to notice; see if you can see it in the new code:
<?php comment_form(); ?>
Did you see it? You may want to read through it again to be sure. I’ll wait.
So there you have it. By deleting the entirety of what was there before and only leaving the final line, full functionality was restored, the attempts at subverting the proper order of things was thwarted, and all is right with the world. Now, anyone who wants to leave a comment can do so in a way that is quick and easy, just like the code that allows it.