Changeset 1753 for trunk/wp-includes/functions.php
- Timestamp:
- 10/06/2004 05:11:11 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r1752 r1753 448 448 } 449 449 450 function get_post_meta($post_id, $key ) {450 function get_post_meta($post_id, $key, $single = false) { 451 451 global $wpdb, $post_meta_cache; 452 452 453 453 if (isset($post_meta_cache[$post_id][$key])) { 454 return $post_meta_cache[$post_id][$key]; 454 if ($single) { 455 return $post_meta_cache[$post_id][$key][0]; 456 } else { 457 return $post_meta_cache[$post_id][$key]; 458 } 455 459 } 456 460 … … 464 468 } 465 469 466 return $values; 470 if ($single) { 471 if (count($values)) { 472 return $values[0]; 473 } else { 474 return ''; 475 } 476 } else { 477 return $values; 478 } 467 479 } 468 480 469 481 function update_post_meta($post_id, $key, $value, $prev_value = '') { 470 482 global $wpdb, $post_meta_cache; 483 484 if(! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key 485 = '$key' AND post_id = '$post_id'") ) { 486 return false; 487 } 471 488 472 489 if (empty($prev_value)) { … … 1821 1838 } 1822 1839 1840 function get_page_template() { 1841 global $wp_query; 1842 1843 $id = $wp_query->post->ID; 1844 $template_dir = get_template_directory(); 1845 $default = "$template_dir/page.php"; 1846 1847 $template = get_post_meta($id, '_wp_page_template', true); 1848 1849 if (empty($template) || ($template == 'default')) { 1850 return $default; 1851 } 1852 1853 if (file_exists("$template_dir/$template")) { 1854 return "$template_dir/$template"; 1855 } 1856 1857 return $default; 1858 } 1859 1823 1860 // Borrowed from the PHP Manual user notes. Convert entities, while 1824 1861 // preserving already-encoded entities:
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)