0

I'm trying to do some optimization on a third party wordpress, and found that some images that are from a cdn are actually taking some time to load, so I would like to modify the post/page/etc where it is being used to point to the same server instead, however I don't know how to pinpoint in which type of element this image is being used, how can I go about it? if it worth something, the page seems to be using a theme called DIVI

Thank you.

1
  • Have you tried doing a standard search? Note that because it's using Divi, standard practices may not apply, you'll probably need Divi specific help from Divi support or Divi communities – Tom J Nowell Jan 21 '20 at 0:17
0
 function searchstring_wpdb(){
    global $wpdb;
    $mytables=$wpdb->get_results("SHOW TABLES");    
    $ss =  'cdn.cloudflare.com'; //string to search
    $used_is = '';
    foreach ($mytables as $mytable)
    {
        foreach ($mytable as $table) 
        {
            $existing_columns = $wpdb->get_col("DESC {$table}", 0);
            foreach ($existing_columns as $existing_column) 
            {
                $last_link =$wpdb->get_results($wpdb->prepare("SELECT * FROM ".$table." WHERE ".$existing_column." LIKE %s", '%'.$ss.'%'));
                if ($last_link){
                    foreach ($last_link as $row) {
                        if (strstr($table,'postmeta')){ 
                            $used_is .= ', Used in post meta:  ' . $row->post_id;
                        } else if (strstr($table,'posts')) {        
                            $used_is .= ',  Used in post types:  ' . $row->ID;
                        } else {
                            $used_is .= ', In Plugin(Table Name): ' . $table . ' And Row ID: '.$row->post_id.$row->ID.$row->id.'<br>';
                            $check_used = $used_is;
                        }
                    }   
                }
            }       
        }
    }
    echo $used_is; // return all post id's where the string is used
}
add_shortcode('show_results', 'searchstring_wpdb');

The above mentioned code will find the string in all wordpress tables, then get the posts id where the string is used. Hope this can help you. Paste the code in theme functions.php file use shortcode on a page to get all posts id's or table row id's having the string cd.clouflare.com

1
  • this looks like what I need, but how do I use it? I uploaded it as a php, but doesn't seem to work that way, am I missing something? – Baldie47 Jan 20 '20 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.