| Server IP : 161.248.188.39 / Your IP : 216.73.216.53 Web Server : Apache System : Linux 161-248-188-39.cprapid.com 4.18.0-513.9.1.el8_9.x86_64 #1 SMP Sat Dec 2 05:23:44 EST 2023 x86_64 User : mysoftbd ( 1002) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/mysoftbd/gopinathpurhs.edu.bd/wp-content/plugins/pdf-embedder/src/Helpers/ |
Upload File : |
<?php
namespace PDFEmbedder\Helpers;
/**
* Class PdfFile for file-specific helper methods.
*
* @since 4.8.0
*/
class PdfFile {
/**
* Get the PDF file ID by its URL.
*
* @since 4.8.0
*
* @param string $url The URL of the attachment.
*/
public static function get_id_by_url( string $url ): int {
global $wpdb;
// Get the attachment ID by its URL.
$pdf_id = wp_cache_get( 'pdfemb_url_to_id_' . md5( $url ) );
if ( empty( $pdf_id ) ) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$pdf_id = $wpdb->get_var(
$wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s;", $url )
);
wp_cache_set( 'pdfemb_url_to_id_' . md5( $url ), $pdf_id );
}
return (int) $pdf_id;
}
}