Beispiel #1
0
 function fix_parent_id()
 {
     $site_global = rtmedia_get_site_option('rtmedia-global-albums');
     if ($site_global && is_array($site_global) && isset($site_global[0])) {
         $model = new RTMediaModel();
         $album_row = $model->get_by_id($site_global[0]);
         if (isset($album_row['result']) && count($album_row['result']) > 0) {
             global $wpdb;
             $row = $album_row['result'][0];
             if (isset($row['media_id'])) {
                 // @codingStandardsIgnoreStart
                 $sql = $wpdb->prepare("update {$wpdb->posts} p\n                                left join\n                            {$model->table_name} r ON ( p.ID = r.media_id and blog_id = %d )\n                        set\n                            post_parent = %d\n                        where\n                            p.guid like %s\n                                and (p.post_parent = 0 or p.post_parent is NULL)\n                                and not r.id is NULL\n                                and r.media_type <> 'album'", get_current_blog_id(), $row['media_id'], '%/rtMedia/%');
                 $wpdb->query($sql);
                 // @codingStandardsIgnoreEnd
             }
         }
     }
 }
Beispiel #2
0
 function fix_parent_id()
 {
     $site_global = rtmedia_get_site_option('rtmedia-global-albums');
     if ($site_global && is_array($site_global) && isset($site_global[0])) {
         $model = new RTMediaModel();
         $album_row = $model->get_by_id($site_global[0]);
         if (isset($album_row["result"]) && count($album_row["result"]) > 0) {
             global $wpdb;
             $row = $album_row["result"][0];
             if (isset($row["media_id"])) {
                 $sql = "update {$wpdb->posts} p\n                                left join\n                            {$model->table_name} r ON ( p.ID = r.media_id and blog_id = '" . get_current_blog_id() . "' )\n                        set\n                            post_parent = {$row["media_id"]}\n                        where\n                            p.guid like '%/rtMedia/%'\n                                and (p.post_parent = 0 or p.post_parent is NULL)\n                                and not r.id is NULL\n                                and r.media_type <> 'album'";
                 $wpdb->query($sql);
             }
         }
     }
 }