Beispiel #1
0
 function create_album($album_name = '', $author_id = 1)
 {
     global $bp_media;
     if (array_key_exists('bp_album_import_name', $bp_media->options)) {
         if ('' !== $bp_media->options['bp_album_import_name']) {
             $album_name = $bp_media->options['bp_album_import_name'];
         }
     }
     $found_album = BuddyPressMedia::get_wall_album();
     if (count($found_album) < 1) {
         $album = new BPMediaAlbum();
         $album->add_album($album_name, $author_id);
         $album_id = $album->get_id();
     } else {
         $album_id = $found_album[0]->ID;
     }
     return $album_id;
 }
 function create_album($author_id, $album_name = 'Imported Media')
 {
     global $bp_media, $wpdb;
     if (array_key_exists('bp_album_import_name', $bp_media->options)) {
         if ('' != $bp_media->options['bp_album_import_name']) {
             $album_name = $bp_media->options['bp_album_import_name'];
         }
     }
     $query = "SELECT ID from {$wpdb->posts} WHERE post_type='bp_media_album' AND post_status = 'publish' AND post_author = {$author_id} AND post_title LIKE '{$album_name}'";
     $result = $wpdb->get_results($query);
     if (count($result) < 1) {
         $album = new BPMediaAlbum();
         $album->add_album($album_name, $author_id);
         $album_id = $album->get_id();
     } else {
         $album_id = $result[0]->ID;
     }
     $wpdb->update($wpdb->base_prefix . 'bp_activity', array('secondary_item_id' => -999), array('id' => get_post_meta($album_id, 'bp_media_child_activity', true)));
     return $album_id;
 }