Archive for the ‘PHP’ Category

Ads Display Bug: 2010-01-19

Tuesday, January 19th, 2010

08:30 AM: Noticed that since the plugin upgrades last night, the advertisements on this blog are appearing on the bottom three posts on the main page, and not the top three as before.  However, my other two blogs do not display this problem.  Investigating.

09:20 AM: Tried uninstalling and reinstalling the AddSense Integrator plugin.  The display problem persists.

09:30 AM: Tried restoring the site software for the   Tom’s Diary   blog from last weekend’s backups.  This had the effect of downgrading the plugins which I upgraded last night.  However, surprisingly, this did not fix the issue either.  Even with the old versions of all plugins, the ads still appear at the bottem of the main page instead of at the top.  Apparently, something has changed in the database itself.  However, I’m reluctant to restore it to last night’s backup, as I’ve made several posts and post edits since then that would be lost.   So I’ll need to find another solution. Stand by.

10:15 AM: Discovered approximately 20 blank ad records in the AddSense Integrator setup page on the   Tom’s Diary   blog, that are not present in the other two, correctly functioning blogs.  So, I deleted these.  This seems to have partially fixed the trouble.  Now, the first of the three ads indeed displays at the bottom of the first post.  This post is located at the top of the page.  However, the other two ads still appear on the bottom two posts on the main page.  So, I’ll keep digging. 

10:40 AM: Tried deleting all add records and then re creating the ones I need.  But the display issue still persists.  I’d like to have all ads close to the top of the main pages, because there, they’ll be more likely to be spotted, and clicked. 

11:00 AM: Looked for where the AddSense Integrator plugin is storing the data about the ads it displays.  First, I checked each table in the blog database. Didn’t see anything resembling these data there.  Then, I looked in the software directories for the blog, but could not find any recently-modified files there.  However, I didn’t check every possible place on the file system.  But I think I will now.

11:30 AM: Scrutenized the AddSense Integrator’s PHP code file for clues.  Nothing useful discovered so far.

01:20 PM: Looks like the AdSense Integrator stores the persistent data for the ads in the WordPress database wp-options table.  These options begin with abs_int_  . 

01:30 PM: Discovered that even when the AdSense Integrator plugin is removed, it leaves old data in the wp_options table.  So I’m going to remove these rows, reinstall the plugin, and see if the ads display where they’re supposed to.

01:35 PM: Removing the old options data from the database, and then reinstalling the AdSense Integrator plugin  did not solve the issue.  Looking further.

01:50 PM: There’s an AddSense Integrator option checkbox that appears on the post editing screen, which allows the editor to stop ads from displaying at the bottom of the post he’s working on.  In version 1.5.4 of this software, which I’d been using prior to the upgrade to 1.5.7 last night, the default value for this checkbox was UNCHECKED.  That is: Ads would display by default on all posts, unless the editor specifically checked this checkbox before saving the post. However, now the behavior is reversed.  The box is checked even though the data in the database for the post indicates that it should not be.  So whenever the editor either creates a new post, or saves an existing one, this checkbox comes up as CHECKED, and unless he specifically unchecks it before saving the post, the post is saved with the display of ads turned off, even though it was turned on before the save.  This would seem to qualify as a bug in the AddSense Integrator plugin.

Further in this latest version (1.5.7) of the AddSense Integrator, the ads still display as before, as long as you do not either add new posts, or modify existing ones.  This is why my other blogs seemed to be unaffected by the plugin upgrade, as I’ve not added or changed any posts on those since last night.  So, I pulled one post from   Tom’s Love Quest   into the editor, and then re-saved it.  Then, I went to the blog home page, and sure enough, ads no longer appeared on that particular post.  So then, I edited the document again and unchecked the “Check to disable ads on this post.” check-box, and again, re saved the post.  Proper ad display then returned.

02:15 PM: So, I’m investigating the possibility of changing the default state of this checkbox from CHECKED to UNCHECKED.

04:20 PM: Modified line 251 in the AddSense Integrator PHP file from this:

<input type=”checkbox” name=”ads_int_disable” <?php if ($ads_int_disable) echo “checked”; ?>/>

 to this:

<input type=”checkbox” name=”ads_int_disable” <?php if ($ads_int_disable) echo “unchecked”; ?>/>

However, a problem still exists that this checkbox is not correctly set from the post’s meta data.  This is a bug for the plugin’s developers to address.  But this work-around I’ve devised above will keep the box unchecked at all times, and stop the automatic setting of this flag when the post is saved.  No troubles with this here, because I prevent none of my posts from showing advertisements.

04:30 PM: Deleted all the ads_int_disable  records from the post_meta table in the database (six posts had been marked here as advertisement-disabled).  This should re enable display of ads on all posts in this blog.

 Tom Hesley

Related Posts

Today’s Business: 2010-01-08

Friday, January 8th, 2010

Today’s Activities

  • Cat duty.  DONE.
  • Dispensing Mom’s meds. DONE.
  • Shower. DONE.
  • Send out five pending memorial checks for the   WPSBC Alumni Association.
  • Pay all pending bills.  IN PROGRESS,
  • Fill out and Return all requested forms to the financial planner.
  • Go grocery shopping.  DONE.

Log 

08:45 AM: I’m up. My current weight is unchanged from yesterday, at 181.5 pounds.

08:55 AM: Sister Mary Ann just emailed me to say that she’d be visiting us this coming Monday, arriving at around noon.

09:30 AM: Swept all sidewalks and ramp; we got a dusting of snow overnight.

10:10 AM: Leaving for our weekly shopping trip with sister Jojo.

02:30 PM: We’re home again, and I’m putting things away and documenting the   shopping trip   now.

02:55 PM: Taking a nap.  Stand by.

06:15 PM: I’m back up again.  Mail received today follows:

  • An offer from Verizon for their DSL high-speed Internet and DIRECTV package for $70 a month for the first six months, then $94.99 a month for the next six months.  I’ve torn up so many of these, I can’t even count.
  • Income statements (W2s) for 2009.
  • A packet from some church in Oklahoma, inviting us to order a metal cross from them, as well as to send them any prayer requests.
  • A bank statement from one of my checking accounts.
  • Home telephone bills (Mom’s and mine).

 

06:45 PM: Posted the    Uncle Jack Sargent Died   piece.   I just found out today from Aunt Joan that Jack died on January 5th, 2006.

07:30 PM: Processed all pending grocery receipts.

07:55 PM: Posted the   Shopping Trip: 2009-12-23b   piece.

09:15 PM: Spent the last hour plus in contemplation, on my favorite bedroom rocking chair. 

11:40 PM: Talked with   [Emmy].  We’re discussing if we will in fact, attend camp this year.  In past years, our YES answer came so easily and without reservation.  This year though, the both of us are quite reserved about going, fearing that we’ll screw up our diets if we attend.  Well, we’ll continue discussing it until next month, when the forms for signing up arrive. 

01:10 AM: Fixed a bug on the   Recent Revisions Page,  that caused posts added or revised more than twenty-four hours ago to be displayed.  [Emmy]  mentioned tonight that she thought that duplicate posts were showing up from day to day in this list, that had not actually been changed during the last day, and in fact, sometimes, one would expect see the same post over several days appearing if I revise it multiple times over that same period.  However, posts that I last changed nearly two days ago appeared, erroneously, due to an apparent bug in the PHP function strtotime(), that incorrectly computes the current time minus 24 hours.  So I rewrote the code for the   Recent Revisions Page  so it no longer relies on this function, and things appear to be working correctly on that page now.  This fix has been applied to all my blogs. 

01:20 AM: Posted the list of changed or or added posts from this blog,  here.

01:25 AM: Posted the list of additions and revisions to the   Tom’s Love Quest   blog,   here

01:55 AM: My heavy eyelids are telling me that this day needs to be over now.  So, I’m going to bed.  *Yawn*   Good day, it was too.  Good day.  Hope yours was equally as fun.  Take care, friends, and I’ll catch you right here again later. 

Tom Hesley

Related Posts

Disabling Post Revisions in WordPress 2.8.5

Tuesday, October 27th, 2009

I discovered that WordPress was again saving every revision of every post, though I had disabled this feature back in March.  Click   here   for more details.  But apparently, in one or more of the many software releases since then, somehow saving these revisions became enabled once more. So I turned off this feature by adding the following lines of code to the wp-config.php file for each of my blogs:

// Disable post revisions.
define(’WP_POST_REVISIONS’, false);

I also changed line 576 in the wp-settings.php file from

$default_constants = array( ‘WP_POST_REVISIONS’ => true );

to

$default_constants = array( ‘WP_POST_REVISIONS’ => false );

Also note that the line number has changed since March from 495 to 576.

Then I deleted all the revisions that had been saved to this point from each blog database by executing the following SQL statement:

DELETE FROM wp_posts WHERE post_type = “revision”;

This query resulted in the deletion of over 900 rows from the   Tom’s Diary   blog database, 327 rows from the   Tom’s Love Quest   blog, and 40 rows from the   Tom’s Views   blog database.

I then logged out and back into each site’s admin id and verified that the revisions saved thus far no longer appear on the Edit Post screen. The deletion apparently worked.   These instructions have been verified to work with WordPress 2.8.5.

That’s all.

Tom Hesley

Related Posts

Displaying More ‘Recent Posts’ Links

Friday, October 23rd, 2009

I desired once again to increase the number of ‘Recent Posts’ links in my blogs’ sidebars. The default in WordPress 2.8.4 is 15 links but I wanted 100 to appear. These changes got erased that I had made in 2.7.1 when I upgraded to WordPress 2.8.  So, I’ve updated these instructions to account for the changes of location of the relevent code in 2.8.  You can see the original instructions for 2.7.1 by clicking here.  I’ve included the revised instructions for 2.8.4 below:

File to change: $WP_ROOT/wp-inclues/default-wigits.php.  Note that this is a different file than when I did this before for WordPress 2.7.1.

Find the Wp_Widget_Recent_Posts() routine in the file given above.  In WordPress 2.8.4 this function should start at line 513 if you’ve not changed the file from what’s contained in the official 2.8.4 release code.

Modify the following code snippet at lines 542 and 543 from…

else if ( $number > 15 )
$number = 15;

to

else if ( $number > 100 )
$number = 100;

Don’t forget to upload your modified file and to change the count of links to display in the admin pages of the “Recent Posts” widget for your WordPress site.  

I’ve verified that these changes work for WordPress 2.8.4 and 2.8.5.

Enjoy.

 

Tom

Displaying More ‘Recent Posts’ Links in WordPress

Wednesday, March 11th, 2009

I desired to increase the number of ‘Recent Posts’ links in my blogs’ sidebars. The default in WordPress 2.7.1 is 15 links but I wanted 100 to appear. To do that, I made the following change:

File to change: $WP_ROOT/wp-inclues/wigits.php

Find the wp_widget_recent_entries() routine in the file given above.

Modify the following code snippet from…

else if ( $number > 15 )
$number = 15;

to

else if ( $number > 100 )
$number = 100;

Don’t forget to upload your modified file and to change the count of links to display in the admin pages of the “Recent Posts” widget for your WordPress site.

Tom Hesley