Plugin Directory

Changeset 2626359


Ignore:
Timestamp:
11/08/2021 10:29:27 PM (4 years ago)
Author:
elukacs
Message:

Tested on Wordpress 5.8

Location:
igefilter/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • igefilter/trunk/igefilter.php

    r2006579 r2626359  
    22/*
    33 * Plugin Name: Igefilter
    4  * Version: 1.0
     4 * Version: 1.1
    55 * Plugin URI: http://dev.wp-plugins.org/wiki/igefilter
    66 * Description: Changes Bible references to hyperlinks.
     
    3535
    3636define('IGEFILTER_DEFAULT_BIBLE_TRANSLATION', '4');
    37 
    38 // you can pick any translation supported by the Bible Gateway, as well as the NRSV, the NET, and the ESV
    39 // should we add Blue Letter Bible and http://www.zhubert.com/greek as original language options somehow? ....
    40 // http://www.blueletterbible.org/cgi-bin/tools/printer-friendly.pl?book=Gen&chapter=1&version=heb
    41 // http://www.blueletterbible.org/cgi-bin/tools/printer-friendly.pl?book=Mat&chapter=1&version=grk
    42 // the interface on zhubert.com is weird - the NT books are numbered instead of named
    43 // we should also take a look at the New American Bible - http://www.nccbuscc.com/nab/bible/index.htm
    4437
    4538/**
     
    266259    $verse_regex="\d{1,3}(?:[:,]\d{1,3})?(?:[-,]?\d+)*[-:\d]*"; // felismeri a kovetkezoket: Mt. 5:2, Jn 5,6, 1Kor. 1:12-2:11
    267260
    268     $translation_regex = 'NIV|NASB|AMP|NLT|KJV|ESV|CEV|NET|NKJV|KJ21|ASV|WE|YLT|DARBY|WYC|NIV-UK|TNIV|MSG|NIRV';
    269     // non Bible Gateway translations are all together at the end to make it easier to maintain the list
    270     //$translation_regex = implode('|',array_keys($igefilter_translations)); // makes it look like 'NIV|KJV|ESV' etc
    271 
    272     // note that this will be executed as PHP code after substitution thanks to the /e at the end!
    273 //    $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/e';
    274     $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/e';
    275 
    276     $replacement_regex = "igefilter_scripturizeLinkReference('\\0','\\1','\\2','\\3','\\4','$bible')";
    277 
    278     $text = preg_replace( $passage_regex, $replacement_regex, $text );
     261//    $translation_regex = 'NIV|NASB|AMP|NLT|KJV|ESV|CEV|NET|NKJV|KJ21|ASV|WE|YLT|DARBY|WYC|NIV-UK|TNIV|MSG|NIRV';
     262//    $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/';
     263    $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:NIV|KJV)|\s?\((?:NIV|KJV)\)))?/';
     264
     265//    $replacement_regex = "igefilter_scripturizeLinkReference('\\0','\\1','\\2','\\3','\\4','$bible')";
     266
     267//    $text = preg_replace_callback( $passage_regex, $replacement_regex, $text );
     268  $wrapper = new IgeFilterCallbackWrapper();
     269  $wrapper->bible = $bible;
     270  $text = preg_replace_callback($passage_regex,
     271    array(
     272      &$wrapper,
     273      "igefilterCallback",
     274    ),
     275     $text);
    279276
    280277    return $text; // TODO: make this an array, to return text, plus OT/NT (for original languages)
    281278}
    282279
    283 function igefilter_scripturizeLinkReference( $reference='', $volume='', $book='', $verse='', $translation='', $user_translation='' ) {
    284     global $igefilter_options;
    285 //echo $reference .'|'. $book .'|' . $volume .'|'. $verse .'|'. $translation .'|';
     280
     281/**
     282 * A simple class to wrap our callback function.
     283 *
     284 * We need this because we need to pass the Bible parameter in.
     285 * The preg_replace callback is only passed the matched groups.
     286 */
     287class IgeFilterCallbackWrapper {
     288
     289  /**
     290   * A function just to work on a Bible reference, and turn into a link.
     291   *
     292   * It is passed the details of the incoming Bible reference to, and also the
     293   * original reference, so that the reference can be surrounded by an anchor
     294   * linking to the relevant site which has the text for that verse. It then
     295   * passes the transformed reference back out so that it can be replaced in the
     296   * wider body of text from which it came.
     297   * Two arguments for book; the first will be populated if no volume is given.
     298   * The second will be populated if there's a volume number.
     299   */
     300//function scripturizeLinkReference($reference='',$volume='',$book='',$verse='',$translation='',$user_translation='') {
     301
     302  public function igefilterCallback($matches) {
     303    $reference = $matches[0];
     304    $book1 = $matches[2];
     305    $volume = $matches[1];
     306//    $book2 = $matches[3];
     307    $verse = $matches[3];
     308    $translation = isset($matches[5]) ? $matches[5] : NULL;
     309    $user_translation = $this->bible;
     310
     311   global $igefilter_options;
     312   //echo $reference .'|'. $book .'|' . $volume .'|'. $verse .'|'. $translation .'|';
    286313
    287314   $link_target = ( $igefilter_options['link_target_blank'] ? ' target="_blank"' : '' );
    288315
     316    $book = ($book1 == '') ? $book2 : $book1;
    289317    if ($volume) {
    290318       $volume = str_replace('IV','4',$volume);
     
    305333        }
    306334   }
    307 
    308335   //if necessary, just choose part of the verse reference to pass to the web interfaces
    309336   //they wouldn't know what to do with John 5:1-2, 5, 10-13 so I just give them John 5:1-2
     
    337364    // $link = sprintf('<a href="%s/%s/%s/%s#v%s" class="reform" title="%s">%s</a>',$link,htmlentities(urlencode($book)),$chapter,$verses,$verses,$title,trim($reference));
    338365    $link = sprintf('<a class="%s"%s href="%s/%s/%s#v%s" class="reform" title="%s">%s</a>',$igefilter_options['link_css_class'], $link_target,$link,htmlentities(urlencode($book)),$chapter,$verses,$title,trim($reference));
    339    
    340 return $link;
     366
     367    return $link;
     368}
    341369}
    342370
  • igefilter/trunk/readme.txt

    r2039180 r2626359  
    44Tags: bible, biblia, scripture, szentiras, ige
    55Requires at least: 3.1
    6 Tested up to: 5.1
    7 Stable tag: 1.0
     6Tested up to: 5.8
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6868== Changelog ==
    6969
     70= 1.1 =
     71* Added compatibility with PHP 7.
     72
    7073= 1.0 =
    7174* Original release.
  • igefilter/trunk/readme_en.txt

    r2039180 r2626359  
    44Tags: bible, biblia, scripture, szentiras
    55Requires at least: 3.1
    6 Tested up to: 5.1
    7 Stable tag: 1.0
     6Tested up to: 5.8
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7474== Changelog ==
    7575
     76= 1.1 =
     77* Added compatibility with PHP 7.
     78
    7679= 1.0 =
    7780* Original release.
Note: See TracChangeset for help on using the changeset viewer.