Make WordPress Core


Ignore:
Timestamp:
12/22/2003 11:00:45 PM (22 years ago)
Author:
emc3
Message:

Fixed %post_id% token handling. Fixed pingback link detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r638 r640  
    494494        '%monthnum%',
    495495        '%day%',
    496         '%postname%'
     496        '%postname%',
     497        '%post_id%'
    497498    );
    498499    $rewritereplace = array(
     
    500501        '([0-9]{1,2})?',
    501502        '([0-9]{1,2})?',
    502         '([0-9a-z-]+)?'
     503        '([0-9a-z-]+)?',
     504        '([0-9]+)?'
    503505    );
    504506
     
    517519        $value = $values[$i+1];
    518520
    519         // Create a variable named $year, $monthnum, $day, or $postname:
     521        // Create a variable named $year, $monthnum, $day, $postname, or $post_id:
    520522        $$name = $value;
    521523    }
    522524   
    523     // Build a WHERE clause, making the values safe along the way:
     525    // If using %post_id%, we're done:
     526    if (intval($post_id)) return intval($post_id);
     527
     528    // Otherwise, build a WHERE clause, making the values safe along the way:
    524529    if ($year) $where .= " AND YEAR(post_date) = " . intval($year);
    525530    if ($monthnum) $where .= " AND MONTH(post_date) = " . intval($monthnum);
     
    528533
    529534    // Run the query to get the post ID:
    530     return intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
     535    $id = intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
     536
     537    return $id;
    531538}
    532539
Note: See TracChangeset for help on using the changeset viewer.