Title: Missing Argument Warning
Last modified: August 31, 2016

---

# Missing Argument Warning

 *  Resolved [YOELO](https://wordpress.org/support/users/yoebo/)
 * (@yoebo)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/missing-argument-warning-1/)
 * Hi, I have the following code in my functions.php to show a lightbox on the **
   Simple Paypal Shopping Cart** Plugin
 *     ```
       function make_wpspsc_thumbs_lightbox_previews( $thumbnail, $atts ) {
   
       	// Code Credit: http://stackoverflow.com/questions/19323324/how-to-get-image-src-attribute-value-from-php-string
   
       	$doc = new DOMDocument();
   
       	// Let's make sure we don't execute this code on the wrong elements & blow up the site
       	if ( ! is_object( $doc ) ) {
       		return $thumbnail;
       	}
   
       	libxml_use_internal_errors(true);
       	$doc->loadHTML( $thumbnail );
       	$xpath = new DOMXPath($doc);
       	$imgs = $xpath->query("//img");
       	for ($i=0; $i < $imgs->length; $i++) {
           		$img = $imgs->item($i);
           		$src = $img->getAttribute("src");
       	}
       	// Now let's use the image src we just got & rel="lightbox" because that's what Responsive Lightbox from dFactory uses
       	$new_thumbnail = '<a href="'.$src.'" rel="lightbox">'.$thumbnail.'</a>';
   
       	return $new_thumbnail;
       }
       add_filter( 'wspsc_product_box_thumbnail_code', 'make_wpspsc_thumbs_lightbox_previews' );
       ```
   
 * When I add something the the cart I get the warning:
 *     ```
       Warning: Missing argument 2 for make_wpspsc_thumbs_lightbox_previews()
       ```
   
 * On line 16 which is this:
 *     ```
       function make_wpspsc_thumbs_lightbox_previews( $thumbnail, $atts ) {
       ```
   
 * Can anyone see what is causing the problem please?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/missing-argument-warning-1/#post-6989481)
 * By default, `add_filter()` only passes 1 parameter to callbacks. Your callback
   is using 2 parameters so you need to specify that in your `add_filter()` call:
   `
   add_filter( 'wspsc_product_box_thumbnail_code', 'make_wpspsc_thumbs_lightbox_previews',
   10, 2 );`
 * The 10 is a priority parameter, the default is 10. Smaller numbers execute earlier,
   bigger later. Very important in some cases, in others it doesn’t matter. It is
   supplied here just so we can supply the 2 after it.
 *  Thread Starter [YOELO](https://wordpress.org/support/users/yoebo/)
 * (@yoebo)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/missing-argument-warning-1/#post-6989484)
 * Thank you so much

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Missing Argument Warning’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [YOELO](https://wordpress.org/support/users/yoebo/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/missing-argument-warning-1/#post-6989484)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
