Changeset 695157
- Timestamp:
- 04/10/2013 10:29:59 AM (13 years ago)
- Location:
- latest-posts-multisite-widget/trunk
- Files:
-
- 2 edited
-
latest_posts_multisite.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
latest-posts-multisite-widget/trunk/latest_posts_multisite.php
r694125 r695157 3 3 * Plugin Name: Latest Posts MultiSite Widget 4 4 * Version: 1.0 5 * Plugin URI: http://wp4u.net/ 5 * Plugin URI: http://wp4u.net/latest-posts-multisite-widget/ 6 6 * Description: Latest Posts MultiSite Widget is a wordpress plugin that enables admin to add widgets which display latest posts content from other sites in a wordpress network. The widget supports custom post types, post images, excerpts and also custom fields data. Admin can use default template or make their custom template. 7 7 * Author: WP4U 8 8 * Author URI: http://wp4u.net/ 9 9 */ 10 class LatestPostsWidget extends WP_Widget10 class WP4U_LatestPostsWidget extends WP_Widget 11 11 { 12 12 /** … … 14 14 * 15 15 */ 16 functionLatestPostsWidget(){17 $widget_ops = array('classname' => 'widget_ LatestPostsWidget', 'description' => __( "Latest Posts MultiSite Widget is a wp plugin that enables admin to add widgets which display latest post content from other sites in wordpress network, support custom post types .") );16 public function WP4U_LatestPostsWidget(){ 17 $widget_ops = array('classname' => 'widget_WP4U_LatestPostsWidget', 'description' => __( "Latest Posts MultiSite Widget is a wp plugin that enables admin to add widgets which display latest post content from other sites in wordpress network, support custom post types .") ); 18 18 $control_ops = array('width' => 300, 'height' => 300); 19 $this->WP_Widget('LatestPostsWidget', __('Latest Posts MultiSite Widget'), $widget_ops, $control_ops);19 parent::WP_Widget(false, __('WP4U Latest Posts MultiSite Widget'), $widget_ops, $control_ops); 20 20 } 21 21 … … 27 27 extract($args); 28 28 extract($instance); 29 switch_to_blog($blog_id); 29 if(is_multisite()) 30 switch_to_blog($blog_id); 30 31 $output = ''; 31 32 global $wpdb; … … 33 34 $request = $wpdb->prepare("SELECT ".$wpdb->prefix."posts.* 34 35 FROM ".$wpdb->prefix."posts 35 WHERE post_type='$post_type' AND post_status = 'publish' ORDER BY post_date DESC LIMIT ".$limit);36 WHERE post_type='$post_type' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 0,%d",(int)$limit); 36 37 $results = $wpdb->get_results($request); 37 38 $results = $wpdb->get_results($request); … … 64 65 } 65 66 } 66 67 $template = trim($template); 67 68 if(empty($template)) 68 69 { … … 92 93 $output .= '</ul>'; 93 94 } 94 restore_current_blog(); 95 if(is_multisite()) 96 restore_current_blog(); 95 97 echo $before_widget . $before_title . $title . $after_title; 96 98 echo $output . $after_widget; … … 125 127 $instance = wp_parse_args( (array) $instance, array('title'=>'', 'limit' => 5,'post_type' => 'post','blog_id' => 1,'template' => '','imagew' => 100,'imageh' => 100,'excerpt_length' => 20)); 126 128 extract($instance); 127 128 $blogs = get_blog_list(0,'all'); 129 $blogs = array(); 130 if(is_multisite()) 131 $blogs = get_blog_list(0,'all'); 132 else 133 $blogs[] = array('blog_id' => 1) 129 134 130 135 ?> … … 145 150 <select class="widefat" id="<?php echo $this->get_field_id( 'blog_id' ); ?>" name="<?php echo $this->get_field_name( 'blog_id' ); ?>" > 146 151 <?php foreach($blogs as $bid=>$blog) { 152 153 if(is_multisite()) 154 $blog_name = get_blog_option($blog['blog_id'],'blogname'); 155 else 156 $blog_name = get_option('blogname'); 147 157 ?> 148 <option value="<?php echo $blog['blog_id'];?>" <?php if((int)$blog['blog_id'] == (int)$blog_id) echo 'selected="selected"'?>><?php echo get_blog_option($blog['blog_id'],'blogname');?></option>158 <option value="<?php echo $blog['blog_id'];?>" <?php if((int)$blog['blog_id'] == (int)$blog_id) echo 'selected="selected"'?>><?php echo $blog_name;?></option> 149 159 <?php } 150 160 ?> … … 190 200 * Calls 'widgets_init' action after widget has been registered. 191 201 */ 192 function LatestPostsWidgetInit() { 193 register_widget('LatestPostsWidget'); 194 } 195 add_action('widgets_init', 'LatestPostsWidgetInit'); 202 add_action('widgets_init', create_function('', 'return register_widget(\'WP4U_LatestPostsWidget\');')); -
latest-posts-multisite-widget/trunk/readme.txt
r694136 r695157 7 7 Requires at least: 3.0 8 8 Tested up to: 3.5.1 9 Stable tag: 1.0 9 Stable tag: 1.1 10 11 Display latest posts from other site in network. 10 12 11 13 == Description == 12 Latest Posts MultiSite Widget is a wordpress plugin that enables admin to add widgets which display latest posts content from other sites in a wordpress network. The widget supports custom post types, post images, excerpts and also custom fields data. Admin can use default template or make their custom template. 14 15 ###Latest Posts MultiSite Widget 16 17 18 [Latest Posts MultiSite Widget](http://wp4u.net/latest-posts-multisite-widget/) is a wordpress plugin that enables admin to add widgets which display latest posts content from other sites in a wordpress network. The widget supports custom post types, post images, excerpts and also custom fields data. Admin can use default template or make their custom template. 19 20 Support Template Tags : 21 22 * Post title : **{title}** 23 * Post excerpt : **{excerpt}** 24 * Featured Image : **{image}** 25 * Post Link : **{link}** 26 * Custom fields: **%%custom_field_key%%** 27 * .... 28 29 And will add more template tags. 13 30 14 31 15 32 == Installation == 33 34 ####Thank you for your interest in [Latest Posts MultiSite Widget](http://wp4u.net/latest-posts-multisite-widget/). 16 35 17 36 * Download "latest-posts-multisite.zip" to your computer. … … 24 43 * Go to your widget and adjust the settings 25 44 * Use template tags to make your custom tempplate : {title}, {link}, {excerpt}, {image}, .. and any custom field data %%custom_field_key%% 45 46 If any problem occurs with **Latest Posts MultiSite Widget**, please submit tickets in our support page: [WP4U Support](http://wp4u.net/support/). 26 47 27 48 … … 39 60 == Changelog == 40 61 62 = v1.1 04.010.2013 = 63 Fixed error with single wordpress site 64 41 65 = v1.0 04.08.2013 = 42 66 initial release 43 67 44 == Frequently Asked Questions ==45 68 46 47 == Upgrade Notice ==48
Note: See TracChangeset
for help on using the changeset viewer.