'', 'value' => '', ), $atts)); if ( empty($type) || empty($value) ) { return ''; } global $post; if ( get_post_meta($post->ID, 'desactive_adfever', true) == '1' ) { // Options desactive adfever return ''; } // init once Shopping if ( $this->shop_obj == null ) { $current_options = get_option( $this->option_name ); $this->shop_obj = new Shopping ( $current_options['aid'], ADFEVER_UUID ); } switch ( $type ) { case 'top-category' : $item = $this->shop_obj->getTop( $value, 5 ); $key = array_rand( $item["shopping"]["products"]["product"] ); return $this->buildTableProduct( $item["shopping"]["products"]["product"][$key] ); break; case 'product' : default : // Get item and stores $item = $this->shop_obj->find( $value ); $item = $item["shopping"]["product"]; return $this->buildTableProduct( $item ); break; } return ''; } function buildTableProduct( $item = null ) { if ( is_null($item) ) { return __( 'Internal error.', 'adfever' ); } $stores = $item["offers"]["offer"]; $current_options = get_option( $this->option_name ); $output = ''; $output .= '
' . "\n"; if ( $current_options['photo'] == '1' ) $output .= ''.attribute_escape($item['name']).'' . "\n"; $output .= '
'.wp_specialchars($item['name']).'
' . "\n"; $output .= apply_filters('the_adfever_description', $item['description']) . "\n"; $output .= '
' . "\n"; if ( is_array($stores) && !empty($stores) ) : $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $stores = array_slice( $stores, 0, $current_options['max-store'], true ); foreach( (array) $stores as $store ) { $output .= '' . "\n"; if ( $current_options['logos'] == '1' && !empty($store['logo']) ) $output .= '' . "\n"; // Display logo for each stores else $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; } $output .= '' . "\n"; $output .= '
'.__('Retailer', 'adfever').''.__('Availability', 'adfever').''.__('Total price (incl.delivery)', 'adfever').'
'.attribute_escape($store['merchant']).''.wp_specialchars($store['merchant']).''.$store['stock'].''.$store['total_price']['value'].'
' . "\n"; else : $output .= '

'.__('No retailers for this product.', 'adfever').'

' . "\n"; endif; $output .= $this->getCopyright(); $output .= '
' . "\n"; return $output; } function getCopyright() { return '

'.__('Technologie AdFever', 'adfever').'

' . "\n"; } function fixLogosUrl( $url = '' ) { $tmp = $url; $url = str_replace('http://i.pricerunner.com/images/logos/fr/', 'http://i.pricerunner.com/images/logos/fr/80x35/', $url ); if ( $url == $tmp ) $url = str_replace('http://i.pricerunner.com/images/logos/', 'http://i.pricerunner.com/images/logos/80x35/', $url ); return $url; } function displayCSS() { $current_options = get_option( $this->option_name ); ?> version . 'line3'; } /** * Load the custom TinyMCE plugin * * @param array $plugins * @return array */ function mce_external_plugins( $plugins ) { $plugins['adfever'] = ADFEVER_URL.'/inc/js/tinymce3/editor_plugin.js'; return $plugins; } /** * Add the custom TinyMCE buttons * * @param array $buttons * @return array */ function mce_buttons( $buttons ) { array_push( $buttons, 'separator', 'adfever' ); return $buttons; } /** * Add the old style buttons to the non-TinyMCE editor views and output all of the JS for the button function + dialog box * */ function AddQuicktagsAndFunctions() { $buttonshtml .= ''; ?> , or " -- instead it converts it to an HTML entity. This is a "fixed" function that's used when needed. * * @param string $text * @return string */ function js_escape($text) { $safe_text = addslashes($text); $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text)); $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text)); $safe_text = str_replace('\\\n', '\n', $safe_text); return apply_filters('js_escape', $safe_text, $text); } } ?>