Advertisement
johnzenausa

Network Shared Post Update

Mar 17th, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.45 KB | None | 0 0
  1. /* This code replaces all code in network-shared-posts.php file */
  2. <?php
  3. /*
  4. Plugin Name: Network Shared Posts Ext
  5. Plugin URI: http://code-ext.com/blog/2012/07/30/network-shared-posts-ext/
  6. Description: Network Shared Posts plugin enables you to share posts over WP Multi Site network. You can display on any blog in your network the posts selected by taxanomy from any other blogs including that blog itself.
  7. Version: 1.1.2
  8. Author: Code Ext
  9. Author URI: https://code-ext.com
  10.  
  11. Copyright 2012 Code Ext, Inc
  12.  
  13. */
  14. if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME']))
  15. {
  16. exit('Please don\'t access this file directly.');
  17. }
  18. ############ SETUP ####################
  19. add_action("plugins_loaded","net_shared_posts_init");
  20. add_shortcode('netsposts','netsposts_shortcode');
  21. add_action('admin_menu', 'add_netsposts_toolpage');
  22.  
  23. // Setup functions
  24.  
  25. function add_netsposts_toolpage()
  26. {
  27. add_management_page( 'Network Shared Posts Tool', 'Network Shared Posts Tool', 'Administrator', 'netsposts_toolpage', 'netsposts_tool_page' );
  28. }
  29.  
  30. function net_shared_posts_init()
  31. {
  32. register_uninstall_hook(__FILE__, 'net_shared_posts_uninstall');
  33. wp_register_style( 'netspostscss', plugins_url('/net_shared_posts.css', __FILE__) );
  34. wp_enqueue_style( 'netspostscss' );
  35. load_plugin_textdomain('netsposts', false, basename( dirname( __FILE__ ) ) . '/language');
  36. }
  37.  
  38. function net_shared_posts_uninstall()
  39. {
  40. remove_shortcode('netsposts');
  41. }
  42.  
  43. function netsposts_shortcode($atts)
  44. {
  45. extract(shortcode_atts(array(
  46. 'limit' => '',
  47. 'days' => 0,
  48. 'page_title_style' => '',
  49. 'title' => '',
  50. 'titles_only' => false,
  51. 'wrap_start' => null,
  52. 'wrap_end' => null,
  53. 'thumbnail' => false,
  54. 'post_type' => 'post',
  55. 'include_blog' => null,
  56. 'exclude_blog' => null,
  57. 'exclude_post' => null,
  58. 'include_post' => null,
  59. 'taxonomy' => '',
  60. 'paginate' => false,
  61. 'pages' => null,
  62. 'list' => 10,
  63. 'excerpt_length' => 400,
  64. 'auto_excerpt' => false,
  65. 'show_author' => false,
  66. 'full_text' => false,
  67. 'size' => 'thumbnail',
  68. 'image_class' => 'post-thumbnail',
  69. 'date_format' => 'n/j/Y',
  70. 'end_size' => '',
  71. 'mid_size' => '',
  72. 'prev_next' => false,
  73. 'prev' => '&laquo; Previous',
  74. 'next' => 'Next &raquo;',
  75. 'column' => '1',
  76. 'menu_name' => '',
  77. 'menu_class' => '',
  78. 'container_class' => ''
  79. ), $atts));
  80.  
  81. ######## OUTPUT STAFF ####################
  82. $titles_only = strtolower($titles_only) == 'true'? true: false;
  83. $thumbnail = strtolower($thumbnail) == 'true'? true: false;
  84. $paginate = strtolower($paginate) == 'true'? true: false;
  85. $auto_excerpt = strtolower($auto_excerpt) == 'true'? true: false;
  86. $show_author = strtolower($show_author) == 'true'? true: false;
  87. $full_text = strtolower($full_text) == 'true'? true: false;
  88. $prev_next = strtolower($prev_next) == 'true'? true: false;
  89. global $wpdb;
  90. global $table_prefix;
  91. if($limit) $limit = " LIMIT 0,$limit ";
  92. ## Params for taxonomy
  93. if($cat)
  94. {
  95. if ($tag)
  96. {
  97. implode(',',$cat, $tag);
  98. }
  99. } else $cat = $tag;
  100. ## Include blogs
  101. if($include_blog) {
  102. $include_arr = explode(",",$include_blog);
  103. $include = " AND (";
  104. foreach($include_arr as $included_blog)
  105. {
  106. $include .= " blog_id = $included_blog OR";
  107. }
  108. $include = substr($include,0,strlen($include)-2);
  109. $include .= ")";
  110. } else { if($exclude_blog) {$exclude_arr = explode(",",$exclude_blog); foreach($exclude_arr as $exclude_blog) {$exclude .= "AND blog_id != $exclude_blog "; }}}
  111. $BlogsTable = $wpdb->base_prefix.'blogs';
  112. $blogs = $wpdb->get_col($wpdb->prepare(
  113.  
  114. "SELECT blog_id FROM $BlogsTable WHERE public = %d AND archived = %d AND mature = %d AND spam = %d AND deleted = %d $include $exclude", 1, 0, 0, 0, 0
  115.  
  116. ));
  117.  
  118. ## Getting posts
  119. $postdata = array();
  120. if ($blogs)
  121. {
  122. foreach ($blogs as $blog_id)
  123. {
  124. if( $blog_id == 1 )
  125. {
  126. $OptionsTable = $wpdb->base_prefix."options";
  127. $PostsTable = $wpdb->base_prefix."posts";
  128. $TermRelationshipTable = $wpdb->base_prefix."term_relationships";
  129. $TermTaxonomyTable = $wpdb->base_prefix."term_taxonomy";
  130. $TermsTable = $wpdb->base_prefix."terms";
  131. }
  132. else {
  133. $OptionsTableTable = $wpdb->base_prefix.$blog_id."_options";
  134. $PostsTable = $wpdb->base_prefix.$blog_id."_posts";
  135. $TermRelationshipTable = $wpdb->base_prefix.$blog_id."_term_relationships";
  136. $TermTaxonomyTable = $wpdb->base_prefix.$blog_id."_term_taxonomy";
  137. $TermsTable = $wpdb->base_prefix.$blog_id."_terms";
  138. }
  139. if ($days > 0) $old = "AND $PostsTable.post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL $days DAY)"; else $old = "";
  140.  
  141. ## Taxonomy
  142. if($taxonomy )
  143. {
  144. $categories = explode(',',$taxonomy);
  145. $cat_arr = array();
  146. foreach($categories as $category)
  147. {
  148. $cat_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $TermsTable WHERE slug = '$category' "));
  149. if($cat_id) $cat_arr[] = $cat_id;
  150. }
  151. $taxonomy_arr = array();
  152. foreach($cat_arr as $cat_id)
  153. {
  154. $tax_id = $wpdb->get_var($wpdb->prepare("SELECT term_taxonomy_id FROM $TermTaxonomyTable WHERE term_id = $cat_id"));
  155. if($tax_id) $taxonomy_arr[] = $tax_id;
  156. }
  157.  
  158. foreach($taxonomy_arr as $tax_id)
  159. {
  160. $post_ids = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM $TermRelationshipTable WHERE term_taxonomy_id = $tax_id"), ARRAY_A);
  161. if( !empty($post_ids) )
  162. {
  163. foreach($post_ids as $key=>$object_id)
  164. {
  165. $ids .= " $PostsTable.ID = ".$object_id['object_id']. ' OR';
  166. }
  167. }
  168. }
  169. }
  170.  
  171. if ($ids) { $ids = ' AND ('. substr($ids,0,strlen($ids)-2).')'; } else { if($taxonomy) $ids = ' AND ID=null';}
  172.  
  173. $the_post = $wpdb->get_results( $wpdb->prepare(
  174. "SELECT $PostsTable.ID, $PostsTable.post_title, $PostsTable.post_excerpt, $PostsTable.post_content, $PostsTable.post_author, $PostsTable.post_date, $PostsTable.guid, $BlogsTable.blog_id
  175. FROM $PostsTable, $BlogsTable WHERE $BlogsTable.blog_id = $blog_id AND $PostsTable.post_status = %s $ids AND $PostsTable.post_type = '$post_type' $old $limit"
  176. , 'publish'
  177. ), ARRAY_A);
  178. $postdata = array_merge_recursive($postdata, $the_post);
  179. $ids='';
  180. }
  181. }
  182. usort($postdata, "custom_sort");
  183. if($paginate)
  184. {
  185. if($column > 1)
  186. {
  187. $column_list =ceil($list/$column); $list = $column_list*$column; if(!$list)
  188. {
  189. $list=$column; $column_list = 1;
  190. }
  191. }
  192. $page = get_query_var('paged');
  193. if(!$page) $page = get_query_var('page');
  194. if(!$page) $page = 1;
  195.  
  196. function super_unique($array,$key)
  197.  
  198. {
  199.  
  200. $temp_array = array();
  201.  
  202. foreach ($array as &$v) {
  203.  
  204. if (!isset($temp_array[$v[$key]]))
  205.  
  206. $temp_array[$v[$key]] =& $v;
  207.  
  208. }
  209.  
  210. $array = array_values($temp_array);
  211.  
  212. return $array;
  213.  
  214.  
  215.  
  216. }
  217.  
  218. $postdata = super_unique($postdata,"ID");
  219.  
  220. function removeElementWithValue($array, $key, $value){
  221. foreach($array as $subKey => $subArray){
  222. if($subArray[$key] == $value){
  223. unset($array[$subKey]);
  224. }
  225. }
  226. return $array;
  227. }
  228.  
  229. $exclude_post2 = explode(",",$exclude_post);
  230.  
  231. foreach($exclude_post2 as $row){
  232.  
  233. $postdata = removeElementWithValue($postdata, "ID", $row);
  234.  
  235. }
  236.  
  237. //if(!in_array($the_post['ID'], $exclude_post2)){
  238.  
  239. $total_records = count($postdata);
  240. $total_pages = ceil($total_records/$list);
  241. $postdata = array_slice($postdata, ($page-1)*$list, $list);
  242. }
  243. if($column > 1)
  244. { $count = count($postdata);
  245. if(!$paginate) $column_list = ceil($count/$column);
  246. for($i = 0; $i<$column; ++$i)
  247. {
  248. if($count < ($column_list*$column)) $column_list = ceil($count/$column);
  249. $colomn_data[$i] = array_slice($postdata, ($i )*$column_list, $column_list);
  250. }
  251. } else{
  252. $colomn_data[0] = $postdata;
  253. }
  254. ## OUTPUT
  255. if($page_title_style) {
  256. ?>
  257.  
  258. <style type="text/css">
  259. h2.pagetitle
  260. {
  261. <?php echo $page_title_style; ?>
  262. }
  263. </style>
  264. <?
  265. }
  266. $html = '<div id="netsposts-menu">';
  267. if($menu_name)
  268. {
  269. $menu=array('menu'=>$menu_name, 'menu_class'=>$menu_class, 'container_class' => $container_class);
  270. wp_nav_menu($menu);
  271. }
  272. $html .= '</div>';
  273. if($postdata)
  274. {
  275. echo '<div id="block-wrapper">';
  276. if($title) echo '<span class="netsposts-title">'.$title.'</span><br />';
  277. foreach($colomn_data as $data)
  278. {
  279. if($column > 1) echo '<div class ="netsposts-column" style="width:'.$col_width.'">';
  280.  
  281. foreach($data as $key => $the_post)
  282. {
  283. $include_post2 = explode(",",$include_post);
  284.  
  285. if(isset($include_post)){
  286.  
  287. if(in_array($the_post['ID'], $include_post2)){
  288. $blog_details = get_blog_details( $the_post['blog_id']);
  289. $blog_name = $blog_details->blogname;
  290. $blog_url = $blog_details->siteurl;
  291. if($titles_only) $title_class = 'netsposts-post-titles-only'; else $title_class = 'netsposts-posttitle';
  292. $html .= html_entity_decode($wrap_start).'<div class="netsposts-content"><span class="'.$title_class.'"><a href="'.$the_post['guid'].'">'.$the_post['post_title'].'</a></span>';
  293.  
  294. if(!$titles_only)
  295. {
  296. $date = new DateTime(trim($the_post['post_date']));
  297. $date_post = $date->format($date_format);
  298. $html .= '<span class="netsposts-source"> '.__('Published','netsposts').' '.$date_post.' '.__('in','netsposts').' <a href="'.$blog_url.'">'.$blog_name.'</a>';
  299. ## Full metadata
  300. if( $show_author)
  301. {
  302. if($column > 1) echo '<br />';
  303. $html .= ' ' . __('Author','netsposts'). ' ' . '<a href="'.$blog_url .'?author='. $the_post['post_author'] .'">'. get_the_author_meta( 'display_name' , $the_post['post_author'] ) . ' </a>';
  304. }
  305. $html .= '</span>';
  306. if($thumbnail)
  307. {
  308.  
  309. $html .= '<a href="'.$the_post['guid'].'">'.get_thumbnail_by_blog($the_post['blog_id'],$the_post['ID'],$size, $image_class).'</a><p class="netsposts-excerpt">';
  310. $the_post['post_content'] = preg_replace("/<img[^>]+\>/i", "", $the_post['post_content']);
  311. }
  312.  
  313. if($auto_excerpt) {$exerpt = get_excerpt($excerpt_length, $the_post['post_content'], $the_post['guid']);}
  314. else $exerpt = $the_post['post_excerpt'];
  315. if($full_text) $text = $the_post['post_content']; else $text = $exerpt;
  316. $html .= strip_shortcodes( $text);
  317. $html .= ' <a href="'.$the_post['guid'].'">read more→</a></p>';
  318. }
  319. $html .= '</div>';
  320. $html .= "<br />";
  321.  
  322. $html .= html_entity_decode($wrap_end);
  323.  
  324. if($column > 1) echo '</div>';
  325. }
  326.  
  327. }else{
  328. // if(!in_array($the_post['ID'], $exclude_post2)){
  329. $blog_details = get_blog_details( $the_post['blog_id']);
  330. $blog_name = $blog_details->blogname;
  331. $blog_url = $blog_details->siteurl;
  332. if($titles_only) $title_class = 'netsposts-post-titles-only'; else $title_class = 'netsposts-posttitle';
  333. $html .= html_entity_decode($wrap_start).'<div class="netsposts-content"><span class="'.$title_class.'"><a href="'.$the_post['guid'].'">'.$the_post['post_title'].'</a></span>';
  334.  
  335. if(!$titles_only)
  336. {
  337. $date = new DateTime(trim($the_post['post_date']));
  338. $date_post = $date->format($date_format);
  339. $html .= '<span class="netsposts-source"> '.__('Published','netsposts').' '.$date_post.' '.__('in','netsposts').' <a href="'.$blog_url.'">'.$blog_name.'</a>';
  340. ## Full metadata
  341. if( $show_author)
  342. {
  343. if($column > 1) echo '<br />';
  344. $html .= ' ' . __('Author','netsposts'). ' ' . '<a href="'.$blog_url .'?author='. $the_post['post_author'] .'">'. get_the_author_meta( 'display_name' , $the_post['post_author'] ) . ' </a>';
  345. }
  346. $html .= '</span>';
  347. if($thumbnail)
  348. {
  349.  
  350. $html .= '<a href="'.$the_post['guid'].'">'.get_thumbnail_by_blog($the_post['blog_id'],$the_post['ID'],$size, $image_class).'</a><p class="netsposts-excerpt">';
  351. $the_post['post_content'] = preg_replace("/<img[^>]+\>/i", "", $the_post['post_content']);
  352. }
  353.  
  354. if($auto_excerpt) {$exerpt = get_excerpt($excerpt_length, $the_post['post_content'], $the_post['guid']);}
  355. else $exerpt = $the_post['post_excerpt'];
  356. if($full_text) $text = $the_post['post_content']; else $text = $exerpt;
  357. $html .= strip_shortcodes( $text);
  358. $html .= ' <a href="'.$the_post['guid'].'">read more→</a></p>';
  359. }
  360. $html .= '</div>';
  361. $html .= "<br />";
  362.  
  363. $html .= html_entity_decode($wrap_end);
  364.  
  365. if($column > 1) echo '</div>';
  366.  
  367. // }
  368. }
  369. }
  370. }
  371. $html .= '<div class="clear"></div>';
  372. if(($paginate) and ($total_pages>1))
  373. {
  374. $html .= '<div id="netsposts-paginate">';
  375. $big = 999999999;
  376. $html .= paginate_links( array(
  377. 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  378. 'format' => '?paged=%#%',
  379. 'current' => $page,
  380. 'total' => $total_pages,
  381. 'prev_text' => __($prev),
  382. 'next_text' => __($next),
  383. 'end_size' => $end_size,
  384. 'mid_size' => $mid_size
  385. ) );
  386.  
  387. $html .= '</div>';
  388.  
  389. }
  390. $html .= '</div>';
  391. }
  392.  
  393. return $html;
  394. }
  395. ##########################################################
  396.  
  397. function get_thumbnail_by_blog($blog_id=NULL,$post_id=NULL,$size='thumbnail',$image_class)
  398. {
  399. if( !$blog_id or !$post_id ) return;
  400. switch_to_blog($blog_id);
  401. $thumb_id = has_post_thumbnail( $post_id );
  402. if(!$thumb_id)
  403. {
  404. restore_current_blog(); return FALSE;
  405. }
  406. $blogdetails = get_blog_details( $blog_id );
  407. $size=explode(',',$size);
  408. $attrs = array('class'=> $image_class);
  409. $thumbcode = str_replace( $current_blog->domain . $current_blog->path, $blogdetails->domain . $blogdetails->path, get_the_post_thumbnail( $post_id, $size, $attrs ) );
  410. restore_current_blog();
  411. return $thumbcode;
  412. }
  413.  
  414. function get_excerpt($length,$content,$permalink)
  415. {
  416. if(!$length) return $content;
  417. else {
  418. $content = strip_tags($content);
  419. $content = substr($content, 0, intval($length));
  420. $words = explode(' ', $content);
  421. array_pop($words);
  422. $content = implode(' ', $words);
  423. return $content.'... <a href="'.$permalink.'"> '.__('read more&rarr;','trans-nlp').'</a>';
  424. }
  425. }
  426.  
  427. function custom_sort($a,$b)
  428. {
  429. return $a['post_date']<$b['post_date'];
  430. }
  431.  
  432. ################### TOOL PAGE #########################
  433.  
  434. function netsposts_tool_page()
  435. {
  436. global $wpdb;
  437. $short_code = '[netsposts ';
  438. if (isset($_POST['blogs_selectbox']))
  439. {
  440. $value = (string)$_POST["radiogroup"];
  441. $short_code .= $value.'=\''. implode(',', $_POST['blogs_selectbox'])."'";
  442. }
  443.  
  444. if (isset($_POST['terms_selectbox'])) { $short_code .= ' taxonomy=\''. implode(',', $_POST['terms_selectbox'])."'"; }
  445. if (isset($_POST['days']) and ($_POST['days'])) { $short_code .= " days=". $_POST['days']; }
  446. if (isset($_POST['titles_only'])) { $short_code .= " titles_only=". $_POST['titles_only']; }
  447. if (isset($_POST['show_author'])) { $short_code .= " show_author=". $_POST['show_author'];}
  448. if (isset($_POST['post_type']) and ($_POST['post_type'])) { $short_code .= " post_type='". $_POST['post_type']."'"; }
  449. if (isset($_POST['wrap_start']) and ($_POST['wrap_start'])) { $short_code .= " wrap_start='". $_POST['wrap_start']."'"; }
  450. if (isset($_POST['wrap_end']) and ($_POST['wrap_end'])) { $short_code .= " wrap_end='". $_POST['wrap_end']."'"; }
  451. if (isset($_POST['full_text'])) { $short_code .= " full_text=". $_POST['full_text']; }
  452. if (isset($_POST['page_title_style']) and ($_POST['page_title_style'])) { $short_code .= " page_title_style='". $_POST['page_title_style']."'"; }
  453. if (isset($_POST['title']) and ($_POST['title'])) { $short_code .= " title='". $_POST['title']."'"; }
  454. if (isset($_POST['column']) and ($_POST['column'])) { $short_code .= " column='". $_POST['column']."'"; }
  455. if (isset($_POST['menu_name']) and ($_POST['menu_name'])) { $short_code .= " menu_name='". $_POST['menu_name']."'"; }
  456. if (isset($_POST['menu_class']) and ($_POST['menu_class'])) { $short_code .= " menu_class='". $_POST['menu_class']."'"; }
  457. if (isset($_POST['container_class']) and ($_POST['container_class'])) { $short_code .= " container_class='". $_POST['container_class']."'"; }
  458. if (isset($_POST['date_format']) and ($_POST['date_format'])) { $short_code .= " date_format='". $_POST['date_format']."'"; }
  459.  
  460. if (isset($_POST['auto_excerpt'])) { $short_code .= " auto_excerpt=". $_POST['auto_excerpt']; }
  461. if (isset($_POST['excerpt_length']) and ($_POST['excerpt_length'])) { $short_code .= " excerpt_length=". $_POST['excerpt_length']; }
  462.  
  463. if (isset($_POST['thumbnail'])) { $short_code .= " thumbnail=". $_POST['thumbnail']; }
  464. if (isset($_POST['size']) and ($_POST['size'][0]) and ($_POST['size'][1])) { $short_code .= " size=". implode(',', $_POST['size']); }
  465. if (isset($_POST['image_class']) and ($_POST['image_class'])) { $short_code .= " image_class='". $_POST['image_class']."'"; }
  466.  
  467.  
  468. if (isset($_POST['paginate'])) { $short_code .= " paginate=". $_POST['paginate']; }
  469. if (isset($_POST['list']) and ($_POST['list'])) { $short_code .= " list=". $_POST['list']; }
  470. if (isset($_POST['end_size']) and ($_POST['end_size'])) { $short_code .= " end_size='". $_POST['end_size']."'"; }
  471. if (isset($_POST['mid_size']) and ($_POST['mid_size'])) { $short_code .= " mid_size='". $_POST['mid_size']."'"; }
  472. if (isset($_POST['prev']) and ($_POST['prev'])) { $short_code .= " prev='". $_POST['prev']."'"; }
  473. if (isset($_POST['next']) and ($_POST['next'])) { $short_code .= " next='". $_POST['next']."'"; }
  474. if (isset($_POST['prev_next'])) { $short_code .= " prev_next=". $_POST['prev_next']; }
  475.  
  476.  
  477.  
  478. $short_code .= ']';
  479. ?>
  480.  
  481. <div class="wrap">
  482. <div id="icon-users" class="icon32"><br /></div>
  483. <h2>Network Shared Posts Ext Short Code Tool</h2>
  484. <hr />
  485. <div style="display:inline-block; ">
  486. <div style ="display:inline-block; padding:15px; float:left;">
  487. <font color=red><?php //if($status) echo "" . $status . ""; ?></font>
  488. <form method="post" action="#">
  489. <input type="radio" name="radiogroup" value="include_blog" <?php if($_POST["radiogroup"] == "include_blog") echo ' checked '; ?>/>&nbsp;include
  490. <input type="radio" name="radiogroup" value="exclude_blog"<?php if($_POST["radiogroup"] == "exclude_blog") echo ' checked '; ?> />&nbsp;exclude
  491. <br />
  492. <label>Sites</label><br />
  493. <select MULTIPLE name="blogs_selectbox[]" >
  494. <?php
  495. $BlogsTable = $wpdb->base_prefix.'blogs';
  496. $blogs = $wpdb->get_results($wpdb->prepare(" select blog_id from $BlogsTable "), ARRAY_A);
  497. $termsdata = array();
  498. foreach($blogs as $val)
  499. {
  500. if($val['blog_id'] == 1) { $OptionsTable = $wpdb->base_prefix.'options'; $TermsTable = $wpdb->base_prefix.'terms'; }
  501. else {$OptionsTable = $wpdb->base_prefix.$val['blog_id'] .'_options'; $TermsTable = $wpdb->base_prefix.$val['blog_id'] .'_terms';
  502. }
  503. $blog_name = $wpdb->get_var($wpdb->prepare(" select option_value from $OptionsTable where option_name = 'blogname' "));
  504. echo '<option value="'.$val['blog_id'].'"';
  505. if (isset($_POST['blogs_selectbox'])) { if(in_array ($val['blog_id'], $_POST['blogs_selectbox'])) echo ' selected '; }
  506. echo ' >'.$blog_name.'</option>';
  507. $terms = $wpdb->get_results($wpdb->prepare(" select name, slug from $TermsTable "), ARRAY_A);
  508. $termsdata = array_merge_recursive($termsdata, $terms);
  509. }
  510. ?>
  511. </select><br />
  512. <label>Taconomy (categories and tags)</label><br />
  513. <? //var_dump($termsdata) ?>
  514. <select MULTIPLE name="terms_selectbox[]" >
  515. <?// echo '<br />';
  516. foreach($termsdata as $val)
  517. {
  518. echo '<option value="'.$val['slug'].'"';
  519. if (isset($_POST['terms_selectbox'])) { if(in_array ($val['slug'], $_POST['terms_selectbox'])) echo ' selected '; }
  520. echo ' >'.$val['name'].'</option>';
  521.  
  522. }
  523.  
  524. ?>
  525. </select><br />
  526. <label>CSS style for page title</label><input type="text" name="page_title_style" value="<?php echo $_POST['page_title_style'] ?>"/><br />
  527. <label>Title</label><input type="text" name="title" value="<?php echo $_POST['title'] ?>"/><br />
  528. <label>Hpw many columns</label><input type="text" name="column" value="<?php echo $_POST['column'] ?>"/><br />
  529. <label>Name of a menu</label><input type="text" name="menu_name" value="<?php echo $_POST['menu_name'] ?>"/><br />
  530. <label>Menu CSS class</label><input type="text" name="menu_class" value="<?php echo $_POST['menu_class'] ?>"/><br />
  531. <label>Menu container CSS class</label><input type="text" name="container_class" value="<?php echo $_POST['container_class'] ?>"/><br />
  532.  
  533. <label>Days (how old posts may be)</label><input type="text" name="days" value="<?php echo $_POST['days'] ?>"/><br />
  534. <input type="checkbox" name="titles_only" value="true" <?php if($_POST['titles_only'] == true) echo ' checked '; ?>/><label>&nbsp;Titles only</label><br />
  535. <input type="checkbox" name="show_author" value="true" <?php if($_POST['show_author'] == true) echo ' checked '; ?>/><label>&nbsp;Show author</label><br />
  536. <label>Type of posts:</label><input type="text" name="post_type" value="<?php echo $_POST['post_type'] ?>"/><br />
  537. <input type="checkbox" name="full_text" value="true" <?php if($_POST['full_text'] == true) echo ' checked '; ?>/><label>&nbsp;Full text instead of excerpt</label><br />
  538. <label>Format of the post date:</label><input type="text" name="date_format" value="<?php echo $_POST['date_format'] ?>"/><br />
  539. <label>Wrap start:</label><input type="text" name="wrap_start" value="<?php echo $_POST['wrap_start'] ?>"/>&nbsp;<label>Wrap end:</label><input type="text" name="wrap_end" value="<?php echo $_POST['wrap_end'] ?>"/><br />
  540.  
  541.  
  542. <input type="checkbox" name="auto_excerpt" value="false" <?php if($_POST['auto_excerpt'] == 'false') echo ' checked '; ?>/><label>&nbsp;No auto excerpts</label><br />
  543. <label>Length of excerpt</label><input type="text" name="excerpt_length" value="<?php echo $_POST['excerpt_length'] ?>"/><br />
  544.  
  545. <input type="checkbox" name="thumbnail" value="true" <?php if($_POST['thumbnail'] == true) echo ' checked '; ?>/><label>&nbsp;Show thumbnails</label><br />
  546. <label>Size of thumbnails (pixeks) </label> <br /><label>Width:</label><input type="text" name="size[0]" value="<?php echo $_POST['size'][0] ?>"/><label>&nbsp;Height:</label><input type="text" name="size[1]" value="<?php echo $_POST['size'][1] ?>"/><br />
  547. <label>Name of CSS class thumbnails</label><input type="text" name="image_class" value="<?php echo $_POST['image_class'] ?>"/><br />
  548.  
  549. <input type="checkbox" name="paginate" value="true" <?php if($_POST['paginate'] == true) echo ' checked '; ?>/><label>&nbsp;Paginate</label><br />
  550. <label>How many posts per page:</label><input type="text" name="list" value="<?php echo $_POST['list'] ?>"/><br />
  551. <label>How many numbers on either the start and the end list edges:</label><br />
  552. <input type="text" name="end_size" value="<?php echo $_POST['end_size'] ?>"/><br />
  553. <label>How many numbers to either side of current page:</label><br />
  554. <input type="text" name="mid_size" value="<?php echo $_POST['mid_size'] ?>"/><br />
  555. <input type="checkbox" name="prev_next" value="false" <?php if($_POST['prev_next'] == 'false') echo ' checked '; ?>/><label>&nbsp;Do not include the previous and next links</label><br />
  556. <label>The previous page link text:</label><input type="text" name="prev" value="<?php echo $_POST['prev'] ?>"/><br />
  557. <label>The next page text:</label><input type="text" name="next" value="<?php echo $_POST['next'] ?>"/><br /><br />
  558.  
  559. <input type="submit" value="Get Short Code" style="color:#fff; background-color:#888; padding:10px; cursor:pointer;" />
  560. </form>
  561. </div>
  562. <div style ="background-color:#eee; display:inline-block; padding:15px;float:right;">
  563. <p><strong>Short Code</strong></p>
  564. <textarea name="short_code" rows="10" cols="40" id="main"><?php echo $short_code ?></textarea><br />
  565. </div>
  566. </div></div>
  567. <?php
  568.  
  569. }
  570.  
  571.  
  572. ?>
  573.  
  574. /* This code replaces all code in net_shared_posts.css file */
  575. #netsposts-menu {
  576. float:left;
  577.  
  578.  
  579. }
  580. .netsposts-ul {
  581. font-size:20px;
  582. padding:0;
  583. margin: 0 0 8px 0 !important;
  584. }
  585.  
  586. .netsposts-ul li{
  587. list-style:none;
  588. border-left:20px solid #d2def0;
  589. line-height:120%;
  590. margin-bottom:10px;
  591. padding-left:8px;
  592. }
  593.  
  594.  
  595.  
  596. #block-wrapper {
  597.  
  598. float:left;
  599. }
  600.  
  601. .clear {
  602. clear:both;
  603. }
  604.  
  605. .netsposts-content {
  606. display:inline-block;
  607. margin-bottom:15px;
  608.  
  609. }
  610.  
  611. .netsposts-title {
  612. font-family: 'Open Sans Condensed',sans-serif;
  613. font-size:32px;
  614. border-bottom:2px solid #ccc;
  615. margin-left:30px;
  616. font-weight:400;
  617. display:block;
  618. padding:2px 5px 12px 5px;
  619. }
  620.  
  621. .netsposts-post-titles-only {
  622. font-family:impact;
  623. font-size:22px;
  624. font-weight:lighter;
  625. margin-bottom:5px;
  626. display:block;
  627.  
  628. }
  629.  
  630. .netsposts-posttitle {
  631. font-family:impact;
  632. font-size:22px;
  633. font-weight:lighter;
  634. margin-bottom:5px;
  635. display:inline-block;
  636. }
  637.  
  638. .netsposts-posttitle a {
  639. color:#004080;
  640. line-height:120%;
  641. }
  642.  
  643. .netsposts-column {
  644. display:inline-block;
  645. float:left;
  646. width:360px;
  647. margin:0 0 0 30px ;
  648. }
  649.  
  650. .netsposts-source {
  651. display:block;
  652. border-top:1px dotted #ccc;
  653. border-bottom:1px dotted #ccc;
  654. margin-bottom:5px;
  655. font-family:serif;
  656. color:#8d8d8d;
  657. }
  658.  
  659. .netsposts-excerpt{
  660. font-size:13px;
  661. font-family:Arial Narrow, Helvetica, Arial;
  662. line-height:120%;
  663. text-align:justify;
  664. text-justify:distribute;
  665. }
  666.  
  667. #netsposts-paginate {
  668. font-family:Arial, Helvetica, sans-serif;
  669. padding: 3px;
  670. border-top:1px dotted #ccc;
  671. border-bottom:1px dotted #ccc;
  672. margin:0 0 0 30px ;
  673. }
  674.  
  675. #netsposts-paginate a {
  676. text-decoration:none;
  677. color: #000080;
  678. }
  679. #netsposts-paginate a:hover {
  680. background-color: #800000;
  681. }
  682. #netsposts-paginate span.current {
  683. padding:2px 5px 2px 5px;
  684. background-color: #d0dff2;
  685. color:#000080;
  686. margin: 2px;
  687. }
  688.  
  689. #netsposts-paginate a.next , #netsposts-paginate a.prev {
  690.  
  691. }
  692.  
  693. #netsposts-paginate .page-numbers {
  694. padding: 2px 5px 2px 5px;
  695. color:#fffbf0;
  696. background-color: #7d99c4;
  697.  
  698. margin: 2px;
  699. }
  700. /* This code replaces everything in readme.txt file */
  701. === Network Shared Posts Ext ===
  702.  
  703. Contributors: Code Ext
  704. Donate link: : http://code-ext.com/blog/2012/08/05/network-shared-posts-ext/
  705. Tags: network global posts, network posts, global posts, multisite posts, shared posts.
  706. Requires at least: 3.0
  707. Tested up to: 3.4.1
  708. Stable tag: 1.1.0
  709.  
  710.  
  711. == Installation ==
  712.  
  713. 1. Upload `network-shared-posts-ext' folder to the `/wp-content/plugins/` directory
  714. 2. Activate the plugin through the 'Plugins' menu in WordPress
  715.  
  716. == Description ==
  717.  
  718. With Network Shared Posts plugin you can share posts over WP Multi Site network. You can display the posts from all blogs in your network on any blog. You can select blogs to display posts from. <br />
  719. This plugin is very useful for multi level network. For example city.state.country.com : <br />
  720. ’state’ level site can collect posts from ‘city‘ level sites and/or its own posts,
  721. ‘country‘ level site can collect posts from ‘state‘ level sites and/or ’city‘ level sites and/or its own posts.<br />
  722. You can specify categories and tags. All posts will be shown in the latest date order no matter from what blog they were taken. You can specify how old (in days) the collected posts may be. Also you can specify how many posts should be displayed from each blog. You can set thumbnails image size and style or disable thumbnails at all. You can adjust CSS styles editing CSS file.
  723.  
  724. == Screenshots ==
  725. 1. Network Shared Posts in demo action
  726.  
  727. == Frequently Asked Questions ==
  728.  
  729. = How to use Network Shared Posts ? =
  730. Craete post or page and put a short code [netsposts ] with desired arguments into your page content .<br />
  731. Example: [netsposts include_blog=’1,2,5′ days=’30′ taxonomy=’news’ titles_only=false show_author=true thumbnail=true size=’90,90′ image_class=’ alignleft’ auto_excerpt=true excerpt_length=500 show_author=true paginate=true list=5]
  732.  
  733. = What short code arguments can I use ? =
  734. You can get the full list of short code arguments on plugin's web site http://code-ext.com/blog/2012/07/30/network-shared-posts-ext/
  735. <br />
  736.  
  737.  
  738. == Changelog ==
  739. =1.1 =
  740. Added 'exclude_blog' argument<br />
  741. The pagination was enchanced with native WordPress pagination.<br />
  742. Added argument for pagination: 'end_size', 'mid_size', 'prev', 'next', 'prev_next'<br />
  743. Tool Page was added to admin menu<br />
  744.  
  745.  
  746.  
  747. == Upgrade Notice ==
  748. = 1.1.0 =
  749. In this version you can use 'exclude_blog' argument. The pagination was enchanced with native WordPress pagination.
  750.  
  751. /* Network Shared Posts Ext */
  752. [netsposts include_blog='1,2,5' days=30 taxonomy=news titles_only=false show_author=true thumbnail=true size='90,90' image_class=alignleft auto_excerpt=true excerpt_length=500 show_author=true paginate=true list=5]
  753.  
  754. include_post - list of posts/pages that you want to include (example: include_post=5 - include_post="5,8,153"
  755. exclude_post - list of posts/pages that you want to exclude (example: exclude_post=5 - exclude_post="5,8,153"
  756. include_blog – list of blogs, with the posts which will be displayed (default all blogs).
  757. exclude_blog – list of excluded blogs (default none) (works only if include_blogs argument is not present).
  758. days – how old in days the post can be (default 0' – no limit).
  759. taxonomy – list of categories and/or tags for the posts selection (use slugs only) (default all).
  760. titles_only – if true shows titles only (default false).
  761. show_author – if true shows a posts author (default false).
  762. thumbnail - if true shows thumbnails (default false).
  763. size - size of thumbnail (width, height) (default thumbnail).
  764. image_class – CSS class for image (default post-thumbnail)..
  765. auto_excerpt - if true an excerpt will be taken from post content, if false a post excerpt will be used (default false)..
  766. excerpt_length – the length of excerpt (auto_excerpt should be true)(default 400'). .
  767. paginate – if true the result will be paginated (default false).
  768. list – how many posts per page (default 10')..
  769. post_type – type of posts (default post).
  770. full_text - full text instead of excerpt (default false).
  771. date_format – format of the post date (default n/j/Y).
  772. wrap_start, wrap_end - you can wrap the posts (for example wrap_start=<div class=myclass> wrap_end=</div>),
  773. end_size – how many numbers on either the start and the end list edges (used for pagination).
  774. mid_size – how many numbers to either side of current page, but not including current page (used for pagination).
  775. prev_next – Wheter to include the previous and next links in the list or not (used for pagination. Default: true).
  776. prev – the previous page link text. Works only if prev_next argument is set to true. (Default:« Previous)
  777. next- The next page text. Works only if prev_next argument is set to true. (Default:Next »)
  778. page_title_style – style for the page title (default: none)
  779. title – custom title (default: none),
  780. column – number of columns (default: 1),
  781. menu_name – name of the menu (should be created in Appearance > Menu)(default: none),
  782. menu_class – CSS class for the menu,
  783. container_class – the CSS class that is applied to the menu container .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement