Changeset 662436
- Timestamp:
- 02/02/2013 09:59:37 AM (13 years ago)
- Location:
- all-inclusive/trunk
- Files:
-
- 2 edited
-
all-inclusive.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
all-inclusive/trunk/all-inclusive.php
r389505 r662436 1 1 <?php 2 2 /* 3 Plugin Name:All Inclusive4 Plugin URI: http://ili.com.ua/wordpress/all-inclusive-en.html 5 Description:Two additional SQL query appends all metadata fields and pictures in the original sample of $ wp_query-> posts6 Author: stur Stepanov Yuri7 Version: 1.0.5 8 Author URI: http://ili.com.ua/wordpress/3 This filter is available as a separate plug-in All Inclusive 4 # http://wp.od.ua/ 5 # Two additional SQL query appends all metadata fields and pictures in the original sample of $ wp_query-> posts 6 #Author: stur Stepanov Yuri 7 #Version: 1.0.6 8 # http://wp.od.ua/ 9 9 */ 10 10 if(!function_exists('all_inclusive')){ 11 11 function all_inclusive($posts, $forcibly = 0){ 12 if(!sizeof($posts))return $posts; 13 global $wpdb, $wp_query, $paged; 12 if(!sizeof($posts)) return $posts; 13 global $wpdb, $wp_query, $paged; 14 14 15 if(!$forcibly){ 15 16 foreach ($posts as $key=>$value) { … … 31 32 $st_id = @implode("','", $ar_post_id); 32 33 //We obtain the first atachmenty 33 $my_wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);34 34 // коректируем found_posts запоминаем его в глоб переменую и возвращаем через фильтр found_posts 35 35 global $all_found_rows; … … 41 41 $my_wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 42 42 $files = $my_wpdb->get_results($query); 43 43 44 // obtain the list id atachmentov 44 45 $ar_file_id = array(); … … 49 50 } 50 51 51 // add up, we obtain a general list52 // add up, we obtain a general list 52 53 $ar_all_id = @array_merge($ar_post_id,$ar_file_id); 53 54 55 54 $all_meta = update_meta_cache('post', $ar_all_id); 56 55 if(!sizeof($all_meta) or ($all_meta===false) ){ … … 60 59 $uploads_dir = wp_upload_dir('baseurl'); 61 60 foreach ($all_meta as $post_id=>$meta) { 62 61 $post_type = $ar_link[$post_id]->post_type; 62 $post_mime_type = $ar_link[$post_id]->post_mime_type; 63 $ar_link[$post_id]->meta = array(); 63 64 foreach($meta as $meta_key=>$value){ 64 $meta_value = maybe_unserialize($value[0]); 65 66 if('_wp_attachment_metadata' == $meta_key AND sizeof($meta_value) ){ 67 65 $meta_value = maybe_unserialize($value[0]); 66 if( '_wp_attachment_metadata' == $meta_key AND sizeof($meta_value)){ 68 67 $imgUrl = strstr ($meta_value['file'], '/wp-content'); 69 68 if(!$imgUrl){ … … 90 89 $ar_link[$post_id]->full = $imgUrl; 91 90 } 92 elseif('_wp_attached_file' ==$row->meta_key){91 elseif('_wp_attached_file' == $meta_key AND !preg_match('`^image/+`',$post_mime_type) ) { 93 92 $ar_link[$post_id]->attachment_url = $uploads_dir['baseurl'].'/'.$meta_value; 94 93 $ar_link[$post_id]->thumbnail = $ar_link[$post_id]->medium = $ar_link[$post_id]->full = wp_mime_type_icon($post_id ); 95 94 } 95 $ar_link[$post_id]->meta[$meta_key] = $meta_value; 96 $ar_link[$post_id]->$meta_key = $ar_link[$post_id]->meta[$meta_key]; 97 $meta_value = ''; $thumbUrl = ''; $mediumUrl = ''; 96 98 97 $ar_link[$post_id]->meta[$meta_key] = $meta_value;98 if( !isset($ar_link[$post_id]->$meta_key) )99 $ar_link[$post_id]->$meta_key = & $ar_link[$post_id]->meta[$meta_key];100 $meta_value = ''; $thumbUrl = ''; $mediumUrl = '';101 99 } 102 100 … … 107 105 } 108 106 // now clings atachmenty to posts 109 110 107 usort ($files,'_sort_order'); 111 108 foreach ($files as $ord=>$row) { 109 if( !is_array($ar_link[$row->post_parent]->files) ) 110 $ar_link[$row->post_parent]->files = array(); 112 111 if($row->menu_order == 0) 113 112 $ar_link[$row->post_parent]->files[] = $row; … … 115 114 $ar_link[$row->post_parent]->files[$row->menu_order] = $row; 116 115 } 117 //remove_filter('posts_results', 'all_inclusive'); 116 117 remove_filter('posts_results', 'all_inclusive'); 118 118 return $posts; 119 119 } … … 128 128 return ($a->menu_order < $b->menu_order) ? -1 : 1; 129 129 } 130 131 add_filter('posts_results', 'all_inclusive');132 130 } 133 134 131 ?> -
all-inclusive/trunk/readme.txt
r451934 r662436 1 === Plugin Name ===1 === All Inclusive === 2 2 Plugin Name: All Inclusive accelerator 3 3 Contributors: stur, Y.Stepanov 4 4 Tags: Post, posts, thumbnail, meta, image, images, picture pictures, integration, theme, themes, thumbnail, meta, accelerator, optimization 5 5 Requires at least: 3.0.0 6 Tested up to: 3. 0.16 Tested up to: 3.5.1 7 7 Stable tag: trunk 8 License: GPLv2 or later 8 9 9 10 The pluginplug-in, with two additional SQL queries, joins the original data sample $wp_query->posts all meta fields, all files and images. … … 68 69 removed error message when an empty result 69 70 = 1.0.4 = 71 Fixed bug when using external plug-in cache 70 72 = 1.0.5 = 71 73 Fixed bug when using external plug-in cache 74 = 1.0.6 = 75 Works with Wordpress 3.5 76 72 77 == A brief Markdown Example == 73 78 [Examples](http://www.wp.od.ua/en/?p=4#Examples)
Note: See TracChangeset
for help on using the changeset viewer.