key written by ACS Portfolio Pro 3.x. * * @return array */ public static function legacy_map() { return array( self::CLIENT_NAME => '_acs_client_name', self::PROJECT_URL => '_acs_project_url', self::START_DATE => '_acs_start_date', self::END_DATE => '_acs_end_date', self::TECHNOLOGIES => '_acs_technologies', self::FILE => '_acs_pf_download_file', self::DOWNLOADS => '_acs_pf_download_count', self::LIKES => '_acs_pf_like_count', ); } /** * The 3.x key for a current key, or an empty string. * * @param string $key Current meta key. * @return string */ public static function legacy_key( $key ) { $map = self::legacy_map(); return isset( $map[ $key ] ) ? $map[ $key ] : ''; } /** * Read a meta value, falling back to the 3.x key name. * * @param int $post_id Post ID. * @param string $key Current meta key. * @return string */ public static function get( $post_id, $key ) { $post_id = absint( $post_id ); if ( ! $post_id ) { return ''; } $value = get_post_meta( $post_id, $key, true ); if ( '' !== $value && null !== $value && false !== $value ) { return $value; } $legacy = self::legacy_key( $key ); if ( '' === $legacy ) { return ''; } $value = get_post_meta( $post_id, $legacy, true ); return ( false === $value || null === $value ) ? '' : $value; } /** * Write a meta value under the current key name. * * @param int $post_id Post ID. * @param string $key Current meta key. * @param mixed $value Value to store. * @return void */ public static function set( $post_id, $key, $value ) { $post_id = absint( $post_id ); if ( ! $post_id ) { return; } update_post_meta( $post_id, $key, $value ); } /** * Delete a meta value under the current key name. * * @param int $post_id Post ID. * @param string $key Current meta key. * @return void */ public static function delete( $post_id, $key ) { $post_id = absint( $post_id ); if ( ! $post_id ) { return; } delete_post_meta( $post_id, $key ); } }