WordPress.org

Forums

WEBphysiology Portfolio
[resolved] Array Indexes Need Quotes (3 posts)

  1. wawco
    Member
    Posted 2 years ago #

    Hey there,

    Some indexes in functions.php are not wrapped in quotes like they should and this generates warning spam (either in logs or on screen if errors display).

    Here's a patch you can apply. I uh... sort of slipped a bunch of nearby whitespace fixes in there, too. My editor automatically trims trailing whitespace, sorry! The code fixes are towards the end.

    I would've submitted this as a ticket but for the life of me I can't find this project to submit a ticket to. It doesn't seem to have you listed as a component in that part of trac.

    Index: trunk/function.php
    ===================================================================
    --- trunk/function.php	(revision 721122)
    +++ trunk/function.php	(working copy)
    @@ -3268,106 +3268,106 @@
     			}
     		}
     	}
    -
    +
     	// if the image was not specified or was cleared due to issues, use the default empty image
     	if ( empty($full_size_img_url) ) {
    -
    +
     		$img_url = $missing_img_url;
    -
    +
     		if ( empty($img_url) ) {
     			$img_url = plugin_dir_url(__FILE__) . 'images/empty_window.png';
     		}
    -
    +
     		if ( ! empty($img_url) ) {
    -
    +
     			$file_path = parse_url( $img_url );
    -
    +
     			// if the missing image is not hosted on our server
     			if ( strtolower($_SERVER['HTTP_HOST']) != strtolower($file_path['host']) ) {
    -
    +
     				if ($debug == true) {
     					echo 'host <> HTTP_HOST =&nbsp;&nbsp;' . $file_path['host'] . '&nbsp;&nbsp;<>&nbsp;&nbsp;' . $_SERVER['HTTP_HOST'] . '<br />';
     				}
    -
    +
     				// go and get the cached image for our externally hosted image
     				if ( $debug == true ) { echo "missing img before check_external = " . $img_url . "<br />"; }
     				$img_url = check_external ($img_url);
     				if ( $debug == true ) { echo "missing img after check_external = " . $img_url . "<br />"; }
    -
    +
     			}
    -
    +
     			$class = ' class="missing"';
     			$continue = 'true';
     		}
    -
    +
     	}
    -
    +
     	if ( $continue == 'true' ) {
     		$img_url = clear_pre_content($img_url);
     	}
    -
    +
     	$vid = false;
    -
    +
     	if ( $img_url == 'images/empty_window.png' ) {
     		$img_url = plugin_dir_url(__FILE__) . $img_url;
     	}
    -
    +
     	// if the portfolio is a supported video, it is being displayed in a litebox and there was no image associated, allow the litebox
     	//   to still be used as the video hosting services supported will provide a thumbnail
     	if ( ( $click_behavior == 'litebox' ) && ( $supported_video ) && ( $continue != 'true' ) ) { $continue = 'true'; }
    -
    +
     	if ( ($click_behavior == 'litebox') && ($continue == 'true') && ( ( ! empty($full_size_img_url) ) || $supported_video ) ) {
    -
    +
     		if ( $supported_video ) {
    -
    +
     			$fbclass = get_video_class($site_url);
     			$anchor_open = '<a class="Portfolio-Link' . $fbclass . '" href="' . $site_url . '" title="' . the_title_attribute( 'echo=0' ) . '"' . $target . '>';
    -
    +
     			if ( empty($non_external_service_full_size_img_url) ) {
     				$img_html = get_Video_Thumbnail($site_url, $img_url, $opt_val_img_width);
     				$vid = true;
     			} else {
     				$img_html = webphys_portfolio_image_resize($img_url);
     			};
    -
    +
     		} else {
    -
    +
     			$anchor_open = '<a class="Portfolio-Link wpp-thickbox" href="' . $full_size_img_url . '" title="' . the_title_attribute( 'echo=0' ) . '"' . $target . '>';
     			$img_html = webphys_portfolio_image_resize($img_url);
    -
    +
     		}
    -
    +
     		$anchor_close = '</a>';
    -
    +
     	} elseif ( ( $click_behavior == 'nav2page' ) && ( $supported_video ) ) {
    -
    +
     		$anchor_open = '<a href="' . $site_url . '" title="' . the_title_attribute( 'echo=0' ) . '" class="Portfolio-Link"' . $target . '>';
     		$anchor_close = '</a>';
    -
    +
     		if ( empty($non_external_service_full_size_img_url) ) {
     			$img_html = get_Video_Thumbnail($site_url, $img_url, $opt_val_img_width);
     			$vid = true;
     		} else {
     			$img_html = webphys_portfolio_image_resize($img_url);
     		};
    -
    +
     	} elseif ( ( $click_behavior == 'nav2page' ) && ( ! empty($site_url) ) && ($continue == 'true') ) {
    -
    +
     		$anchor_open = '<a href="' . $site_url . '" title="' . the_title_attribute( 'echo=0' ) . '" class="Portfolio-Link"' . $target . '>';
     		$anchor_close = '</a>';
     		$img_html = webphys_portfolio_image_resize($img_url);
    -
    +
     	} elseif ( ( ! empty($img_url) ) && ($continue == 'true') ) {
    -
    +
     		$img_html = webphys_portfolio_image_resize( $img_url);
    -
    +
     	}
    -
    +
     	if ( ! empty($img_html) ) {
    -		if ( isset($img_html[width]) ) {
    -			$path = $anchor_open . '<img src="' . $img_html[url] . '" alt="' . the_title_attribute('echo=0') . '" width="' . $img_html[width] . '" height="' . $img_html[height] . '"' . $class . ' />' . $anchor_close;
    +		if ( isset($img_html['width']) ) {
    +			$path = $anchor_open . '<img src="' . $img_html['url'] . '" alt="' . the_title_attribute('echo=0') . '" width="' . $img_html['width'] . '" height="' . $img_html['height'] . '"' . $class . ' />' . $anchor_close;
     		} else {
    -			$path = $anchor_open . '<img src="' . $img_html[url] . '" alt="' . the_title_attribute('echo=0') . '"' . $class . ' />' . $anchor_close;
    +			$path = $anchor_open . '<img src="' . $img_html['url'] . '" alt="' . the_title_attribute('echo=0') . '"' . $class . ' />' . $anchor_close;
     		}
     	} elseif ( ($continue == 'false') && ($stw == "true") ) {
     		$path = $anchor_open . $full_size_img_url . $anchor_close;

    http://wordpress.org/extend/plugins/webphysiology-portfolio/

  2. wawco
    Member
    Posted 2 years ago #

    The code at line 266 can also cause problems when editing. It will begin to generate SQL errors if you change a post.

    $post_ID should be changed to $post_id.

    There are also one or two more array indexes I missed in my above patch.

  3. Jeff Lambert
    Member
    Plugin Author

    Posted 2 years ago #

    Hi @wawco,

    Appreciate that catches and have gone through this file and added quotes where they were missing and updated $post_ID to $post_id. I'll check the rest of the code for these issues too.

    Thanks again

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WEBphysiology Portfolio
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags