Plugin Directory

Changeset 662436


Ignore:
Timestamp:
02/02/2013 09:59:37 AM (13 years ago)
Author:
stur
Message:

Changed details in readme file

Location:
all-inclusive/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • all-inclusive/trunk/all-inclusive.php

    r389505 r662436  
    11<?php
    22/*
    3 Plugin Name: All Inclusive
    4 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-> posts
    6 Author: stur Stepanov Yuri
    7 Version: 1.0.5
    8 Author URI: http://ili.com.ua/wordpress/
     3This 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/
    99*/
    1010if(!function_exists('all_inclusive')){
    1111    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
    1415       if(!$forcibly){
    1516           foreach ($posts as $key=>$value) {
     
    3132       $st_id = @implode("','", $ar_post_id);
    3233       //We obtain the first atachmenty
    33        $my_wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    3434       // коректируем  found_posts  запоминаем его в глоб переменую и возвращаем через фильтр found_posts
    3535       global $all_found_rows;
     
    4141       $my_wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    4242       $files = $my_wpdb->get_results($query);
     43
    4344       // obtain the list id atachmentov
    4445       $ar_file_id = array();
     
    4950       }
    5051
    51        // add up, we obtain a general list
     52     // add up, we obtain a general list
    5253       $ar_all_id = @array_merge($ar_post_id,$ar_file_id);
    53 
    54 
    5554       $all_meta = update_meta_cache('post', $ar_all_id);
    5655       if(!sizeof($all_meta) or ($all_meta===false) ){
     
    6059       $uploads_dir = wp_upload_dir('baseurl');
    6160       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();
    6364           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)){
    6867                  $imgUrl = strstr ($meta_value['file'], '/wp-content');
    6968                  if(!$imgUrl){
     
    9089                  $ar_link[$post_id]->full = $imgUrl;
    9190              }
    92               elseif('_wp_attached_file'==$row->meta_key){
     91              elseif('_wp_attached_file' == $meta_key AND !preg_match('`^image/+`',$post_mime_type) ) {
    9392                    $ar_link[$post_id]->attachment_url = $uploads_dir['baseurl'].'/'.$meta_value;
    9493                    $ar_link[$post_id]->thumbnail = $ar_link[$post_id]->medium = $ar_link[$post_id]->full = wp_mime_type_icon($post_id );
    9594              }
     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 = '';
    9698
    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 = '';
    10199           }
    102100
     
    107105       }
    108106       //  now clings atachmenty to posts
    109 
    110107       usort ($files,'_sort_order');
    111108       foreach ($files as $ord=>$row) {
     109           if( !is_array($ar_link[$row->post_parent]->files) )
     110                $ar_link[$row->post_parent]->files = array();
    112111           if($row->menu_order == 0)
    113112            $ar_link[$row->post_parent]->files[] = $row;
     
    115114            $ar_link[$row->post_parent]->files[$row->menu_order] = $row;
    116115       }
    117        //remove_filter('posts_results', 'all_inclusive');
     116
     117       remove_filter('posts_results', 'all_inclusive');
    118118       return $posts;
    119119    }
     
    128128       return ($a->menu_order < $b->menu_order) ? -1 : 1;
    129129    }
    130 
    131 add_filter('posts_results', 'all_inclusive');
    132130}
    133 
    134 
     131?>
  • all-inclusive/trunk/readme.txt

    r451934 r662436  
    1 === Plugin Name ===
     1=== All Inclusive ===
    22Plugin Name: All Inclusive accelerator
    33Contributors: stur, Y.Stepanov
    44Tags:  Post, posts, thumbnail, meta, image, images, picture pictures, integration, theme, themes, thumbnail, meta, accelerator, optimization
    55Requires at least: 3.0.0
    6 Tested up to: 3.0.1
     6Tested up to: 3.5.1
    77Stable tag: trunk
     8License: GPLv2 or later
    89
    910The pluginplug-in, with two additional SQL queries, joins the original data sample $wp_query->posts all meta fields, all files and images.
     
    6869removed error message when an empty result
    6970= 1.0.4 =
     71Fixed bug when using external plug-in cache
    7072= 1.0.5 =
    7173Fixed bug when using external plug-in cache
     74= 1.0.6 =
     75Works with Wordpress 3.5
     76
    7277== A brief Markdown Example ==
    7378[Examples](http://www.wp.od.ua/en/?p=4#Examples)
Note: See TracChangeset for help on using the changeset viewer.