__( 'Display the Afables Widget.', 'afables' ) ) // Args ); } public function add_options_to_script(){ //If there is data to add, add it //wp_localize_script( 'my_script', 'my_var', self::$variables); wp_localize_script('afables-widget', 'afablesObject', self::$instances ); } public function widget( $args, $instance ) { //wp_enqueue_script('afables-jquery-ui','//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js', array('jquery'),'',true); wp_enqueue_style( 'afables-widget-style', plugins_url( '../css/afables-widget.css' , __FILE__ )); if(AFABLES_DISPLAY_RATTING == 'font-awesome'): wp_enqueue_style( 'font-awesome', plugins_url( '../css/font-awesome.css' , __FILE__ )); endif; //wp_enqueue_script('jquery'); wp_register_script( 'afables-widget', plugins_url( '../js/afables-widget.js' , __FILE__ ), array('jquery'), AFABLES_PLUGIN_VERSION ,true ); //$translation_array = array(); //$idInstance = array ('widgetId' => $this->id); //$translation_array[] = $idInstance; //wp_localize_script('afables-widget', 'afablesObject', $translation_array ); add_action('wp_footer', array(__CLASS__, 'add_options_to_script')); wp_enqueue_script('afables-widget'); $id = $this->id; self::$instances[$id] = '#'. $this->id; $before_texto = '
'; $after_texto = '
'; // outputs the content of the widget extract( $args ); $title = $instance['title']; //$url = $instance['url']; //$place = $instance['place']; //$channel = $instance['channel']; $language = $this->afable_get_language(); /** Preparamos la url del FEED **/ $data = array( 'city' => $instance['place'], 'channel' => ($instance['channel']!= 'none') ? $instance['channel'] : null, 'type' => ($instance['type']!= 'all') ? $instance['type'] : null, 'language' => $language ); $params = http_build_query($data); $url = AFABLES_RSS.'?'.$params; $items = $this->load_feed( $url ); $total = count($items); echo $before_widget; if (!empty($title)) : ?>


0 ): # Si hay resultados ?>

%d caregivers rated and recommended by other families in %s','afables'),$total, $instance['place'] ); ?>

1 ): # Si hay mas de uno mostramos el navegador ?>

|

display_items($items,$instance['hide_thumbnail'],$language); ?> RSS no_results(); endif;?>
//wp_enqueue_script('afables-maps'); $selected = 'selected="selected"'; ?>

load_google_map_autocomplete();?>

$instance['place'], 'channel' => ($instance['channel']!= 'none') ? $instance['channel'] : null, 'type' => ($instance['type']!= 'all') ? $instance['type'] : null, 'language' => $this->afable_get_language() //'type' => 'INDIVIDUAL' ); $params = http_build_query($data); $instance['url'] = AFABLES_RSS.'?'.$params;*/ //$instance['url'] = AFABLES_RSS; //$instance['url'] = 'http://afablesyii.dev.ohayoweb.com/rss/rss?city=madrid&channel=facebook'; if (WP_DEBUG == true) : # $instance['debug_entitat_id'] = strip_tags($new_instance['debug_entitat_id']); #update_option( 'entitat_id', $new_instance['debug_entitat_id'] ); endif; return $instance; } public function load_feed($url){ //include_once plugin_dir_path( __FILE__ ).'../rss-robot/inc/load_SimplePie.php'; //include_once plugin_dir_path( __FILE__ ).'load_SimplePie.php'; require_once (ABSPATH . WPINC . '/class-simplepie.php'); $channel_feed = new SimplePie(); $channel_feed->cache_location = AFABLES_CACHE_FOLDER; $channel_feed->cache_duration = AFABLES_CACHE_DURATION; $channel_feed->set_useragent(AFABLES_USERAGENT); $channel_feed->set_feed_url($url); #if(WP_DEBUG == true) $channel_feed->enable_cache = false; // Desactivamos la cache en debug $channel_feed->init(); $channel_feed->handle_content_type(); //$channel_feed->error(); return $channel_feed->get_items(); } public function display_items($items,$hide_thumbnail = true,$language = 'es'){ #echo '
'; echo ''; #echo '
'; } public function get_single_permalink($permalink){ /** Preparamos la url de la ficha **/ $blogname = get_bloginfo('name'); if(empty($blogname)) $blogname = site_url(); $data = array( 'utm_source' => $blogname, 'utm_medium' => AFABLES_UTM_MEDIUM, 'utm_campaign' => AFABLES_UTM_CAMPAING, 'utm_content' => AFABLES_PLUGIN_VERSION, ); $params = http_build_query($data); $url = $permalink.'?'.$params; //$params = '?utm_source=nombredelblog&utm_medium=widget&utm_campaign=widgetWordpress&utm_content=v1'; return $url; } public function display_specialities($specialities){ $array = get_object_vars($specialities); $properties = array_keys($array); echo implode($properties,' - '); } public function no_results(){ // ?>

'; $empty = ''; else: /** png **/ $full = ''; $empty = ''; endif; for ($i = 1; $i <= AFABLES_MAX_RATTING; $i++) { if($i<=$value) echo $full; else echo $empty; } } public function load_google_map_autocomplete(){ ?> "A", "Ç" => "c", "É" => "e", "Í" => "i", "Ñ" => "n", "Ó" => "o", "Ú" => "u", "á" => "a", "ç" => "c", "é" => "e", "í" => "i", "ñ" => "n", "ó" => "o", "ú" => "u", "à" => "a", "è" => "e", "ì" => "i", "ò" => "o", "ù" => "u" ); // replace non letter or digits by - $text = preg_replace('~[^\\pL\d]+~u', '-', $text); if (empty($text)) return "aqui"; // trim $text = trim($text, '-'); if (empty($text)) return "aqui1"; // transliterate if (function_exists('iconv')) { $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); } if (empty($text)) return "aqui2"; // lowercase $text = strtolower($text); //replace characters with accents $string = strtr($string, $characters); // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); if (empty($text)) { return 'n-a'; } return $text; } } ?>