Changeset 46174 for trunk/src/wp-admin/includes/file.php
- Timestamp:
- 09/19/2019 01:25:14 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r45932 r46174 979 979 } 980 980 981 /** 982 * Temporarily stores the client upload reference in a transient. 983 * 984 * @since 5.3.0 985 * @access private 986 * 987 * @param string $upload_ref The upload reference sent by the client. 988 * @param int $attachment_id Attachment post ID. 989 * @return bool Whether the transient was set. 990 */ 991 function _wp_set_upload_ref( $upload_ref, $attachment_id ) { 992 $upload_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $upload_ref ); 993 994 if ( ! empty( $upload_ref ) ) { 995 return set_transient( '_wp_temp_image_ref:' . $upload_ref, $attachment_id, HOUR_IN_SECONDS ); 996 } 997 998 return false; 999 } 1000 1001 /** 1002 * Get attachment post ID from an upload reference. 1003 * 1004 * @since 5.3.0 1005 * @access private 1006 * 1007 * @param string $upload_ref The upload reference sent by the client. 1008 * @return int The attachemtn post ID. Zero if the upload reference has expired or doesn't exist. 1009 */ 1010 function _wp_get_upload_ref_attachment_id( $upload_ref ) { 1011 $upload_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $upload_ref ); 1012 1013 if ( ! empty( $upload_ref ) ) { 1014 return (int) get_transient( '_wp_temp_image_ref:' . $upload_ref ); 1015 } 1016 1017 return 0; 1018 } 1019 1020 /** 1021 * Remove the transient that stores a temporary upload reference. 1022 * 1023 * @since 5.3.0 1024 * @access private 1025 * 1026 * @param string $upload_ref The upload reference sent by the client. 1027 * @return bool Whether the transient was removed. 1028 */ 1029 function _wp_clear_upload_ref( $upload_ref ) { 1030 $upload_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $upload_ref ); 1031 1032 if ( ! empty( $upload_ref ) ) { 1033 return delete_transient( '_wp_temp_image_ref:' . $upload_ref ); 1034 } 1035 1036 return false; 1037 } 981 1038 982 1039 /**
Note: See TracChangeset
for help on using the changeset viewer.