Changeset 433619
- Timestamp:
- 09/05/2011 03:57:55 PM (15 years ago)
- Location:
- blog-in-blog
- Files:
-
- 6 edited
- 1 copied
-
tags/1.0.9 (copied) (copied from blog-in-blog/trunk)
-
tags/1.0.9/blog-in-blog.php (modified) (14 diffs)
-
tags/1.0.9/options.php (modified) (2 diffs)
-
tags/1.0.9/readme.txt (modified) (2 diffs)
-
trunk/blog-in-blog.php (modified) (14 diffs)
-
trunk/options.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blog-in-blog/tags/1.0.9/blog-in-blog.php
r432139 r433619 70 70 'tag_slug' => '', 71 71 'custom_post_type' => '', 72 'author' => '', 73 'author_name' => '', 74 // 'taxonomy' => '', 75 // 'tax_field' => '', 76 // 'tax_terms' => '', 77 // 'tax_operator' => '', 72 78 'num' => '10', 73 79 'order_by' => 'date', … … 77 83 'post_id' => '', 78 84 'custom_order_by' => '', 79 'thumbnail_size' => 'thumbnail' 85 'thumbnail_size' => 'thumbnail', 86 'hidefirst' => 0 80 87 ), $atts)); 81 88 … … 85 92 $blog_in_blog_opts['tag_slug'] = $tag_slug; 86 93 $blog_in_blog_opts['custom_post_type'] = $custom_post_type; 94 // $blog_in_blog_opts['taxonomy'] = $taxonomy; 95 // $blog_in_blog_opts['tax_field'] = $tax_field; 96 // $blog_in_blog_opts['tax_terms'] = $tax_terms; 97 // $blog_in_blog_opts['tax_operator'] = $tax_operator; 87 98 $blog_in_blog_opts['num'] = $num; 88 99 $blog_in_blog_opts['post_order'] = bib_set_post_order($sort); … … 92 103 $blog_in_blog_opts['pagination'] = $pagination; 93 104 $blog_in_blog_opts['template'] = $template ; 105 $blog_in_blog_opts['author'] = $author ; 106 $blog_in_blog_opts['author_name'] = $author_name ; 107 $blog_in_blog_opts['hidefirst'] = $hidefirst ; 94 108 95 109 if(isset ($wp_query->post->ID)){ … … 122 136 // currently no default applied here... 123 137 } 124 elseif (file_exists(BIB_WP_UPLOADS_DIR . "/" . $template)) {138 if (file_exists(BIB_WP_UPLOADS_DIR . "/" . $template)) { 125 139 $blog_in_blog_opts['bib_post_template'] = BIB_WP_UPLOADS_DIR . "/" . $template; 126 echo "<!-- blog-in-blogusing template: ".$blog_in_blog_opts['bib_post_template']." -->" ;140 echo "<!-- BIB: using template: ".$blog_in_blog_opts['bib_post_template']." -->" ; 127 141 bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']); 142 128 143 } else if (file_exists(WP_CONTENT_DIR . '/uploads/' . $template)) { 129 144 $blog_in_blog_opts['bib_post_template'] = WP_CONTENT_DIR . '/uploads/' . $template; 130 echo "<!-- blog-in-blogusing template: ".$blog_in_blog_opts['bib_post_template']." -->" ;145 echo "<!-- BIB: using template: ".$blog_in_blog_opts['bib_post_template']." -->" ; 131 146 bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']); 147 132 148 } else if (file_exists(WP_PLUGIN_DIR . "/blog-in-blog/" . $template)) { 133 149 $blog_in_blog_opts['bib_post_template'] = WP_PLUGIN_DIR . "/blog-in-blog/" . $template; 134 echo "<!-- blog-in-blogusing template: ".$blog_in_blog_opts['bib_post_template']." -->" ;150 echo "<!-- BIB: using template: ".$blog_in_blog_opts['bib_post_template']." -->" ; 135 151 bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']); 152 136 153 }else{ 137 154 $blog_in_blog_opts['bib_post_template'] = ''; // this will force using of bib_html option … … 141 158 } else { 142 159 $blog_in_blog_opts['bib_post_template'] = ''; // this will force using bib_html from database. 143 echo "<!-- blog-in-blog usingtemplate from database -->" ;160 echo "<!-- BIB: using default template from database -->" ; 144 161 bib_write_debug(__FUNCTION__, "defaulting to database template."); 145 162 } … … 148 165 149 166 $out = ""; // reset output 167 168 // validate selections and give useful responses 169 // TODO expand this properly into a separate function... 170 if($blog_in_blog_opts['author'] != '' && !is_object(get_user_by('id',$blog_in_blog_opts['author']))){ 171 $out = "Error: Author with id '{$blog_in_blog_opts['author']}' is not an author in this site."; 172 return $out; 173 } 174 if($blog_in_blog_opts['author_name'] != '' && !is_object(get_user_by('slug',$blog_in_blog_opts['author_name']))){ 175 $out = "Error: Author with slug '{$blog_in_blog_opts['author_name']}' is not an author in this site."; 176 return $out; 177 } 150 178 151 179 if (isset($wp_query->query['bib_page_offset'])) { … … 159 187 // get the posts 160 188 $postslist = bib_get_posts(); 161 162 189 // now for each post, populate the data 163 190 if (is_array($postslist)){ 191 192 if(count($postslist) <= 0){ 193 $out = "<strong>Blog in Blog:</strong> There are no posts that match the selection criteria."; 194 return $out; 195 } 196 164 197 foreach ($postslist as $post) { 165 198 166 199 //var_dump($post); 167 200 201 setup_postdata($post); 202 168 203 $data['post_id'] = $post->ID; 169 204 … … 188 223 $data['post_content'] = wpautop(wptexturize($post->post_content)); 189 224 $data['post_content'] = bib_process_gallery($data['post_content'], $post->ID); 190 $data['post_excerpt'] = wpautop(wptexturize(bib_process_excerpt($post))); 225 //$data['post_excerpt'] = wpautop(wptexturize(bib_process_excerpt($post))); 226 $data['post_excerpt'] = wpautop(wptexturize(get_the_excerpt())); 191 227 $data['post_permalink'] = get_permalink($post); 192 228 $data['post_comments'] = bib_process_comments($post->comment_status, $post->comment_count, $data['post_permalink']); … … 214 250 215 251 $out .= bib_parse_template($data); // finally output the data in the template 252 253 wp_reset_postdata(); 216 254 } 217 255 } … … 275 313 $params['order'] = $blog_in_blog_opts['post_order']; 276 314 } 315 // if ($blog_in_blog_opts['taxonomy'] != ''){ 316 // 317 // if($blog_in_blog_opts['tax_operator'] != ''){ 318 // $operator = $blog_in_blog_opts['tax_operator']; 319 // } 320 // else 321 // { 322 // $operator = 'IN'; 323 // } 324 // 325 // $params['tax_query'] = array( 326 // 'taxonomy' => $blog_in_blog_opts['taxonomy'], 327 // 'field' => $blog_in_blog_opts['tax_field'], 328 // 'terms' => explode(',',$blog_in_blog_opts['tax_terms']), 329 // 'operator' => $operator 330 // ); 331 // } 277 332 278 333 // apply whatever the case: 279 334 $params['suppress_filters'] = false; 280 $params['offset'] = $blog_in_blog_opts['offset']; 335 336 // adjust the offsett 337 if($blog_in_blog_opts['hidefirst'] != '' ){ 338 $params['offset'] = intval($blog_in_blog_opts['hidefirst']) + intval($blog_in_blog_opts['offset']); 339 }else{ 340 $params['offset'] = $blog_in_blog_opts['offset']; 341 } 342 281 343 $params['numberposts'] = $blog_in_blog_opts['num']; 282 344 … … 559 621 } 560 622 623 // this function possible needs deprecating 561 624 function bib_process_excerpt($post) { 562 625 … … 569 632 } 570 633 571 #return apply_filters('get_the_excerpt', $output);572 634 return $output; 573 635 } … … 900 962 901 963 // do something with the author_name 964 if($blog_in_blog_opts['author'] != ''){ 902 965 $querystr .= " 903 AND $wpdb->posts.author = '".$blog_in_blog_opts['author']."'"; 904 905 $querystr .= " 906 AND $wpdb->posts.author = '".$blog_in_blog_opts['author']."'"; 966 AND $wpdb->posts.post_author = '".$blog_in_blog_opts['author']."'"; 967 } 968 if($blog_in_blog_opts['author_name'] != ''){ 969 $author = get_user_by('slug',$blog_in_blog_opts['author_name']); 970 bib_write_debug(__FUNCTION__, print_r($author,true)); 971 $querystr .= " 972 AND $wpdb->posts.post_author = '".$author->ID."'"; 973 } 907 974 } 908 975 -
blog-in-blog/tags/1.0.9/options.php
r411897 r433619 362 362 363 363 function bib_templates_textarea() { 364 // Style not selected 365 $templates = get_option('bib_templates'); 366 364 367 365 // templates = array( 368 366 // array('template_name' => 'one' , 'template_html' => 'some HTML'), 369 367 // array('template_name' => 'two' , 'template_html' => 'some HTML') 370 368 // ) 371 372 //print_r($templates); 369 $templates = get_option('bib_templates'); 373 370 374 371 if(is_array($templates) ){ 375 372 foreach ($templates as $k => $v) { 376 373 if(is_array($v)){ 377 echo '<hr><div >';374 echo '<hr><div class="usertemplate">'; 378 375 echo '<input type="text" size="40" name="bib_templates['.$k.'][template_name]" value="'.$v['template_name'].'" /> template name <a href="javascript:void();" class="delete_user_template" id="bib_templates['.$k.']">Delete this template</a>'; 379 echo '<textarea rows="20" cols="60" name="bib_templates['.$k.'][template_html]" >' . html_entity_decode($v['template_html']). '</textarea>';376 echo '<textarea rows="20" cols="60" name="bib_templates['.$k.'][template_html]" >' . $v['template_html'] . '</textarea>'; 380 377 echo '</div>' ; 381 378 } … … 396 393 existing = parent.html(); 397 394 398 template_count = parent.children(" input").length ;399 400 html_before = '<hr><div >';395 template_count = parent.children("div.usertemplate").length ; 396 397 html_before = '<hr><div class="usertemplate">'; 401 398 input = '<input type="text" size="40" name="bib_templates['+ template_count +'][template_name]" value="Your template name here" /> (not saved)'; 402 399 textarea = '<textarea rows="20" cols="60" name="bib_templates['+ template_count +'][template_html]" >Your html here</textarea>'; -
blog-in-blog/tags/1.0.9/readme.txt
r432139 r433619 84 84 * `custom_post_type=<post_type>` Posts with a custom post type that you want to show 85 85 * `tag_slug=<tag_slug>` Posts of this tag slug will be shown. You can do OR (slug1,slug2,slug3) and AND (slug1+slug2+slug3) 86 * `author `=<author id>Posts from this author, identified by a numeric author id.87 * `author_name `=<author user_nicename>Posts from this author, identified by their user nicename.86 * `author=<author id>` Posts from this author, identified by a numeric author id. 87 * `author_name=<author user_nicename>` Posts from this author, identified by their user nicename. 88 88 * `post_id=<a post id>` If specified only shows a single post. All other selection or sort parameters are ignored. 89 89 … … 193 193 == Changelog == 194 194 195 = 1.0.9 = 196 197 * Added: `hidefirst` shortcode parameter to offset the first n posts in the query. 198 * Added: `author` and `author_name` selectors fpr posts by an author. 199 * Fixed: Bug where user templates were not being saved to the database. 200 * Fixed: Bug where Entity encoded chars in a template were decoded then causing problems on save. 201 * Fixed: Bug where excerpts were not shown. 202 195 203 = 1.0.8 = 196 204 -
blog-in-blog/trunk/blog-in-blog.php
r432139 r433619 70 70 'tag_slug' => '', 71 71 'custom_post_type' => '', 72 'author' => '', 73 'author_name' => '', 74 // 'taxonomy' => '', 75 // 'tax_field' => '', 76 // 'tax_terms' => '', 77 // 'tax_operator' => '', 72 78 'num' => '10', 73 79 'order_by' => 'date', … … 77 83 'post_id' => '', 78 84 'custom_order_by' => '', 79 'thumbnail_size' => 'thumbnail' 85 'thumbnail_size' => 'thumbnail', 86 'hidefirst' => 0 80 87 ), $atts)); 81 88 … … 85 92 $blog_in_blog_opts['tag_slug'] = $tag_slug; 86 93 $blog_in_blog_opts['custom_post_type'] = $custom_post_type; 94 // $blog_in_blog_opts['taxonomy'] = $taxonomy; 95 // $blog_in_blog_opts['tax_field'] = $tax_field; 96 // $blog_in_blog_opts['tax_terms'] = $tax_terms; 97 // $blog_in_blog_opts['tax_operator'] = $tax_operator; 87 98 $blog_in_blog_opts['num'] = $num; 88 99 $blog_in_blog_opts['post_order'] = bib_set_post_order($sort); … … 92 103 $blog_in_blog_opts['pagination'] = $pagination; 93 104 $blog_in_blog_opts['template'] = $template ; 105 $blog_in_blog_opts['author'] = $author ; 106 $blog_in_blog_opts['author_name'] = $author_name ; 107 $blog_in_blog_opts['hidefirst'] = $hidefirst ; 94 108 95 109 if(isset ($wp_query->post->ID)){ … … 122 136 // currently no default applied here... 123 137 } 124 elseif (file_exists(BIB_WP_UPLOADS_DIR . "/" . $template)) {138 if (file_exists(BIB_WP_UPLOADS_DIR . "/" . $template)) { 125 139 $blog_in_blog_opts['bib_post_template'] = BIB_WP_UPLOADS_DIR . "/" . $template; 126 echo "<!-- blog-in-blogusing template: ".$blog_in_blog_opts['bib_post_template']." -->" ;140 echo "<!-- BIB: using template: ".$blog_in_blog_opts['bib_post_template']." -->" ; 127 141 bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']); 142 128 143 } else if (file_exists(WP_CONTENT_DIR . '/uploads/' . $template)) { 129 144 $blog_in_blog_opts['bib_post_template'] = WP_CONTENT_DIR . '/uploads/' . $template; 130 echo "<!-- blog-in-blogusing template: ".$blog_in_blog_opts['bib_post_template']." -->" ;145 echo "<!-- BIB: using template: ".$blog_in_blog_opts['bib_post_template']." -->" ; 131 146 bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']); 147 132 148 } else if (file_exists(WP_PLUGIN_DIR . "/blog-in-blog/" . $template)) { 133 149 $blog_in_blog_opts['bib_post_template'] = WP_PLUGIN_DIR . "/blog-in-blog/" . $template; 134 echo "<!-- blog-in-blogusing template: ".$blog_in_blog_opts['bib_post_template']." -->" ;150 echo "<!-- BIB: using template: ".$blog_in_blog_opts['bib_post_template']." -->" ; 135 151 bib_write_debug(__FUNCTION__, "using template ".$blog_in_blog_opts['bib_post_template']); 152 136 153 }else{ 137 154 $blog_in_blog_opts['bib_post_template'] = ''; // this will force using of bib_html option … … 141 158 } else { 142 159 $blog_in_blog_opts['bib_post_template'] = ''; // this will force using bib_html from database. 143 echo "<!-- blog-in-blog usingtemplate from database -->" ;160 echo "<!-- BIB: using default template from database -->" ; 144 161 bib_write_debug(__FUNCTION__, "defaulting to database template."); 145 162 } … … 148 165 149 166 $out = ""; // reset output 167 168 // validate selections and give useful responses 169 // TODO expand this properly into a separate function... 170 if($blog_in_blog_opts['author'] != '' && !is_object(get_user_by('id',$blog_in_blog_opts['author']))){ 171 $out = "Error: Author with id '{$blog_in_blog_opts['author']}' is not an author in this site."; 172 return $out; 173 } 174 if($blog_in_blog_opts['author_name'] != '' && !is_object(get_user_by('slug',$blog_in_blog_opts['author_name']))){ 175 $out = "Error: Author with slug '{$blog_in_blog_opts['author_name']}' is not an author in this site."; 176 return $out; 177 } 150 178 151 179 if (isset($wp_query->query['bib_page_offset'])) { … … 159 187 // get the posts 160 188 $postslist = bib_get_posts(); 161 162 189 // now for each post, populate the data 163 190 if (is_array($postslist)){ 191 192 if(count($postslist) <= 0){ 193 $out = "<strong>Blog in Blog:</strong> There are no posts that match the selection criteria."; 194 return $out; 195 } 196 164 197 foreach ($postslist as $post) { 165 198 166 199 //var_dump($post); 167 200 201 setup_postdata($post); 202 168 203 $data['post_id'] = $post->ID; 169 204 … … 188 223 $data['post_content'] = wpautop(wptexturize($post->post_content)); 189 224 $data['post_content'] = bib_process_gallery($data['post_content'], $post->ID); 190 $data['post_excerpt'] = wpautop(wptexturize(bib_process_excerpt($post))); 225 //$data['post_excerpt'] = wpautop(wptexturize(bib_process_excerpt($post))); 226 $data['post_excerpt'] = wpautop(wptexturize(get_the_excerpt())); 191 227 $data['post_permalink'] = get_permalink($post); 192 228 $data['post_comments'] = bib_process_comments($post->comment_status, $post->comment_count, $data['post_permalink']); … … 214 250 215 251 $out .= bib_parse_template($data); // finally output the data in the template 252 253 wp_reset_postdata(); 216 254 } 217 255 } … … 275 313 $params['order'] = $blog_in_blog_opts['post_order']; 276 314 } 315 // if ($blog_in_blog_opts['taxonomy'] != ''){ 316 // 317 // if($blog_in_blog_opts['tax_operator'] != ''){ 318 // $operator = $blog_in_blog_opts['tax_operator']; 319 // } 320 // else 321 // { 322 // $operator = 'IN'; 323 // } 324 // 325 // $params['tax_query'] = array( 326 // 'taxonomy' => $blog_in_blog_opts['taxonomy'], 327 // 'field' => $blog_in_blog_opts['tax_field'], 328 // 'terms' => explode(',',$blog_in_blog_opts['tax_terms']), 329 // 'operator' => $operator 330 // ); 331 // } 277 332 278 333 // apply whatever the case: 279 334 $params['suppress_filters'] = false; 280 $params['offset'] = $blog_in_blog_opts['offset']; 335 336 // adjust the offsett 337 if($blog_in_blog_opts['hidefirst'] != '' ){ 338 $params['offset'] = intval($blog_in_blog_opts['hidefirst']) + intval($blog_in_blog_opts['offset']); 339 }else{ 340 $params['offset'] = $blog_in_blog_opts['offset']; 341 } 342 281 343 $params['numberposts'] = $blog_in_blog_opts['num']; 282 344 … … 559 621 } 560 622 623 // this function possible needs deprecating 561 624 function bib_process_excerpt($post) { 562 625 … … 569 632 } 570 633 571 #return apply_filters('get_the_excerpt', $output);572 634 return $output; 573 635 } … … 900 962 901 963 // do something with the author_name 964 if($blog_in_blog_opts['author'] != ''){ 902 965 $querystr .= " 903 AND $wpdb->posts.author = '".$blog_in_blog_opts['author']."'"; 904 905 $querystr .= " 906 AND $wpdb->posts.author = '".$blog_in_blog_opts['author']."'"; 966 AND $wpdb->posts.post_author = '".$blog_in_blog_opts['author']."'"; 967 } 968 if($blog_in_blog_opts['author_name'] != ''){ 969 $author = get_user_by('slug',$blog_in_blog_opts['author_name']); 970 bib_write_debug(__FUNCTION__, print_r($author,true)); 971 $querystr .= " 972 AND $wpdb->posts.post_author = '".$author->ID."'"; 973 } 907 974 } 908 975 -
blog-in-blog/trunk/options.php
r411897 r433619 362 362 363 363 function bib_templates_textarea() { 364 // Style not selected 365 $templates = get_option('bib_templates'); 366 364 367 365 // templates = array( 368 366 // array('template_name' => 'one' , 'template_html' => 'some HTML'), 369 367 // array('template_name' => 'two' , 'template_html' => 'some HTML') 370 368 // ) 371 372 //print_r($templates); 369 $templates = get_option('bib_templates'); 373 370 374 371 if(is_array($templates) ){ 375 372 foreach ($templates as $k => $v) { 376 373 if(is_array($v)){ 377 echo '<hr><div >';374 echo '<hr><div class="usertemplate">'; 378 375 echo '<input type="text" size="40" name="bib_templates['.$k.'][template_name]" value="'.$v['template_name'].'" /> template name <a href="javascript:void();" class="delete_user_template" id="bib_templates['.$k.']">Delete this template</a>'; 379 echo '<textarea rows="20" cols="60" name="bib_templates['.$k.'][template_html]" >' . html_entity_decode($v['template_html']). '</textarea>';376 echo '<textarea rows="20" cols="60" name="bib_templates['.$k.'][template_html]" >' . $v['template_html'] . '</textarea>'; 380 377 echo '</div>' ; 381 378 } … … 396 393 existing = parent.html(); 397 394 398 template_count = parent.children(" input").length ;399 400 html_before = '<hr><div >';395 template_count = parent.children("div.usertemplate").length ; 396 397 html_before = '<hr><div class="usertemplate">'; 401 398 input = '<input type="text" size="40" name="bib_templates['+ template_count +'][template_name]" value="Your template name here" /> (not saved)'; 402 399 textarea = '<textarea rows="20" cols="60" name="bib_templates['+ template_count +'][template_html]" >Your html here</textarea>'; -
blog-in-blog/trunk/readme.txt
r432139 r433619 84 84 * `custom_post_type=<post_type>` Posts with a custom post type that you want to show 85 85 * `tag_slug=<tag_slug>` Posts of this tag slug will be shown. You can do OR (slug1,slug2,slug3) and AND (slug1+slug2+slug3) 86 * `author `=<author id>Posts from this author, identified by a numeric author id.87 * `author_name `=<author user_nicename>Posts from this author, identified by their user nicename.86 * `author=<author id>` Posts from this author, identified by a numeric author id. 87 * `author_name=<author user_nicename>` Posts from this author, identified by their user nicename. 88 88 * `post_id=<a post id>` If specified only shows a single post. All other selection or sort parameters are ignored. 89 89 … … 193 193 == Changelog == 194 194 195 = 1.0.9 = 196 197 * Added: `hidefirst` shortcode parameter to offset the first n posts in the query. 198 * Added: `author` and `author_name` selectors fpr posts by an author. 199 * Fixed: Bug where user templates were not being saved to the database. 200 * Fixed: Bug where Entity encoded chars in a template were decoded then causing problems on save. 201 * Fixed: Bug where excerpts were not shown. 202 195 203 = 1.0.8 = 196 204
Note: See TracChangeset
for help on using the changeset viewer.