Skip to content

Commit

Permalink
tag v5.9 with all the updates from the latest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lwangaman authored and Lwangaman committed Jun 6, 2020
1 parent db24dbb commit 5d81ed2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
35 changes: 17 additions & 18 deletions bibleget-io.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Plugin Name: BibleGet I/O
* Version: 5.8
* Version: 5.9
* Plugin URI: https://www.bibleget.io/
* Description: Easily insert Bible quotes from a choice of Bible versions into your articles or pages with the "Bible quote" block or with the shortcode [bibleget].
* Author: John Romano D'Orazio
Expand All @@ -27,9 +27,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

//TODO: better ui for the customizer, use sliders

define("BIBLEGETPLUGINVERSION", "v5_8");
define("BIBLEGETPLUGINVERSION", "v5_9");

if (!defined('ABSPATH')) {
header('Status: 403 Forbidden');
Expand Down Expand Up @@ -465,19 +464,19 @@ function bibleGet_renderGutenbergBlock($atts)
$domDocument = new DOMDocument();
$domDocument->loadHTML('<!DOCTYPE HTML><head></head><body>' . mb_convert_encoding($output, 'HTML-ENTITIES', 'UTF-8') . '</body>');
if($domDocument){
$results = $domDocument->getElementById('results');
$errors = $domDocument->getElementById('errors');
$info = $domDocument->getElementById('BibleGetInfo');
$xPath = new DOMXPath($domDocument);
if($atts['LAYOUTPREFS_SHOWBIBLEVERSION'] === false && $results !== null ){
$results = $xPath->query('//div[contains(@class,"results")]')->item(0); //$domDocument->getElementById('results');
$errors = $xPath->query('//div[contains(@class,"errors")]')->item(0); //$domDocument->getElementById('errors');
$info = $xPath->query('//input[contains(@class,"BibleGetInfo")]')->item(0); //$domDocument->getElementById('BibleGetInfo');
if($atts['LAYOUTPREFS_SHOWBIBLEVERSION'] === false && $results !== false ){
$nonDefaultLayout = true;
$bibleVersionEls = $xPath->query('//p[contains(@class,"bibleVersion")]');
foreach($bibleVersionEls as $bibleVersionEl){
$bibleVersionEl->setAttribute("style","display:none;");
}
}

if($atts['LAYOUTPREFS_BIBLEVERSIONALIGNMENT'] !== BGET::ALIGN["LEFT"] && $results !== null ){
if($atts['LAYOUTPREFS_BIBLEVERSIONALIGNMENT'] !== BGET::ALIGN["LEFT"] && $results !== false ){
$nonDefaultLayout = true;
$bibleVersionEls = $xPath->query('//p[contains(@class,"bibleVersion")]');
foreach ($bibleVersionEls as $bibleVersionEl) {
Expand All @@ -486,7 +485,7 @@ function bibleGet_renderGutenbergBlock($atts)
}
}

if ($atts['LAYOUTPREFS_BIBLEVERSIONPOSITION'] !== BGET::POS["TOP"] && $results !== null) {
if ($atts['LAYOUTPREFS_BIBLEVERSIONPOSITION'] !== BGET::POS["TOP"] && $results !== false) {
$nonDefaultLayout = true;
$bibleVersionEls = $xPath->query('//p[contains(@class,"bibleVersion")]');
$bibleVersionCnt = $bibleVersionEls->count();
Expand All @@ -511,7 +510,7 @@ function bibleGet_renderGutenbergBlock($atts)
}
}

if($atts['LAYOUTPREFS_BIBLEVERSIONWRAP'] !== BGET::WRAP["NONE"] && $results !== null){
if($atts['LAYOUTPREFS_BIBLEVERSIONWRAP'] !== BGET::WRAP["NONE"] && $results !== false){
$nonDefaultLayout = true;
$bibleVersionEls = $xPath->query('//p[contains(@class,"bibleVersion")]');
foreach($bibleVersionEls as $bibleVersionEl){
Expand All @@ -528,7 +527,7 @@ function bibleGet_renderGutenbergBlock($atts)
}
}

if ($atts['LAYOUTPREFS_BOOKCHAPTERALIGNMENT'] !== BGET::ALIGN["LEFT"] && $results !== null) {
if ($atts['LAYOUTPREFS_BOOKCHAPTERALIGNMENT'] !== BGET::ALIGN["LEFT"] && $results !== false) {
$nonDefaultLayout = true;
$bookChapterEls = $xPath->query('//p[contains(@class,"bookChapter")]');
foreach ($bookChapterEls as $bookChapterEl) {
Expand All @@ -538,15 +537,15 @@ function bibleGet_renderGutenbergBlock($atts)
}


if(($atts['LAYOUTPREFS_BOOKCHAPTERFORMAT'] !== BGET::FORMAT["BIBLELANG"]) && $results !== null){
if(($atts['LAYOUTPREFS_BOOKCHAPTERFORMAT'] !== BGET::FORMAT["BIBLELANG"]) && $results !== false){
$nonDefaultLayout = true;
$bookChapterEls = $xPath->query('//p[contains(@class,"bookChapter")]');
if($atts['LAYOUTPREFS_BOOKCHAPTERFORMAT'] === BGET::FORMAT["USERLANG"] || $atts['LAYOUTPREFS_BOOKCHAPTERFORMAT'] === BGET::FORMAT["USERLANGABBREV"] ){
$locale = substr(get_locale(), 0, 2);
$languageName = Locale::getDisplayLanguage($locale, 'en');
foreach ($bookChapterEls as $bookChapterEl) {
$bookNum = (int) $xPath->query('following-sibling::input[@class="bookNum"]', $bookChapterEl)->item(0)->getAttribute("value");
$usrprop = "bibleget_biblebooks" . $bookNum;
$bookNum = (int) $xPath->query('following-sibling::input[@class="univBookNum"]', $bookChapterEl)->item(0)->getAttribute("value");
$usrprop = "bibleget_biblebooks" . ($bookNum-1);
$jsbook = json_decode(get_option($usrprop), true);
//get the index of the current language from the available languages
$biblebookslangs = get_option("bibleget_languages");
Expand Down Expand Up @@ -589,7 +588,7 @@ function bibleGet_renderGutenbergBlock($atts)
=> if pos is bottominline it will change the p to a span and then we won't know what to look for
=> if we have already wrapped then the fullreference will be appended to the parentheses or the brackets!
*/
if ($atts['LAYOUTPREFS_BOOKCHAPTERFULLQUERY'] === true && $results !== null) {
if ($atts['LAYOUTPREFS_BOOKCHAPTERFULLQUERY'] === true && $results !== false) {
$nonDefaultLayout = true;
$bookChapterEls = $xPath->query('//p[contains(@class,"bookChapter")]');
foreach ($bookChapterEls as $bookChapterEl) {
Expand All @@ -607,7 +606,7 @@ function bibleGet_renderGutenbergBlock($atts)
}

/* Make sure to deal with wrap before you deal with pos, because if pos is bottominline it will change the p to a span and then we won't know what to look for */
if ($atts['LAYOUTPREFS_BOOKCHAPTERWRAP'] !== BGET::WRAP["NONE"] && $results !== null) {
if ($atts['LAYOUTPREFS_BOOKCHAPTERWRAP'] !== BGET::WRAP["NONE"] && $results !== false) {
$nonDefaultLayout = true;
$bookChapterEls = $xPath->query('//p[contains(@class,"bookChapter")]');
foreach ($bookChapterEls as $bookChapterEl) {
Expand All @@ -624,7 +623,7 @@ function bibleGet_renderGutenbergBlock($atts)
}
}

if ($atts['LAYOUTPREFS_BOOKCHAPTERPOSITION'] !== BGET::POS["TOP"] && $results !== null) {
if ($atts['LAYOUTPREFS_BOOKCHAPTERPOSITION'] !== BGET::POS["TOP"] && $results !== false) {
$nonDefaultLayout = true;
$bookChapterEls = $xPath->query('//p[contains(@class,"bookChapter")]');
switch($atts['LAYOUTPREFS_BOOKCHAPTERPOSITION']){
Expand All @@ -647,7 +646,7 @@ function bibleGet_renderGutenbergBlock($atts)

}

if($atts['LAYOUTPREFS_SHOWVERSENUMBERS'] === BGET::VISIBILITY["HIDE"] && $results !== null ){
if($atts['LAYOUTPREFS_SHOWVERSENUMBERS'] === BGET::VISIBILITY["HIDE"] && $results !== false ){
$nonDefaultLayout = true;
$verseNumberEls = $xPath->query('//span[contains(@class,"verseNum")]');
foreach($verseNumberEls as $verseNumberEl){
Expand Down
19 changes: 18 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: bible,shortcode,quote,citation,verses,bibbia,citazione,versetti,biblia,cit
Requires at least: 5.0
Tested up to: 5.4.1
Requires PHP: 5.6
Stable tag: 5.8
Stable tag: 5.9
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -91,6 +91,14 @@ However Bible quotes are cached by the BibleGet plugin for a seven day period, w
If you do not want to wait seven days or until the cache expires, there is a new option in the BibleGet Settings page since version 5.7 which allows to flush the cache.
A word of caution however: the more recent updates to the BibleGet service endpoint have started imposing hard limits on the number of requests that can be issued from any given domain, IP address or referer. No more than 30 requests for one same Bible quote can be issued in a two day period, and no more than 100 requests for different Bible quotes can be issued in a two day period. If you have many Bible quotes on your website and you risk hitting the limit, it may be best not to flush the cache all at once but rather wait out the seven days until the cache expires.

= Sometimes the Bible quote block is giving an error 'Error loading block: The response is not a valid JSON response.' =
If you sometimes see this error, one possible situation is that your server configuration needs to allow for a larger buffer for proxy requests. You can check that that is the case if you open your browser's Inspector Tools (for example CTRL-SHIFT-I in Google Chrome) and you see a failed GET request by the api-fetch.min.js script to a wp-json endpoint something like this: **/wp-json/wp/v2/block-renderer/bibleget/bible-quote?...**
You can further inspect the *Network* tab of the browser's Inspector Tools (this may require reloading the page and retrying the request). If you see a similar request in the Network tab with a response of '502 Bad Gateway', this could be an indication that you may need a larger buffer for your server.
If for example you have an nginx server, you may need to edit your **/etc/nginx/nginx.conf** and set 'proxy_buffer_size' to a larger value (see for example [this thread](https://talk.plesk.com/threads/fpm-buffer-settings-and-proxy-buffer.344813/ "fpm buffer settings and proxy buffer")).

= I'm not able to use some options in the Gutenberg block such as positioning of the Bible version =
There was recently an update to the BibleGet service endpoint which slightly changed the structure of the html that comprises the Bible quotes. It is necessary to update the plugin to v5.9 in order to be compatible with these changes.

== Screenshots ==

1. Inserting a Bible quote block into an article or page
Expand All @@ -103,6 +111,12 @@ A word of caution however: the more recent updates to the BibleGet service endpo

== Changelog ==

= 5.9 =
* Gutenberg block now has all possible options in the sidebar, which are in synchronized to Customizer options
* Customizer has better UI, even though it doesn't have all the options from the Customizer
* An update to the html output from the BibleGet server requests required an update to the plugin handling logic of the html structure
* Better handling both from the BibleGet endpoint and from the plugin for rendering of Bible book names in WP interface language when using non catholic versions with different book numbering

= 5.8 =
* once a traditional shortcode is transformed into a block shortcode, allow transforming the block shortcode into a 'Bible quote' block

Expand Down Expand Up @@ -277,6 +291,9 @@ A word of caution however: the more recent updates to the BibleGet service endpo

== Upgrade Notice ==

= 5.9 =
Must update to maintain compatibility with the BibleGet endpoint

= 5.8 =
Versions prior to 5.1 must be updated. v5.4 adds a Gutenberg block

Expand Down

0 comments on commit 5d81ed2

Please sign in to comment.