WordPress All-in-One SEO Pack PHP Error

The All-in-One SEO pack made by Semper Fi Web Design is a WordPress plugin that is used by innumerable blogs and websites all over the Internet.

It’s popular because it promises that strange SEO voodoo at the click(s) of a mouse and a few taps of a keyboard through the magic of the WordPress plugin.

It’s easy to install and relatively easy to setup if you already know all your SEO terminology.

So, I’m not a big fan of the plugin. From what I could work out, 98% of the features it provides really should be baked-in to any half-decent website.

The value is no doubt for those that either don’t have the tech-savvy to build such features into their websites or maybe because of shared or limited hosting access can’t tinker with the raw HTML/CSS/PHP of their website.

After installing the All-in-One SEO Pack (v1.6.13.8) plugin on WordPress v3.3.1 for the first time, I get this error message on the front-end:

Notice: Undefined index: aiosp_ex_pages in /var/www/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 118
Notice: Undefined index: aiosp_ex_pages in /var/www/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 118

Travelling to line 118 in aioseop.class.php I get to see:

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
	function aioseop_mrt_exclude_this_page(){
			global $aioseop_options;
			$currenturl = trim($_SERVER['REQUEST_URI'],'/');
	/*		echo "<br /><br />";
			echo $aioseop_options['aiosp_ex_pages'];
			echo "<br /><br />";
*/
 
			$excludedstuff = explode(',',$aioseop_options['aiosp_ex_pages']);
			foreach($excludedstuff as $exedd){
				//echo $exedd;
			    $exedd = trim($exedd);
			            if($exedd){
			                if(stristr($currenturl, $exedd)){
			                    return true;
				}
			}
		}
		return false;
	}

From a quick look it seems like there is no check to see whether or not they index/key aiosp_ex_pages existing within the $aioseop_options variable, which it most likely would not following a fresh install.

Quick fix, should be just to add a conditional statement to check if that index/key is in fact set before looping over it.

See fixed code below:

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	function aioseop_mrt_exclude_this_page(){
			global $aioseop_options;
			$currenturl = trim($_SERVER['REQUEST_URI'],'/');
	/*		echo "<br /><br />";
			echo $aioseop_options['aiosp_ex_pages'];
			echo "<br /><br />";
*/
			// check for existence of key.
			if ( isset( $aioseop_options['aiosp_ex_pages'] ) )
			{
				$excludedstuff = explode(',',$aioseop_options['aiosp_ex_pages']);
				foreach($excludedstuff as $exedd){
					//echo $exedd;
					$exedd = trim($exedd);
							if($exedd){
								if(stristr($currenturl, $exedd)){
									return true;
					}
				}
			}
		}
		return false;
	}

That should silence those notice errors. Of course you could bury your head in the sand and just turn all error messages off so you don’t even see this, but that wouldn’t be good web development, would it?

Any questions/comments, drop a line below.

Post a Comment

Wrap code blocks with <pre lang="LANGUAGE" line="1"> and </pre> where LANGUAGE is a GeSHi supported language syntax. The line attribute is optional. More help here.

Your email is never shared. Required fields are marked *

*
*