Plugin Directory

Changeset 2181143


Ignore:
Timestamp:
10/28/2019 12:56:26 AM (6 years ago)
Author:
UaMV
Message:

YouVersion URL fix

Location:
truth
Files:
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • truth/tags/2.3/class-truth-admin.php

    r1917073 r2181143  
    11<?php
    22/**
    3  * The admin Truth class
    4  */
     3* The admin Truth class
     4*/
    55if ( ! class_exists( 'Truth_Admin' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth_Admin {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        static $instance = false;
    1717
    18         /**
    19          * Static property to hold our singleton instance
    20          * @var $instance
    21          */
     18        /**
     19        * Static property to hold our singleton instance
     20        * @var $instance
     21        */
    2222        public $options = array();
    2323
    2424        /**
    25          * this is our constructor.
    26          * there are many like it, but this one is mine
    27          */
     25        * this is our constructor.
     26        * there are many like it, but this one is mine
     27        */
    2828        private function __construct() {
    2929
    30             $this->options = get_option( 'truth_settings' );
    31 
    32             register_activation_hook( TRUTH_FILE, array( $this, 'initialize_plugin' ) );
    33 
    34             require_once( TRUTH_DIR . 'class-truth-notice.php' );
    35 
    36             // Load the administrative Stylesheets and JavaScript
    37             add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
     30            $this->options = get_option( 'truth_settings' );
     31
     32            register_activation_hook( TRUTH_FILE, array( $this, 'initialize_plugin' ) );
     33
     34            require_once( TRUTH_DIR . 'class-truth-notice.php' );
     35
     36            // Load the administrative Stylesheets and JavaScript
     37            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    3838            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    3939
    40             if ( TRUTH_AUTH_ALL ) {
    41 
    42                 update_option( 'truth_authorization', true );
    43 
    44             } else {
    45 
    46                 add_action( 'admin_init', array( $this, 'check_authorization' ) );
    47 
    48             }
    49 
    50             add_action( 'admin_init', array( $this, 'register_settings' ) );
    51 
    52         }
    53 
    54         /**
    55          * If an instance exists, this returns it.  If not, it creates one and
    56          * returns it.
    57          *
    58          * @return $instance
    59          */
     40            if ( TRUTH_AUTH_ALL ) {
     41
     42                update_option( 'truth_authorization', true );
     43
     44            } else {
     45
     46                add_action( 'admin_init', array( $this, 'check_authorization' ) );
     47
     48            }
     49
     50            add_action( 'admin_init', array( $this, 'register_settings' ) );
     51
     52        }
     53
     54        /**
     55        * If an instance exists, this returns it.  If not, it creates one and
     56        * returns it.
     57        *
     58        * @return $instance
     59        */
    6060        public static function get_instance() {
    6161            if ( ! self::$instance ) {
     
    6666        }
    6767
    68         /**
    69          * Register the stylesheets.
    70          *
    71          * @since    0.0.1
    72          */
    73         public function enqueue_styles() {
    74 
    75             wp_enqueue_style( 'truth', plugin_dir_url( __FILE__ ) . 'css/truth-admin.css', array(), TRUTH_VERSION, 'all' );
    76 
    77         }
    78 
    79         /**
    80          * Register the JavaScript for the dashboard.
    81          *
    82          * @since    0.0.1
    83          */
    84         public function enqueue_scripts() {
    85 
    86             wp_enqueue_script( 'truth', plugin_dir_url( __FILE__ ) . 'js/truth-admin.js', array( 'jquery' ), TRUTH_VERSION, false );
    87             wp_localize_script( 'truth', 'TRUTH', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    88 
    89         }
    90 
    91         public function check_authorization() {
    92 
    93             if ( ! get_option( 'truth_authorization' ) ) {
    94 
    95                 $args = array(
    96                     'notice'  => 'truth-authorization',
    97                     'class'   => 'update-nag',
    98                     'message' => 'The <code>Truth</code> plugin needs authorization to link scripture references to an external site. Click <a href="#" id="authorize-truth" data-security="' . wp_create_nonce( 'authorize-truth' ) . '">here</a> to permit this action.',
    99                     'echo'    => true,
    100                 );
    101 
    102                 $notice = new Truth_Notice( $args );
    103 
    104                 $notice->show();
    105 
    106             }
    107 
    108         }
    109 
    110         public function register_settings() {
    111 
    112             register_setting( 'reading', 'truth_settings' );
    113             add_settings_field( 'truth_settings', 'Biblical References', array( $this, 'display_settings' ), 'reading', 'default' );
    114 
    115         }
    116 
    117         public function display_settings() {
    118 
    119             $sources = Truth::get_sources();
     68        /**
     69        * Register the stylesheets.
     70        *
     71        * @since    0.0.1
     72        */
     73        public function enqueue_styles() {
     74
     75            wp_enqueue_style( 'truth', plugin_dir_url( __FILE__ ) . 'css/truth-admin.css', array(), TRUTH_VERSION, 'all' );
     76
     77        }
     78
     79        /**
     80        * Register the JavaScript for the dashboard.
     81        *
     82        * @since    0.0.1
     83        */
     84        public function enqueue_scripts() {
     85
     86            wp_enqueue_script( 'truth', plugin_dir_url( __FILE__ ) . 'js/truth-admin.js', array( 'jquery' ), TRUTH_VERSION, false );
     87            wp_localize_script( 'truth', 'TRUTH', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
     88
     89        }
     90
     91        public function check_authorization() {
     92
     93            if ( ! get_option( 'truth_authorization' ) ) {
     94
     95                $args = array(
     96                    'notice'  => 'truth-authorization',
     97                    'class'   => 'update-nag',
     98                    'message' => 'The <code>Truth</code> plugin needs authorization to link scripture references to an external site. Click <a href="#" id="authorize-truth" data-security="' . wp_create_nonce( 'authorize-truth' ) . '">here</a> to permit this action.',
     99                    'echo'    => true,
     100                );
     101
     102                $notice = new Truth_Notice( $args );
     103
     104                $notice->show();
     105
     106            }
     107
     108        }
     109
     110        public function register_settings() {
     111
     112            register_setting( 'reading', 'truth_settings' );
     113            add_settings_field( 'truth_settings', 'Biblical References', array( $this, 'display_settings' ), 'reading', 'default' );
     114
     115        }
     116
     117        public function display_settings() {
     118
     119            $sources = Truth::get_sources();
    120120
    121121            foreach ( $sources as $source => $data ) {
     
    125125            }
    126126
    127             ?>
    128             <fieldset id="truth-general-settings">
    129                 <label>Bible Service: <select id="truth-engine" name="truth_settings[engine]"></label>
    130                     <option value="biblesorg_highlighter" <?php selected( $this->options['engine'], 'biblesorg_highlighter' ); ?>>Bibles.org Highlighter</option>
    131                     <option value="youversion" <?php selected( $this->options['engine'], 'youversion' ); ?>>YouVersion</option>
    132                 </select></label>
    133                 <span id="description-engine-biblesorg_highlighter" class="description" <?php echo 'biblesorg_highlighter' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(allows display of verses via modal when verses are clicked)</span>
    134                 <span id="description-engine-youversion" class="description" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(directs users to YouVersion.com upon click)</span>
    135                 </p>
    136             </fieldset>
    137 
    138             <fieldset id="truth-biblesorg_highlighter-settings" <?php echo ( ! isset( $this->options['engine'] ) || 'biblesorg_highlighter' == $this->options['engine'] ) ? '' : 'style="display:none;"'; ?>>
    139                 <h2>Bibles.org Highlighter Settings</h2>
    140                 <label>Version: <select id="bible-version" name="truth_settings[biblesorg_highlighter][bible_version]">
    141                     <?php foreach( $versions['biblesorg_highlighter'] as $languageGroup => $languageVersions ): ?>
    142                         <optgroup label="<?php echo $languageGroup?>">
    143                             <?php foreach( $languageVersions as $versionID => $versionInfo ): ?>
    144                                 <option value="<?php echo $versionID; ?>" <?php selected( $this->options['biblesorg_highlighter']['bible_version'], $versionID ); ?>><?php echo $versionInfo['name'] . ' (' . strtoupper( $versionInfo['abbr'] ). ')'; ?></option> <?php
    145                             endforeach; ?>
    146                         </optgroup>
    147                     <?php endforeach; ?>
    148                 </select></label><br />
    149                 <label>Overwrite Highlighter Targeting: <input name="truth_settings[biblesorg_highlighter][target_ids]" value="<?php echo ! isset( $this->options['biblesorg_highlighter']['target_ids'] ) ? '' : $this->options['biblesorg_highlighter']['target_ids']; ?>" style="width: 40%"></label><span id="description-biblesorg-target-ids" class="description">(comma-separated list of DOM element ids, overrides default search for verse references)
    150             </fieldset>
     127            ?>
     128            <fieldset id="truth-general-settings">
     129                <label>Bible Service: <select id="truth-engine" name="truth_settings[engine]"></label>
     130                    <option value="biblesorg_highlighter" <?php selected( $this->options['engine'], 'biblesorg_highlighter' ); ?>>Bibles.org Highlighter</option>
     131                    <option value="youversion" <?php selected( $this->options['engine'], 'youversion' ); ?>>YouVersion</option>
     132                </select></label>
     133                <span id="description-engine-biblesorg_highlighter" class="description" <?php echo 'biblesorg_highlighter' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(allows display of verses via modal when verses are clicked)</span>
     134                <span id="description-engine-youversion" class="description" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(directs users to YouVersion.com upon click)</span>
     135            </p>
     136        </fieldset>
     137
     138        <fieldset id="truth-biblesorg_highlighter-settings" <?php echo ( ! isset( $this->options['engine'] ) || 'biblesorg_highlighter' == $this->options['engine'] ) ? '' : 'style="display:none;"'; ?>>
     139            <h2>Bibles.org Highlighter Settings</h2>
     140            <label>Version: <select id="bible-version" name="truth_settings[biblesorg_highlighter][bible_version]">
     141                <?php foreach( $versions['biblesorg_highlighter'] as $languageGroup => $languageVersions ): ?>
     142                    <optgroup label="<?php echo $languageGroup?>">
     143                        <?php foreach( $languageVersions as $versionID => $versionInfo ): ?>
     144                            <option value="<?php echo $versionID; ?>" <?php selected( $this->options['biblesorg_highlighter']['bible_version'], $versionID ); ?>><?php echo $versionInfo['name'] . ' (' . strtoupper( $versionInfo['abbr'] ). ')'; ?></option> <?php
     145                        endforeach; ?>
     146                    </optgroup>
     147                <?php endforeach; ?>
     148            </select></label><br />
     149            <label>Overwrite Highlighter Targeting: <input name="truth_settings[biblesorg_highlighter][target_ids]" value="<?php echo ! isset( $this->options['biblesorg_highlighter']['target_ids'] ) ? '' : $this->options['biblesorg_highlighter']['target_ids']; ?>" style="width: 40%"></label><span id="description-biblesorg-target-ids" class="description">(comma-separated list of DOM element ids, overrides default search for verse references)
     150            </fieldset>
    151151
    152152            <fieldset id="truth-youversion-settings" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>
     
    163163                <p><input type="checkbox" id="link_in_new_tab" name="truth_settings[link_in_new_tab]" value="1" <?php checked( $this->options['link_in_new_tab'], 1 ); ?>> <label for="link_in_new_tab">Open links in new tab.</label></input></p>
    164164                <p><input type="checkbox" id="disable_auto_links" name="truth_settings[disable_auto_links]" value="1" <?php checked( $this->options['disable_auto_links'], 1 ); ?>> <label for="disable_auto_links">Disable auto-generation of links.</label></input> <span class="description">(maintains use of [truth] shortcode)</span></p>
    165                 <p><label> Append Version to Shortcode Text: <select id="append_version" name="truth_settings[append_version]">
    166                     <option value="none" <?php selected( $this->options['append_version'], 'none' ); ?>>No (Disabled)</option>
    167                     <option value="abbr" <?php selected( $this->options['append_version'], 'abbr' ); ?>>Abbreviation</option>
    168                     <option value="full" <?php selected( $this->options['append_version'], 'full' ); ?>>Full Name</option>
    169                 </select></label>
    170                 </p>
    171             </fieldset>
    172 
    173             <?php
    174 
    175         }
    176 
    177     }
     165                <p><label> Append Version to Shortcode Text: <select id="append_version" name="truth_settings[append_version]">
     166                    <option value="none" <?php selected( $this->options['append_version'], 'none' ); ?>>No (Disabled)</option>
     167                    <option value="abbr" <?php selected( $this->options['append_version'], 'abbr' ); ?>>Abbreviation</option>
     168                    <option value="full" <?php selected( $this->options['append_version'], 'full' ); ?>>Full Name</option>
     169                </select></label>
     170            </p>
     171        </fieldset>
     172
     173        <?php
     174
     175    }
     176
     177}
    178178
    179179}
     
    186186    add_action( 'admin_notices', 'typewheel_truth_notices' );
    187187    /**
    188      * Displays a plugin notices
    189      *
    190      * @since    1.0
    191      */
     188    * Displays a plugin notices
     189    *
     190    * @since    1.0
     191    */
    192192    function typewheel_truth_notices() {
    193193
    194194        $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) );
    195195
    196             // Notice to show on plugin activation
    197             $activation_notice = array(
    198 
    199             );
    200 
    201             // Define the notices
    202             $typewheel_notices = array(
    203                 // $prefix . '-tutorial' => array(
    204                 //  'trigger' => true,
    205                 //  'time' => time() - 5,
    206                 //  'dismiss' => array(),
    207                 //  'type' => '',
    208                 //  'content' => '<h2 style="margin:0;"><i class="dashicons dashicons-welcome-learn-more"></i> Glance That Tutorial</h2><br />Allow me to give you a brief run down on your <strong>Glance That</strong> options. You can hover over the <i class="dashicons dashicons-admin-settings"></i> settings icon at the top-right of <strong>At A Glance</strong> to reveal your controls. Clicking the <i class="dashicons dashicons-filter"></i> filter will allow you to add and remove items. You can also control <i class="dashicons dashicons-visibility"></i> visibility of available statuses for each item. Rearrange items by <i class="dashicons dashicons-move"></i> dragging them. Then, you can <i class="dashicons dashicons-migrate"></i> push your setup to other users. Let me know if you have any questions. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
    209                 //  // 'icon' => 'heart',
    210                 //  'style' => array( 'background-image' => 'linear-gradient( to bottom right, rgb(215, 215, 215), rgb(231, 211, 186) )', 'border-left-color' => '#3F3F3F', 'max-width' => '700px', 'padding' => '.5em 2em' ),
    211                 //  'location' => array( 'index.php' ),
    212                 //  'capability' => GT_ADMIN_GLANCES,
    213                 // ),
    214                 // $prefix . '-review' => array(
    215                 //  'trigger' => true,
    216                 //  'time' => time() + 604800,
    217                 //  'dismiss' => array( 'month' ),
    218                 //  'type' => '',
    219                 //  'content' => 'How are you liking the <strong>Glance That</strong> plugin? Help spread the word by <a href="https://wordpress.org/support/plugin/glance-that/reviews/?rate=5#new-post" target="_blank"><i class="dashicons dashicons-star-filled"></i> giving a review</a> or <a href="https://twitter.com/intent/tweet/?url=https%3A%2F%2Fwordpress.org%2Fplugins%2Fglance-that%2F" target="_blank"><i class="dashicons dashicons-twitter"></i> tweeting your support</a>. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
    220                 //  'icon' => 'share-alt',
    221                 //  'style' => array( 'background-image' => 'linear-gradient( to bottom right, rgb(215, 215, 215), rgb(231, 211, 186) )', 'border-left-color' => '#3F3F3F' ),
    222                 //  'location' => array( 'index.php' ),
    223                 //  'capability' => GT_ADMIN_GLANCES,
    224                 // ),
    225                 $prefix . '-give' => array(
    226                     'trigger' => true,
    227                     'time' => time() + 2592000,
    228                     'dismiss' => array( 'month' ),
    229                     'type' => '',
    230                     'content' => 'Is the <strong>Truth</strong> plugin working well for you? Please consider giving <a href="https://wordpress.org/support/plugin/truth/reviews/?rate=5#new-post" target="_blank"><i class="dashicons dashicons-star-filled"></i> a review</a>, <a href="https://twitter.com/intent/tweet/?url=https%3A%2F%2Fwordpress.org%2Fplugins%2Ftruth%2F" target="_blank"><i class="dashicons dashicons-twitter"></i> a tweet</a> or <a href="https://typewheel.xyz/give/?ref=Truth" target="_blank"><i class="dashicons dashicons-heart"></i> a donation</a> to encourage further development. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
     196        // Notice to show on plugin activation
     197        $activation_notice = array(
     198
     199        );
     200
     201        // Define the notices
     202        $typewheel_notices = array(
     203            $prefix . '-give' => array(
     204                'trigger' => true,
     205                'time' => time() + 2592000,
     206                'dismiss' => array( 'month' ),
     207                'type' => '',
     208                'content' => 'Is the <strong>Truth</strong> plugin working well for you? Please consider giving <a href="https://wordpress.org/support/plugin/truth/reviews/?rate=5#new-post" target="_blank"><i class="dashicons dashicons-star-filled"></i> a review</a>, <a href="https://twitter.com/intent/tweet/?url=https%3A%2F%2Fwordpress.org%2Fplugins%2Ftruth%2F" target="_blank"><i class="dashicons dashicons-twitter"></i> a tweet</a> or <a href="https://typewheel.xyz/give/?ref=Truth" target="_blank"><i class="dashicons dashicons-heart"></i> a donation</a> to encourage further development. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
    231209                    'icon' => 'heart',
    232                     'style' => array( 'background-image' => 'linear-gradient( to bottom right, rgb(215, 215, 215), rgb(231, 211, 186) )', 'border-left-color' => '#3F3F3F' ),
     210                    'style' => array( 'background-image' => 'linear-gradient( to left, rgb(215, 215, 215), rgb(220, 213, 206) )', 'border-left-color' => '#3F3F3F' ),
    233211                    'location' => array( 'options-reading.php' ),
    234212                    'capability' => 'manage_options',
     
    239217            new Typewheel_Notice( $prefix, $typewheel_notices, $activation_notice );
    240218
    241     } // end display_plugin_notices
    242 }
    243 
    244 /**
    245  * Deletes activation marker so it can be displayed when the plugin is reinstalled or reactivated
    246  *
    247  * @since    1.0
    248  */
    249 function typewheel_truth_remove_activation_marker() {
    250 
    251     $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) );
    252 
    253     delete_option( $prefix . '_activated' );
    254 
    255 }
    256 register_deactivation_hook( dirname(__FILE__) . '/truth.php', 'typewheel_truth_remove_activation_marker' );
     219        } // end display_plugin_notices
     220    }
     221
     222    /**
     223    * Deletes activation marker so it can be displayed when the plugin is reinstalled or reactivated
     224    *
     225    * @since    1.0
     226    */
     227    function typewheel_truth_remove_activation_marker() {
     228
     229        $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) );
     230
     231        delete_option( $prefix . '_activated' );
     232
     233    }
     234    register_deactivation_hook( dirname(__FILE__) . '/truth.php', 'typewheel_truth_remove_activation_marker' );
  • truth/tags/2.3/class-truth-notice.php

    r1468222 r2181143  
    11<?php
    22/**
    3  * The public Truth class
    4  */
     3* The public Truth class
     4*/
    55if ( ! class_exists( 'Truth_Notice' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth_Notice {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        public $notice = array();
    1717
    1818        /**
    19          * this is our constructor.
    20          * there are many like it, but this one is mine
    21          */
     19        * this is our constructor.
     20        * there are many like it, but this one is mine
     21        */
    2222        public function __construct( $notice ) {
    2323
     
    4848
    4949        /**
    50          * AJAX action target that authorizes plugin
    51          *
    52          * @since    0.0.1
    53          */
     50        * AJAX action target that authorizes plugin
     51        *
     52        * @since    0.0.1
     53        */
    5454        public function authorize_truth() {
    5555
     
    6161                $authorize = add_option( 'truth_authorization', true );
    6262
    63                     if ( $authorize ) {
     63                if ( $authorize ) {
    6464
    65                         $args = array(
    66                             'notice'  => 'truth-authorization-success',
    67                             'class'   => 'updated fade',
    68                             'message' => '<p>Thank you! Visit <code><a href="' . admin_url( 'options-reading.php#truth-engine' ) . '" data-security="' . wp_create_nonce( 'authorized-truth' ) . '">Settings > Reading</a></code> to customize <strong>(and save)</strong> your plugin settings.</p>',
    69                             'echo'    => false
    70                         );
     65                    $args = array(
     66                        'notice'  => 'truth-authorization-success',
     67                        'class'   => 'updated fade',
     68                        'message' => '<p>Thank you! Visit <code><a href="' . admin_url( 'options-reading.php#truth-engine' ) . '" data-security="' . wp_create_nonce( 'authorized-truth' ) . '">Settings > Reading</a></code> to customize <strong>(and save)</strong> your plugin settings.</p>',
     69                        'echo'    => false
     70                    );
    7171
    72                         $success = new Truth_Notice( $args );
     72                    $success = new Truth_Notice( $args );
    7373
    74                         $response['notice'] = $success->get();
    75                         $response['success'] = true;
     74                    $response['notice'] = $success->get();
     75                    $response['success'] = true;
    7676
    77                     } else {
     77                } else {
    7878
    79                         $args = array(
    80                             'notice'  => 'truth-authorization-failure',
    81                             'class'   => 'error',
    82                             'message' => 'Failed to authorize the Truth plugin. Please try again.',
    83                             'echo'    => false
    84                         );
     79                    $args = array(
     80                        'notice'  => 'truth-authorization-failure',
     81                        'class'   => 'error',
     82                        'message' => 'Failed to authorize the Truth plugin. Please try again.',
     83                        'echo'    => false
     84                    );
    8585
    86                         $failure = new Truth_Notice( $args );
    87                         $response['notice'] = $failure->get();
    88                         $response['success'] = false;
     86                    $failure = new Truth_Notice( $args );
     87                    $response['notice'] = $failure->get();
     88                    $response['success'] = false;
    8989
    90                     }
     90                }
    9191
    9292            } else {
     
    109109        }
    110110
    111     }
     111    }
    112112
    113113}
  • truth/tags/2.3/class-truth-public.php

    r1917073 r2181143  
    11<?php
    22/**
    3  * The public Truth class
    4  */
     3* The public Truth class
     4*/
    55if ( ! class_exists( 'Truth_Public' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth_Public {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        static $instance = false;
    1717
    18         /**
    19          * Static property to hold our singleton instance
    20          * @var $instance
    21          */
    22         public $options = array();
    23 
    24         /**
    25          * Indexes all book names
    26          * @var $instance
    27          */
    28         public $index = array();
    29 
    30         /**
    31          * this is our constructor.
    32          * there are many like it, but this one is mine
    33          */
     18        /**
     19        * Static property to hold our singleton instance
     20        * @var $instance
     21        */
     22        public $options = array();
     23
     24        /**
     25        * Indexes all book names
     26        * @var $instance
     27        */
     28        public $index = array();
     29
     30        /**
     31        * this is our constructor.
     32        * there are many like it, but this one is mine
     33        */
    3434        private function __construct() {
    3535
    36             $this->options = get_option( 'truth_settings' );
     36            $this->options = get_option( 'truth_settings' );
    3737
    3838            add_action( 'wp_head', array( $this, 'insert_scripts' ) );
    3939
    40             if ( get_option('truth_authorization') && ! $this->options['disable_auto_links'] && 'youversion' == $this->options['engine'] ) {
     40            if ( get_option('truth_authorization') && ! $this->options['disable_auto_links'] && 'youversion' == $this->options['engine'] ) {
    4141
    4242                add_action( 'init', array( $this, 'create_index' ) );
    4343
    44                 add_filter( 'the_content', array( $this, 'search_content' ), 99, 2 );
    45                 add_filter( 'comment_text', array( $this, 'search_content' ), 99, 2 );
    46                 add_filter( 'widget_text', array( $this, 'search_content' ), 99, 2 );
    47 
    48             }
     44                add_filter( 'the_content', array( $this, 'search_content' ), 99, 2 );
     45                add_filter( 'comment_text', array( $this, 'search_content' ), 99, 2 );
     46                add_filter( 'widget_text', array( $this, 'search_content' ), 99, 2 );
     47
     48            }
    4949
    5050            add_shortcode( 'truth', array( $this, 'shortcode' ) );
     
    5353
    5454        /**
    55          * If an instance exists, this returns it.  If not, it creates one and
    56          * returns it.
    57          *
    58          * @return $instance
    59          */
     55        * If an instance exists, this returns it.  If not, it creates one and
     56        * returns it.
     57        *
     58        * @return $instance
     59        */
    6060        public static function get_instance() {
    6161            if ( ! self::$instance ) {
     
    6767
    6868        /**
    69          * Register the JavaScript for the front-end.
    70          *
    71          * @since    0.0.1
    72          */
    73         public function insert_scripts() {
     69        * Register the JavaScript for the front-end.
     70        *
     71        * @since    0.0.1
     72        */
     73        public function insert_scripts() {
    7474
    7575            if ( 'biblesorg_highlighter' == $this->options['engine'] ) {
     
    7878                $targetIDs = explode( ',', $this->options['biblesorg_highlighter']['target_ids'] );
    7979
    80                  ?>
     80                ?>
    8181
    8282                <script id="bw-highlighter-config" data-version="<?php echo $versionInfo['abbr']; ?>">
    83                 (function(w, d, s, e, id) {
    84                   w._bhparse = w._bhparse || [];
    85                   function l() {
    86                     if (d.getElementById(id)) return;
    87                     var n = d.createElement(s), x = d.getElementsByTagName(s)[0];
    88                     n.id = id; n.async = true; n.src = '//bibles.org/linker/js/client.js';
    89                     x.parentNode.insertBefore(n, x);
    90                   }
    91                   (w.attachEvent) ? w.attachEvent('on' + e, l) : w.addEventListener(e, l, false);
    92                 })(window, document, 'script', 'load', 'bw-highlighter-src');
     83                    (function(w, d, s, e, id) {
     84                        w._bhparse = w._bhparse || [];
     85                        function l() {
     86                            if (d.getElementById(id)) return;
     87                            var n = d.createElement(s), x = d.getElementsByTagName(s)[0];
     88                            n.id = id; n.async = true; n.src = '//bibles.org/linker/js/client.js';
     89                            x.parentNode.insertBefore(n, x);
     90                        }
     91                        (w.attachEvent) ? w.attachEvent('on' + e, l) : w.addEventListener(e, l, false);
     92                    })(window, document, 'script', 'load', 'bw-highlighter-src');
    9393                </script>
    9494                <?php if ( isset( $this->options['biblesorg_highlighter']['target_ids'] ) && '' != $this->options['biblesorg_highlighter']['target_ids'] ) { ?>
    95                     <script>
    96                         _bhparse.push(
    97                             <?php foreach ($targetIDs as $targetID) {
    98                                 echo "'" . $targetID . "',";
    99                             } ?>
    100                         );
    101                     </script>
     95                <script>
     96                    _bhparse.push(
     97                        <?php foreach ($targetIDs as $targetID) {
     98                            echo "'" . $targetID . "',";
     99                        } ?>
     100                    );
     101                </script>
    102102                <?php }
    103103            }
    104104
    105         }
     105        }
    106106
    107107        public function shortcode( $atts, $content = '' ) {
     
    110110
    111111                extract( shortcode_atts( array(
    112                         'version' => '',
    113                     ), $atts ) );
     112                    'version' => '',
     113                ), $atts ) );
    114114
    115115                $reference = $this->parse_verse( $content );
     
    121121                    switch ( $this->options['append_version'] ) {
    122122                        case 'none':
    123                             break;
     123                        break;
    124124                        case 'abbr':
    125                             $content .= ', ' . strtoupper( $bibleVersion['abbr'] );
    126                             break;
     125                        $content .= ', ' . strtoupper( $bibleVersion['abbr'] );
     126                        break;
    127127                        case 'full':
    128                             $content .= ', ' . $bibleVersion['name'];
    129                             break;
     128                        $content .= ', ' . $bibleVersion['name'];
     129                        break;
    130130                        default:
    131                             break;
     131                        break;
    132132                    }
    133133                    $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : '';
     
    144144
    145145        /**
    146          * Searches content for matches to reference regex
    147          * @param  string $content The content to be searched
    148          * @return string          The content after links have been added
    149          */
    150         public function search_content( $content ) {
    151 
    152             $pattern = apply_filters( 'truth_regex_pattern', '/([0-3Ii]{0,3}|Song of|First|Second|Third|1st|2nd|3rd|Primero|Segundo|Tercero|Segunda|Tercera)[ ]{0,1}[\p{L}.]{1,20} \\d{1,3}(?!\\d):{0,1}[\\d,]*-{0,1}\\d{1,3}(?!\\d):{0,1}[\\d,]*/u' );
    153 
    154             preg_match_all( $pattern, $content, $matches, PREG_OFFSET_CAPTURE );
    155 
    156             $content = $this->insert_links( $content, $matches );
    157 
    158             return $content;
    159 
    160         }
    161 
    162         public function insert_links( $content, $matches ) {
     146        * Searches content for matches to reference regex
     147        * @param  string $content The content to be searched
     148        * @return string          The content after links have been added
     149        */
     150        public function search_content( $content ) {
     151
     152            $pattern = apply_filters( 'truth_regex_pattern', '/([0-3Ii]{0,3}|Song of|First|Second|Third|1st|2nd|3rd|Primero|Segundo|Tercero|Segunda|Tercera)[ ]{0,1}[\p{L}.]{1,20} \\d{1,3}(?!\\d):{0,1}[\\d,]*-{0,1}\\d{1,3}(?!\\d):{0,1}[\\d,]*/u' );
     153
     154            preg_match_all( $pattern, $content, $matches, PREG_OFFSET_CAPTURE );
     155
     156            $content = $this->insert_links( $content, $matches );
     157
     158            return $content;
     159
     160        }
     161
     162        public function insert_links( $content, $matches ) {
    163163
    164164            // Loop through matches, beginning at last match and working forward in order to use position of match for replacement in string.
    165             for ( $i = count( $matches[0] ) - 1; $i >= 0 ; $i-- ) {
     165            for ( $i = count( $matches[0] ) - 1; $i >= 0 ; $i-- ) {
    166166
    167167                // Grab the matched string and position of the match
    168                 $match = $matches[0][ $i ][0];
    169                 $idx = $matches[0][ $i ][1];
     168                $match = $matches[0][ $i ][0];
     169                $idx = $matches[0][ $i ][1];
    170170
    171171                // Parse the match into [0] bookNumber, [1] chapterNumber, [2] verseNumber, [3] endChapterNumber, [4] endVerseNumber
    172                 $reference = $this->parse_verse( $match );
    173 
    174                 $truth_url = $this->get_verse_url( $reference );
    175 
    176                 if ( $truth_url != '' ) {
    177 
    178                     substr( $match, 0, 1) == ' ' ? $idx++ : FALSE;  //Make sure the $idx isn't thrown off when it trims
    179                     $match = trim( $match );
    180                     $before = substr( $content, 0, $idx );
    181                     $after = substr( $content, $idx + strlen( $match ), strlen( $content ) - $idx - strlen( $match ) );
    182                     $closeAnchor = strpos( $after, '</a' );
    183                     $openAnchor = strpos( $after, '<a' );
    184                     // is the following needed?
    185                     $insertLink = FALSE;
    186                     if ( $closeAnchor === FALSE && $openAnchor === FALSE ) {
    187                         $insertLink = TRUE;
    188                     } elseif ( $closeAnchor !== FALSE && $openAnchor !== FALSE && $closeAnchor > $openAnchor ) {
    189                         $insertLink = TRUE;
    190                     }
    191 
    192                     if ( $insertLink === TRUE ) {
    193                         $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : '';
    194                         $content = $before . '<a href="' . $truth_url . '" class="verseLink"' . $truth_target . '>' . $match . "</a>" . $after;
    195                     }
    196 
    197                 }
    198 
    199             }
    200 
    201             return $content;
    202 
    203         }
     172                $reference = $this->parse_verse( $match );
     173
     174                $truth_url = $this->get_verse_url( $reference );
     175
     176                if ( $truth_url != '' ) {
     177
     178                    substr( $match, 0, 1) == ' ' ? $idx++ : FALSE;  //Make sure the $idx isn't thrown off when it trims
     179                    $match = trim( $match );
     180                    $before = substr( $content, 0, $idx );
     181                    $after = substr( $content, $idx + strlen( $match ), strlen( $content ) - $idx - strlen( $match ) );
     182                    $closeAnchor = strpos( $after, '</a' );
     183                    $openAnchor = strpos( $after, '<a' );
     184                    // is the following needed?
     185                    $insertLink = FALSE;
     186                    if ( $closeAnchor === FALSE && $openAnchor === FALSE ) {
     187                        $insertLink = TRUE;
     188                    } elseif ( $closeAnchor !== FALSE && $openAnchor !== FALSE && $closeAnchor > $openAnchor ) {
     189                        $insertLink = TRUE;
     190                    }
     191
     192                    if ( $insertLink === TRUE ) {
     193                        $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : '';
     194                        $content = $before . '<a href="' . $truth_url . '" class="verseLink"' . $truth_target . '>' . $match . "</a>" . $after;
     195                    }
     196
     197                }
     198
     199            }
     200
     201            return $content;
     202
     203        }
    204204
    205205        public function get_bible_version( $bibleVersionID = '' ) {
     
    279279                'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
    280280                'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
    281             $bookPart = strtr( $bookPart, $replacement_array );
    282 
    283             $bookNumber = isset( $this->index[ $bookPart ] ) ? $this->index[ $bookPart ] : NULL;
    284 
    285             // Get Verses Part
    286             $versesPart = str_replace( $initialBookPart, '', $match );
    287             $versesPart = str_replace( ';', ',', $versesPart );
    288 
    289             $versesParts = explode( ',', $versesPart );
    290 
    291 
    292             $chapterNumber = (int) trim( substr( $firstSplit[0], $idx, strlen( $firstSplit[0] ) - $idx ) );
    293 
    294             $verseNumber = $endChapterNumber = $endVerseNumber = 0;
    295 
    296             $verseSplit = explode( '-', $firstSplit[1] );
    297 
    298             $verseNumber = $verseSplit[0];
    299 
    300             if ( count( $verseSplit ) > 1 ) {
    301                 $endSplit = explode( ':', $verseSplit[1] );
    302                 if (count( $endSplit ) == 1 ) {
    303                   $endVerseNumber = $endSplit[0];
    304                 } else {
    305                   $endChapterNumber = (int) $endSplit[0];
    306                   $endVerseNumber = (int) $endSplit[1];
    307                 }
    308             }
    309 
    310             return array(
    311                 'bookNumber'       => $bookNumber,
    312                 'chapterNumber'    => $chapterNumber,
    313                 'verseNumber'      => $verseNumber,
    314                 'endChapterNumber' => $endChapterNumber,
    315                 'endVerseNumber'   => $endVerseNumber
    316             );
    317 
    318         }
    319 
    320 
    321         public function create_index() {
    322 
    323             $books = array(
    324                 array(),
    325                 array('genesis','gen','ge','gn'),
    326                 array('exodus','exo','ex','exod','exodo'),
    327                 array('leviticus','lev','le','lv','levitico'),
    328                 array('numbers','num', 'nu', 'nm', 'nb'),
    329                 array('deuteronomy','deut','dt','deuteronomio'),
    330                 array('joshua','josh','jos','jsh','josue'),
    331                 array('judges','judg','jdg','jg','jdgs','jueces','jue','jc'),
    332                 array('ruth','rth','ru'),
    333                 array('1 samuel','1 sam','1 sa','1samuel','1s','i sa','1 sm','1sa','i sam','1sam','i samuel','1st samuel','first samuel'),
    334                 array('2 samuel','2 sam','2 sa','2s','ii sa','2 sm','2sa','ii sam','2sam','ii samuel','2samuel','2nd samuel','second samuel'),
    335                 array('1 kings','1 kgs','1 ki','1k','i kgs','1kgs','i ki','1ki','i kings','1kings','1st kgs','1st kings','first kings','first kgs','1kin','1 reyes','1 rey','1 re'),
    336                 array('2 kings','2 kgs','2 ki','2k','ii kgs','2kgs','ii ki','2ki','ii kings','2kings','2nd kgs','2nd kings','second kings','second kgs','2kin','2 reyes','2 rey','2 re'),
    337                 array('1 chronicles','1 chron','1 ch','i ch','1ch','1 chr','i chr','1chr','i chron','1chron','i chronicles','1chronicles','1st chronicles','first chronicles','1 cronicas','1 cro','1cr'),
    338                 array('2 chronicles','2 chron','2 ch','ii ch','2ch','ii chr','2chr','ii chron','2chron','ii chronicles','2chronicles','2nd chronicles','second chronicles','2 cronicas','2 cro','2cr'),
    339                 array('ezra','ezr','esdras','esd','es'),
    340                 array('nehemiah','neh','ne','nehemias'),
    341                 array('esther','esth','es','ester','est'),
    342                 array('job','jb'),
    343                 array('psalms','pslm','ps','psalm','psa','psm','pss','salmos','sal'),
    344                 array('proverbs','prov','pr','prv','pro','proverbios'),
    345                 array('ecclesiastes','eccles','ec','ecc','eclesiastes','ecl'),
    346                 array('song of solomon','song','so','song of songs','sos','son','cantar de los cantares','cant'),
    347                 array('isaiah','isa','is','isaias'),
    348                 array('jeremiah','jer','je','jr','jeremias'),
    349                 array('lamentations','lam','la','lamentaciones'),
    350                 array('ezekiel','ezek','eze','ezk','ezequiel','ezeq','ez'),
    351                 array('daniel','dan','da','dn'),
    352                 array('hosea','hos','ho','oseas','os'),
    353                 array('joel','joe','jl'),
    354                 array('amos','am'),
    355                 array('obadiah','obad','ob','abdias','abd'),
    356                 array('jonah','jnh','jon','jonas'),
    357                 array('micah','mic','miqueas','miq'),
    358                 array('nahum','nah','na','nahun'),
    359                 array('habakkuk','hab','habacuc'),
    360                 array('zephaniah','zeph','zep','zp','sofonias','sof'),
    361                 array('haggai','hag','hg','ageo','ag'),
    362                 array('zechariah','zech','zec','zc','zacarias','zac','za'),
    363                 array('malachi','mal','ml','malaquias'),
    364                 array('matthew','matt','mt','mat','mateo'),
    365                 array('mark','mrk','mk','mr','marcos','mc'),
    366                 array('luke','luk','lk','lucas','luc','lc'),
    367                 array('john','jn','jhn','juan'),
    368                 array('acts','ac','hechos de los apostoles','hech','hch'),
    369                 array('romans','rom','ro','rm','romanos'),
    370                 array('1 corinthians','1 cor','1 co','i co','1co','i cor','1cor','i corinthians','1corinthians','1st corinthians','first corinthians','1 corin','1 corintios'),
    371                 array('2 corinthians','2 cor','2 co','ii co','2co','ii cor','2cor','ii corinthians','2corinthians','2nd corinthians','second corinthians','2 corin','2 corintios'),
    372                 array('galatians','gal','ga','galatas'),
    373                 array('ephesians','ephes','eph','efesios','efes','ef'),
    374                 array('philippians','phil','php','filipenses','fil','flp'),
    375                 array('colossians','col','colosenses'),
    376                 array('1 thessalonians','1 thess','1 th','i th','1th','i thes','1thes','i thess','1thess','i thessalonians','1thessalonians','1st thessalonians','first thessalonians','1ts','1 tesalonicenses'),
    377                 array('2 thessalonians','2 thess','2 th','ii th','2th','ii thes','2thes','ii thess','2thess','ii thessalonians','2thessalonians','2nd thessalonians','second thessalonians','2ts','2 tesalonicenses'),
    378                 array('1 timothy','1 tim','1 ti','i ti','1ti','i tim','1tim','i timothy','1timothy','1st timothy','first timothy','1 timoteo'),
    379                 array('2 timothy','2 tim','2 ti','ii ti','2ti','ii tim','2tim','ii timothy','2timothy','2nd timothy','second timothy','2 timoteo'),
    380                 array('titus','tit','tito'),
    381                 array('philemon','philem','phm','filemon','filem','flm'),
    382                 array('hebrews','heb','hebreos'),
    383                 array('james','jas','jm','santiago','sant','stgo','st'),
    384                 array('1 peter','1 pet','1 pe','i pe','1pe','i pet','1pet','i pt','1 pt','1pt','i peter','1peter','1st peter','first peter','1 pedro'),
    385                 array('2 peter','2 pet','2 pe','ii pe','2pe','ii pet','2pet','ii pt','2 pt','2pt','ii peter','2peter','2nd peter','second peter','2 pedro'),
    386                 array('1 john','1 jn','i jn','1jn','i jo','1jo','i joh','1joh','i jhn','1 jhn','1jhn','i john','1john','1st john','first john','1 juan'),
    387                 array('2 john','2 jn','ii jn','2jn','ii jo','2jo','ii joh','2joh','ii jhn','2 jhn','2jhn','ii john','2john','2nd john','second john','2 juan'),
    388                 array('3 john','3 jn','iii jn','3jn','iii jo','3jo','iii joh','3joh','iii jhn','3 jhn','3jhn','iii john','3john','3rd john','third john','3 juan'),
    389                 array('jude','jud','judas','jds'),
    390                 array('revelation','rev','re','apocalipsis','apocalipsis (de juan)','apoc','ap'),
    391             );
    392 
    393             // Re-key array to start at 1
    394             unset( $books[0] );
    395 
    396             foreach ( $books as $key => $names ) {
    397                 foreach ( $names as $name ) {
    398                     $this->index[ $name ] = $key;
    399                 }
    400             }
    401 
    402         }
    403 
    404     }
    405 
    406 }
     281                $bookPart = strtr( $bookPart, $replacement_array );
     282
     283                $bookNumber = isset( $this->index[ $bookPart ] ) ? $this->index[ $bookPart ] : NULL;
     284
     285                // Get Verses Part
     286                $versesPart = str_replace( $initialBookPart, '', $match );
     287                $versesPart = str_replace( ';', ',', $versesPart );
     288
     289                $versesParts = explode( ',', $versesPart );
     290
     291
     292                $chapterNumber = (int) trim( substr( $firstSplit[0], $idx, strlen( $firstSplit[0] ) - $idx ) );
     293
     294                $verseNumber = $endChapterNumber = $endVerseNumber = 0;
     295
     296                $verseSplit = explode( '-', $firstSplit[1] );
     297
     298                $verseNumber = $verseSplit[0];
     299
     300                if ( count( $verseSplit ) > 1 ) {
     301                    $endSplit = explode( ':', $verseSplit[1] );
     302                    if (count( $endSplit ) == 1 ) {
     303                        $endVerseNumber = $endSplit[0];
     304                    } else {
     305                        $endChapterNumber = (int) $endSplit[0];
     306                        $endVerseNumber = (int) $endSplit[1];
     307                    }
     308                }
     309
     310                return array(
     311                    'bookNumber'       => $bookNumber,
     312                    'chapterNumber'    => $chapterNumber,
     313                    'verseNumber'      => $verseNumber,
     314                    'endChapterNumber' => $endChapterNumber,
     315                    'endVerseNumber'   => $endVerseNumber
     316                );
     317
     318            }
     319
     320
     321            public function create_index() {
     322
     323                $books = array(
     324                    array(),
     325                    array('genesis','gen','ge','gn'),
     326                    array('exodus','exo','ex','exod','exodo'),
     327                    array('leviticus','lev','le','lv','levitico'),
     328                    array('numbers','num', 'nu', 'nm', 'nb'),
     329                    array('deuteronomy','deut','dt','deuteronomio'),
     330                    array('joshua','josh','jos','jsh','josue'),
     331                    array('judges','judg','jdg','jg','jdgs','jueces','jue','jc'),
     332                    array('ruth','rth','ru'),
     333                    array('1 samuel','1 sam','1 sa','1samuel','1s','i sa','1 sm','1sa','i sam','1sam','i samuel','1st samuel','first samuel'),
     334                    array('2 samuel','2 sam','2 sa','2s','ii sa','2 sm','2sa','ii sam','2sam','ii samuel','2samuel','2nd samuel','second samuel'),
     335                    array('1 kings','1 kgs','1 ki','1k','i kgs','1kgs','i ki','1ki','i kings','1kings','1st kgs','1st kings','first kings','first kgs','1kin','1 reyes','1 rey','1 re'),
     336                    array('2 kings','2 kgs','2 ki','2k','ii kgs','2kgs','ii ki','2ki','ii kings','2kings','2nd kgs','2nd kings','second kings','second kgs','2kin','2 reyes','2 rey','2 re'),
     337                    array('1 chronicles','1 chron','1 ch','i ch','1ch','1 chr','i chr','1chr','i chron','1chron','i chronicles','1chronicles','1st chronicles','first chronicles','1 cronicas','1 cro','1cr'),
     338                    array('2 chronicles','2 chron','2 ch','ii ch','2ch','ii chr','2chr','ii chron','2chron','ii chronicles','2chronicles','2nd chronicles','second chronicles','2 cronicas','2 cro','2cr'),
     339                    array('ezra','ezr','esdras','esd','es'),
     340                    array('nehemiah','neh','ne','nehemias'),
     341                    array('esther','esth','es','ester','est'),
     342                    array('job','jb'),
     343                    array('psalms','pslm','ps','psalm','psa','psm','pss','salmos','sal'),
     344                    array('proverbs','prov','pr','prv','pro','proverbios'),
     345                    array('ecclesiastes','eccles','ec','ecc','eclesiastes','ecl'),
     346                    array('song of solomon','song','so','song of songs','sos','son','cantar de los cantares','cant'),
     347                    array('isaiah','isa','is','isaias'),
     348                    array('jeremiah','jer','je','jr','jeremias'),
     349                    array('lamentations','lam','la','lamentaciones'),
     350                    array('ezekiel','ezek','eze','ezk','ezequiel','ezeq','ez'),
     351                    array('daniel','dan','da','dn'),
     352                    array('hosea','hos','ho','oseas','os'),
     353                    array('joel','joe','jl'),
     354                    array('amos','am'),
     355                    array('obadiah','obad','ob','abdias','abd'),
     356                    array('jonah','jnh','jon','jonas'),
     357                    array('micah','mic','miqueas','miq'),
     358                    array('nahum','nah','na','nahun'),
     359                    array('habakkuk','hab','habacuc'),
     360                    array('zephaniah','zeph','zep','zp','sofonias','sof'),
     361                    array('haggai','hag','hg','ageo','ag'),
     362                    array('zechariah','zech','zec','zc','zacarias','zac','za'),
     363                    array('malachi','mal','ml','malaquias'),
     364                    array('matthew','matt','mt','mat','mateo'),
     365                    array('mark','mrk','mk','mr','marcos','mc'),
     366                    array('luke','luk','lk','lucas','luc','lc'),
     367                    array('john','jn','jhn','juan'),
     368                    array('acts','ac','hechos de los apostoles','hech','hch'),
     369                    array('romans','rom','ro','rm','romanos'),
     370                    array('1 corinthians','1 cor','1 co','i co','1co','i cor','1cor','i corinthians','1corinthians','1st corinthians','first corinthians','1 corin','1 corintios'),
     371                    array('2 corinthians','2 cor','2 co','ii co','2co','ii cor','2cor','ii corinthians','2corinthians','2nd corinthians','second corinthians','2 corin','2 corintios'),
     372                    array('galatians','gal','ga','galatas'),
     373                    array('ephesians','ephes','eph','efesios','efes','ef'),
     374                    array('philippians','phil','php','filipenses','fil','flp'),
     375                    array('colossians','col','colosenses'),
     376                    array('1 thessalonians','1 thess','1 th','i th','1th','i thes','1thes','i thess','1thess','i thessalonians','1thessalonians','1st thessalonians','first thessalonians','1ts','1 tesalonicenses'),
     377                    array('2 thessalonians','2 thess','2 th','ii th','2th','ii thes','2thes','ii thess','2thess','ii thessalonians','2thessalonians','2nd thessalonians','second thessalonians','2ts','2 tesalonicenses'),
     378                    array('1 timothy','1 tim','1 ti','i ti','1ti','i tim','1tim','i timothy','1timothy','1st timothy','first timothy','1 timoteo'),
     379                    array('2 timothy','2 tim','2 ti','ii ti','2ti','ii tim','2tim','ii timothy','2timothy','2nd timothy','second timothy','2 timoteo'),
     380                    array('titus','tit','tito'),
     381                    array('philemon','philem','phm','filemon','filem','flm'),
     382                    array('hebrews','heb','hebreos'),
     383                    array('james','jas','jm','santiago','sant','stgo','st'),
     384                    array('1 peter','1 pet','1 pe','i pe','1pe','i pet','1pet','i pt','1 pt','1pt','i peter','1peter','1st peter','first peter','1 pedro'),
     385                    array('2 peter','2 pet','2 pe','ii pe','2pe','ii pet','2pet','ii pt','2 pt','2pt','ii peter','2peter','2nd peter','second peter','2 pedro'),
     386                    array('1 john','1 jn','i jn','1jn','i jo','1jo','i joh','1joh','i jhn','1 jhn','1jhn','i john','1john','1st john','first john','1 juan'),
     387                    array('2 john','2 jn','ii jn','2jn','ii jo','2jo','ii joh','2joh','ii jhn','2 jhn','2jhn','ii john','2john','2nd john','second john','2 juan'),
     388                    array('3 john','3 jn','iii jn','3jn','iii jo','3jo','iii joh','3joh','iii jhn','3 jhn','3jhn','iii john','3john','3rd john','third john','3 juan'),
     389                    array('jude','jud','judas','jds'),
     390                    array('revelation','rev','re','apocalipsis','apocalipsis (de juan)','apoc','ap'),
     391                );
     392
     393                // Re-key array to start at 1
     394                unset( $books[0] );
     395
     396                foreach ( $books as $key => $names ) {
     397                    foreach ( $names as $name ) {
     398                        $this->index[ $name ] = $key;
     399                    }
     400                }
     401
     402            }
     403
     404        }
     405
     406    }
  • truth/tags/2.3/class-truth.php

    r1468222 r2181143  
    11<?php
    22/**
    3  * The core Truth class
    4  */
     3* The core Truth class
     4*/
    55if ( ! class_exists( 'Truth' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        static $instance = false;
    1717
    1818        /**
    19          * this is our constructor.
    20          * there are many like it, but this one is mine
    21          */
     19        * this is our constructor.
     20        * there are many like it, but this one is mine
     21        */
    2222        private function __construct() {
    2323
     
    3333
    3434        /**
    35          * If an instance exists, this returns it.  If not, it creates one and
    36          * returns it.
    37          *
    38          * @return $instance
    39          */
     35        * If an instance exists, this returns it.  If not, it creates one and
     36        * returns it.
     37        *
     38        * @return $instance
     39        */
    4040        public static function get_instance() {
    4141            if ( ! self::$instance ) {
     
    4747
    4848        /**
    49          * Return supported version for Truth plugin
    50          * @return [type] [description]
    51          */
     49        * Return supported version for Truth plugin
     50        * @return [type] [description]
     51        */
    5252        public function get_sources() {
    5353
     
    7979                            'DHH' => array( 'name' => 'Biblia Dios Habla Hoy (sin notas ni ayudas)', 'abbr' => 'DHH' ),
    8080                            'RVR1960' => array( 'name' => 'Biblia Reina Valera 1960', 'abbr' => 'RVR1960' ),
    81                         ),             
     81                        ),
    8282                    )
    8383                ),
    8484                'youversion' => array(
    85                     'URLSingleVerse'  => 'http://bible.us/[id]/[book].[chapter].[verse].[version]',
    86                     'URLVerseRange'   => 'http://bible.us/[id]/[book].[chapter].[verse]-[endverse].[version]',
    87                     'URLSingleChapter'=> 'http://bible.us/[id]/[book].[chapter].[version]',
     85                    'URLSingleVerse'  => 'https://my.bible.com/[id]/[book].[chapter].[verse]',
     86                    'URLVerseRange'   => 'https://my.bible.com/[id]/[book].[chapter].[verse]-[endverse]',
     87                    'URLSingleChapter'=> 'https://my.bible.com/[id]/[book].[chapter]',
    8888                    'URLChapterRange' => '',
    8989                    'bookFind'        => array( 'song_of_solomon', ' ' ),
     
    116116                            '314' => array( 'name' => 'Tree of Life Bible', 'abbr' => 'tlv', 'id' => '314' ),
    117117                            '206' => array( 'name' => 'World English Bible', 'abbr' => 'web', 'id' => '206' ),
    118                             ),
     118                        ),
    119119                        'Español' => array(
    120120                            '28' => array( 'name' => 'La Palabra', 'abbr' => 'blph', 'id' => '28'),
     
    131131        }
    132132
    133     }
     133    }
    134134
    135135}
  • truth/tags/2.3/js/truth-admin.js

    r1468222 r2181143  
    33
    44    /**
    5      * All of the code for your Dashboard-specific JavaScript source
    6      * should reside in this file.
    7      *
    8      * Note that this assume you're going to use jQuery, so it prepares
    9      * the $ function reference to be used within the scope of this
    10      * function.
    11      *
    12      * From here, you're able to define handlers for when the DOM is
    13      * ready:
    14      *
    15      * $(function() {
    16      *
    17      * });
    18      *
    19      * Or when the window is loaded:
    20      *
    21      * $( window ).load(function() {
    22      *
    23      * });
    24      *
    25      * ...and so on.
    26      *
    27      * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
    28      * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
    29      * be doing this, we should try to minimize doing that in our own work.
    30      */
     5    * All of the code for your Dashboard-specific JavaScript source
     6    * should reside in this file.
     7    *
     8    * Note that this assume you're going to use jQuery, so it prepares
     9    * the $ function reference to be used within the scope of this
     10    * function.
     11    *
     12    * From here, you're able to define handlers for when the DOM is
     13    * ready:
     14    *
     15    * $(function() {
     16        *
     17        * });
     18        *
     19        * Or when the window is loaded:
     20        *
     21        * $( window ).load(function() {
     22            *
     23            * });
     24            *
     25            * ...and so on.
     26            *
     27            * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
     28            * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
     29            * be doing this, we should try to minimize doing that in our own work.
     30            */
    3131
    32     // Toggle internal lable for site URL input
    33     $( document ).ready( function() {
     32            // Toggle internal lable for site URL input
     33            $( document ).ready( function() {
    3434
    35         /* Send ajax after add site click */
    36         $( document ).on( 'click', '#authorize-truth', function(){
     35                /* Send ajax after add site click */
     36                $( document ).on( 'click', '#authorize-truth', function(){
    3737
    38             $.post( TRUTH.ajaxurl, {
     38                    $.post( TRUTH.ajaxurl, {
    3939
    40                 action: 'authorize_truth',
    41                 truth_security: $(this).data('security'),
     40                        action: 'authorize_truth',
     41                        truth_security: $(this).data('security'),
    4242
    43             }, function (response) {
     43                    }, function (response) {
    4444
    45                 if ( response.success ) {
     45                        if ( response.success ) {
    4646
    47                     $('#truth-authorization').hide();
    48                     $('#truth-authorization').after(response.notice);
     47                            $('#truth-authorization').hide();
     48                            $('#truth-authorization').after(response.notice);
    4949
    50                 } else {
     50                        } else {
    5151
    52                     $('#truth-authorization').after(response.notice);
    53                     $('#truth-authorization-failure').delay(4000).slideUp();
     52                            $('#truth-authorization').after(response.notice);
     53                            $('#truth-authorization-failure').delay(4000).slideUp();
    5454
    55                 }
     55                        }
     56
     57                    });
     58
     59                });
     60
     61                // Modify UI on engine selection
     62                $('#truth-engine').change(function() {
     63
     64                    // Show/hide engine descriptors
     65                    $('span[id^="description-engine"]:not([id="description-engine-'+$(this).find(':selected').val()+'"])').hide();
     66                    $('span[id="description-engine-'+$(this).find(':selected').val()+'"]').show();
     67
     68                    // Change UI of engine options
     69                    $('fieldset[id^="truth-"][id$="-settings"]:not([id="truth-'+$(this).find(':selected').val()+'-settings"]):not([id="truth-general-settings"])').hide();
     70                    $('fieldset[id="truth-'+$(this).find(':selected').val()+'-settings"]').show();
     71
     72                });
    5673
    5774            });
    5875
    59         });
    60 
    61         // Modify UI on engine selection
    62         $('#truth-engine').change(function() {
    63 
    64             // Show/hide engine descriptors
    65             $('span[id^="description-engine"]:not([id="description-engine-'+$(this).find(':selected').val()+'"])').hide();
    66             $('span[id="description-engine-'+$(this).find(':selected').val()+'"]').show();
    67 
    68             // Change UI of engine options
    69             $('fieldset[id^="truth-"][id$="-settings"]:not([id="truth-'+$(this).find(':selected').val()+'-settings"]):not([id="truth-general-settings"])').hide();
    70             $('fieldset[id="truth-'+$(this).find(':selected').val()+'-settings"]').show();
    71 
    72         });
    73 
    74     });
    75 
    76 })( jQuery );
     76        })( jQuery );
  • truth/tags/2.3/readme.txt

    r1917073 r2181143  
    44Tags: bible, scripture, truth, verse, version, youversion, passage, christian
    55Requires at least: 3.1
    6 Tested up to: 4.9
    7 Stable tag: trunk
     6Tested up to: 5.3
     7Stable tag: 2.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    103103== Changelog ==
    104104
     105= 2.3 =
     106* URL fix for YouVersion links
     107
    105108= 2.2 =
    106109* Added Bible Highlighter option to target specific DOM ids for instances when reference is not identified.
  • truth/tags/2.3/truth.php

    r1917073 r2181143  
    55Description: Generates YouVersion links for Biblical scripture references
    66Author: Joshua Vandercar
    7 Version: 2.2
     7Version: 2.3
    88Requires WP: 3.6
    99Author URI: http://vandercar.net
     
    1111*/
    1212
    13 define( 'TRUTH_VERSION', '2.2' );
     13define( 'TRUTH_VERSION', '2.3' );
    1414define( 'TRUTH_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    1515define( 'TRUTH_DIR', plugin_dir_path( __FILE__ ) );
  • truth/tags/2.3/typewheel-notice/class-typewheel-notice.php

    r1917073 r2181143  
    2121if ( ! class_exists( 'Typewheel_Notice' ) ) {
    2222    /**
    23      * Typewheel Notice Class
    24      *
    25      * Adds Typewheel notices to the WP admin
    26      *
    27      * @package Typewheel Notice
    28      * @author  UaMV
    29      */
     23    * Typewheel Notice Class
     24    *
     25    * Adds Typewheel notices to the WP admin
     26    *
     27    * @package Typewheel Notice
     28    * @author  UaMV
     29    */
    3030    class Typewheel_Notice {
    3131
    3232        /*---------------------------------------------------------------------------------*
    33          * Attributes
    34          *---------------------------------------------------------------------------------*/
    35 
    36         /**
    37          * Notices.
    38          *
    39          * @since    1.0
    40          *
    41          * @var      array
    42          */
     33        * Attributes
     34        *---------------------------------------------------------------------------------*/
     35
     36        /**
     37        * Notices.
     38        *
     39        * @since    1.0
     40        *
     41        * @var      array
     42        */
    4343        public $notices;
    4444
    4545        /**
    46          * User.
    47          *
    48          * @since    1.0
    49          *
    50          * @var      array
    51          */
     46        * User.
     47        *
     48        * @since    1.0
     49        *
     50        * @var      array
     51        */
    5252        public $user;
    5353
    5454        /**
    55          * Notices.
    56          *
    57          * @since    1.0
    58          *
    59          * @var      array
    60          */
     55        * Notices.
     56        *
     57        * @since    1.0
     58        *
     59        * @var      array
     60        */
    6161        public $prefix;
    6262
    6363        /*---------------------------------------------------------------------------------*
    64          * Constructor
    65          *---------------------------------------------------------------------------------*/
    66 
    67         /**
    68          * Initialize the plugin by setting localization, filters, and administration functions.
    69          *
    70          * @since     1.0
    71          */
     64        * Constructor
     65        *---------------------------------------------------------------------------------*/
     66
     67        /**
     68        * Initialize the plugin by setting localization, filters, and administration functions.
     69        *
     70        * @since     1.0
     71        */
    7272        public function __construct( $prefix, $notices = array(), $activation = array() ) {
    7373
     
    9999
    100100        /*---------------------------------------------------------------------------------*
    101          * Public Functions
    102          *---------------------------------------------------------------------------------*/
    103 
    104          /**
    105          * Check user and set/get notices
    106          *
    107          * @since    1.0
    108          */
    109         public function process_user() {
    110 
    111             $current_user = wp_get_current_user();
     101        * Public Functions
     102        *---------------------------------------------------------------------------------*/
     103
     104        /**
     105        * Check user and set/get notices
     106        *
     107        * @since    1.0
     108        */
     109        public function process_user() {
     110
     111            $current_user = wp_get_current_user();
    112112
    113113            $this->user['ID'] = $current_user->ID;
    114114
    115             // Get the notice options from the user
    116             $this->user['notices'] = get_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', true );
    117 
    118             // If not yet set, then set the usermeta as an array
     115            // Get the notice options from the user
     116            $this->user['notices'] = get_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', true );
     117
     118            // If not yet set, then set the usermeta as an array
    119119            if ( '' == $this->user['notices'] ) {
    120120                add_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', array(), true );
     
    133133            }
    134134
    135             // Create specific notices if they do not exist, otherwise set to current notice state
    136             foreach ( $this->notices as $notice => $args ) {
    137 
    138                 if ( ! isset( $this->user['notices'][ $notice ] ) ) {
    139 
    140                     $this->user['notices'][ $notice ] = array(
    141                         'trigger' => $args['trigger'],
    142                         'time'    => $args['time'],
    143                         );
    144 
    145                 }
    146 
    147             }
    148 
    149             // Update the user meta
    150             update_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', $this->user['notices'] );
     135            // Create specific notices if they do not exist, otherwise set to current notice state
     136            foreach ( $this->notices as $notice => $args ) {
     137
     138                if ( ! isset( $this->user['notices'][ $notice ] ) ) {
     139
     140                    $this->user['notices'][ $notice ] = array(
     141                        'trigger' => $args['trigger'],
     142                        'time'    => $args['time'],
     143                    );
     144
     145                }
     146
     147            }
     148
     149            // Update the user meta
     150            update_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', $this->user['notices'] );
    151151
    152152        }
    153153
    154154        /**
    155          * Displays active plugin notices.
    156          *
    157          * @since    1.0
    158          */
     155        * Displays active plugin notices.
     156        *
     157        * @since    1.0
     158        */
    159159        public function display() {
    160160
     
    178178                    // Assemble the notice
    179179                    $html .= '<div id="' . $notice . '-typewheel-notice" class="notice notice-' . $args['type'] . ' typewheel-notice' . '" style="' . esc_attr( $this->styles( $args['style'] ) ) . '">';
    180                         $html .= '<p>';
    181                             $html .= $this->get_dismissals( $notice, $args['dismiss'] );
    182                             $html .= isset( $args['icon'] ) && '' != $args['icon'] ? '<i class="dashicons dashicons-' . $args['icon'] . ' featured-icon"></i>' : '';
    183                             $html .= apply_filters( $notice . '_typewheel_notice_content', $args['content'], $notice );
    184                         $html .= '</p>';
     180                    $html .= '<p>';
     181                    $html .= $this->get_dismissals( $notice, $args['dismiss'] );
     182                    $html .= isset( $args['icon'] ) && '' != $args['icon'] ? '<i class="dashicons dashicons-' . $args['icon'] . ' featured-icon"></i>' : '';
     183                    $html .= apply_filters( $notice . '_typewheel_notice_content', $args['content'], $notice );
     184                    $html .= '</p>';
    185185                    $html .= '</div>';
    186186
     
    194194
    195195        /**
    196          * Displays activation notice.
    197          *
    198          * @since    1.0
    199          */
     196        * Displays activation notice.
     197        *
     198        * @since    1.0
     199        */
    200200        public function display_activation() {
    201201
     
    210210                // Assemble notice
    211211                $html = '<div id="activation-typewheel-notice" class="notice notice-info typewheel-notice' . '" style="' . esc_attr( $this->styles( $this->activation['style'] ) ) . '">';
    212                     $html .= '<p>';
    213                         $html .= isset( $this->activation['icon'] ) && '' != $this->activation['icon'] ? '<i class="dashicons dashicons-' . $this->activation['icon'] . ' featured-icon"></i>' : '';
    214                         $html .= apply_filters( 'activation_typewheel_notice_content', $this->activation['content'] );
    215                     $html .= '</p>';
     212                $html .= '<p>';
     213                $html .= isset( $this->activation['icon'] ) && '' != $this->activation['icon'] ? '<i class="dashicons dashicons-' . $this->activation['icon'] . ' featured-icon"></i>' : '';
     214                $html .= apply_filters( 'activation_typewheel_notice_content', $this->activation['content'] );
     215                $html .= '</p>';
    216216                $html .= '</div>';
    217217
     
    223223
    224224        /**
    225          * Assemble the styles from array or string
    226          *
    227          * @since    1.0
    228          */
     225        * Assemble the styles from array or string
     226        *
     227        * @since    1.0
     228        */
    229229        private function styles( $styles ) {
    230230
     
    250250
    251251        /**
    252          * Assemble and return any assigned dismissal notices
    253          *
    254          * @since    1.0
    255          */
     252        * Assemble and return any assigned dismissal notices
     253        *
     254        * @since    1.0
     255        */
    256256        public function get_dismissals( $notice, $dismiss ) {
    257257
     
    293293        switch ( $duration ) {
    294294            case 'week':
    295                 $user[ $notice ]['time'] = time() + 604800;
    296                 break;
     295            $user[ $notice ]['time'] = time() + 604800;
     296            break;
    297297            case 'month':
    298                 $user[ $notice ]['time'] = time() + 2592000;
    299                 break;
     298            $user[ $notice ]['time'] = time() + 2592000;
     299            break;
    300300            case 'forever':
    301301                $user[ $notice ]['trigger'] = FALSE;
    302302                break;
    303             case 'undismiss':
     303                case 'undismiss':
    304304                foreach ( $user as $name => $args ) {
    305305                    $user[ $name ]['trigger'] = TRUE;
     
    307307                }
    308308                break;
    309             default:
     309                default:
    310310                break;
     311            }
     312
     313            // Update the user meta
     314            update_user_meta( $userid, $plugin . '_typewheel_notices', $user );
     315
     316            $response = array( 'success' => true, 'notice' => $notice, 'plugin' => $plugin );
     317
     318            wp_send_json( $response );
     319
    311320        }
    312 
    313         // Update the user meta
    314         update_user_meta( $userid, $plugin . '_typewheel_notices', $user );
    315 
    316         $response = array( 'success' => true, 'notice' => $notice, 'plugin' => $plugin );
    317 
    318         wp_send_json( $response );
    319 
    320321    }
    321 }
  • truth/tags/2.3/typewheel-notice/typewheel-notice.js

    r1917073 r2181143  
    11/**
    2  * Handles Typewheel Notice Dismissals
    3  */
    4  jQuery(document).ready(function($) {
     2* Handles Typewheel Notice Dismissals
     3*/
     4jQuery(document).ready(function($) {
    55
    6     $('span[id$="-typewheel-notice-dismissals"] i').click(
    7         function() {
    8             $.post(TypewheelNotice.ajaxurl, {
    9                 action: 'dismiss_notice',
    10                 typewheel_notice_duration: $(this).data('dismissal-duration'),
    11                 typewheel_notice: $(this).data('notice'),
    12                 typewheel_notice_plugin: $(this).data('plugin'),
    13                 typewheel_user: $(this).data('user'),
     6  $('span[id$="-typewheel-notice-dismissals"] i').click(
     7      function() {
     8        $.post(TypewheelNotice.ajaxurl, {
     9            action: 'dismiss_notice',
     10            typewheel_notice_duration: $(this).data('dismissal-duration'),
     11            typewheel_notice: $(this).data('notice'),
     12            typewheel_notice_plugin: $(this).data('plugin'),
     13            typewheel_user: $(this).data('user'),
    1414
    15             }, function (response) {
     15        }, function (response) {
    1616
    17                 if ( response.success ) {
     17            if ( response.success ) {
    1818
    19                     $('div#'+response.notice+'-typewheel-notice').slideUp();
     19              $('div#'+response.notice+'-typewheel-notice').slideUp();
    2020
    21                 }
    22             }
    23     )});
     21            }
     22        }
     23      )});
    2424
    25  });
     25   });
  • truth/trunk/class-truth-admin.php

    r1917073 r2181143  
    11<?php
    22/**
    3  * The admin Truth class
    4  */
     3* The admin Truth class
     4*/
    55if ( ! class_exists( 'Truth_Admin' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth_Admin {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        static $instance = false;
    1717
    18         /**
    19          * Static property to hold our singleton instance
    20          * @var $instance
    21          */
     18        /**
     19        * Static property to hold our singleton instance
     20        * @var $instance
     21        */
    2222        public $options = array();
    2323
    2424        /**
    25          * this is our constructor.
    26          * there are many like it, but this one is mine
    27          */
     25        * this is our constructor.
     26        * there are many like it, but this one is mine
     27        */
    2828        private function __construct() {
    2929
    30             $this->options = get_option( 'truth_settings' );
    31 
    32             register_activation_hook( TRUTH_FILE, array( $this, 'initialize_plugin' ) );
    33 
    34             require_once( TRUTH_DIR . 'class-truth-notice.php' );
    35 
    36             // Load the administrative Stylesheets and JavaScript
    37             add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
     30            $this->options = get_option( 'truth_settings' );
     31
     32            register_activation_hook( TRUTH_FILE, array( $this, 'initialize_plugin' ) );
     33
     34            require_once( TRUTH_DIR . 'class-truth-notice.php' );
     35
     36            // Load the administrative Stylesheets and JavaScript
     37            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    3838            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    3939
    40             if ( TRUTH_AUTH_ALL ) {
    41 
    42                 update_option( 'truth_authorization', true );
    43 
    44             } else {
    45 
    46                 add_action( 'admin_init', array( $this, 'check_authorization' ) );
    47 
    48             }
    49 
    50             add_action( 'admin_init', array( $this, 'register_settings' ) );
    51 
    52         }
    53 
    54         /**
    55          * If an instance exists, this returns it.  If not, it creates one and
    56          * returns it.
    57          *
    58          * @return $instance
    59          */
     40            if ( TRUTH_AUTH_ALL ) {
     41
     42                update_option( 'truth_authorization', true );
     43
     44            } else {
     45
     46                add_action( 'admin_init', array( $this, 'check_authorization' ) );
     47
     48            }
     49
     50            add_action( 'admin_init', array( $this, 'register_settings' ) );
     51
     52        }
     53
     54        /**
     55        * If an instance exists, this returns it.  If not, it creates one and
     56        * returns it.
     57        *
     58        * @return $instance
     59        */
    6060        public static function get_instance() {
    6161            if ( ! self::$instance ) {
     
    6666        }
    6767
    68         /**
    69          * Register the stylesheets.
    70          *
    71          * @since    0.0.1
    72          */
    73         public function enqueue_styles() {
    74 
    75             wp_enqueue_style( 'truth', plugin_dir_url( __FILE__ ) . 'css/truth-admin.css', array(), TRUTH_VERSION, 'all' );
    76 
    77         }
    78 
    79         /**
    80          * Register the JavaScript for the dashboard.
    81          *
    82          * @since    0.0.1
    83          */
    84         public function enqueue_scripts() {
    85 
    86             wp_enqueue_script( 'truth', plugin_dir_url( __FILE__ ) . 'js/truth-admin.js', array( 'jquery' ), TRUTH_VERSION, false );
    87             wp_localize_script( 'truth', 'TRUTH', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    88 
    89         }
    90 
    91         public function check_authorization() {
    92 
    93             if ( ! get_option( 'truth_authorization' ) ) {
    94 
    95                 $args = array(
    96                     'notice'  => 'truth-authorization',
    97                     'class'   => 'update-nag',
    98                     'message' => 'The <code>Truth</code> plugin needs authorization to link scripture references to an external site. Click <a href="#" id="authorize-truth" data-security="' . wp_create_nonce( 'authorize-truth' ) . '">here</a> to permit this action.',
    99                     'echo'    => true,
    100                 );
    101 
    102                 $notice = new Truth_Notice( $args );
    103 
    104                 $notice->show();
    105 
    106             }
    107 
    108         }
    109 
    110         public function register_settings() {
    111 
    112             register_setting( 'reading', 'truth_settings' );
    113             add_settings_field( 'truth_settings', 'Biblical References', array( $this, 'display_settings' ), 'reading', 'default' );
    114 
    115         }
    116 
    117         public function display_settings() {
    118 
    119             $sources = Truth::get_sources();
     68        /**
     69        * Register the stylesheets.
     70        *
     71        * @since    0.0.1
     72        */
     73        public function enqueue_styles() {
     74
     75            wp_enqueue_style( 'truth', plugin_dir_url( __FILE__ ) . 'css/truth-admin.css', array(), TRUTH_VERSION, 'all' );
     76
     77        }
     78
     79        /**
     80        * Register the JavaScript for the dashboard.
     81        *
     82        * @since    0.0.1
     83        */
     84        public function enqueue_scripts() {
     85
     86            wp_enqueue_script( 'truth', plugin_dir_url( __FILE__ ) . 'js/truth-admin.js', array( 'jquery' ), TRUTH_VERSION, false );
     87            wp_localize_script( 'truth', 'TRUTH', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
     88
     89        }
     90
     91        public function check_authorization() {
     92
     93            if ( ! get_option( 'truth_authorization' ) ) {
     94
     95                $args = array(
     96                    'notice'  => 'truth-authorization',
     97                    'class'   => 'update-nag',
     98                    'message' => 'The <code>Truth</code> plugin needs authorization to link scripture references to an external site. Click <a href="#" id="authorize-truth" data-security="' . wp_create_nonce( 'authorize-truth' ) . '">here</a> to permit this action.',
     99                    'echo'    => true,
     100                );
     101
     102                $notice = new Truth_Notice( $args );
     103
     104                $notice->show();
     105
     106            }
     107
     108        }
     109
     110        public function register_settings() {
     111
     112            register_setting( 'reading', 'truth_settings' );
     113            add_settings_field( 'truth_settings', 'Biblical References', array( $this, 'display_settings' ), 'reading', 'default' );
     114
     115        }
     116
     117        public function display_settings() {
     118
     119            $sources = Truth::get_sources();
    120120
    121121            foreach ( $sources as $source => $data ) {
     
    125125            }
    126126
    127             ?>
    128             <fieldset id="truth-general-settings">
    129                 <label>Bible Service: <select id="truth-engine" name="truth_settings[engine]"></label>
    130                     <option value="biblesorg_highlighter" <?php selected( $this->options['engine'], 'biblesorg_highlighter' ); ?>>Bibles.org Highlighter</option>
    131                     <option value="youversion" <?php selected( $this->options['engine'], 'youversion' ); ?>>YouVersion</option>
    132                 </select></label>
    133                 <span id="description-engine-biblesorg_highlighter" class="description" <?php echo 'biblesorg_highlighter' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(allows display of verses via modal when verses are clicked)</span>
    134                 <span id="description-engine-youversion" class="description" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(directs users to YouVersion.com upon click)</span>
    135                 </p>
    136             </fieldset>
    137 
    138             <fieldset id="truth-biblesorg_highlighter-settings" <?php echo ( ! isset( $this->options['engine'] ) || 'biblesorg_highlighter' == $this->options['engine'] ) ? '' : 'style="display:none;"'; ?>>
    139                 <h2>Bibles.org Highlighter Settings</h2>
    140                 <label>Version: <select id="bible-version" name="truth_settings[biblesorg_highlighter][bible_version]">
    141                     <?php foreach( $versions['biblesorg_highlighter'] as $languageGroup => $languageVersions ): ?>
    142                         <optgroup label="<?php echo $languageGroup?>">
    143                             <?php foreach( $languageVersions as $versionID => $versionInfo ): ?>
    144                                 <option value="<?php echo $versionID; ?>" <?php selected( $this->options['biblesorg_highlighter']['bible_version'], $versionID ); ?>><?php echo $versionInfo['name'] . ' (' . strtoupper( $versionInfo['abbr'] ). ')'; ?></option> <?php
    145                             endforeach; ?>
    146                         </optgroup>
    147                     <?php endforeach; ?>
    148                 </select></label><br />
    149                 <label>Overwrite Highlighter Targeting: <input name="truth_settings[biblesorg_highlighter][target_ids]" value="<?php echo ! isset( $this->options['biblesorg_highlighter']['target_ids'] ) ? '' : $this->options['biblesorg_highlighter']['target_ids']; ?>" style="width: 40%"></label><span id="description-biblesorg-target-ids" class="description">(comma-separated list of DOM element ids, overrides default search for verse references)
    150             </fieldset>
     127            ?>
     128            <fieldset id="truth-general-settings">
     129                <label>Bible Service: <select id="truth-engine" name="truth_settings[engine]"></label>
     130                    <option value="biblesorg_highlighter" <?php selected( $this->options['engine'], 'biblesorg_highlighter' ); ?>>Bibles.org Highlighter</option>
     131                    <option value="youversion" <?php selected( $this->options['engine'], 'youversion' ); ?>>YouVersion</option>
     132                </select></label>
     133                <span id="description-engine-biblesorg_highlighter" class="description" <?php echo 'biblesorg_highlighter' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(allows display of verses via modal when verses are clicked)</span>
     134                <span id="description-engine-youversion" class="description" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>(directs users to YouVersion.com upon click)</span>
     135            </p>
     136        </fieldset>
     137
     138        <fieldset id="truth-biblesorg_highlighter-settings" <?php echo ( ! isset( $this->options['engine'] ) || 'biblesorg_highlighter' == $this->options['engine'] ) ? '' : 'style="display:none;"'; ?>>
     139            <h2>Bibles.org Highlighter Settings</h2>
     140            <label>Version: <select id="bible-version" name="truth_settings[biblesorg_highlighter][bible_version]">
     141                <?php foreach( $versions['biblesorg_highlighter'] as $languageGroup => $languageVersions ): ?>
     142                    <optgroup label="<?php echo $languageGroup?>">
     143                        <?php foreach( $languageVersions as $versionID => $versionInfo ): ?>
     144                            <option value="<?php echo $versionID; ?>" <?php selected( $this->options['biblesorg_highlighter']['bible_version'], $versionID ); ?>><?php echo $versionInfo['name'] . ' (' . strtoupper( $versionInfo['abbr'] ). ')'; ?></option> <?php
     145                        endforeach; ?>
     146                    </optgroup>
     147                <?php endforeach; ?>
     148            </select></label><br />
     149            <label>Overwrite Highlighter Targeting: <input name="truth_settings[biblesorg_highlighter][target_ids]" value="<?php echo ! isset( $this->options['biblesorg_highlighter']['target_ids'] ) ? '' : $this->options['biblesorg_highlighter']['target_ids']; ?>" style="width: 40%"></label><span id="description-biblesorg-target-ids" class="description">(comma-separated list of DOM element ids, overrides default search for verse references)
     150            </fieldset>
    151151
    152152            <fieldset id="truth-youversion-settings" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>>
     
    163163                <p><input type="checkbox" id="link_in_new_tab" name="truth_settings[link_in_new_tab]" value="1" <?php checked( $this->options['link_in_new_tab'], 1 ); ?>> <label for="link_in_new_tab">Open links in new tab.</label></input></p>
    164164                <p><input type="checkbox" id="disable_auto_links" name="truth_settings[disable_auto_links]" value="1" <?php checked( $this->options['disable_auto_links'], 1 ); ?>> <label for="disable_auto_links">Disable auto-generation of links.</label></input> <span class="description">(maintains use of [truth] shortcode)</span></p>
    165                 <p><label> Append Version to Shortcode Text: <select id="append_version" name="truth_settings[append_version]">
    166                     <option value="none" <?php selected( $this->options['append_version'], 'none' ); ?>>No (Disabled)</option>
    167                     <option value="abbr" <?php selected( $this->options['append_version'], 'abbr' ); ?>>Abbreviation</option>
    168                     <option value="full" <?php selected( $this->options['append_version'], 'full' ); ?>>Full Name</option>
    169                 </select></label>
    170                 </p>
    171             </fieldset>
    172 
    173             <?php
    174 
    175         }
    176 
    177     }
     165                <p><label> Append Version to Shortcode Text: <select id="append_version" name="truth_settings[append_version]">
     166                    <option value="none" <?php selected( $this->options['append_version'], 'none' ); ?>>No (Disabled)</option>
     167                    <option value="abbr" <?php selected( $this->options['append_version'], 'abbr' ); ?>>Abbreviation</option>
     168                    <option value="full" <?php selected( $this->options['append_version'], 'full' ); ?>>Full Name</option>
     169                </select></label>
     170            </p>
     171        </fieldset>
     172
     173        <?php
     174
     175    }
     176
     177}
    178178
    179179}
     
    186186    add_action( 'admin_notices', 'typewheel_truth_notices' );
    187187    /**
    188      * Displays a plugin notices
    189      *
    190      * @since    1.0
    191      */
     188    * Displays a plugin notices
     189    *
     190    * @since    1.0
     191    */
    192192    function typewheel_truth_notices() {
    193193
    194194        $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) );
    195195
    196             // Notice to show on plugin activation
    197             $activation_notice = array(
    198 
    199             );
    200 
    201             // Define the notices
    202             $typewheel_notices = array(
    203                 // $prefix . '-tutorial' => array(
    204                 //  'trigger' => true,
    205                 //  'time' => time() - 5,
    206                 //  'dismiss' => array(),
    207                 //  'type' => '',
    208                 //  'content' => '<h2 style="margin:0;"><i class="dashicons dashicons-welcome-learn-more"></i> Glance That Tutorial</h2><br />Allow me to give you a brief run down on your <strong>Glance That</strong> options. You can hover over the <i class="dashicons dashicons-admin-settings"></i> settings icon at the top-right of <strong>At A Glance</strong> to reveal your controls. Clicking the <i class="dashicons dashicons-filter"></i> filter will allow you to add and remove items. You can also control <i class="dashicons dashicons-visibility"></i> visibility of available statuses for each item. Rearrange items by <i class="dashicons dashicons-move"></i> dragging them. Then, you can <i class="dashicons dashicons-migrate"></i> push your setup to other users. Let me know if you have any questions. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
    209                 //  // 'icon' => 'heart',
    210                 //  'style' => array( 'background-image' => 'linear-gradient( to bottom right, rgb(215, 215, 215), rgb(231, 211, 186) )', 'border-left-color' => '#3F3F3F', 'max-width' => '700px', 'padding' => '.5em 2em' ),
    211                 //  'location' => array( 'index.php' ),
    212                 //  'capability' => GT_ADMIN_GLANCES,
    213                 // ),
    214                 // $prefix . '-review' => array(
    215                 //  'trigger' => true,
    216                 //  'time' => time() + 604800,
    217                 //  'dismiss' => array( 'month' ),
    218                 //  'type' => '',
    219                 //  'content' => 'How are you liking the <strong>Glance That</strong> plugin? Help spread the word by <a href="https://wordpress.org/support/plugin/glance-that/reviews/?rate=5#new-post" target="_blank"><i class="dashicons dashicons-star-filled"></i> giving a review</a> or <a href="https://twitter.com/intent/tweet/?url=https%3A%2F%2Fwordpress.org%2Fplugins%2Fglance-that%2F" target="_blank"><i class="dashicons dashicons-twitter"></i> tweeting your support</a>. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
    220                 //  'icon' => 'share-alt',
    221                 //  'style' => array( 'background-image' => 'linear-gradient( to bottom right, rgb(215, 215, 215), rgb(231, 211, 186) )', 'border-left-color' => '#3F3F3F' ),
    222                 //  'location' => array( 'index.php' ),
    223                 //  'capability' => GT_ADMIN_GLANCES,
    224                 // ),
    225                 $prefix . '-give' => array(
    226                     'trigger' => true,
    227                     'time' => time() + 2592000,
    228                     'dismiss' => array( 'month' ),
    229                     'type' => '',
    230                     'content' => 'Is the <strong>Truth</strong> plugin working well for you? Please consider giving <a href="https://wordpress.org/support/plugin/truth/reviews/?rate=5#new-post" target="_blank"><i class="dashicons dashicons-star-filled"></i> a review</a>, <a href="https://twitter.com/intent/tweet/?url=https%3A%2F%2Fwordpress.org%2Fplugins%2Ftruth%2F" target="_blank"><i class="dashicons dashicons-twitter"></i> a tweet</a> or <a href="https://typewheel.xyz/give/?ref=Truth" target="_blank"><i class="dashicons dashicons-heart"></i> a donation</a> to encourage further development. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
     196        // Notice to show on plugin activation
     197        $activation_notice = array(
     198
     199        );
     200
     201        // Define the notices
     202        $typewheel_notices = array(
     203            $prefix . '-give' => array(
     204                'trigger' => true,
     205                'time' => time() + 2592000,
     206                'dismiss' => array( 'month' ),
     207                'type' => '',
     208                'content' => 'Is the <strong>Truth</strong> plugin working well for you? Please consider giving <a href="https://wordpress.org/support/plugin/truth/reviews/?rate=5#new-post" target="_blank"><i class="dashicons dashicons-star-filled"></i> a review</a>, <a href="https://twitter.com/intent/tweet/?url=https%3A%2F%2Fwordpress.org%2Fplugins%2Ftruth%2F" target="_blank"><i class="dashicons dashicons-twitter"></i> a tweet</a> or <a href="https://typewheel.xyz/give/?ref=Truth" target="_blank"><i class="dashicons dashicons-heart"></i> a donation</a> to encourage further development. Thanks! <a href="https://twitter.com/uamv/">@uamv</a>',
    231209                    'icon' => 'heart',
    232                     'style' => array( 'background-image' => 'linear-gradient( to bottom right, rgb(215, 215, 215), rgb(231, 211, 186) )', 'border-left-color' => '#3F3F3F' ),
     210                    'style' => array( 'background-image' => 'linear-gradient( to left, rgb(215, 215, 215), rgb(220, 213, 206) )', 'border-left-color' => '#3F3F3F' ),
    233211                    'location' => array( 'options-reading.php' ),
    234212                    'capability' => 'manage_options',
     
    239217            new Typewheel_Notice( $prefix, $typewheel_notices, $activation_notice );
    240218
    241     } // end display_plugin_notices
    242 }
    243 
    244 /**
    245  * Deletes activation marker so it can be displayed when the plugin is reinstalled or reactivated
    246  *
    247  * @since    1.0
    248  */
    249 function typewheel_truth_remove_activation_marker() {
    250 
    251     $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) );
    252 
    253     delete_option( $prefix . '_activated' );
    254 
    255 }
    256 register_deactivation_hook( dirname(__FILE__) . '/truth.php', 'typewheel_truth_remove_activation_marker' );
     219        } // end display_plugin_notices
     220    }
     221
     222    /**
     223    * Deletes activation marker so it can be displayed when the plugin is reinstalled or reactivated
     224    *
     225    * @since    1.0
     226    */
     227    function typewheel_truth_remove_activation_marker() {
     228
     229        $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) );
     230
     231        delete_option( $prefix . '_activated' );
     232
     233    }
     234    register_deactivation_hook( dirname(__FILE__) . '/truth.php', 'typewheel_truth_remove_activation_marker' );
  • truth/trunk/class-truth-notice.php

    r1468222 r2181143  
    11<?php
    22/**
    3  * The public Truth class
    4  */
     3* The public Truth class
     4*/
    55if ( ! class_exists( 'Truth_Notice' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth_Notice {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        public $notice = array();
    1717
    1818        /**
    19          * this is our constructor.
    20          * there are many like it, but this one is mine
    21          */
     19        * this is our constructor.
     20        * there are many like it, but this one is mine
     21        */
    2222        public function __construct( $notice ) {
    2323
     
    4848
    4949        /**
    50          * AJAX action target that authorizes plugin
    51          *
    52          * @since    0.0.1
    53          */
     50        * AJAX action target that authorizes plugin
     51        *
     52        * @since    0.0.1
     53        */
    5454        public function authorize_truth() {
    5555
     
    6161                $authorize = add_option( 'truth_authorization', true );
    6262
    63                     if ( $authorize ) {
     63                if ( $authorize ) {
    6464
    65                         $args = array(
    66                             'notice'  => 'truth-authorization-success',
    67                             'class'   => 'updated fade',
    68                             'message' => '<p>Thank you! Visit <code><a href="' . admin_url( 'options-reading.php#truth-engine' ) . '" data-security="' . wp_create_nonce( 'authorized-truth' ) . '">Settings > Reading</a></code> to customize <strong>(and save)</strong> your plugin settings.</p>',
    69                             'echo'    => false
    70                         );
     65                    $args = array(
     66                        'notice'  => 'truth-authorization-success',
     67                        'class'   => 'updated fade',
     68                        'message' => '<p>Thank you! Visit <code><a href="' . admin_url( 'options-reading.php#truth-engine' ) . '" data-security="' . wp_create_nonce( 'authorized-truth' ) . '">Settings > Reading</a></code> to customize <strong>(and save)</strong> your plugin settings.</p>',
     69                        'echo'    => false
     70                    );
    7171
    72                         $success = new Truth_Notice( $args );
     72                    $success = new Truth_Notice( $args );
    7373
    74                         $response['notice'] = $success->get();
    75                         $response['success'] = true;
     74                    $response['notice'] = $success->get();
     75                    $response['success'] = true;
    7676
    77                     } else {
     77                } else {
    7878
    79                         $args = array(
    80                             'notice'  => 'truth-authorization-failure',
    81                             'class'   => 'error',
    82                             'message' => 'Failed to authorize the Truth plugin. Please try again.',
    83                             'echo'    => false
    84                         );
     79                    $args = array(
     80                        'notice'  => 'truth-authorization-failure',
     81                        'class'   => 'error',
     82                        'message' => 'Failed to authorize the Truth plugin. Please try again.',
     83                        'echo'    => false
     84                    );
    8585
    86                         $failure = new Truth_Notice( $args );
    87                         $response['notice'] = $failure->get();
    88                         $response['success'] = false;
     86                    $failure = new Truth_Notice( $args );
     87                    $response['notice'] = $failure->get();
     88                    $response['success'] = false;
    8989
    90                     }
     90                }
    9191
    9292            } else {
     
    109109        }
    110110
    111     }
     111    }
    112112
    113113}
  • truth/trunk/class-truth-public.php

    r1917073 r2181143  
    11<?php
    22/**
    3  * The public Truth class
    4  */
     3* The public Truth class
     4*/
    55if ( ! class_exists( 'Truth_Public' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth_Public {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        static $instance = false;
    1717
    18         /**
    19          * Static property to hold our singleton instance
    20          * @var $instance
    21          */
    22         public $options = array();
    23 
    24         /**
    25          * Indexes all book names
    26          * @var $instance
    27          */
    28         public $index = array();
    29 
    30         /**
    31          * this is our constructor.
    32          * there are many like it, but this one is mine
    33          */
     18        /**
     19        * Static property to hold our singleton instance
     20        * @var $instance
     21        */
     22        public $options = array();
     23
     24        /**
     25        * Indexes all book names
     26        * @var $instance
     27        */
     28        public $index = array();
     29
     30        /**
     31        * this is our constructor.
     32        * there are many like it, but this one is mine
     33        */
    3434        private function __construct() {
    3535
    36             $this->options = get_option( 'truth_settings' );
     36            $this->options = get_option( 'truth_settings' );
    3737
    3838            add_action( 'wp_head', array( $this, 'insert_scripts' ) );
    3939
    40             if ( get_option('truth_authorization') && ! $this->options['disable_auto_links'] && 'youversion' == $this->options['engine'] ) {
     40            if ( get_option('truth_authorization') && ! $this->options['disable_auto_links'] && 'youversion' == $this->options['engine'] ) {
    4141
    4242                add_action( 'init', array( $this, 'create_index' ) );
    4343
    44                 add_filter( 'the_content', array( $this, 'search_content' ), 99, 2 );
    45                 add_filter( 'comment_text', array( $this, 'search_content' ), 99, 2 );
    46                 add_filter( 'widget_text', array( $this, 'search_content' ), 99, 2 );
    47 
    48             }
     44                add_filter( 'the_content', array( $this, 'search_content' ), 99, 2 );
     45                add_filter( 'comment_text', array( $this, 'search_content' ), 99, 2 );
     46                add_filter( 'widget_text', array( $this, 'search_content' ), 99, 2 );
     47
     48            }
    4949
    5050            add_shortcode( 'truth', array( $this, 'shortcode' ) );
     
    5353
    5454        /**
    55          * If an instance exists, this returns it.  If not, it creates one and
    56          * returns it.
    57          *
    58          * @return $instance
    59          */
     55        * If an instance exists, this returns it.  If not, it creates one and
     56        * returns it.
     57        *
     58        * @return $instance
     59        */
    6060        public static function get_instance() {
    6161            if ( ! self::$instance ) {
     
    6767
    6868        /**
    69          * Register the JavaScript for the front-end.
    70          *
    71          * @since    0.0.1
    72          */
    73         public function insert_scripts() {
     69        * Register the JavaScript for the front-end.
     70        *
     71        * @since    0.0.1
     72        */
     73        public function insert_scripts() {
    7474
    7575            if ( 'biblesorg_highlighter' == $this->options['engine'] ) {
     
    7878                $targetIDs = explode( ',', $this->options['biblesorg_highlighter']['target_ids'] );
    7979
    80                  ?>
     80                ?>
    8181
    8282                <script id="bw-highlighter-config" data-version="<?php echo $versionInfo['abbr']; ?>">
    83                 (function(w, d, s, e, id) {
    84                   w._bhparse = w._bhparse || [];
    85                   function l() {
    86                     if (d.getElementById(id)) return;
    87                     var n = d.createElement(s), x = d.getElementsByTagName(s)[0];
    88                     n.id = id; n.async = true; n.src = '//bibles.org/linker/js/client.js';
    89                     x.parentNode.insertBefore(n, x);
    90                   }
    91                   (w.attachEvent) ? w.attachEvent('on' + e, l) : w.addEventListener(e, l, false);
    92                 })(window, document, 'script', 'load', 'bw-highlighter-src');
     83                    (function(w, d, s, e, id) {
     84                        w._bhparse = w._bhparse || [];
     85                        function l() {
     86                            if (d.getElementById(id)) return;
     87                            var n = d.createElement(s), x = d.getElementsByTagName(s)[0];
     88                            n.id = id; n.async = true; n.src = '//bibles.org/linker/js/client.js';
     89                            x.parentNode.insertBefore(n, x);
     90                        }
     91                        (w.attachEvent) ? w.attachEvent('on' + e, l) : w.addEventListener(e, l, false);
     92                    })(window, document, 'script', 'load', 'bw-highlighter-src');
    9393                </script>
    9494                <?php if ( isset( $this->options['biblesorg_highlighter']['target_ids'] ) && '' != $this->options['biblesorg_highlighter']['target_ids'] ) { ?>
    95                     <script>
    96                         _bhparse.push(
    97                             <?php foreach ($targetIDs as $targetID) {
    98                                 echo "'" . $targetID . "',";
    99                             } ?>
    100                         );
    101                     </script>
     95                <script>
     96                    _bhparse.push(
     97                        <?php foreach ($targetIDs as $targetID) {
     98                            echo "'" . $targetID . "',";
     99                        } ?>
     100                    );
     101                </script>
    102102                <?php }
    103103            }
    104104
    105         }
     105        }
    106106
    107107        public function shortcode( $atts, $content = '' ) {
     
    110110
    111111                extract( shortcode_atts( array(
    112                         'version' => '',
    113                     ), $atts ) );
     112                    'version' => '',
     113                ), $atts ) );
    114114
    115115                $reference = $this->parse_verse( $content );
     
    121121                    switch ( $this->options['append_version'] ) {
    122122                        case 'none':
    123                             break;
     123                        break;
    124124                        case 'abbr':
    125                             $content .= ', ' . strtoupper( $bibleVersion['abbr'] );
    126                             break;
     125                        $content .= ', ' . strtoupper( $bibleVersion['abbr'] );
     126                        break;
    127127                        case 'full':
    128                             $content .= ', ' . $bibleVersion['name'];
    129                             break;
     128                        $content .= ', ' . $bibleVersion['name'];
     129                        break;
    130130                        default:
    131                             break;
     131                        break;
    132132                    }
    133133                    $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : '';
     
    144144
    145145        /**
    146          * Searches content for matches to reference regex
    147          * @param  string $content The content to be searched
    148          * @return string          The content after links have been added
    149          */
    150         public function search_content( $content ) {
    151 
    152             $pattern = apply_filters( 'truth_regex_pattern', '/([0-3Ii]{0,3}|Song of|First|Second|Third|1st|2nd|3rd|Primero|Segundo|Tercero|Segunda|Tercera)[ ]{0,1}[\p{L}.]{1,20} \\d{1,3}(?!\\d):{0,1}[\\d,]*-{0,1}\\d{1,3}(?!\\d):{0,1}[\\d,]*/u' );
    153 
    154             preg_match_all( $pattern, $content, $matches, PREG_OFFSET_CAPTURE );
    155 
    156             $content = $this->insert_links( $content, $matches );
    157 
    158             return $content;
    159 
    160         }
    161 
    162         public function insert_links( $content, $matches ) {
     146        * Searches content for matches to reference regex
     147        * @param  string $content The content to be searched
     148        * @return string          The content after links have been added
     149        */
     150        public function search_content( $content ) {
     151
     152            $pattern = apply_filters( 'truth_regex_pattern', '/([0-3Ii]{0,3}|Song of|First|Second|Third|1st|2nd|3rd|Primero|Segundo|Tercero|Segunda|Tercera)[ ]{0,1}[\p{L}.]{1,20} \\d{1,3}(?!\\d):{0,1}[\\d,]*-{0,1}\\d{1,3}(?!\\d):{0,1}[\\d,]*/u' );
     153
     154            preg_match_all( $pattern, $content, $matches, PREG_OFFSET_CAPTURE );
     155
     156            $content = $this->insert_links( $content, $matches );
     157
     158            return $content;
     159
     160        }
     161
     162        public function insert_links( $content, $matches ) {
    163163
    164164            // Loop through matches, beginning at last match and working forward in order to use position of match for replacement in string.
    165             for ( $i = count( $matches[0] ) - 1; $i >= 0 ; $i-- ) {
     165            for ( $i = count( $matches[0] ) - 1; $i >= 0 ; $i-- ) {
    166166
    167167                // Grab the matched string and position of the match
    168                 $match = $matches[0][ $i ][0];
    169                 $idx = $matches[0][ $i ][1];
     168                $match = $matches[0][ $i ][0];
     169                $idx = $matches[0][ $i ][1];
    170170
    171171                // Parse the match into [0] bookNumber, [1] chapterNumber, [2] verseNumber, [3] endChapterNumber, [4] endVerseNumber
    172                 $reference = $this->parse_verse( $match );
    173 
    174                 $truth_url = $this->get_verse_url( $reference );
    175 
    176                 if ( $truth_url != '' ) {
    177 
    178                     substr( $match, 0, 1) == ' ' ? $idx++ : FALSE;  //Make sure the $idx isn't thrown off when it trims
    179                     $match = trim( $match );
    180                     $before = substr( $content, 0, $idx );
    181                     $after = substr( $content, $idx + strlen( $match ), strlen( $content ) - $idx - strlen( $match ) );
    182                     $closeAnchor = strpos( $after, '</a' );
    183                     $openAnchor = strpos( $after, '<a' );
    184                     // is the following needed?
    185                     $insertLink = FALSE;
    186                     if ( $closeAnchor === FALSE && $openAnchor === FALSE ) {
    187                         $insertLink = TRUE;
    188                     } elseif ( $closeAnchor !== FALSE && $openAnchor !== FALSE && $closeAnchor > $openAnchor ) {
    189                         $insertLink = TRUE;
    190                     }
    191 
    192                     if ( $insertLink === TRUE ) {
    193                         $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : '';
    194                         $content = $before . '<a href="' . $truth_url . '" class="verseLink"' . $truth_target . '>' . $match . "</a>" . $after;
    195                     }
    196 
    197                 }
    198 
    199             }
    200 
    201             return $content;
    202 
    203         }
     172                $reference = $this->parse_verse( $match );
     173
     174                $truth_url = $this->get_verse_url( $reference );
     175
     176                if ( $truth_url != '' ) {
     177
     178                    substr( $match, 0, 1) == ' ' ? $idx++ : FALSE;  //Make sure the $idx isn't thrown off when it trims
     179                    $match = trim( $match );
     180                    $before = substr( $content, 0, $idx );
     181                    $after = substr( $content, $idx + strlen( $match ), strlen( $content ) - $idx - strlen( $match ) );
     182                    $closeAnchor = strpos( $after, '</a' );
     183                    $openAnchor = strpos( $after, '<a' );
     184                    // is the following needed?
     185                    $insertLink = FALSE;
     186                    if ( $closeAnchor === FALSE && $openAnchor === FALSE ) {
     187                        $insertLink = TRUE;
     188                    } elseif ( $closeAnchor !== FALSE && $openAnchor !== FALSE && $closeAnchor > $openAnchor ) {
     189                        $insertLink = TRUE;
     190                    }
     191
     192                    if ( $insertLink === TRUE ) {
     193                        $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : '';
     194                        $content = $before . '<a href="' . $truth_url . '" class="verseLink"' . $truth_target . '>' . $match . "</a>" . $after;
     195                    }
     196
     197                }
     198
     199            }
     200
     201            return $content;
     202
     203        }
    204204
    205205        public function get_bible_version( $bibleVersionID = '' ) {
     
    279279                'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
    280280                'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
    281             $bookPart = strtr( $bookPart, $replacement_array );
    282 
    283             $bookNumber = isset( $this->index[ $bookPart ] ) ? $this->index[ $bookPart ] : NULL;
    284 
    285             // Get Verses Part
    286             $versesPart = str_replace( $initialBookPart, '', $match );
    287             $versesPart = str_replace( ';', ',', $versesPart );
    288 
    289             $versesParts = explode( ',', $versesPart );
    290 
    291 
    292             $chapterNumber = (int) trim( substr( $firstSplit[0], $idx, strlen( $firstSplit[0] ) - $idx ) );
    293 
    294             $verseNumber = $endChapterNumber = $endVerseNumber = 0;
    295 
    296             $verseSplit = explode( '-', $firstSplit[1] );
    297 
    298             $verseNumber = $verseSplit[0];
    299 
    300             if ( count( $verseSplit ) > 1 ) {
    301                 $endSplit = explode( ':', $verseSplit[1] );
    302                 if (count( $endSplit ) == 1 ) {
    303                   $endVerseNumber = $endSplit[0];
    304                 } else {
    305                   $endChapterNumber = (int) $endSplit[0];
    306                   $endVerseNumber = (int) $endSplit[1];
    307                 }
    308             }
    309 
    310             return array(
    311                 'bookNumber'       => $bookNumber,
    312                 'chapterNumber'    => $chapterNumber,
    313                 'verseNumber'      => $verseNumber,
    314                 'endChapterNumber' => $endChapterNumber,
    315                 'endVerseNumber'   => $endVerseNumber
    316             );
    317 
    318         }
    319 
    320 
    321         public function create_index() {
    322 
    323             $books = array(
    324                 array(),
    325                 array('genesis','gen','ge','gn'),
    326                 array('exodus','exo','ex','exod','exodo'),
    327                 array('leviticus','lev','le','lv','levitico'),
    328                 array('numbers','num', 'nu', 'nm', 'nb'),
    329                 array('deuteronomy','deut','dt','deuteronomio'),
    330                 array('joshua','josh','jos','jsh','josue'),
    331                 array('judges','judg','jdg','jg','jdgs','jueces','jue','jc'),
    332                 array('ruth','rth','ru'),
    333                 array('1 samuel','1 sam','1 sa','1samuel','1s','i sa','1 sm','1sa','i sam','1sam','i samuel','1st samuel','first samuel'),
    334                 array('2 samuel','2 sam','2 sa','2s','ii sa','2 sm','2sa','ii sam','2sam','ii samuel','2samuel','2nd samuel','second samuel'),
    335                 array('1 kings','1 kgs','1 ki','1k','i kgs','1kgs','i ki','1ki','i kings','1kings','1st kgs','1st kings','first kings','first kgs','1kin','1 reyes','1 rey','1 re'),
    336                 array('2 kings','2 kgs','2 ki','2k','ii kgs','2kgs','ii ki','2ki','ii kings','2kings','2nd kgs','2nd kings','second kings','second kgs','2kin','2 reyes','2 rey','2 re'),
    337                 array('1 chronicles','1 chron','1 ch','i ch','1ch','1 chr','i chr','1chr','i chron','1chron','i chronicles','1chronicles','1st chronicles','first chronicles','1 cronicas','1 cro','1cr'),
    338                 array('2 chronicles','2 chron','2 ch','ii ch','2ch','ii chr','2chr','ii chron','2chron','ii chronicles','2chronicles','2nd chronicles','second chronicles','2 cronicas','2 cro','2cr'),
    339                 array('ezra','ezr','esdras','esd','es'),
    340                 array('nehemiah','neh','ne','nehemias'),
    341                 array('esther','esth','es','ester','est'),
    342                 array('job','jb'),
    343                 array('psalms','pslm','ps','psalm','psa','psm','pss','salmos','sal'),
    344                 array('proverbs','prov','pr','prv','pro','proverbios'),
    345                 array('ecclesiastes','eccles','ec','ecc','eclesiastes','ecl'),
    346                 array('song of solomon','song','so','song of songs','sos','son','cantar de los cantares','cant'),
    347                 array('isaiah','isa','is','isaias'),
    348                 array('jeremiah','jer','je','jr','jeremias'),
    349                 array('lamentations','lam','la','lamentaciones'),
    350                 array('ezekiel','ezek','eze','ezk','ezequiel','ezeq','ez'),
    351                 array('daniel','dan','da','dn'),
    352                 array('hosea','hos','ho','oseas','os'),
    353                 array('joel','joe','jl'),
    354                 array('amos','am'),
    355                 array('obadiah','obad','ob','abdias','abd'),
    356                 array('jonah','jnh','jon','jonas'),
    357                 array('micah','mic','miqueas','miq'),
    358                 array('nahum','nah','na','nahun'),
    359                 array('habakkuk','hab','habacuc'),
    360                 array('zephaniah','zeph','zep','zp','sofonias','sof'),
    361                 array('haggai','hag','hg','ageo','ag'),
    362                 array('zechariah','zech','zec','zc','zacarias','zac','za'),
    363                 array('malachi','mal','ml','malaquias'),
    364                 array('matthew','matt','mt','mat','mateo'),
    365                 array('mark','mrk','mk','mr','marcos','mc'),
    366                 array('luke','luk','lk','lucas','luc','lc'),
    367                 array('john','jn','jhn','juan'),
    368                 array('acts','ac','hechos de los apostoles','hech','hch'),
    369                 array('romans','rom','ro','rm','romanos'),
    370                 array('1 corinthians','1 cor','1 co','i co','1co','i cor','1cor','i corinthians','1corinthians','1st corinthians','first corinthians','1 corin','1 corintios'),
    371                 array('2 corinthians','2 cor','2 co','ii co','2co','ii cor','2cor','ii corinthians','2corinthians','2nd corinthians','second corinthians','2 corin','2 corintios'),
    372                 array('galatians','gal','ga','galatas'),
    373                 array('ephesians','ephes','eph','efesios','efes','ef'),
    374                 array('philippians','phil','php','filipenses','fil','flp'),
    375                 array('colossians','col','colosenses'),
    376                 array('1 thessalonians','1 thess','1 th','i th','1th','i thes','1thes','i thess','1thess','i thessalonians','1thessalonians','1st thessalonians','first thessalonians','1ts','1 tesalonicenses'),
    377                 array('2 thessalonians','2 thess','2 th','ii th','2th','ii thes','2thes','ii thess','2thess','ii thessalonians','2thessalonians','2nd thessalonians','second thessalonians','2ts','2 tesalonicenses'),
    378                 array('1 timothy','1 tim','1 ti','i ti','1ti','i tim','1tim','i timothy','1timothy','1st timothy','first timothy','1 timoteo'),
    379                 array('2 timothy','2 tim','2 ti','ii ti','2ti','ii tim','2tim','ii timothy','2timothy','2nd timothy','second timothy','2 timoteo'),
    380                 array('titus','tit','tito'),
    381                 array('philemon','philem','phm','filemon','filem','flm'),
    382                 array('hebrews','heb','hebreos'),
    383                 array('james','jas','jm','santiago','sant','stgo','st'),
    384                 array('1 peter','1 pet','1 pe','i pe','1pe','i pet','1pet','i pt','1 pt','1pt','i peter','1peter','1st peter','first peter','1 pedro'),
    385                 array('2 peter','2 pet','2 pe','ii pe','2pe','ii pet','2pet','ii pt','2 pt','2pt','ii peter','2peter','2nd peter','second peter','2 pedro'),
    386                 array('1 john','1 jn','i jn','1jn','i jo','1jo','i joh','1joh','i jhn','1 jhn','1jhn','i john','1john','1st john','first john','1 juan'),
    387                 array('2 john','2 jn','ii jn','2jn','ii jo','2jo','ii joh','2joh','ii jhn','2 jhn','2jhn','ii john','2john','2nd john','second john','2 juan'),
    388                 array('3 john','3 jn','iii jn','3jn','iii jo','3jo','iii joh','3joh','iii jhn','3 jhn','3jhn','iii john','3john','3rd john','third john','3 juan'),
    389                 array('jude','jud','judas','jds'),
    390                 array('revelation','rev','re','apocalipsis','apocalipsis (de juan)','apoc','ap'),
    391             );
    392 
    393             // Re-key array to start at 1
    394             unset( $books[0] );
    395 
    396             foreach ( $books as $key => $names ) {
    397                 foreach ( $names as $name ) {
    398                     $this->index[ $name ] = $key;
    399                 }
    400             }
    401 
    402         }
    403 
    404     }
    405 
    406 }
     281                $bookPart = strtr( $bookPart, $replacement_array );
     282
     283                $bookNumber = isset( $this->index[ $bookPart ] ) ? $this->index[ $bookPart ] : NULL;
     284
     285                // Get Verses Part
     286                $versesPart = str_replace( $initialBookPart, '', $match );
     287                $versesPart = str_replace( ';', ',', $versesPart );
     288
     289                $versesParts = explode( ',', $versesPart );
     290
     291
     292                $chapterNumber = (int) trim( substr( $firstSplit[0], $idx, strlen( $firstSplit[0] ) - $idx ) );
     293
     294                $verseNumber = $endChapterNumber = $endVerseNumber = 0;
     295
     296                $verseSplit = explode( '-', $firstSplit[1] );
     297
     298                $verseNumber = $verseSplit[0];
     299
     300                if ( count( $verseSplit ) > 1 ) {
     301                    $endSplit = explode( ':', $verseSplit[1] );
     302                    if (count( $endSplit ) == 1 ) {
     303                        $endVerseNumber = $endSplit[0];
     304                    } else {
     305                        $endChapterNumber = (int) $endSplit[0];
     306                        $endVerseNumber = (int) $endSplit[1];
     307                    }
     308                }
     309
     310                return array(
     311                    'bookNumber'       => $bookNumber,
     312                    'chapterNumber'    => $chapterNumber,
     313                    'verseNumber'      => $verseNumber,
     314                    'endChapterNumber' => $endChapterNumber,
     315                    'endVerseNumber'   => $endVerseNumber
     316                );
     317
     318            }
     319
     320
     321            public function create_index() {
     322
     323                $books = array(
     324                    array(),
     325                    array('genesis','gen','ge','gn'),
     326                    array('exodus','exo','ex','exod','exodo'),
     327                    array('leviticus','lev','le','lv','levitico'),
     328                    array('numbers','num', 'nu', 'nm', 'nb'),
     329                    array('deuteronomy','deut','dt','deuteronomio'),
     330                    array('joshua','josh','jos','jsh','josue'),
     331                    array('judges','judg','jdg','jg','jdgs','jueces','jue','jc'),
     332                    array('ruth','rth','ru'),
     333                    array('1 samuel','1 sam','1 sa','1samuel','1s','i sa','1 sm','1sa','i sam','1sam','i samuel','1st samuel','first samuel'),
     334                    array('2 samuel','2 sam','2 sa','2s','ii sa','2 sm','2sa','ii sam','2sam','ii samuel','2samuel','2nd samuel','second samuel'),
     335                    array('1 kings','1 kgs','1 ki','1k','i kgs','1kgs','i ki','1ki','i kings','1kings','1st kgs','1st kings','first kings','first kgs','1kin','1 reyes','1 rey','1 re'),
     336                    array('2 kings','2 kgs','2 ki','2k','ii kgs','2kgs','ii ki','2ki','ii kings','2kings','2nd kgs','2nd kings','second kings','second kgs','2kin','2 reyes','2 rey','2 re'),
     337                    array('1 chronicles','1 chron','1 ch','i ch','1ch','1 chr','i chr','1chr','i chron','1chron','i chronicles','1chronicles','1st chronicles','first chronicles','1 cronicas','1 cro','1cr'),
     338                    array('2 chronicles','2 chron','2 ch','ii ch','2ch','ii chr','2chr','ii chron','2chron','ii chronicles','2chronicles','2nd chronicles','second chronicles','2 cronicas','2 cro','2cr'),
     339                    array('ezra','ezr','esdras','esd','es'),
     340                    array('nehemiah','neh','ne','nehemias'),
     341                    array('esther','esth','es','ester','est'),
     342                    array('job','jb'),
     343                    array('psalms','pslm','ps','psalm','psa','psm','pss','salmos','sal'),
     344                    array('proverbs','prov','pr','prv','pro','proverbios'),
     345                    array('ecclesiastes','eccles','ec','ecc','eclesiastes','ecl'),
     346                    array('song of solomon','song','so','song of songs','sos','son','cantar de los cantares','cant'),
     347                    array('isaiah','isa','is','isaias'),
     348                    array('jeremiah','jer','je','jr','jeremias'),
     349                    array('lamentations','lam','la','lamentaciones'),
     350                    array('ezekiel','ezek','eze','ezk','ezequiel','ezeq','ez'),
     351                    array('daniel','dan','da','dn'),
     352                    array('hosea','hos','ho','oseas','os'),
     353                    array('joel','joe','jl'),
     354                    array('amos','am'),
     355                    array('obadiah','obad','ob','abdias','abd'),
     356                    array('jonah','jnh','jon','jonas'),
     357                    array('micah','mic','miqueas','miq'),
     358                    array('nahum','nah','na','nahun'),
     359                    array('habakkuk','hab','habacuc'),
     360                    array('zephaniah','zeph','zep','zp','sofonias','sof'),
     361                    array('haggai','hag','hg','ageo','ag'),
     362                    array('zechariah','zech','zec','zc','zacarias','zac','za'),
     363                    array('malachi','mal','ml','malaquias'),
     364                    array('matthew','matt','mt','mat','mateo'),
     365                    array('mark','mrk','mk','mr','marcos','mc'),
     366                    array('luke','luk','lk','lucas','luc','lc'),
     367                    array('john','jn','jhn','juan'),
     368                    array('acts','ac','hechos de los apostoles','hech','hch'),
     369                    array('romans','rom','ro','rm','romanos'),
     370                    array('1 corinthians','1 cor','1 co','i co','1co','i cor','1cor','i corinthians','1corinthians','1st corinthians','first corinthians','1 corin','1 corintios'),
     371                    array('2 corinthians','2 cor','2 co','ii co','2co','ii cor','2cor','ii corinthians','2corinthians','2nd corinthians','second corinthians','2 corin','2 corintios'),
     372                    array('galatians','gal','ga','galatas'),
     373                    array('ephesians','ephes','eph','efesios','efes','ef'),
     374                    array('philippians','phil','php','filipenses','fil','flp'),
     375                    array('colossians','col','colosenses'),
     376                    array('1 thessalonians','1 thess','1 th','i th','1th','i thes','1thes','i thess','1thess','i thessalonians','1thessalonians','1st thessalonians','first thessalonians','1ts','1 tesalonicenses'),
     377                    array('2 thessalonians','2 thess','2 th','ii th','2th','ii thes','2thes','ii thess','2thess','ii thessalonians','2thessalonians','2nd thessalonians','second thessalonians','2ts','2 tesalonicenses'),
     378                    array('1 timothy','1 tim','1 ti','i ti','1ti','i tim','1tim','i timothy','1timothy','1st timothy','first timothy','1 timoteo'),
     379                    array('2 timothy','2 tim','2 ti','ii ti','2ti','ii tim','2tim','ii timothy','2timothy','2nd timothy','second timothy','2 timoteo'),
     380                    array('titus','tit','tito'),
     381                    array('philemon','philem','phm','filemon','filem','flm'),
     382                    array('hebrews','heb','hebreos'),
     383                    array('james','jas','jm','santiago','sant','stgo','st'),
     384                    array('1 peter','1 pet','1 pe','i pe','1pe','i pet','1pet','i pt','1 pt','1pt','i peter','1peter','1st peter','first peter','1 pedro'),
     385                    array('2 peter','2 pet','2 pe','ii pe','2pe','ii pet','2pet','ii pt','2 pt','2pt','ii peter','2peter','2nd peter','second peter','2 pedro'),
     386                    array('1 john','1 jn','i jn','1jn','i jo','1jo','i joh','1joh','i jhn','1 jhn','1jhn','i john','1john','1st john','first john','1 juan'),
     387                    array('2 john','2 jn','ii jn','2jn','ii jo','2jo','ii joh','2joh','ii jhn','2 jhn','2jhn','ii john','2john','2nd john','second john','2 juan'),
     388                    array('3 john','3 jn','iii jn','3jn','iii jo','3jo','iii joh','3joh','iii jhn','3 jhn','3jhn','iii john','3john','3rd john','third john','3 juan'),
     389                    array('jude','jud','judas','jds'),
     390                    array('revelation','rev','re','apocalipsis','apocalipsis (de juan)','apoc','ap'),
     391                );
     392
     393                // Re-key array to start at 1
     394                unset( $books[0] );
     395
     396                foreach ( $books as $key => $names ) {
     397                    foreach ( $names as $name ) {
     398                        $this->index[ $name ] = $key;
     399                    }
     400                }
     401
     402            }
     403
     404        }
     405
     406    }
  • truth/trunk/class-truth.php

    r1468222 r2181143  
    11<?php
    22/**
    3  * The core Truth class
    4  */
     3* The core Truth class
     4*/
    55if ( ! class_exists( 'Truth' ) ) {
    66
    77    /**
    8      * lets get started
    9      */
     8    * lets get started
     9    */
    1010    class Truth {
    1111
    1212        /**
    13          * Static property to hold our singleton instance
    14          * @var $instance
    15          */
     13        * Static property to hold our singleton instance
     14        * @var $instance
     15        */
    1616        static $instance = false;
    1717
    1818        /**
    19          * this is our constructor.
    20          * there are many like it, but this one is mine
    21          */
     19        * this is our constructor.
     20        * there are many like it, but this one is mine
     21        */
    2222        private function __construct() {
    2323
     
    3333
    3434        /**
    35          * If an instance exists, this returns it.  If not, it creates one and
    36          * returns it.
    37          *
    38          * @return $instance
    39          */
     35        * If an instance exists, this returns it.  If not, it creates one and
     36        * returns it.
     37        *
     38        * @return $instance
     39        */
    4040        public static function get_instance() {
    4141            if ( ! self::$instance ) {
     
    4747
    4848        /**
    49          * Return supported version for Truth plugin
    50          * @return [type] [description]
    51          */
     49        * Return supported version for Truth plugin
     50        * @return [type] [description]
     51        */
    5252        public function get_sources() {
    5353
     
    7979                            'DHH' => array( 'name' => 'Biblia Dios Habla Hoy (sin notas ni ayudas)', 'abbr' => 'DHH' ),
    8080                            'RVR1960' => array( 'name' => 'Biblia Reina Valera 1960', 'abbr' => 'RVR1960' ),
    81                         ),             
     81                        ),
    8282                    )
    8383                ),
    8484                'youversion' => array(
    85                     'URLSingleVerse'  => 'http://bible.us/[id]/[book].[chapter].[verse].[version]',
    86                     'URLVerseRange'   => 'http://bible.us/[id]/[book].[chapter].[verse]-[endverse].[version]',
    87                     'URLSingleChapter'=> 'http://bible.us/[id]/[book].[chapter].[version]',
     85                    'URLSingleVerse'  => 'https://my.bible.com/[id]/[book].[chapter].[verse]',
     86                    'URLVerseRange'   => 'https://my.bible.com/[id]/[book].[chapter].[verse]-[endverse]',
     87                    'URLSingleChapter'=> 'https://my.bible.com/[id]/[book].[chapter]',
    8888                    'URLChapterRange' => '',
    8989                    'bookFind'        => array( 'song_of_solomon', ' ' ),
     
    116116                            '314' => array( 'name' => 'Tree of Life Bible', 'abbr' => 'tlv', 'id' => '314' ),
    117117                            '206' => array( 'name' => 'World English Bible', 'abbr' => 'web', 'id' => '206' ),
    118                             ),
     118                        ),
    119119                        'Español' => array(
    120120                            '28' => array( 'name' => 'La Palabra', 'abbr' => 'blph', 'id' => '28'),
     
    131131        }
    132132
    133     }
     133    }
    134134
    135135}
  • truth/trunk/js/truth-admin.js

    r1468222 r2181143  
    33
    44    /**
    5      * All of the code for your Dashboard-specific JavaScript source
    6      * should reside in this file.
    7      *
    8      * Note that this assume you're going to use jQuery, so it prepares
    9      * the $ function reference to be used within the scope of this
    10      * function.
    11      *
    12      * From here, you're able to define handlers for when the DOM is
    13      * ready:
    14      *
    15      * $(function() {
    16      *
    17      * });
    18      *
    19      * Or when the window is loaded:
    20      *
    21      * $( window ).load(function() {
    22      *
    23      * });
    24      *
    25      * ...and so on.
    26      *
    27      * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
    28      * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
    29      * be doing this, we should try to minimize doing that in our own work.
    30      */
     5    * All of the code for your Dashboard-specific JavaScript source
     6    * should reside in this file.
     7    *
     8    * Note that this assume you're going to use jQuery, so it prepares
     9    * the $ function reference to be used within the scope of this
     10    * function.
     11    *
     12    * From here, you're able to define handlers for when the DOM is
     13    * ready:
     14    *
     15    * $(function() {
     16        *
     17        * });
     18        *
     19        * Or when the window is loaded:
     20        *
     21        * $( window ).load(function() {
     22            *
     23            * });
     24            *
     25            * ...and so on.
     26            *
     27            * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
     28            * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
     29            * be doing this, we should try to minimize doing that in our own work.
     30            */
    3131
    32     // Toggle internal lable for site URL input
    33     $( document ).ready( function() {
     32            // Toggle internal lable for site URL input
     33            $( document ).ready( function() {
    3434
    35         /* Send ajax after add site click */
    36         $( document ).on( 'click', '#authorize-truth', function(){
     35                /* Send ajax after add site click */
     36                $( document ).on( 'click', '#authorize-truth', function(){
    3737
    38             $.post( TRUTH.ajaxurl, {
     38                    $.post( TRUTH.ajaxurl, {
    3939
    40                 action: 'authorize_truth',
    41                 truth_security: $(this).data('security'),
     40                        action: 'authorize_truth',
     41                        truth_security: $(this).data('security'),
    4242
    43             }, function (response) {
     43                    }, function (response) {
    4444
    45                 if ( response.success ) {
     45                        if ( response.success ) {
    4646
    47                     $('#truth-authorization').hide();
    48                     $('#truth-authorization').after(response.notice);
     47                            $('#truth-authorization').hide();
     48                            $('#truth-authorization').after(response.notice);
    4949
    50                 } else {
     50                        } else {
    5151
    52                     $('#truth-authorization').after(response.notice);
    53                     $('#truth-authorization-failure').delay(4000).slideUp();
     52                            $('#truth-authorization').after(response.notice);
     53                            $('#truth-authorization-failure').delay(4000).slideUp();
    5454
    55                 }
     55                        }
     56
     57                    });
     58
     59                });
     60
     61                // Modify UI on engine selection
     62                $('#truth-engine').change(function() {
     63
     64                    // Show/hide engine descriptors
     65                    $('span[id^="description-engine"]:not([id="description-engine-'+$(this).find(':selected').val()+'"])').hide();
     66                    $('span[id="description-engine-'+$(this).find(':selected').val()+'"]').show();
     67
     68                    // Change UI of engine options
     69                    $('fieldset[id^="truth-"][id$="-settings"]:not([id="truth-'+$(this).find(':selected').val()+'-settings"]):not([id="truth-general-settings"])').hide();
     70                    $('fieldset[id="truth-'+$(this).find(':selected').val()+'-settings"]').show();
     71
     72                });
    5673
    5774            });
    5875
    59         });
    60 
    61         // Modify UI on engine selection
    62         $('#truth-engine').change(function() {
    63 
    64             // Show/hide engine descriptors
    65             $('span[id^="description-engine"]:not([id="description-engine-'+$(this).find(':selected').val()+'"])').hide();
    66             $('span[id="description-engine-'+$(this).find(':selected').val()+'"]').show();
    67 
    68             // Change UI of engine options
    69             $('fieldset[id^="truth-"][id$="-settings"]:not([id="truth-'+$(this).find(':selected').val()+'-settings"]):not([id="truth-general-settings"])').hide();
    70             $('fieldset[id="truth-'+$(this).find(':selected').val()+'-settings"]').show();
    71 
    72         });
    73 
    74     });
    75 
    76 })( jQuery );
     76        })( jQuery );
  • truth/trunk/readme.txt

    r1917073 r2181143  
    44Tags: bible, scripture, truth, verse, version, youversion, passage, christian
    55Requires at least: 3.1
    6 Tested up to: 4.9
    7 Stable tag: trunk
     6Tested up to: 5.3
     7Stable tag: 2.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    103103== Changelog ==
    104104
     105= 2.3 =
     106* URL fix for YouVersion links
     107
    105108= 2.2 =
    106109* Added Bible Highlighter option to target specific DOM ids for instances when reference is not identified.
  • truth/trunk/truth.php

    r1917073 r2181143  
    55Description: Generates YouVersion links for Biblical scripture references
    66Author: Joshua Vandercar
    7 Version: 2.2
     7Version: 2.3
    88Requires WP: 3.6
    99Author URI: http://vandercar.net
     
    1111*/
    1212
    13 define( 'TRUTH_VERSION', '2.2' );
     13define( 'TRUTH_VERSION', '2.3' );
    1414define( 'TRUTH_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    1515define( 'TRUTH_DIR', plugin_dir_path( __FILE__ ) );
  • truth/trunk/typewheel-notice/class-typewheel-notice.php

    r1917073 r2181143  
    2121if ( ! class_exists( 'Typewheel_Notice' ) ) {
    2222    /**
    23      * Typewheel Notice Class
    24      *
    25      * Adds Typewheel notices to the WP admin
    26      *
    27      * @package Typewheel Notice
    28      * @author  UaMV
    29      */
     23    * Typewheel Notice Class
     24    *
     25    * Adds Typewheel notices to the WP admin
     26    *
     27    * @package Typewheel Notice
     28    * @author  UaMV
     29    */
    3030    class Typewheel_Notice {
    3131
    3232        /*---------------------------------------------------------------------------------*
    33          * Attributes
    34          *---------------------------------------------------------------------------------*/
    35 
    36         /**
    37          * Notices.
    38          *
    39          * @since    1.0
    40          *
    41          * @var      array
    42          */
     33        * Attributes
     34        *---------------------------------------------------------------------------------*/
     35
     36        /**
     37        * Notices.
     38        *
     39        * @since    1.0
     40        *
     41        * @var      array
     42        */
    4343        public $notices;
    4444
    4545        /**
    46          * User.
    47          *
    48          * @since    1.0
    49          *
    50          * @var      array
    51          */
     46        * User.
     47        *
     48        * @since    1.0
     49        *
     50        * @var      array
     51        */
    5252        public $user;
    5353
    5454        /**
    55          * Notices.
    56          *
    57          * @since    1.0
    58          *
    59          * @var      array
    60          */
     55        * Notices.
     56        *
     57        * @since    1.0
     58        *
     59        * @var      array
     60        */
    6161        public $prefix;
    6262
    6363        /*---------------------------------------------------------------------------------*
    64          * Constructor
    65          *---------------------------------------------------------------------------------*/
    66 
    67         /**
    68          * Initialize the plugin by setting localization, filters, and administration functions.
    69          *
    70          * @since     1.0
    71          */
     64        * Constructor
     65        *---------------------------------------------------------------------------------*/
     66
     67        /**
     68        * Initialize the plugin by setting localization, filters, and administration functions.
     69        *
     70        * @since     1.0
     71        */
    7272        public function __construct( $prefix, $notices = array(), $activation = array() ) {
    7373
     
    9999
    100100        /*---------------------------------------------------------------------------------*
    101          * Public Functions
    102          *---------------------------------------------------------------------------------*/
    103 
    104          /**
    105          * Check user and set/get notices
    106          *
    107          * @since    1.0
    108          */
    109         public function process_user() {
    110 
    111             $current_user = wp_get_current_user();
     101        * Public Functions
     102        *---------------------------------------------------------------------------------*/
     103
     104        /**
     105        * Check user and set/get notices
     106        *
     107        * @since    1.0
     108        */
     109        public function process_user() {
     110
     111            $current_user = wp_get_current_user();
    112112
    113113            $this->user['ID'] = $current_user->ID;
    114114
    115             // Get the notice options from the user
    116             $this->user['notices'] = get_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', true );
    117 
    118             // If not yet set, then set the usermeta as an array
     115            // Get the notice options from the user
     116            $this->user['notices'] = get_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', true );
     117
     118            // If not yet set, then set the usermeta as an array
    119119            if ( '' == $this->user['notices'] ) {
    120120                add_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', array(), true );
     
    133133            }
    134134
    135             // Create specific notices if they do not exist, otherwise set to current notice state
    136             foreach ( $this->notices as $notice => $args ) {
    137 
    138                 if ( ! isset( $this->user['notices'][ $notice ] ) ) {
    139 
    140                     $this->user['notices'][ $notice ] = array(
    141                         'trigger' => $args['trigger'],
    142                         'time'    => $args['time'],
    143                         );
    144 
    145                 }
    146 
    147             }
    148 
    149             // Update the user meta
    150             update_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', $this->user['notices'] );
     135            // Create specific notices if they do not exist, otherwise set to current notice state
     136            foreach ( $this->notices as $notice => $args ) {
     137
     138                if ( ! isset( $this->user['notices'][ $notice ] ) ) {
     139
     140                    $this->user['notices'][ $notice ] = array(
     141                        'trigger' => $args['trigger'],
     142                        'time'    => $args['time'],
     143                    );
     144
     145                }
     146
     147            }
     148
     149            // Update the user meta
     150            update_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', $this->user['notices'] );
    151151
    152152        }
    153153
    154154        /**
    155          * Displays active plugin notices.
    156          *
    157          * @since    1.0
    158          */
     155        * Displays active plugin notices.
     156        *
     157        * @since    1.0
     158        */
    159159        public function display() {
    160160
     
    178178                    // Assemble the notice
    179179                    $html .= '<div id="' . $notice . '-typewheel-notice" class="notice notice-' . $args['type'] . ' typewheel-notice' . '" style="' . esc_attr( $this->styles( $args['style'] ) ) . '">';
    180                         $html .= '<p>';
    181                             $html .= $this->get_dismissals( $notice, $args['dismiss'] );
    182                             $html .= isset( $args['icon'] ) && '' != $args['icon'] ? '<i class="dashicons dashicons-' . $args['icon'] . ' featured-icon"></i>' : '';
    183                             $html .= apply_filters( $notice . '_typewheel_notice_content', $args['content'], $notice );
    184                         $html .= '</p>';
     180                    $html .= '<p>';
     181                    $html .= $this->get_dismissals( $notice, $args['dismiss'] );
     182                    $html .= isset( $args['icon'] ) && '' != $args['icon'] ? '<i class="dashicons dashicons-' . $args['icon'] . ' featured-icon"></i>' : '';
     183                    $html .= apply_filters( $notice . '_typewheel_notice_content', $args['content'], $notice );
     184                    $html .= '</p>';
    185185                    $html .= '</div>';
    186186
     
    194194
    195195        /**
    196          * Displays activation notice.
    197          *
    198          * @since    1.0
    199          */
     196        * Displays activation notice.
     197        *
     198        * @since    1.0
     199        */
    200200        public function display_activation() {
    201201
     
    210210                // Assemble notice
    211211                $html = '<div id="activation-typewheel-notice" class="notice notice-info typewheel-notice' . '" style="' . esc_attr( $this->styles( $this->activation['style'] ) ) . '">';
    212                     $html .= '<p>';
    213                         $html .= isset( $this->activation['icon'] ) && '' != $this->activation['icon'] ? '<i class="dashicons dashicons-' . $this->activation['icon'] . ' featured-icon"></i>' : '';
    214                         $html .= apply_filters( 'activation_typewheel_notice_content', $this->activation['content'] );
    215                     $html .= '</p>';
     212                $html .= '<p>';
     213                $html .= isset( $this->activation['icon'] ) && '' != $this->activation['icon'] ? '<i class="dashicons dashicons-' . $this->activation['icon'] . ' featured-icon"></i>' : '';
     214                $html .= apply_filters( 'activation_typewheel_notice_content', $this->activation['content'] );
     215                $html .= '</p>';
    216216                $html .= '</div>';
    217217
     
    223223
    224224        /**
    225          * Assemble the styles from array or string
    226          *
    227          * @since    1.0
    228          */
     225        * Assemble the styles from array or string
     226        *
     227        * @since    1.0
     228        */
    229229        private function styles( $styles ) {
    230230
     
    250250
    251251        /**
    252          * Assemble and return any assigned dismissal notices
    253          *
    254          * @since    1.0
    255          */
     252        * Assemble and return any assigned dismissal notices
     253        *
     254        * @since    1.0
     255        */
    256256        public function get_dismissals( $notice, $dismiss ) {
    257257
     
    293293        switch ( $duration ) {
    294294            case 'week':
    295                 $user[ $notice ]['time'] = time() + 604800;
    296                 break;
     295            $user[ $notice ]['time'] = time() + 604800;
     296            break;
    297297            case 'month':
    298                 $user[ $notice ]['time'] = time() + 2592000;
    299                 break;
     298            $user[ $notice ]['time'] = time() + 2592000;
     299            break;
    300300            case 'forever':
    301301                $user[ $notice ]['trigger'] = FALSE;
    302302                break;
    303             case 'undismiss':
     303                case 'undismiss':
    304304                foreach ( $user as $name => $args ) {
    305305                    $user[ $name ]['trigger'] = TRUE;
     
    307307                }
    308308                break;
    309             default:
     309                default:
    310310                break;
     311            }
     312
     313            // Update the user meta
     314            update_user_meta( $userid, $plugin . '_typewheel_notices', $user );
     315
     316            $response = array( 'success' => true, 'notice' => $notice, 'plugin' => $plugin );
     317
     318            wp_send_json( $response );
     319
    311320        }
    312 
    313         // Update the user meta
    314         update_user_meta( $userid, $plugin . '_typewheel_notices', $user );
    315 
    316         $response = array( 'success' => true, 'notice' => $notice, 'plugin' => $plugin );
    317 
    318         wp_send_json( $response );
    319 
    320321    }
    321 }
  • truth/trunk/typewheel-notice/typewheel-notice.js

    r1917073 r2181143  
    11/**
    2  * Handles Typewheel Notice Dismissals
    3  */
    4  jQuery(document).ready(function($) {
     2* Handles Typewheel Notice Dismissals
     3*/
     4jQuery(document).ready(function($) {
    55
    6     $('span[id$="-typewheel-notice-dismissals"] i').click(
    7         function() {
    8             $.post(TypewheelNotice.ajaxurl, {
    9                 action: 'dismiss_notice',
    10                 typewheel_notice_duration: $(this).data('dismissal-duration'),
    11                 typewheel_notice: $(this).data('notice'),
    12                 typewheel_notice_plugin: $(this).data('plugin'),
    13                 typewheel_user: $(this).data('user'),
     6  $('span[id$="-typewheel-notice-dismissals"] i').click(
     7      function() {
     8        $.post(TypewheelNotice.ajaxurl, {
     9            action: 'dismiss_notice',
     10            typewheel_notice_duration: $(this).data('dismissal-duration'),
     11            typewheel_notice: $(this).data('notice'),
     12            typewheel_notice_plugin: $(this).data('plugin'),
     13            typewheel_user: $(this).data('user'),
    1414
    15             }, function (response) {
     15        }, function (response) {
    1616
    17                 if ( response.success ) {
     17            if ( response.success ) {
    1818
    19                     $('div#'+response.notice+'-typewheel-notice').slideUp();
     19              $('div#'+response.notice+'-typewheel-notice').slideUp();
    2020
    21                 }
    22             }
    23     )});
     21            }
     22        }
     23      )});
    2424
    25  });
     25   });
Note: See TracChangeset for help on using the changeset viewer.