Plugin Directory

Changeset 738340


Ignore:
Timestamp:
07/09/2013 04:04:32 PM (13 years ago)
Author:
tcbarrett
Message:

Version: 3.0-alpha

Now uses qtip2
Now uses ajax to generate tooltips

Location:
wp-glossary/trunk
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp-glossary/trunk/class/wpg-admin.class.php

    r723484 r738340  
    113113            'selected' => $qtipstyle,
    114114            '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),
    122125            ),
    123126        ));
  • wp-glossary/trunk/class/wpg-shortcode-glossary.class.php

    r723484 r738340  
    88        add_action( 'save_post',  array(&$this, 'save_post_check_for_glossary_usage'), 10, 2 );
    99        add_action( 'get_header', array(&$this, 'glossary_usage_reset_for_post') );
    10 //      add_action( 'shutdown',   array(&$this, 'glossary_remove_update_marker') );
    1110        add_action( 'wp_footer',  array(&$this, 'glossary_remove_update_marker') );
    1211    }
     
    7675        $wpg_glossary_count++;
    7776
    78         // Global variable that tells WP to print related js files.
    79         $tcb_wpg_scripts = true;
    8077
    8178        // Get WP Glossary options
     
    8582        $jsdata = array();
    8683
     84error_log( "slug={$atts['slug']}" );
    8785        // Let shortcode attributes override general settings
    8886        foreach( $glossary_options as $k => $v ):
    8987            if( isset($atts[$k]) ):
     88error_log( "$k = {$atts[$k]}" );
    9089                $jsdata[] = 'data-' . $k . '="' . trim( esc_attr($atts[$k]) ) . '"';
    9190                $glossary_options[$k] = trim( $atts[$k] );
     
    103102        ), $atts) );
    104103
    105         // Set text to default content.
     104        // Set text to default to content. This allows syntax like: [glossary]Cheddar[/glossary]
    106105        if( empty($text) ) $text = $content;
     106error_log( "text=$text style={$qtipstyle} ttopt={$tooltip_option}" );
    107107
    108108        $glossary = false;
    109109   
    110         // Trivial case
     110        // Find the term in the database
    111111        if( !empty($id) ):
    112112            $glossary = get_post( $id );
     
    128128        if( empty($glossary) ) return $text; // No glossary term found. Return the original text.
    129129
     130        // Term Usage
    130131        if( $termusage && $termusage == 'on' && !$wpg_doing_shortcode ):
    131132            if( get_post_meta( $post->ID, 'wpg_update_term_usage') ):
     
    139140        endif;
    140141   
    141         //setup_postdata( $glossary );
     142        // Get the term title, and use as default text to use for the shortcode
    142143        $title = get_the_title( $glossary->ID );
     144        if( empty($text) )
     145            $text = $title;
    143146
    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;
    145153
    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;
    173158
    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 . '"';
    176163
    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;
    180169    }
    181170}
  • wp-glossary/trunk/class/wpg.class.php

    r723484 r738340  
    7171        $options   = get_option( 'wp_glossary', array() );
    7272        $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        ) );
    8581
    8682        wp_register_script( 'simple-ajax', $this->base_url() . '/js/simple-ajax-form.js', array('jquery-form') );
     
    10197            wp_enqueue_style( 'wp-glossary-css', $this->base_url() . '/css/wp-glossary.css' );
    10298        endif;
     99        wp_enqueue_style( 'wp-glossary-qtip-css', $this->base_url() . '/ext/jquery.qtip.css' );
    103100    }
    104101
  • wp-glossary/trunk/wp-glossary.php

    r723484 r738340  
    55 * Description: Build a glossary of terms and link your post content to it.
    66 * Author: TCBarrett
    7  * Version: 2.4.1
     7 * Version: 3.0-alpha
    88 * Author URI: http://www.tcbarrett.com/
    99 * Text Domain: wp-glossary
     
    1919require_once( dirname(__FILE__) . '/class/wpg-admin.class.php' );
    2020require_once( dirname(__FILE__) . '/fn-lib.php' );
     21require_once( dirname(__FILE__) . '/ajax.php' );
    2122
    2223new WPG( dirname(__FILE__) );
Note: See TracChangeset for help on using the changeset viewer.