run(); } run_add_custom_fields_to_media(); /** * Keeping the below functions for backwards compatibility * with the old version of the plugin. */ /** * Return our new unique field * * @param int $attachment_id the attachment id. * @param sting $unique_field_id the unique field name. * * @since 1.0.0 * @return array */ function thisismyurl_get_custom_media_field( $attachment_id, $unique_field_id ) { $attachment_id = ( empty( $attachment_id ) ) ? get_post_thumbnail_id() : (int) $attachment_id; if ( $attachment_id ) { return get_post_meta( $attachment_id, '_' . $unique_field_id, true ); } } /** * Returns a boolean value based on if the unqiue field exists * * @param int $attachment_id the attachment id. * @param sting $unique_field_id the unique field name. * * @since 1.0.0 * @return array */ function thisismyurl_has_custom_media_field( $attachment_id, $unique_field_id ) { $attachment_id = ( empty( $attachment_id ) ) ? get_post_thumbnail_id() : (int) $attachment_id; if ( $attachment_id ) { return get_post_meta( $attachment_id, '_' . $unique_field_id, true ); } if ( $attachment_id ) { return true; } else { return false; } } /** * Echo our new unique field * * @param int $attachment_id the attachment id. * @param sting $unique_field_id the unique field name. * * @since 1.0.0 */ function thisismyurl_custom_media_field( $attachment_id, $unique_field_id ) { echo esc_html( thisismyurl_get_custom_media_field( $attachment_id, $unique_field_id ) ); }