_ok = parent::isValidAid( true ); add_shortcode( 'adfever', array(&$this, 'shortCode') ); if ( !is_admin() ) { wp_enqueue_style( 'adfever-shortcode', get_bloginfo('siteurl').'/?adfever-css=shortcode', array(), $this->version, 'all' ); $this->checkCSS(); } } function shortCode($atts) { global $post; if ( get_post_meta($post->ID, 'desactive_adfever', true) == '1' ) { // Options desactive adfever return ''; } if($this->_ok!==true) { return ''; } extract(shortcode_atts(array( 'type' => '', 'value' => '', ), $atts)); if ( empty($type) || empty($value) ) { return ''; } $shop_obj = $this->getShopObj(); switch ( $type ) { case 'top-category' : $item = $shop_obj->getTop( $value, 5 ); if ( !is_array($item["shopping"]["products"]["product"]) ) { return ''; } $key = array_rand( $item["shopping"]["products"]["product"] ); return $this->buildTableProduct( $item["shopping"]["products"]["product"][$key] ); break; case 'product' : default : // Get item and stores $item = $shop_obj->find( $value ); $item = $item["shopping"]["product"]; if($item) { return $this->buildTableProduct( $item ); } else { return ""; } break; } return ''; } function buildTableProduct( $item = null ) { if ( is_null($item) || ( isset($item[0]) && empty($item[0]) ) ) { //return __( 'Internal error.', 'adfever' ); return ""; } $stores = isset($item["offers"]["offer"]) ? $item["offers"]["offer"] : (isset($item[0]["offers"]["offer"]) ? $item[0]["offers"]["offer"]: False); if (!$stores) return ""; $item = isset($item['name']) ? $item : $item[0]; $current_options = get_option( $this->option_name ); $output = ''; $output .= '
| '.__('Retailer', 'adfever').' | ' . "\n"; $output .= ''.__('Availability', 'adfever').' | ' . "\n"; $output .= ''.__('Total price (incl.delivery)', 'adfever').' | ' . "\n"; $output .= '|
|---|---|---|---|
| '.wp_specialchars($store['merchant']).' | ' . "\n"; $output .= ''.$store['stock'].' | ' . "\n"; $output .= ''.$store['total_price']['value'].' ![]() | ' . "\n";
$output .= '
'.__('No retailers for this product.', 'adfever').'
' . "\n"; endif; $output .= parent::getCopyright(); $output .= '