Regístrate

pop

‘communities_widget’, ‘description’ => __(‘Elgg\’s communities’, ‘example’) ); /* Widget control settings. */ $control_ops = array( ‘width’ => 300, ‘height’ => 350, ‘id_base’ => ‘communities_widget’ ); /* Create the widget. */ $this->WP_Widget( ‘communities_widget’, __(‘Communities Widget’, ‘example’), $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = apply_filters(‘widget_title’, $instance[‘title’] ); echo ““; /* Before widget (defined by themes). */ echo $before_widget; echo ““; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo /*$before_title*/ “

“. $title . $after_title; /* Get RSS Feed(s) */ include_once(ABSPATH . WPINC . ‘/feed.php’); /* Get a SimplePie feed object from the specified feed source. */ //$rss = fetch_feed(get_site_url().’/comunidad/pg/groups/world/?filter=pop&view=rss’); // diego.ramirez dramirez #1120 - Changed to internal cache management $rss = self::get_feed(get_site_url().’/comunidad/pg/groups/world/?filter=pop&view=rss’); // Checks that the object is created correctly if (!is_wp_error( $rss ) ){ // Figure out how many total items there are, but limit it to 5. $maxitems = $rss->get_item_quantity(10); // Build an array of all the items, starting with element 0 (first element). $rss_items = $rss->get_items(0, $maxitems); } // diego.ramirez dramirez #1002 Changing communities display layout $widget_content = “
“; if ($maxitems == 0) { $widget_content .= “
  • No items to display.
  • “; } else { $i=1; $j=0; foreach ( $rss_items as $item ) { $item_permalink = $item->get_permalink(); $item_title = $item->get_title(); $item_date = date_i18n( ‘j F Y’, $item->get_date(‘U’), false ); $tag_icon = $item->get_item_tags(”, ‘cfkn_icon_url’); if($tag_icon){ $item_icon = $tag_icon[0][‘data’]; } // diego.ramirez dramirez #1002 Changing communities display layout using just divs $widget_content .= ”
    “; if( $i % 4 == 0){ $widget_content.=”
     
    “; $j++; } $i++; } } if($j % 3 != 0 ){ $widget_content.=”
     
    “; } $widget_content .= “
    “; /* view all link */ // $view_all = $rss->get_link(); $view_all = get_site_url().”/comunidad/pg/groups/world”; $widget_content .= ““; $widget_content .= “
    “; //$widget_content = self::dummy_widget(); echo $widget_content; /* After widget (defined by themes). */ echo $after_widget; } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance[‘title’] = strip_tags( $new_instance[‘title’] ); return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( ‘title’ => __(‘Comunidades’, ‘example’), ‘name’ => __(‘John Doe’, ‘example’), ‘sex’ => ‘male’, ‘show_sex’ => true ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

    “; return $dummy_widget; } /** * Retrieves a SimplePie feed object from a given URL * @param string $url Feed URL to be retrieved. * @return SimplePie */ static function get_feed( $url) { $cache_dir = “/”. dirname( plugin_basename(__FILE__) ) . “/cache”; @mkdir($cache_dir); $feed = new SimplePie(); $feed->set_feed_url($url); $feed->enable_cache(true); $feed->set_cache_duration( COMMUNITIES_WIDGET_CACHE_DURATION ); $feed->set_cache_location( $cache_dir ); $feed->init(); $feed->handle_content_type(); if ( $feed->error() ) return null; return $feed; } } ?>

    Comments are closed.