Plugin Directory

Changeset 484003


Ignore:
Timestamp:
01/03/2012 06:52:08 PM (14 years ago)
Author:
maymond
Message:

Updated for single and multi-site as well as 3.3 compatibility updates

Location:
link-to-your-content/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • link-to-your-content/trunk/link_to_your_content.php

    r463297 r484003  
    44        Plugin URI: http://www.maymond.com/link-to-your-content
    55        Description: This plugin gives you an easy way to link to your media library, posts, pages, custom post types and taxonomies.
    6         Version: 1.4
     6        Version: 1.5
    77        Author: Ray Milstrey
    88        Author URI: http://www.maymond.com
     
    4444                global $wpdb; global $ltyc_db_version;
    4545                // Set the database version number
    46                 $ltyc_db_version = "1.4";
     46                $ltyc_db_version = "1.5";
    4747                require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    4848               
     
    117117            // Sanitize and validate input. Accepts an array, return a sanitized array.
    118118            function ltyc_options_validate($input) {
    119                 $input['ltyc_db_version'] = '0.2';
     119                $input['ltyc_db_version'] = '1.5';
    120120                // Our values are either a 0 or 1
    121121                $input['ltyc_taxonomy'] = ( $input['ltyc_taxonomy'] == 1 ? 1 : 0 );
     
    155155            // Panel display
    156156            function ltyc_panel_display($type='posts') {
    157                 $panel_display;
     157                $panel_display = '';
    158158                if($type == 'cptypes') { $panel_display .= $this->ltyc_cpt_toggle(); }
    159159                if($type == 'taxonomies') { $panel_display .= $this->ltyc_tax_toggle(); }
     
    184184            // Toggle between sites in the network
    185185            function ltyc_site_toggle() {
    186                 global $wpdb; $siteToggle;
     186                global $wpdb; $siteToggle = '';
    187187                if(function_exists('switch_to_blog') && switch_to_blog(1)) { $this->ltycOptions = get_option('ltyc_options'); restore_current_blog(); }
    188188
     
    207207            // Content type tabs
    208208            function ltyc_content_tabs() {
    209                 global $wpdb; $contentTabs;
     209                global $wpdb; $contentTabs = '';
     210                if(function_exists('switch_to_blog') && switch_to_blog(1)) { $this->ltycOptions = get_option('ltyc_options'); restore_current_blog(); }
     211                else { $this->ltycOptions = get_option('ltyc_options'); }
    210212               
    211213                $contentTabs .= '<ul>'."\n";
     
    231233            function ltyc_cpt_toggle() {
    232234                global $wpdb;
    233                 $cptSelect; $loopCounter = 0;
     235                $cptSelect = ''; $loopCounter = 0;
    234236                if(function_exists('switch_to_blog') && switch_to_blog(1)) { $this->ltycOptions = get_option('ltyc_options'); restore_current_blog(); }
    235237                else { $this->ltycOptions = get_option('ltyc_options'); }
     
    241243                    if($loopCounter == 0 && !isset($this->customPostType)) { $this->customPostType = $post_type; }
    242244                    $cptObj = get_post_type_object($post_type);
     245                    if(!is_object($cptObj)) { $cptObj->labels->name = ucfirst($post_type); }
    243246
    244247                    $cptSelect .= '<option value="'.$post_type.'~'.$wpdb->blogid.'"';
     
    257260            function ltyc_tax_toggle() {
    258261                global $wpdb;
    259                 $taxSelect; $loopCounter = 0;
     262                $taxSelect = ''; $loopCounter = 0;
    260263                if(function_exists('switch_to_blog') && switch_to_blog(1)) { $this->ltycOptions = get_option('ltyc_options'); restore_current_blog(); }
    261264                else { $this->ltycOptions = get_option('ltyc_options'); }
     
    267270                    if($loopCounter == 0 && !isset($this->taxonomy)) { $this->taxonomy = $taxonomy; }
    268271                    $taxObj = get_taxonomy($taxonomy);
     272                    if(!is_object($taxObj)) { $taxObj->labels->name = ucfirst($taxonomy); }
    269273
    270274                    $taxSelect .= '<option value="'.$taxonomy.'~'.$wpdb->blogid.'"';
     
    397401                            else {
    398402                                $this->queryBlog = $wpdb->prefix;
    399                                 $json_response['cptypes_panel'] = $this->ltyc_panel_display('cptypes');
     403                                $json_response['taxonomies_panel'] = $this->ltyc_panel_display('taxonomies');
    400404                            }
    401405                           
     
    411415            // Creates the page heirarchy output
    412416            function ltyc_page_heirarchy_output($entryId, $type) {
    413                 global $wpdb; $documentSubList;
     417                global $wpdb; $documentSubList = '';
    414418                switch($type) {
    415419                    case 'pages' :
     
    433437                    foreach($subEntryResults as $subEntry) {   
    434438                        if($type == 'taxonomies') {
    435                             $currentLevel = count(get_ancestors($subEntry['term_id'], $this->taxonomy));
    436                             $subEntryTitle = $subEntry['name'];
    437                             $subEntryId = $subEntry['term_id'];
    438                             $subEntryPermalink = get_term_link($subEntry['slug'], $this->taxonomy);
     439                            if(taxonomy_exists($this->taxonomy) === true) {
     440                                $currentLevel = count(get_ancestors($subEntry['term_id'], $this->taxonomy));
     441                                $subEntryTitle = $subEntry['name'];
     442                                $subEntryId = $subEntry['term_id'];
     443                                $subEntryPermalink = get_term_link($subEntry['slug'], $this->taxonomy);
     444                            }
     445                            else {
     446                                $currentLevel = $this->ltyc_tax_ancestors($subEntry['term_id']);
     447                                $subEntryTitle = $subEntry['name'];
     448                                $subEntryId = $subEntry['term_id'];
     449                                if(function_exists('switch_to_blog') && switch_to_blog($this->currentBlog)) {
     450                                    $subEntryPermalink = get_bloginfo('url').'/?'.$this->taxonomy.'='.$subEntry['slug'];
     451                                    restore_current_blog();
     452                                }
     453                                else {
     454                                    $subEntryPermalink = get_bloginfo('url').'/?'.$this->taxonomy.'='.$subEntry['slug'];
     455                                }
     456                            }
    439457                        }
    440458                        else {
     
    457475                }
    458476            }
     477
     478            // Recursive function for getting the top ancestor for taxonomies
     479            function ltyc_tax_ancestors($term_id, &$currentLevel = 0) {
     480                global $wpdb;
     481                $ancestorCheck = $wpdb->prepare('SELECT parent FROM '.$this->queryBlog.'term_taxonomy WHERE term_id = '.$term_id.'');
     482                $ancestor = $wpdb->get_var($ancestorCheck);
     483                if($ancestor != 0) {
     484                    $currentLevel++;
     485                    $ancestorRecursion = $this->ltyc_tax_ancestors($ancestor, $currentLevel);
     486                }
     487                return $currentLevel;
     488            }
    459489           
    460490            // Pagination control when viewing documents lists
    461491            function ltyc_pagination($type) {
    462                 global $wpdb; $cpt_page_link; $tax_page_link;
     492                global $wpdb; $cpt_page_link = ''; $tax_page_link = '';
    463493                // Get the list of documents count based on the current view
    464494                if($type == 'posts') {
     
    476506                        $cpt_page_link = '&cpt='.$this->customPostType;
    477507                    }
     508                    else {
     509                        $paginationTitle = 'Select '.ucfirst($this->customPostType).':';
     510                        $entriesTest = 'SELECT post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" ORDER BY menu_order ASC';
     511                        $entryTest = $wpdb->get_results($entriesTest, ARRAY_A);
     512                        $hierarchical = 0;
     513                        foreach($entryTest as $entry) {
     514                            if($entry['post_parent'] != 0) { $hierarchical = 1; }
     515                        }
     516                        if($hierarchical == 1) { $cpt_hierarchical = 1; }
     517                        else { $cpt_hierarchical = 0; }
     518                        $cpt_page_link = '&cpt='.$this->customPostType;
     519                    }
    478520                } else if($type == 'taxonomies') {
    479521                    $queryCount = 'SELECT term_id FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'"';
     
    482524                        $paginationTitle = 'Select '.$tax_obj->labels->singular_name.':';   
    483525                        $tax_hierarchical = $tax_obj->hierarchical;
     526                        $tax_page_link = '&tax='.$this->taxonomy;
     527                    }
     528                    else {
     529                        $paginationTitle = 'Select '.ucfirst($this->taxonomy).':';
     530                        $tax_hierarchical = $tax_obj->hierarchical;
     531                        $entriesTest = 'SELECT parent FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" ORDER BY name ASC';
     532                        $entryTest = $wpdb->get_results($entriesTest, ARRAY_A);
     533                        foreach($entryTest as $entry) {
     534                            if($entry['parent'] != 0) { $hierarchical = 1; }
     535                        }
     536                        if($hierarchical == 1) { $tax_hierarchical = 1; }
     537                        else { $tax_hierarchical = 0; }
    484538                        $tax_page_link = '&tax='.$this->taxonomy;
    485539                    }
     
    496550                $this->pageOffset = 20; //25
    497551                $pageCount = ceil($totalResults / $this->pageOffset);
    498                 $paginationDisplay;
     552                $paginationDisplay = '';
    499553               
    500554                if(isset($this->page) && ctype_digit($this->page) && $this->page >= 1 && $this->page > $pageCount) { $this->page = $pageCount; }
     
    553607            // Outputs the list of documents that have been uploaded
    554608            function ltyc_document_list($type, $page, $pageOffset) {
    555                 global $wpdb; $documentList;
     609                global $wpdb; $documentList = ''; global $wp_post_types;
    556610                // Get the list of documents based on the current view
    557611                if($type == 'posts') {
    558                     $entries = 'SELECT post_title, guid, ID, post_mime_type FROM '.$this->queryBlog.'posts WHERE post_type = "post" AND post_status = "publish" ORDER BY post_date DESC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
     612                    $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "post" AND post_status = "publish" ORDER BY post_date DESC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    559613                } else if($type == 'pages') {
    560                     $entries = 'SELECT post_title, guid, ID, post_mime_type FROM '.$this->queryBlog.'posts WHERE post_type = "page" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC';
     614                    $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "page" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC';
    561615                } else if($type == 'cptypes') {
    562616                    if(post_type_exists($this->customPostType) === true) {
     
    564618                        $cpt_hierarchical = $cpt_obj->hierarchical;
    565619                        if($cpt_hierarchical == 0) {
    566                             $entries = 'SELECT post_title, guid, ID, post_mime_type FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
     620                            $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    567621                        }
    568622                        else {
    569                             $entries = 'SELECT post_title, guid, ID, post_mime_type FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC';
     623                            $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC';
     624                        }
     625                    }
     626                    else {
     627                        $entries = 'SELECT post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" ORDER BY menu_order ASC';
     628                        $entryTest = $wpdb->get_results($entries, ARRAY_A);
     629                        foreach($entryTest as $entry) {
     630                            if($entry['post_parent'] != 0) { $cpt_hierarchical = true; }
     631                        }
     632                        if($cpt_hierarchical === true) {
     633                            $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC';
     634                        }
     635                        else {
     636                            $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "'.$this->customPostType.'" AND post_status = "publish" AND post_parent = 0 ORDER BY menu_order ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    570637                        }
    571638                    }
     
    575642                        $tax_hierarchical = $tax_obj->hierarchical;
    576643                        if($tax_hierarchical == 0) {
    577                             $entries = 'SELECT term_id, name, slug FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" AND '.$this->queryBlog.'term_taxonomy.parent = 0 ORDER BY name ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
     644                            $entries = 'SELECT term_id, name, slug, '.$this->queryBlog.'term_taxonomy.parent FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" AND '.$this->queryBlog.'term_taxonomy.parent = 0 ORDER BY name ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    578645                        }
    579646                        else {
    580                             $entries = 'SELECT term_id, name, slug FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" AND '.$this->queryBlog.'term_taxonomy.parent = 0 ORDER BY name ASC';
     647                            $entries = 'SELECT term_id, name, slug, '.$this->queryBlog.'term_taxonomy.parent FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" AND '.$this->queryBlog.'term_taxonomy.parent = 0 ORDER BY name ASC';
     648                        }
     649                    }
     650                    else {
     651                        $entries = 'SELECT parent FROM '.$this->queryBlog.'term_taxonomy NATURAL JOIN '.$this->queryBlog.'terms WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" ORDER BY name ASC';
     652                        $entryTest = $wpdb->get_results($entries, ARRAY_A);
     653                        foreach($entryTest as $entry) {
     654                            if($entry['parent'] != 0) { $tax_hierarchical = true; }
     655                        }
     656                        if($tax_hierarchical === true) {
     657                            $entries = 'SELECT term_id, name, slug, '.$this->queryBlog.'term_taxonomy.parent FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" AND '.$this->queryBlog.'term_taxonomy.parent = 0 ORDER BY name ASC';
     658                        }
     659                        else {
     660                            $entries = 'SELECT term_id, name, slug, '.$this->queryBlog.'term_taxonomy.parent FROM '.$this->queryBlog.'terms NATURAL JOIN '.$this->queryBlog.'term_taxonomy WHERE '.$this->queryBlog.'term_taxonomy.taxonomy = "'.$this->taxonomy.'" AND '.$this->queryBlog.'term_taxonomy.parent = 0 ORDER BY name ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    581661                        }
    582662                    }
    583663                } else if($type == 'docs') {
    584                     $entries = 'SELECT post_title, guid, ID, post_mime_type FROM '.$this->queryBlog.'posts WHERE post_type = "attachment" AND (SUBSTRING(post_mime_type, 1, 11) = "application" OR SUBSTRING(post_mime_type, 1, 4) = "text") ORDER BY post_title ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
     664                    $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "attachment" AND (SUBSTRING(post_mime_type, 1, 11) = "application" OR SUBSTRING(post_mime_type, 1, 4) = "text") ORDER BY post_title ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    585665                } else if($type == 'images') {
    586                     $entries = 'SELECT post_title, guid, ID, post_mime_type FROM '.$this->queryBlog.'posts WHERE post_type = "attachment" AND SUBSTRING(post_mime_type, 1, 5) = "image" ORDER BY post_title ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
     666                    $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "attachment" AND SUBSTRING(post_mime_type, 1, 5) = "image" ORDER BY post_title ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    587667                } else {
    588                     $entries = 'SELECT post_title, guid, ID, post_mime_type FROM '.$this->queryBlog.'posts WHERE post_type = "post" AND post_status = "publish" ORDER BY post_title ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
     668                    $entries = 'SELECT post_title, guid, ID, post_mime_type, post_parent FROM '.$this->queryBlog.'posts WHERE post_type = "post" AND post_status = "publish" ORDER BY post_title ASC LIMIT '.(($page * $pageOffset) - $pageOffset).', '.$pageOffset;
    589669                } $entryResults = $wpdb->get_results($entries, ARRAY_A);
    590670
     
    593673                        $cpt_obj = get_post_type_object($this->customPostType);
    594674                    }
    595                     if(taxonomy_exists($this->customPostType) === true) {
     675                    else {
     676                        foreach($entryResults as $entry) {
     677                            if($entry['post_parent'] != 0) { $cpt_hierarchical = true; }
     678                        }
     679                    }
     680                    if(taxonomy_exists($this->taxonomy) === true) {
    596681                        $tax_obj = get_taxonomy($this->taxonomy);
    597682                    }
    598                     if($type == 'pages' || ($type == 'cptypes' && isset($cpt_obj->hierarchical) && $cpt_obj->hierarchical == true)) {
     683                    else {
    599684                        foreach($entryResults as $entry) {
    600                             $documentList .= '<tr>'."\n";
    601                             $documentList .= '<td width="480">'.$entry['post_title'].'</td>'."\n"; 
    602                             $documentList .= '<td width="30"><a href="'.get_permalink($entry['ID']).'" title="'.$entry['post_title'].'" class="selectDocument">Select</a></td>'."\n";
    603                             $documentList .= '</tr>'."\n";
    604                             $documentList .= $this->ltyc_page_heirarchy_output($entry['ID'], $type);
    605                         }                   
    606                     }
    607                     else if($type == 'taxonomies') {
    608                         if(isset($tax_obj->hierarchical) && $tax_obj->hierarchical == true) {
     685                            if($entry['parent'] != 0) { $tax_hierarchical = true; }
     686                        }
     687                    }
     688                    if($type == 'pages' || ($type == 'cptypes' && (isset($cpt_obj->hierarchical) && $cpt_obj->hierarchical == true) || (isset($cpt_hierarchical) && $cpt_hierarchical == true))) {
     689                        if(is_array($entryResults)) {
    609690                            foreach($entryResults as $entry) {
    610691                                $documentList .= '<tr>'."\n";
    611                                 $documentList .= '<td width="480">'.$entry['name'].'</td>'."\n";   
    612                                 $documentList .= '<td width="30"><a href="'.get_term_link($entry['slug'], $this->taxonomy).'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     692                                $documentList .= '<td width="480">'.$entry['post_title'].'</td>'."\n"; 
     693                                $documentList .= '<td width="30"><a href="'.get_permalink($entry['ID']).'" title="'.$entry['post_title'].'" class="selectDocument">Select</a></td>'."\n";
    613694                                $documentList .= '</tr>'."\n";
    614                                 $documentList .= $this->ltyc_page_heirarchy_output($entry['term_id'], $type);
    615                             }
    616                         }
    617                         else {             
     695                                $documentList .= $this->ltyc_page_heirarchy_output($entry['ID'], $type);
     696                            }
     697                        }                   
     698                    }
     699                    else if($type == 'taxonomies') {
     700                        if((isset($tax_obj->hierarchical) && $tax_obj->hierarchical == true) || (isset($tax_hierarchical) && $tax_hierarchical == true)) {
     701                            if(is_array($entryResults)) {
     702                                foreach($entryResults as $entry) {
     703                                    $documentList .= '<tr>'."\n";
     704                                    $documentList .= '<td width="480">'.$entry['name'].'</td>'."\n";   
     705                                    if(taxonomy_exists($this->taxonomy) === true) {
     706                                        $documentList .= '<td width="30"><a href="'.get_term_link($entry['slug'], $this->taxonomy).'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     707                                    }
     708                                    else {
     709                                        if(function_exists('switch_to_blog') && switch_to_blog($this->currentBlog)) {
     710                                            $documentList .= '<td width="30"><a href="'.get_bloginfo('url').'/?'.$this->taxonomy.'='.$entry['slug'].'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     711                                            restore_current_blog();
     712                                        }
     713                                        else {
     714                                            $documentList .= '<td width="30"><a href="'.get_bloginfo('url').'/?'.$this->taxonomy.'='.$entry['slug'].'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     715                                        }
     716                                    }
     717                                    $documentList .= '</tr>'."\n";
     718                                    $documentList .= $this->ltyc_page_heirarchy_output($entry['term_id'], $type);
     719                                }
     720                            }
     721                        }
     722                        else { 
     723                            if(is_array($entryResults)) {           
     724                                foreach($entryResults as $entry) {
     725                                    $documentList .= '<tr>'."\n";
     726                                    $documentList .= '<td width="480">'.$entry['name'].'</td>'."\n";
     727                                    if(taxonomy_exists($this->taxonomy) === true) {
     728                                        $documentList .= '<td width="30"><a href="'.get_term_link($entry['slug'], $this->taxonomy).'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     729                                    }
     730                                    else {
     731                                        if(function_exists('switch_to_blog') && switch_to_blog($this->currentBlog)) {
     732                                            $documentList .= '<td width="30"><a href="'.get_bloginfo('url').'/?'.$this->taxonomy.'='.$entry['slug'].'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     733                                            restore_current_blog();
     734                                        }
     735                                        else {
     736                                            $documentList .= '<td width="30"><a href="'.get_bloginfo('url').'/?'.$this->taxonomy.'='.$entry['slug'].'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     737                                        }
     738                                    }
     739                                    $documentList .= '</tr>'."\n";
     740                                }
     741                            }
     742                        }
     743                    }
     744                    else {
     745                        if(is_array($entryResults)) {               
    618746                            foreach($entryResults as $entry) {
    619747                                $documentList .= '<tr>'."\n";
    620                                 $documentList .= '<td width="480">'.$entry['name'].'</td>'."\n";
    621                                 $documentList .= '<td width="30"><a href="'.get_term_link($entry['slug'], $this->taxonomy).'" title="'.$entry['name'].'" class="selectDocument">Select</a></td>'."\n";
     748                                if($entry['post_mime_type'] == '') {
     749                                    $documentList .= '<td width="480">'.$entry['post_title'].'</td>'."\n";
     750                                    $permalink = get_permalink($entry['ID']);
     751                                }
     752                                else {
     753                                    $mimePos = strrpos($entry['guid'], ".");
     754                                    $attachmentType = strtoupper(substr($entry['guid'], ($mimePos + 1)));
     755                                    $documentList .= '<td width="430">'.$entry['post_title'].'</td>'."\n";
     756                                    $documentList .= '<td width="50">('.$attachmentType.')</td>'."\n";
     757                                    $permalink = $entry['guid'];
     758                                }
     759                                $documentList .= '<td width="30"><a href="'.$permalink.'" title="'.$entry['post_title'].'" class="selectDocument">Select</a></td>'."\n";
    622760                                $documentList .= '</tr>'."\n";
    623761                            }
    624                         }
    625                     }
    626                     else {                 
    627                         foreach($entryResults as $entry) {
    628                             $documentList .= '<tr>'."\n";
    629                             if($entry['post_mime_type'] == '') {
    630                                 $documentList .= '<td width="480">'.$entry['post_title'].'</td>'."\n";
    631                                 $permalink = get_permalink($entry['ID']);
    632                             }
    633                             else {
    634                                 $mimePos = strrpos($entry['guid'], ".");
    635                                 $attachmentType = strtoupper(substr($entry['guid'], ($mimePos + 1)));
    636                                 $documentList .= '<td width="430">'.$entry['post_title'].'</td>'."\n";
    637                                 $documentList .= '<td width="50">('.$attachmentType.')</td>'."\n";
    638                                 $permalink = $entry['guid'];
    639                             }
    640                             $documentList .= '<td width="30"><a href="'.$permalink.'" title="'.$entry['post_title'].'" class="selectDocument">Select</a></td>'."\n";
    641                             $documentList .= '</tr>'."\n";
    642762                        }
    643763                    }
  • link-to-your-content/trunk/readme.txt

    r463297 r484003  
    44Tags: document, doc, pdf, xls, image, jpg, png, attachment, link, media library, post, page, custom post type, taxonomy, tinymce
    55Requires at least: 3.0
    6 Tested up to: 3.3beta2
    7 Stable tag: 1.4
     6Tested up to: 3.3
     7Stable tag: 1.5
    88
    99Gives you the ability to easily link to the various forms of content you have.
     
    3838== Changelog ==
    3939
     40= 1.5 =
     41* Updated for WordPress 3.3 with a fix for working with custom post types and custom taxonomies created with a plugin on a multi-site network.
     42
    4043= 1.4 =
    4144* Fixed an issue with linking to posts and pages in certain versions of IE.
     
    4851
    4952== Upgrade Notice ==
     53
     54= 1.5 =
     55* WordPress 3.3 and mutli-site compatibility update.
    5056
    5157= 1.4 =
     
    6167
    62681. User defined pagination value.
    63 2. The ability to search for content.
    64 3. ???
    65 4. Add to list per user feedback. (Translations are always welcome)
     692. External links (http, mailto).
     703. The ability to search for content.
     714. ???
     725. Add to list per user feedback. (Translations are always welcome)
Note: See TracChangeset for help on using the changeset viewer.