Changeset 738340
- Timestamp:
- 07/09/2013 04:04:32 PM (13 years ago)
- Location:
- wp-glossary/trunk
- Files:
-
- 5 added
- 4 edited
-
ajax.php (added)
-
class/wpg-admin.class.php (modified) (1 diff)
-
class/wpg-shortcode-glossary.class.php (modified) (6 diffs)
-
class/wpg.class.php (modified) (2 diffs)
-
ext/jquery.qtip.css (added)
-
ext/jquery.qtip.js (added)
-
js/jquery.qtip2.js (added)
-
js/wp-glossary-qtip2.js (added)
-
wp-glossary.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-glossary/trunk/class/wpg-admin.class.php
r723484 r738340 113 113 'selected' => $qtipstyle, 114 114 'options' => array( 115 'off' => __('Off', WPG_TEXTDOMAIN), 116 'cream' => __('Cream', WPG_TEXTDOMAIN), 117 'dark' => __('Dark', WPG_TEXTDOMAIN), 118 'green' => __('Green', WPG_TEXTDOMAIN), 119 'light' => __('Light', WPG_TEXTDOMAIN), 120 'red' => __('Red', WPG_TEXTDOMAIN), 121 'blue' => __('Blue', WPG_TEXTDOMAIN) 115 'cream' => __('Cream', WPG_TEXTDOMAIN), 116 'dark' => __('Dark', WPG_TEXTDOMAIN), 117 'green' => __('Green', WPG_TEXTDOMAIN), 118 'light' => __('Light', WPG_TEXTDOMAIN), 119 'red' => __('Red', WPG_TEXTDOMAIN), 120 'blue' => __('Blue', WPG_TEXTDOMAIN), 121 'plain' => __('Plain', WPG_TEXTDOMAIN), 122 'bootstrap' => __('Bootstrap', WPG_TEXTDOMAIN), 123 'youtube' => __('YouTube', WPG_TEXTDOMAIN), 124 'tipsy' => __('Tipsy', WPG_TEXTDOMAIN), 122 125 ), 123 126 )); -
wp-glossary/trunk/class/wpg-shortcode-glossary.class.php
r723484 r738340 8 8 add_action( 'save_post', array(&$this, 'save_post_check_for_glossary_usage'), 10, 2 ); 9 9 add_action( 'get_header', array(&$this, 'glossary_usage_reset_for_post') ); 10 // add_action( 'shutdown', array(&$this, 'glossary_remove_update_marker') );11 10 add_action( 'wp_footer', array(&$this, 'glossary_remove_update_marker') ); 12 11 } … … 76 75 $wpg_glossary_count++; 77 76 78 // Global variable that tells WP to print related js files.79 $tcb_wpg_scripts = true;80 77 81 78 // Get WP Glossary options … … 85 82 $jsdata = array(); 86 83 84 error_log( "slug={$atts['slug']}" ); 87 85 // Let shortcode attributes override general settings 88 86 foreach( $glossary_options as $k => $v ): 89 87 if( isset($atts[$k]) ): 88 error_log( "$k = {$atts[$k]}" ); 90 89 $jsdata[] = 'data-' . $k . '="' . trim( esc_attr($atts[$k]) ) . '"'; 91 90 $glossary_options[$k] = trim( $atts[$k] ); … … 103 102 ), $atts) ); 104 103 105 // Set text to default content.104 // Set text to default to content. This allows syntax like: [glossary]Cheddar[/glossary] 106 105 if( empty($text) ) $text = $content; 106 error_log( "text=$text style={$qtipstyle} ttopt={$tooltip_option}" ); 107 107 108 108 $glossary = false; 109 109 110 // Trivial case110 // Find the term in the database 111 111 if( !empty($id) ): 112 112 $glossary = get_post( $id ); … … 128 128 if( empty($glossary) ) return $text; // No glossary term found. Return the original text. 129 129 130 // Term Usage 130 131 if( $termusage && $termusage == 'on' && !$wpg_doing_shortcode ): 131 132 if( get_post_meta( $post->ID, 'wpg_update_term_usage') ): … … 139 140 endif; 140 141 141 // setup_postdata( $glossary );142 // Get the term title, and use as default text to use for the shortcode 142 143 $title = get_the_title( $glossary->ID ); 144 if( empty($text) ) 145 $text = $title; 143 146 144 if( empty($text) ) $text = $title; // Glossary found, but no text supplied, so use the glossary term's title. 147 $link = $text; // Set to just plain text (used if 'none' linkopt set in settings) 148 if( $linkopt != 'none' ): 149 $href = apply_filters( 'wpg_term_link', get_post_permalink($glossary->ID) ); 150 $target = ($linkopt == 'blank') ? 'target="_blank"' : ''; 151 $link = '<a href="' . $href . '" ' . $target . ' title="' . esc_attr($title) . '">' . $text . '</a>'; 152 endif; 145 153 146 $href = apply_filters( 'wpg_term_link', get_post_permalink($glossary->ID) ); 147 $tooltip = ''; 148 $class = 'glossary-hover'; 149 switch( $tooltip_option ): 150 case 'full': 151 if( !$wpg_doing_shortcode ): 152 $wpg_doing_shortcode = true; 153 setup_postdata( $glossary ); 154 $tooltip = ($qtipstyle=='off') ? strip_tags($glossary->post_content) : apply_filters('the_content', $glossary->post_content); 155 wp_reset_postdata(); 156 $wpg_doing_shortcode = false; 157 endif; 158 break; 159 case 'excerpt': 160 if( !$wpg_doing_shortcode ): 161 $wpg_doing_shortcode = true; 162 setup_postdata( $glossary ); 163 $excerpt = apply_filters( 'get_the_excerpt', $glossary->post_excerpt ); 164 $tooltip = ($qtipstyle=='off') ? $excerpt : wpautop($excerpt); 165 wp_reset_postdata(); 166 $wpg_doing_shortcode = false; 167 endif; 168 break; 169 case 'off': 170 $class = 'glossary-term'; 171 break; 172 endswitch; 154 $span = '<span class="wp-glossary">' . $link . '</span>'; // Trivial default when tooltips switched off. 155 if( $tooltip_option != 'off' ): 156 // Global variable that tells WP to print related js files. 157 $tcb_wpg_scripts = true; 173 158 174 $target = ($linkopt == 'blank') ? 'target="_blank"' : ''; 175 $href = ($linkopt != 'none') ? 'href="'.$href.'"' : ''; 159 // qtip jquery data 160 $jsdata[] = 'data-termid="' . $glossary->ID . '"'; 161 $jsdata[] = 'data-content="' . $tooltip_option . '"'; 162 $jsdata[] = 'data-qtipstyle="' . $qtipstyle . '"'; 176 163 177 $link = '<a class="' . $class . '" '.$target.' '.$href.' title="' . esc_attr($tooltip) . '" '.implode(' ',$jsdata).'>' . $text . '</a>'; 178 //wp_reset_postdata(); 179 return '<span class="wp-glossary">' . $link . '</span>'; 164 // Span that qtip finds 165 $span = '<span class="wp-glossary wpg-tooltip" '.implode(' ',$jsdata).'>' . $link . '</span>'; 166 endif; 167 168 return $span; 180 169 } 181 170 } -
wp-glossary/trunk/class/wpg.class.php
r723484 r738340 71 71 $options = get_option( 'wp_glossary', array() ); 72 72 $qtipstyle = isset( $options['qtipstyle'] ) ? $options['qtipstyle']: 'cream'; 73 if( $qtipstyle != 'off' ): 74 wp_register_script( 'jquery-tooltip', $this->base_url() . '/ext/qtip.js', array('jquery') ); 75 wp_register_script( 'wp-glossary-js', $this->base_url() . '/js/wp-glossary-qtip.js', array('jquery-tooltip') ); 76 // qTip localisation settings 77 wp_localize_script( 'wp-glossary-js', 'WPG', array( 78 'admin_ajax' => admin_url('admin-ajax.php'), 79 'qtipstyle' => $qtipstyle, 80 ) ); 81 else: 82 wp_register_script( 'jquery-tooltip', $this->base_url() . '/js/jquery.tools.min.js', array('jquery') ); 83 wp_register_script( 'wp-glossary-js', $this->base_url() . '/js/wp-glossary.js', array('jquery-tooltip') ); 84 endif; 73 //wp_register_script( 'jquery-tooltip', $this->base_url() . '/ext/qtip.js', array('jquery') ); 74 wp_register_script( 'jquery-tooltip', $this->base_url() . '/ext/jquery.qtip.js', array('jquery') ); 75 wp_register_script( 'wp-glossary-js', $this->base_url() . '/js/wp-glossary-qtip2.js', array('jquery-tooltip') ); 76 // qTip localisation settings 77 wp_localize_script( 'wp-glossary-js', 'WPG', array( 78 'admin_ajax' => admin_url('admin-ajax.php'), 79 'qtipstyle' => $qtipstyle, 80 ) ); 85 81 86 82 wp_register_script( 'simple-ajax', $this->base_url() . '/js/simple-ajax-form.js', array('jquery-form') ); … … 101 97 wp_enqueue_style( 'wp-glossary-css', $this->base_url() . '/css/wp-glossary.css' ); 102 98 endif; 99 wp_enqueue_style( 'wp-glossary-qtip-css', $this->base_url() . '/ext/jquery.qtip.css' ); 103 100 } 104 101 -
wp-glossary/trunk/wp-glossary.php
r723484 r738340 5 5 * Description: Build a glossary of terms and link your post content to it. 6 6 * Author: TCBarrett 7 * Version: 2.4.17 * Version: 3.0-alpha 8 8 * Author URI: http://www.tcbarrett.com/ 9 9 * Text Domain: wp-glossary … … 19 19 require_once( dirname(__FILE__) . '/class/wpg-admin.class.php' ); 20 20 require_once( dirname(__FILE__) . '/fn-lib.php' ); 21 require_once( dirname(__FILE__) . '/ajax.php' ); 21 22 22 23 new WPG( dirname(__FILE__) );
Note: See TracChangeset
for help on using the changeset viewer.