function bfox_plan_reading_shortcode($atts) { // [bible-reading plan="cbr" intersects="old"] extract(shortcode_atts(array('post_id' => 0, 'reading' => 'latest', 'intersects' => '', 'tool' => ''), $atts)); if (empty($post_id)) { return; } if ($reading == 'latest') { $reading = bfox_plan_latest_reading($post_id); } $reading_id = intval($reading); if ($reading_id >= bfox_plan_reading_count($post_id)) { return; } $ref_str = bfox_plan_reading_ref_str($reading_id, $post_id); if (!empty($intersects)) { $ref = new BfoxRef($ref_str); $sub = new BibleGroupPassage('bible'); $sub->sub_ref(new BibleGroupPassage($intersects)); $ref->sub_ref($sub); $ref_str = $ref->get_string(); } $link = bfox_ref_link($ref_str); $content = $link; if (!empty($tool)) { $passage = bfox_tool_shortcode(array('tool' => $tool, 'ref' => $ref_str)); $content = "{$link} {$passage}"; } return $content; }
/** * Refresh the index data for a given translation * * @param BfoxTrans $trans * @param string $group */ private static function refresh_translation_index(BfoxTrans $trans, $group = 'bible') { global $wpdb; // Delete all the old index data for this translation $wpdb->query($wpdb->prepare("DELETE FROM " . self::index_table . " WHERE trans_id = %d", $trans->id)); // Add the new index data, one book at a time $books = range(BibleGroupPassage::get_first_book_of_group($group), BibleGroupPassage::get_last_book_of_group($group)); foreach ($books as $book) { // Get all the verses to index for this book (we don't index chapter 0 or verse 0) $verses = $wpdb->get_results($wpdb->prepare("SELECT unique_id, book_id, verse FROM {$trans->table} WHERE book_id = %d AND chapter_id != 0 AND verse_id != 0", $book)); // If we have verses for this book, insert their index text into the index table if (!empty($verses)) { $values = array(); foreach ($verses as $verse) { $values[] = $wpdb->prepare('(%d, %d, %d, %s)', $verse->unique_id, $verse->book_id, $trans->id, implode(' ', self::get_index_words($verse->verse))); } $wpdb->query("INSERT INTO " . self::index_table . " (unique_id, book_id, trans_id, index_text) VALUES " . implode(', ', $values)); } } }