| Server IP : 212.183.175.188 / Your IP : 216.73.217.18 Web Server : Apache System : Linux duemilacom6.interac.it 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64 User : cvevolpi ( 10022) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/cvevolpi.it/httpdocs/wp-content/themes/sentinel/install/ |
Upload File : |
<?php
class ffGetByTitle{
static $terms = array();
static $images = array();
static $posts = array();
static $post_types = array();
static function initTerms(){
global $wpdb;
$r = $wpdb->get_results( "SELECT `name`, `term_id` FROM ".$wpdb->terms." ORDER BY `term_id` DESC" , ARRAY_A);
foreach ($r as $key => $row) {
self::$terms[ $row['name'] ] = (int) $row['term_id'];
}
}
static function initImages(){
global $wpdb;
$r = $wpdb->get_results( "SELECT `post_title`, `ID` FROM ".$wpdb->posts." WHERE `post_type`='attachment'" , ARRAY_A);
foreach ($r as $key => $row) {
self::$images[ $row['post_title'] ] = (int) $row['ID'];
}
}
static function initPosts(){
global $wpdb;
$r = $wpdb->get_results( " SELECT *
FROM ".$wpdb->posts."
WHERE 1
AND ( `post_type` = 'post' OR `post_type` = 'page' OR `post_type` = 'portfolio' OR `post_type` = 'wpcf7_contact_form' )
AND `post_status` = 'publish' " , ARRAY_A);
foreach ($r as $key => $row) {
self::$posts[ $row['post_title'] ] = (int) $row['ID'];
self::$post_types[ $row['post_title'] ] = $row['post_type'];
}
}
static function term($title){
if( empty( self::$terms ) ) self::initTerms();
if( empty( self::$terms[ $title ] ) ) return 0;
return self::$terms[ $title ];
}
static function image($title){
if( empty( self::$images ) ) self::initImages();
if( empty( self::$images[ $title ] ) ) return 0;
return self::$images[ $title ];
}
static function post($title){
if( empty( self::$posts ) ) self::initPosts();
if( empty( self::$posts[ $title ] ) ) return 0;
return self::$posts[ $title ];
}
static function post_type($title){
if( empty( self::$post_types ) ) self::initPosts();
if( empty( self::$post_types[ $title ] ) ) return 'post';
return self::$post_types[ $title ];
}
}