Plugin Directory

Changeset 835197


Ignore:
Timestamp:
01/08/2014 11:56:46 PM (12 years ago)
Author:
sydcode
Message:

Improved post checking

Location:
pubmed-posts/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pubmed-posts/trunk/pubmed-posts.php

    r818923 r835197  
    44Plugin URI: http://wordpress.org/plugins/pubmed-posts/
    55Description: This plugin adds a dashboard widget that creates posts from <a href='http://www.ncbi.nlm.nih.gov/pubmed/'>PubMed</a> articles, plus a search widget that finds posts with specific article data.
    6 Version: 1.1.0
     6Version: 1.1.1
    77Author: sydcode
    88Author URI: http://profiles.wordpress.org/sydcode
     
    4343    protected static $instance = null;
    4444    const PLUGIN_SLUG = 'pubmed-posts';
    45     const PLUGIN_VERSION = '1.1.0';
     45    const PLUGIN_VERSION = '1.1.1';
    4646    const DEFAULT_TEMPLATE = <<<HTML
    4747<p>[article_authors]</p>
     
    577577     */
    578578    public function get_article_post($pmid) {
     579        global $wpdb;
    579580        $pmid = trim($pmid);
    580         $args = array(
    581             'posts_per_page' => -1
    582         );
    583         $posts = get_posts($args);
    584         foreach($posts as $post) {
    585             $data = get_post_meta($post->ID, 'PMID', true);
    586             if (strtolower($data) == strtolower($pmid)) {
    587                 return $post->ID;
    588             }
    589         }
    590         return 0;
     581        $sql = $wpdb->prepare("
     582            SELECT post_id
     583            FROM $wpdb->postmeta
     584            WHERE meta_key = 'PMID'
     585            AND meta_value = '%s'
     586        ", $pmid);
     587        $results = $wpdb->get_results($sql);
     588        if (empty($results)) {
     589            return 0;
     590        } else {
     591            return $results[0]->post_id;
     592        }
    591593    }
    592594   
  • pubmed-posts/trunk/readme.txt

    r818923 r835197  
    33Donate link:
    44Tags: posts, pubmed, research, academic, science, education, references, medical, abstracts, bibliography, pmid
    5 Requires at least: 3.3
    6 Tested up to: 3.7.1
    7 Stable tag: 1.1.0
     5Requires at least: 3.3.0
     6Tested up to: 3.8.0
     7Stable tag: 1.1.1
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    4545== Changelog ==
    4646
     47= 1.1.1 =
     48* Improved post checking
     49
    4750= 1.1.0 =
    4851* Added search widget
Note: See TracChangeset for help on using the changeset viewer.