Changeset 706376
- Timestamp:
- 05/01/2013 10:04:04 AM (13 years ago)
- File:
-
- 1 edited
-
cross-network-posts/trunk/cnp.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cross-network-posts/trunk/cnp.php
r706122 r706376 110 110 111 111 //our popup's title 112 $title = 'Create CNPshortcode';112 $title = 'Create a Cross-Network posts shortcode'; 113 113 114 114 //append the icon … … 120 120 } 121 121 122 //get all available blogs except currect 123 function cnp_get_blogs(){ 124 global $wpdb; 125 $blogId = get_current_blog_id(); 126 $blog_details = get_blog_details($blogId); 127 $sql = $wpdb->prepare( 128 "SELECT blog_id,path FROM {$wpdb->blogs} 129 WHERE blog_id != %d 130 AND site_id = %s 131 AND spam = '0' 132 AND deleted = '0' 133 AND archived = '0' 134 order by blog_id", $blogId, $wpdb->siteid); 135 136 $result = $wpdb->get_results( $sql, ARRAY_A); 137 return $result; 138 } 139 140 function cnp_get_content($blogid, $type){ 141 if(!ms_is_switched()){ 142 if( function_exists('switch_to_blog')){ 143 switch_to_blog($blogid); 144 }else{ 145 echo 'switch_to_blog does not exist'; 146 } 147 } 148 if($type == 'cat'){ 149 $args = array( 150 'type' => 'post', 151 'orderby' => 'name', 152 'order' => 'ASC', 153 'hide_empty' => 0, 154 'hierarchical' => 1, 155 'taxonomy' => 'category'); 156 $result = get_categories( $args ); 157 } 158 if(ms_is_switched()){ 159 if( function_exists('restore_current_blog')){ restore_current_blog();} 160 }else{ 161 $result .= 'restore_current_blog does not exist'; 162 } 163 return $result; 164 165 } 166 167 //add inline popup 122 168 function add_cnp_inline_popup_content() { 123 169 ?> 124 170 <div id="cnp_popup_container" style="display:none;"> 125 <h2>Create a Cross-Network posts shortcode</h2>126 <p>127 To display a post or category from another website in your Wordpress Network:128 <ol>129 <li>Select whether you want to display a single post or you want to show a set of posts from a category</li>130 <li>Select from which website in your network you want to display the content from</li>131 <li>Select the content</li>132 </ol>133 </p>134 171 <form method="post" action=""> 135 <input type="radio" name="cnp-type" value="post" class="cnp-type" id="cnp-type-post" /><label for="cnp-type-post">Single post</label> 172 <h4>Choose type of content</h4> 173 <input type="radio" name="cnp-type" value="post" class="cnp-type" id="cnp-type-post" /><label for="cnp-type-post">Single post</label><br /> 136 174 <input type="radio" name="cnp-type" value="category" class="cnp-type" id="cnp-type-category" /><label for="cnp-type-category">Posts from category</label> 175 <h4>Choose which blog you want to get the content from</h4> 176 <?php 177 foreach(cnp_get_blogs() as $blog): 178 ?> 179 <input type="radio" name="cnp-blogid" value="<?php echo $blog['blog_id'];?>" class="cnp-blogid" id="cnp-type-blogid-<?php echo $blog['blog_id'];?>" /><label for="cnp-type-blogid-<?php echo $blog['blog_id'];?>"><?php echo $blog['path'];?></label><br /> 180 <select name="cnp-categoryid" class="cnp-categoryid"> 181 <?php 182 foreach(cnp_get_content($blog['blog_id'],'cat') as $category):?> 183 <option value="<?php echo $category->cat_ID;?>"/><?php echo $category->name;?></option> 184 <?php 185 endforeach; 186 ?></select><br /> 187 <?php 188 endforeach; 189 ?> 137 190 <div class="cnpwizard"></div> 138 191 </form> 139 192 140 193 <script type="text/javascript"> 141 jQuery('.cnp-type').on('click',function(){142 jQuery.getJSON('<?php echo plugins_url("cnp-get-blogs.php" , __FILE__ );?>', function(data) {143 jQuery.('.cnpwizard').val(data);144 });145 });194 // jQuery('.cnp-blogid').on('click',function(){ 195 // jQuery.getJSON('<?php echo plugins_url("cnp-get-blogs.php" , __FILE__ );?>', function(data) { 196 // jQuery.('.cnpwizard').val(data); 197 // }); 198 // }); 146 199 </script> 147 200 </div>
Note: See TracChangeset
for help on using the changeset viewer.