Changeset 2181143
- Timestamp:
- 10/28/2019 12:56:26 AM (6 years ago)
- Location:
- truth
- Files:
-
- 18 edited
- 1 copied
-
tags/2.3 (copied) (copied from truth/trunk)
-
tags/2.3/class-truth-admin.php (modified) (6 diffs)
-
tags/2.3/class-truth-notice.php (modified) (4 diffs)
-
tags/2.3/class-truth-public.php (modified) (8 diffs)
-
tags/2.3/class-truth.php (modified) (6 diffs)
-
tags/2.3/js/truth-admin.js (modified) (1 diff)
-
tags/2.3/readme.txt (modified) (2 diffs)
-
tags/2.3/truth.php (modified) (2 diffs)
-
tags/2.3/typewheel-notice/class-typewheel-notice.php (modified) (10 diffs)
-
tags/2.3/typewheel-notice/typewheel-notice.js (modified) (1 diff)
-
trunk/class-truth-admin.php (modified) (6 diffs)
-
trunk/class-truth-notice.php (modified) (4 diffs)
-
trunk/class-truth-public.php (modified) (8 diffs)
-
trunk/class-truth.php (modified) (6 diffs)
-
trunk/js/truth-admin.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/truth.php (modified) (2 diffs)
-
trunk/typewheel-notice/class-typewheel-notice.php (modified) (10 diffs)
-
trunk/typewheel-notice/typewheel-notice.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
truth/tags/2.3/class-truth-admin.php
r1917073 r2181143 1 1 <?php 2 2 /** 3 * The admin Truth class4 */3 * The admin Truth class 4 */ 5 5 if ( ! class_exists( 'Truth_Admin' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth_Admin { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 static $instance = false; 17 17 18 /**19 * Static property to hold our singleton instance20 * @var $instance21 */18 /** 19 * Static property to hold our singleton instance 20 * @var $instance 21 */ 22 22 public $options = array(); 23 23 24 24 /** 25 * this is our constructor.26 * there are many like it, but this one is mine27 */25 * this is our constructor. 26 * there are many like it, but this one is mine 27 */ 28 28 private function __construct() { 29 29 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 JavaScript37 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' ) ); 38 38 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 39 39 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 and56 * returns it.57 *58 * @return $instance59 */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 */ 60 60 public static function get_instance() { 61 61 if ( ! self::$instance ) { … … 66 66 } 67 67 68 /**69 * Register the stylesheets.70 *71 * @since 0.0.172 */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.183 */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(); 120 120 121 121 foreach ( $sources as $source => $data ) { … … 125 125 } 126 126 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> <?php145 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> 151 151 152 152 <fieldset id="truth-youversion-settings" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>> … … 163 163 <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> 164 164 <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 <?php174 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 } 178 178 179 179 } … … 186 186 add_action( 'admin_notices', 'typewheel_truth_notices' ); 187 187 /** 188 * Displays a plugin notices189 *190 * @since 1.0191 */188 * Displays a plugin notices 189 * 190 * @since 1.0 191 */ 192 192 function typewheel_truth_notices() { 193 193 194 194 $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) ); 195 195 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>', 231 209 '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' ), 233 211 'location' => array( 'options-reading.php' ), 234 212 'capability' => 'manage_options', … … 239 217 new Typewheel_Notice( $prefix, $typewheel_notices, $activation_notice ); 240 218 241 } // end display_plugin_notices242 }243 244 /**245 * Deletes activation marker so it can be displayed when the plugin is reinstalled or reactivated246 *247 * @since 1.0248 */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 1 1 <?php 2 2 /** 3 * The public Truth class4 */3 * The public Truth class 4 */ 5 5 if ( ! class_exists( 'Truth_Notice' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth_Notice { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 public $notice = array(); 17 17 18 18 /** 19 * this is our constructor.20 * there are many like it, but this one is mine21 */19 * this is our constructor. 20 * there are many like it, but this one is mine 21 */ 22 22 public function __construct( $notice ) { 23 23 … … 48 48 49 49 /** 50 * AJAX action target that authorizes plugin51 *52 * @since 0.0.153 */50 * AJAX action target that authorizes plugin 51 * 52 * @since 0.0.1 53 */ 54 54 public function authorize_truth() { 55 55 … … 61 61 $authorize = add_option( 'truth_authorization', true ); 62 62 63 if ( $authorize ) {63 if ( $authorize ) { 64 64 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' => false70 );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 ); 71 71 72 $success = new Truth_Notice( $args );72 $success = new Truth_Notice( $args ); 73 73 74 $response['notice'] = $success->get();75 $response['success'] = true;74 $response['notice'] = $success->get(); 75 $response['success'] = true; 76 76 77 } else {77 } else { 78 78 79 $args = array(80 'notice' => 'truth-authorization-failure',81 'class' => 'error',82 'message' => 'Failed to authorize the Truth plugin. Please try again.',83 'echo' => false84 );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 ); 85 85 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; 89 89 90 }90 } 91 91 92 92 } else { … … 109 109 } 110 110 111 }111 } 112 112 113 113 } -
truth/tags/2.3/class-truth-public.php
r1917073 r2181143 1 1 <?php 2 2 /** 3 * The public Truth class4 */3 * The public Truth class 4 */ 5 5 if ( ! class_exists( 'Truth_Public' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth_Public { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 static $instance = false; 17 17 18 /**19 * Static property to hold our singleton instance20 * @var $instance21 */22 public $options = array();23 24 /** 25 * Indexes all book names26 * @var $instance27 */28 public $index = array();29 30 /** 31 * this is our constructor.32 * there are many like it, but this one is mine33 */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 */ 34 34 private function __construct() { 35 35 36 $this->options = get_option( 'truth_settings' );36 $this->options = get_option( 'truth_settings' ); 37 37 38 38 add_action( 'wp_head', array( $this, 'insert_scripts' ) ); 39 39 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'] ) { 41 41 42 42 add_action( 'init', array( $this, 'create_index' ) ); 43 43 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 } 49 49 50 50 add_shortcode( 'truth', array( $this, 'shortcode' ) ); … … 53 53 54 54 /** 55 * If an instance exists, this returns it. If not, it creates one and56 * returns it.57 *58 * @return $instance59 */55 * If an instance exists, this returns it. If not, it creates one and 56 * returns it. 57 * 58 * @return $instance 59 */ 60 60 public static function get_instance() { 61 61 if ( ! self::$instance ) { … … 67 67 68 68 /** 69 * Register the JavaScript for the front-end.70 *71 * @since 0.0.172 */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() { 74 74 75 75 if ( 'biblesorg_highlighter' == $this->options['engine'] ) { … … 78 78 $targetIDs = explode( ',', $this->options['biblesorg_highlighter']['target_ids'] ); 79 79 80 ?>80 ?> 81 81 82 82 <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'); 93 93 </script> 94 94 <?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> 102 102 <?php } 103 103 } 104 104 105 }105 } 106 106 107 107 public function shortcode( $atts, $content = '' ) { … … 110 110 111 111 extract( shortcode_atts( array( 112 'version' => '',113 ), $atts ) );112 'version' => '', 113 ), $atts ) ); 114 114 115 115 $reference = $this->parse_verse( $content ); … … 121 121 switch ( $this->options['append_version'] ) { 122 122 case 'none': 123 break;123 break; 124 124 case 'abbr': 125 $content .= ', ' . strtoupper( $bibleVersion['abbr'] );126 break;125 $content .= ', ' . strtoupper( $bibleVersion['abbr'] ); 126 break; 127 127 case 'full': 128 $content .= ', ' . $bibleVersion['name'];129 break;128 $content .= ', ' . $bibleVersion['name']; 129 break; 130 130 default: 131 break;131 break; 132 132 } 133 133 $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : ''; … … 144 144 145 145 /** 146 * Searches content for matches to reference regex147 * @param string $content The content to be searched148 * @return string The content after links have been added149 */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 ) { 163 163 164 164 // 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-- ) { 166 166 167 167 // 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]; 170 170 171 171 // 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 trims179 $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 } 204 204 205 205 public function get_bible_version( $bibleVersionID = '' ) { … … 279 279 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 280 280 'ö'=>'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 Part286 $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' => $endVerseNumber316 );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 1394 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 1 1 <?php 2 2 /** 3 * The core Truth class4 */3 * The core Truth class 4 */ 5 5 if ( ! class_exists( 'Truth' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 static $instance = false; 17 17 18 18 /** 19 * this is our constructor.20 * there are many like it, but this one is mine21 */19 * this is our constructor. 20 * there are many like it, but this one is mine 21 */ 22 22 private function __construct() { 23 23 … … 33 33 34 34 /** 35 * If an instance exists, this returns it. If not, it creates one and36 * returns it.37 *38 * @return $instance39 */35 * If an instance exists, this returns it. If not, it creates one and 36 * returns it. 37 * 38 * @return $instance 39 */ 40 40 public static function get_instance() { 41 41 if ( ! self::$instance ) { … … 47 47 48 48 /** 49 * Return supported version for Truth plugin50 * @return [type] [description]51 */49 * Return supported version for Truth plugin 50 * @return [type] [description] 51 */ 52 52 public function get_sources() { 53 53 … … 79 79 'DHH' => array( 'name' => 'Biblia Dios Habla Hoy (sin notas ni ayudas)', 'abbr' => 'DHH' ), 80 80 'RVR1960' => array( 'name' => 'Biblia Reina Valera 1960', 'abbr' => 'RVR1960' ), 81 ), 81 ), 82 82 ) 83 83 ), 84 84 '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]', 88 88 'URLChapterRange' => '', 89 89 'bookFind' => array( 'song_of_solomon', ' ' ), … … 116 116 '314' => array( 'name' => 'Tree of Life Bible', 'abbr' => 'tlv', 'id' => '314' ), 117 117 '206' => array( 'name' => 'World English Bible', 'abbr' => 'web', 'id' => '206' ), 118 ),118 ), 119 119 'Español' => array( 120 120 '28' => array( 'name' => 'La Palabra', 'abbr' => 'blph', 'id' => '28'), … … 131 131 } 132 132 133 }133 } 134 134 135 135 } -
truth/tags/2.3/js/truth-admin.js
r1468222 r2181143 3 3 4 4 /** 5 * All of the code for your Dashboard-specific JavaScript source6 * should reside in this file.7 *8 * Note that this assume you're going to use jQuery, so it prepares9 * the $ function reference to be used within the scope of this10 * function.11 *12 * From here, you're able to define handlers for when the DOM is13 * 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 handler28 * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may29 * 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 */ 31 31 32 // Toggle internal lable for site URL input33 $( document ).ready( function() {32 // Toggle internal lable for site URL input 33 $( document ).ready( function() { 34 34 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(){ 37 37 38 $.post( TRUTH.ajaxurl, {38 $.post( TRUTH.ajaxurl, { 39 39 40 action: 'authorize_truth',41 truth_security: $(this).data('security'),40 action: 'authorize_truth', 41 truth_security: $(this).data('security'), 42 42 43 }, function (response) {43 }, function (response) { 44 44 45 if ( response.success ) {45 if ( response.success ) { 46 46 47 $('#truth-authorization').hide();48 $('#truth-authorization').after(response.notice);47 $('#truth-authorization').hide(); 48 $('#truth-authorization').after(response.notice); 49 49 50 } else {50 } else { 51 51 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(); 54 54 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 }); 56 73 57 74 }); 58 75 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 4 4 Tags: bible, scripture, truth, verse, version, youversion, passage, christian 5 5 Requires at least: 3.1 6 Tested up to: 4.97 Stable tag: trunk6 Tested up to: 5.3 7 Stable tag: 2.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 103 103 == Changelog == 104 104 105 = 2.3 = 106 * URL fix for YouVersion links 107 105 108 = 2.2 = 106 109 * Added Bible Highlighter option to target specific DOM ids for instances when reference is not identified. -
truth/tags/2.3/truth.php
r1917073 r2181143 5 5 Description: Generates YouVersion links for Biblical scripture references 6 6 Author: Joshua Vandercar 7 Version: 2. 27 Version: 2.3 8 8 Requires WP: 3.6 9 9 Author URI: http://vandercar.net … … 11 11 */ 12 12 13 define( 'TRUTH_VERSION', '2. 2' );13 define( 'TRUTH_VERSION', '2.3' ); 14 14 define( 'TRUTH_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 15 15 define( 'TRUTH_DIR', plugin_dir_path( __FILE__ ) ); -
truth/tags/2.3/typewheel-notice/class-typewheel-notice.php
r1917073 r2181143 21 21 if ( ! class_exists( 'Typewheel_Notice' ) ) { 22 22 /** 23 * Typewheel Notice Class24 *25 * Adds Typewheel notices to the WP admin26 *27 * @package Typewheel Notice28 * @author UaMV29 */23 * Typewheel Notice Class 24 * 25 * Adds Typewheel notices to the WP admin 26 * 27 * @package Typewheel Notice 28 * @author UaMV 29 */ 30 30 class Typewheel_Notice { 31 31 32 32 /*---------------------------------------------------------------------------------* 33 * Attributes34 *---------------------------------------------------------------------------------*/35 36 /** 37 * Notices.38 *39 * @since 1.040 *41 * @var array42 */33 * Attributes 34 *---------------------------------------------------------------------------------*/ 35 36 /** 37 * Notices. 38 * 39 * @since 1.0 40 * 41 * @var array 42 */ 43 43 public $notices; 44 44 45 45 /** 46 * User.47 *48 * @since 1.049 *50 * @var array51 */46 * User. 47 * 48 * @since 1.0 49 * 50 * @var array 51 */ 52 52 public $user; 53 53 54 54 /** 55 * Notices.56 *57 * @since 1.058 *59 * @var array60 */55 * Notices. 56 * 57 * @since 1.0 58 * 59 * @var array 60 */ 61 61 public $prefix; 62 62 63 63 /*---------------------------------------------------------------------------------* 64 * Constructor65 *---------------------------------------------------------------------------------*/66 67 /** 68 * Initialize the plugin by setting localization, filters, and administration functions.69 *70 * @since 1.071 */64 * Constructor 65 *---------------------------------------------------------------------------------*/ 66 67 /** 68 * Initialize the plugin by setting localization, filters, and administration functions. 69 * 70 * @since 1.0 71 */ 72 72 public function __construct( $prefix, $notices = array(), $activation = array() ) { 73 73 … … 99 99 100 100 /*---------------------------------------------------------------------------------* 101 * Public Functions102 *---------------------------------------------------------------------------------*/103 104 /**105 * Check user and set/get notices106 *107 * @since 1.0108 */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(); 112 112 113 113 $this->user['ID'] = $current_user->ID; 114 114 115 // Get the notice options from the user116 $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 array115 // 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 119 119 if ( '' == $this->user['notices'] ) { 120 120 add_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', array(), true ); … … 133 133 } 134 134 135 // Create specific notices if they do not exist, otherwise set to current notice state136 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 meta150 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'] ); 151 151 152 152 } 153 153 154 154 /** 155 * Displays active plugin notices.156 *157 * @since 1.0158 */155 * Displays active plugin notices. 156 * 157 * @since 1.0 158 */ 159 159 public function display() { 160 160 … … 178 178 // Assemble the notice 179 179 $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>'; 185 185 $html .= '</div>'; 186 186 … … 194 194 195 195 /** 196 * Displays activation notice.197 *198 * @since 1.0199 */196 * Displays activation notice. 197 * 198 * @since 1.0 199 */ 200 200 public function display_activation() { 201 201 … … 210 210 // Assemble notice 211 211 $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>'; 216 216 $html .= '</div>'; 217 217 … … 223 223 224 224 /** 225 * Assemble the styles from array or string226 *227 * @since 1.0228 */225 * Assemble the styles from array or string 226 * 227 * @since 1.0 228 */ 229 229 private function styles( $styles ) { 230 230 … … 250 250 251 251 /** 252 * Assemble and return any assigned dismissal notices253 *254 * @since 1.0255 */252 * Assemble and return any assigned dismissal notices 253 * 254 * @since 1.0 255 */ 256 256 public function get_dismissals( $notice, $dismiss ) { 257 257 … … 293 293 switch ( $duration ) { 294 294 case 'week': 295 $user[ $notice ]['time'] = time() + 604800;296 break;295 $user[ $notice ]['time'] = time() + 604800; 296 break; 297 297 case 'month': 298 $user[ $notice ]['time'] = time() + 2592000;299 break;298 $user[ $notice ]['time'] = time() + 2592000; 299 break; 300 300 case 'forever': 301 301 $user[ $notice ]['trigger'] = FALSE; 302 302 break; 303 case 'undismiss':303 case 'undismiss': 304 304 foreach ( $user as $name => $args ) { 305 305 $user[ $name ]['trigger'] = TRUE; … … 307 307 } 308 308 break; 309 default:309 default: 310 310 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 311 320 } 312 313 // Update the user meta314 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 320 321 } 321 } -
truth/tags/2.3/typewheel-notice/typewheel-notice.js
r1917073 r2181143 1 1 /** 2 * Handles Typewheel Notice Dismissals3 */4 jQuery(document).ready(function($) {2 * Handles Typewheel Notice Dismissals 3 */ 4 jQuery(document).ready(function($) { 5 5 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'), 14 14 15 }, function (response) {15 }, function (response) { 16 16 17 if ( response.success ) {17 if ( response.success ) { 18 18 19 $('div#'+response.notice+'-typewheel-notice').slideUp();19 $('div#'+response.notice+'-typewheel-notice').slideUp(); 20 20 21 }22 }23 )});21 } 22 } 23 )}); 24 24 25 });25 }); -
truth/trunk/class-truth-admin.php
r1917073 r2181143 1 1 <?php 2 2 /** 3 * The admin Truth class4 */3 * The admin Truth class 4 */ 5 5 if ( ! class_exists( 'Truth_Admin' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth_Admin { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 static $instance = false; 17 17 18 /**19 * Static property to hold our singleton instance20 * @var $instance21 */18 /** 19 * Static property to hold our singleton instance 20 * @var $instance 21 */ 22 22 public $options = array(); 23 23 24 24 /** 25 * this is our constructor.26 * there are many like it, but this one is mine27 */25 * this is our constructor. 26 * there are many like it, but this one is mine 27 */ 28 28 private function __construct() { 29 29 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 JavaScript37 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' ) ); 38 38 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 39 39 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 and56 * returns it.57 *58 * @return $instance59 */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 */ 60 60 public static function get_instance() { 61 61 if ( ! self::$instance ) { … … 66 66 } 67 67 68 /**69 * Register the stylesheets.70 *71 * @since 0.0.172 */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.183 */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(); 120 120 121 121 foreach ( $sources as $source => $data ) { … … 125 125 } 126 126 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> <?php145 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> 151 151 152 152 <fieldset id="truth-youversion-settings" <?php echo 'youversion' == $this->options['engine'] ? '' : 'style="display:none;"'; ?>> … … 163 163 <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> 164 164 <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 <?php174 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 } 178 178 179 179 } … … 186 186 add_action( 'admin_notices', 'typewheel_truth_notices' ); 187 187 /** 188 * Displays a plugin notices189 *190 * @since 1.0191 */188 * Displays a plugin notices 189 * 190 * @since 1.0 191 */ 192 192 function typewheel_truth_notices() { 193 193 194 194 $prefix = str_replace( '-', '_', dirname( plugin_basename(__FILE__) ) ); 195 195 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>', 231 209 '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' ), 233 211 'location' => array( 'options-reading.php' ), 234 212 'capability' => 'manage_options', … … 239 217 new Typewheel_Notice( $prefix, $typewheel_notices, $activation_notice ); 240 218 241 } // end display_plugin_notices242 }243 244 /**245 * Deletes activation marker so it can be displayed when the plugin is reinstalled or reactivated246 *247 * @since 1.0248 */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 1 1 <?php 2 2 /** 3 * The public Truth class4 */3 * The public Truth class 4 */ 5 5 if ( ! class_exists( 'Truth_Notice' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth_Notice { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 public $notice = array(); 17 17 18 18 /** 19 * this is our constructor.20 * there are many like it, but this one is mine21 */19 * this is our constructor. 20 * there are many like it, but this one is mine 21 */ 22 22 public function __construct( $notice ) { 23 23 … … 48 48 49 49 /** 50 * AJAX action target that authorizes plugin51 *52 * @since 0.0.153 */50 * AJAX action target that authorizes plugin 51 * 52 * @since 0.0.1 53 */ 54 54 public function authorize_truth() { 55 55 … … 61 61 $authorize = add_option( 'truth_authorization', true ); 62 62 63 if ( $authorize ) {63 if ( $authorize ) { 64 64 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' => false70 );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 ); 71 71 72 $success = new Truth_Notice( $args );72 $success = new Truth_Notice( $args ); 73 73 74 $response['notice'] = $success->get();75 $response['success'] = true;74 $response['notice'] = $success->get(); 75 $response['success'] = true; 76 76 77 } else {77 } else { 78 78 79 $args = array(80 'notice' => 'truth-authorization-failure',81 'class' => 'error',82 'message' => 'Failed to authorize the Truth plugin. Please try again.',83 'echo' => false84 );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 ); 85 85 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; 89 89 90 }90 } 91 91 92 92 } else { … … 109 109 } 110 110 111 }111 } 112 112 113 113 } -
truth/trunk/class-truth-public.php
r1917073 r2181143 1 1 <?php 2 2 /** 3 * The public Truth class4 */3 * The public Truth class 4 */ 5 5 if ( ! class_exists( 'Truth_Public' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth_Public { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 static $instance = false; 17 17 18 /**19 * Static property to hold our singleton instance20 * @var $instance21 */22 public $options = array();23 24 /** 25 * Indexes all book names26 * @var $instance27 */28 public $index = array();29 30 /** 31 * this is our constructor.32 * there are many like it, but this one is mine33 */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 */ 34 34 private function __construct() { 35 35 36 $this->options = get_option( 'truth_settings' );36 $this->options = get_option( 'truth_settings' ); 37 37 38 38 add_action( 'wp_head', array( $this, 'insert_scripts' ) ); 39 39 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'] ) { 41 41 42 42 add_action( 'init', array( $this, 'create_index' ) ); 43 43 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 } 49 49 50 50 add_shortcode( 'truth', array( $this, 'shortcode' ) ); … … 53 53 54 54 /** 55 * If an instance exists, this returns it. If not, it creates one and56 * returns it.57 *58 * @return $instance59 */55 * If an instance exists, this returns it. If not, it creates one and 56 * returns it. 57 * 58 * @return $instance 59 */ 60 60 public static function get_instance() { 61 61 if ( ! self::$instance ) { … … 67 67 68 68 /** 69 * Register the JavaScript for the front-end.70 *71 * @since 0.0.172 */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() { 74 74 75 75 if ( 'biblesorg_highlighter' == $this->options['engine'] ) { … … 78 78 $targetIDs = explode( ',', $this->options['biblesorg_highlighter']['target_ids'] ); 79 79 80 ?>80 ?> 81 81 82 82 <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'); 93 93 </script> 94 94 <?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> 102 102 <?php } 103 103 } 104 104 105 }105 } 106 106 107 107 public function shortcode( $atts, $content = '' ) { … … 110 110 111 111 extract( shortcode_atts( array( 112 'version' => '',113 ), $atts ) );112 'version' => '', 113 ), $atts ) ); 114 114 115 115 $reference = $this->parse_verse( $content ); … … 121 121 switch ( $this->options['append_version'] ) { 122 122 case 'none': 123 break;123 break; 124 124 case 'abbr': 125 $content .= ', ' . strtoupper( $bibleVersion['abbr'] );126 break;125 $content .= ', ' . strtoupper( $bibleVersion['abbr'] ); 126 break; 127 127 case 'full': 128 $content .= ', ' . $bibleVersion['name'];129 break;128 $content .= ', ' . $bibleVersion['name']; 129 break; 130 130 default: 131 break;131 break; 132 132 } 133 133 $truth_target = $this->options['link_in_new_tab'] ? ' target="_blank"' : ''; … … 144 144 145 145 /** 146 * Searches content for matches to reference regex147 * @param string $content The content to be searched148 * @return string The content after links have been added149 */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 ) { 163 163 164 164 // 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-- ) { 166 166 167 167 // 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]; 170 170 171 171 // 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 trims179 $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 } 204 204 205 205 public function get_bible_version( $bibleVersionID = '' ) { … … 279 279 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 280 280 'ö'=>'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 Part286 $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' => $endVerseNumber316 );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 1394 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 1 1 <?php 2 2 /** 3 * The core Truth class4 */3 * The core Truth class 4 */ 5 5 if ( ! class_exists( 'Truth' ) ) { 6 6 7 7 /** 8 * lets get started9 */8 * lets get started 9 */ 10 10 class Truth { 11 11 12 12 /** 13 * Static property to hold our singleton instance14 * @var $instance15 */13 * Static property to hold our singleton instance 14 * @var $instance 15 */ 16 16 static $instance = false; 17 17 18 18 /** 19 * this is our constructor.20 * there are many like it, but this one is mine21 */19 * this is our constructor. 20 * there are many like it, but this one is mine 21 */ 22 22 private function __construct() { 23 23 … … 33 33 34 34 /** 35 * If an instance exists, this returns it. If not, it creates one and36 * returns it.37 *38 * @return $instance39 */35 * If an instance exists, this returns it. If not, it creates one and 36 * returns it. 37 * 38 * @return $instance 39 */ 40 40 public static function get_instance() { 41 41 if ( ! self::$instance ) { … … 47 47 48 48 /** 49 * Return supported version for Truth plugin50 * @return [type] [description]51 */49 * Return supported version for Truth plugin 50 * @return [type] [description] 51 */ 52 52 public function get_sources() { 53 53 … … 79 79 'DHH' => array( 'name' => 'Biblia Dios Habla Hoy (sin notas ni ayudas)', 'abbr' => 'DHH' ), 80 80 'RVR1960' => array( 'name' => 'Biblia Reina Valera 1960', 'abbr' => 'RVR1960' ), 81 ), 81 ), 82 82 ) 83 83 ), 84 84 '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]', 88 88 'URLChapterRange' => '', 89 89 'bookFind' => array( 'song_of_solomon', ' ' ), … … 116 116 '314' => array( 'name' => 'Tree of Life Bible', 'abbr' => 'tlv', 'id' => '314' ), 117 117 '206' => array( 'name' => 'World English Bible', 'abbr' => 'web', 'id' => '206' ), 118 ),118 ), 119 119 'Español' => array( 120 120 '28' => array( 'name' => 'La Palabra', 'abbr' => 'blph', 'id' => '28'), … … 131 131 } 132 132 133 }133 } 134 134 135 135 } -
truth/trunk/js/truth-admin.js
r1468222 r2181143 3 3 4 4 /** 5 * All of the code for your Dashboard-specific JavaScript source6 * should reside in this file.7 *8 * Note that this assume you're going to use jQuery, so it prepares9 * the $ function reference to be used within the scope of this10 * function.11 *12 * From here, you're able to define handlers for when the DOM is13 * 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 handler28 * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may29 * 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 */ 31 31 32 // Toggle internal lable for site URL input33 $( document ).ready( function() {32 // Toggle internal lable for site URL input 33 $( document ).ready( function() { 34 34 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(){ 37 37 38 $.post( TRUTH.ajaxurl, {38 $.post( TRUTH.ajaxurl, { 39 39 40 action: 'authorize_truth',41 truth_security: $(this).data('security'),40 action: 'authorize_truth', 41 truth_security: $(this).data('security'), 42 42 43 }, function (response) {43 }, function (response) { 44 44 45 if ( response.success ) {45 if ( response.success ) { 46 46 47 $('#truth-authorization').hide();48 $('#truth-authorization').after(response.notice);47 $('#truth-authorization').hide(); 48 $('#truth-authorization').after(response.notice); 49 49 50 } else {50 } else { 51 51 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(); 54 54 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 }); 56 73 57 74 }); 58 75 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 4 4 Tags: bible, scripture, truth, verse, version, youversion, passage, christian 5 5 Requires at least: 3.1 6 Tested up to: 4.97 Stable tag: trunk6 Tested up to: 5.3 7 Stable tag: 2.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 103 103 == Changelog == 104 104 105 = 2.3 = 106 * URL fix for YouVersion links 107 105 108 = 2.2 = 106 109 * Added Bible Highlighter option to target specific DOM ids for instances when reference is not identified. -
truth/trunk/truth.php
r1917073 r2181143 5 5 Description: Generates YouVersion links for Biblical scripture references 6 6 Author: Joshua Vandercar 7 Version: 2. 27 Version: 2.3 8 8 Requires WP: 3.6 9 9 Author URI: http://vandercar.net … … 11 11 */ 12 12 13 define( 'TRUTH_VERSION', '2. 2' );13 define( 'TRUTH_VERSION', '2.3' ); 14 14 define( 'TRUTH_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 15 15 define( 'TRUTH_DIR', plugin_dir_path( __FILE__ ) ); -
truth/trunk/typewheel-notice/class-typewheel-notice.php
r1917073 r2181143 21 21 if ( ! class_exists( 'Typewheel_Notice' ) ) { 22 22 /** 23 * Typewheel Notice Class24 *25 * Adds Typewheel notices to the WP admin26 *27 * @package Typewheel Notice28 * @author UaMV29 */23 * Typewheel Notice Class 24 * 25 * Adds Typewheel notices to the WP admin 26 * 27 * @package Typewheel Notice 28 * @author UaMV 29 */ 30 30 class Typewheel_Notice { 31 31 32 32 /*---------------------------------------------------------------------------------* 33 * Attributes34 *---------------------------------------------------------------------------------*/35 36 /** 37 * Notices.38 *39 * @since 1.040 *41 * @var array42 */33 * Attributes 34 *---------------------------------------------------------------------------------*/ 35 36 /** 37 * Notices. 38 * 39 * @since 1.0 40 * 41 * @var array 42 */ 43 43 public $notices; 44 44 45 45 /** 46 * User.47 *48 * @since 1.049 *50 * @var array51 */46 * User. 47 * 48 * @since 1.0 49 * 50 * @var array 51 */ 52 52 public $user; 53 53 54 54 /** 55 * Notices.56 *57 * @since 1.058 *59 * @var array60 */55 * Notices. 56 * 57 * @since 1.0 58 * 59 * @var array 60 */ 61 61 public $prefix; 62 62 63 63 /*---------------------------------------------------------------------------------* 64 * Constructor65 *---------------------------------------------------------------------------------*/66 67 /** 68 * Initialize the plugin by setting localization, filters, and administration functions.69 *70 * @since 1.071 */64 * Constructor 65 *---------------------------------------------------------------------------------*/ 66 67 /** 68 * Initialize the plugin by setting localization, filters, and administration functions. 69 * 70 * @since 1.0 71 */ 72 72 public function __construct( $prefix, $notices = array(), $activation = array() ) { 73 73 … … 99 99 100 100 /*---------------------------------------------------------------------------------* 101 * Public Functions102 *---------------------------------------------------------------------------------*/103 104 /**105 * Check user and set/get notices106 *107 * @since 1.0108 */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(); 112 112 113 113 $this->user['ID'] = $current_user->ID; 114 114 115 // Get the notice options from the user116 $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 array115 // 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 119 119 if ( '' == $this->user['notices'] ) { 120 120 add_user_meta( $this->user['ID'], $this->prefix . '_typewheel_notices', array(), true ); … … 133 133 } 134 134 135 // Create specific notices if they do not exist, otherwise set to current notice state136 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 meta150 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'] ); 151 151 152 152 } 153 153 154 154 /** 155 * Displays active plugin notices.156 *157 * @since 1.0158 */155 * Displays active plugin notices. 156 * 157 * @since 1.0 158 */ 159 159 public function display() { 160 160 … … 178 178 // Assemble the notice 179 179 $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>'; 185 185 $html .= '</div>'; 186 186 … … 194 194 195 195 /** 196 * Displays activation notice.197 *198 * @since 1.0199 */196 * Displays activation notice. 197 * 198 * @since 1.0 199 */ 200 200 public function display_activation() { 201 201 … … 210 210 // Assemble notice 211 211 $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>'; 216 216 $html .= '</div>'; 217 217 … … 223 223 224 224 /** 225 * Assemble the styles from array or string226 *227 * @since 1.0228 */225 * Assemble the styles from array or string 226 * 227 * @since 1.0 228 */ 229 229 private function styles( $styles ) { 230 230 … … 250 250 251 251 /** 252 * Assemble and return any assigned dismissal notices253 *254 * @since 1.0255 */252 * Assemble and return any assigned dismissal notices 253 * 254 * @since 1.0 255 */ 256 256 public function get_dismissals( $notice, $dismiss ) { 257 257 … … 293 293 switch ( $duration ) { 294 294 case 'week': 295 $user[ $notice ]['time'] = time() + 604800;296 break;295 $user[ $notice ]['time'] = time() + 604800; 296 break; 297 297 case 'month': 298 $user[ $notice ]['time'] = time() + 2592000;299 break;298 $user[ $notice ]['time'] = time() + 2592000; 299 break; 300 300 case 'forever': 301 301 $user[ $notice ]['trigger'] = FALSE; 302 302 break; 303 case 'undismiss':303 case 'undismiss': 304 304 foreach ( $user as $name => $args ) { 305 305 $user[ $name ]['trigger'] = TRUE; … … 307 307 } 308 308 break; 309 default:309 default: 310 310 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 311 320 } 312 313 // Update the user meta314 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 320 321 } 321 } -
truth/trunk/typewheel-notice/typewheel-notice.js
r1917073 r2181143 1 1 /** 2 * Handles Typewheel Notice Dismissals3 */4 jQuery(document).ready(function($) {2 * Handles Typewheel Notice Dismissals 3 */ 4 jQuery(document).ready(function($) { 5 5 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'), 14 14 15 }, function (response) {15 }, function (response) { 16 16 17 if ( response.success ) {17 if ( response.success ) { 18 18 19 $('div#'+response.notice+'-typewheel-notice').slideUp();19 $('div#'+response.notice+'-typewheel-notice').slideUp(); 20 20 21 }22 }23 )});21 } 22 } 23 )}); 24 24 25 });25 });
Note: See TracChangeset
for help on using the changeset viewer.