public static function getMostRecentCommentsForProjects($bimsieUrl, $projects) { global $wpdb; if (!isset($projects) || !is_array($projects)) { return array(); } $options = BIMBCFManagement::getOptions(); // get issues for bimsie url and poid $bimsieUrl = BIMBCFManagement::removeProtocol($bimsieUrl); $issues = array(); foreach ($projects as $project) { $issues = array_merge($issues, get_posts(array('post_type' => $options['bcf_issue_post_type'], 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => 'import_status', 'value' => 'complete'), array('key' => '_bimsie_uri', 'value' => $bimsieUrl), array('key' => 'poid', 'value' => $project->oid))))); } $includeList = array(); foreach ($issues as $issue) { $includeList[] = $issue->ID; } if (count($includeList) > 0) { $commentPostIds = $wpdb->get_results("SELECT comment_post_ID\n FROM {$wpdb->comments}\n WHERE comment_post_ID IN (" . implode(', ', $includeList) . ")\n ORDER BY comment_date DESC\n LIMIT 10"); } else { $commentPostIds = array(); } $markups = array(); $comments = array(); foreach ($commentPostIds as $commentPostId) { if (!isset($markups[$commentPostId->comment_post_ID])) { $markups[$commentPostId->comment_post_ID] = get_post_meta($commentPostId->comment_post_ID, 'markup', true); } $comments[] = array_pop($markups[$commentPostId->comment_post_ID]['Comment']); } return $comments; }
fclose($file); } else { ?> <p> <?php _e('Could not write extensions.xsd, make sure the file is writable.', 'bim-bcf-management'); ?> <br /> <?php print plugin_dir_path(__FILE__) . 'xsd/extensions.xsd'; ?> </p> <?php } } else { $bimBCFManagementOptions = BIMBCFManagement::getOptions(); } $postTypes = get_post_types(array(), 'objects'); $pages = get_posts(array('post_type' => 'page', 'posts_per_page' => -1)); ?> <div class="wrap"> <div class="icon32" id="icon-options-general"></div> <h2>BIM BCF Management Options</h2> <form method="post" enctype="multipart/form-data"> <table class="form-table"> <tr valign="top"> <td><label for="bcf-issue-post-type">BCF Issue Post Type</label></td> <td> <?php if (is_array($postTypes)) { ?>