• Resolved dontcair

    (@dontcair)


    I am adding code to a plugin that adds a widget and an additional shortcode handler. the shortcode is being recognized and processed correctly however some of the variables are blank. Here is the code

    function WPOS_Shortcodes( $attr ) {
    		shortcode_atts( array(
    				'id' => '',
    				'type' => '',
    				'data' => '',
    				'amount' => '1',
    				'rows' => '1',
    				'cols' => '1',
    				'dsize' => '300',
    				'match-all' => '0',
    				'hide-price' => '0'
    		), $attr );
    		return static::display($attr);
    	}
    
    	function display( $args ) {
    		$widgetContent = '';
    		extract( $args );
    		$dblink = tep_db_connect();
    	    $query = "select p.products_id, pd.products_name, p.products_image, pd.products_url, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1'";
    		if (!empty($id))
    		{
    		    $query .= " and p.products_id = '" . $id . "' and pd.products_id = p.products_id";
    			$product_query = tep_db_query($query);
    			$product = tep_db_fetch_array($product_query);
    			$widgetContent = '<a href="' . HTTP_SERVER . '/' . STORE_SLUG . '/?slug=' . FILENAME_PRODUCT_INFO . '&products_id=' . $product['products_id'] . '"><img src="' . DIR_WS_IMAGES . $product['products_image'] . '" width="' . $dsize . '" height="' . $dsize . '"><br />' . $product['products_name'] . '</a><br />' . $product['products_price'];
    		}
    		else
    		{
    
    		}
    		return $widgetContent;
    	}

    both of the functions are inside of a class if that makes a difference.
    The problem is that dsize is blank so the image is not resized. I was under the impression that the shortcode_atts() call was supposed to set default values when the value isn’t passed to the shortcode. I am only passing the id value to the short code. so if the defaults are set why aren’t they propagating to the extracted variables?

Viewing 1 replies (of 1 total)
  • Thread Starter dontcair

    (@dontcair)

    DUH!! haha sorry I figured it out. I didn’t reassign $attr with the result of shortcode_atts()

Viewing 1 replies (of 1 total)

The topic ‘problem with processing short codes’ is closed to new replies.