Plugin Directory

Changeset 715343


Ignore:
Timestamp:
05/19/2013 08:49:22 PM (13 years ago)
Author:
tcbarrett
Message:

Fix recursive reference loop on glossary terms

Location:
wp-glossary/trunk
Files:
3 edited

Legend:

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

    r714426 r715343  
    1616     */
    1717    public function save_post_check_for_glossary_usage( $post_id, $post ){
     18    $glossary_options = get_option( 'wp_glossary' );
     19    $termusage        = isset($glossary_options['termusage'] )  ? $glossary_options['termusage']   : 'on';
     20
     21        if( $termusage != 'on' )
     22            return $post_id;
     23
    1824        if( !wp_is_post_revision($post_id)  ):
    1925            if( strpos($post->post_content,'[glossary ') !== false):
     
    6672    /** */
    6773    public function glossary( $atts, $content='' ){
    68         global $wpdb, $tcb_wpg_scripts, $wpg_glossary_count, $post;
     74        global $wpdb, $tcb_wpg_scripts, $wpg_glossary_count, $post, $wpg_doing_shortcode;
    6975
    7076        $wpg_glossary_count++;
     
    8995        $qtipstyle        = isset($glossary_options['qtipstyle'])   ? $glossary_options['qtipstyle']   : 'cream';
    9096        $linkopt          = isset($glossary_options['termlinkopt']) ? $glossary_options['termlinkopt'] : 'standard';
     97        $termusage        = isset($glossary_options['termusage'] )  ? $glossary_options['termusage']   : 'on';
    9198
    9299        extract( shortcode_atts( array(
     
    113120            endif;
    114121            $slug      = strtolower($slug);
    115             $sqlstring = "SELECT ID FROM {$wpdb->posts} WHERE post_name='%s' AND post_type='glossary' LIMIT 1";
    116             $id        = $wpdb->get_var( $wpdb->prepare( $sqlstring, $slug ) );
     122            $sqlstring = "SELECT ID FROM {$wpdb->posts} WHERE post_name='%s' AND post_type='glossary' AND post_status='publish' LIMIT 1";
     123            $id        = $wpdb->get_var( $wpdb->prepare($sqlstring, $slug) );
    117124            if( $id ):
    118125                $glossary = get_post( $id );
     
    121128        if( empty($glossary) ) return $text; // No glossary term found. Return the original text.
    122129
    123         if( get_post_meta( $post->ID, 'wpg_update_term_usage') ):
    124             // Note this post against the glossary
    125       add_post_meta( $glossary->ID, 'wpg_term_used', $post->ID );
    126             // Note this post/page has glossary terms
    127             update_post_meta( $post->ID, 'wpg_has_terms', current_time('mysql') );
    128     endif;
    129 
    130         setup_postdata( $glossary );
     130        if( $termusage && $termusage == 'on' ):
     131            if( get_post_meta( $post->ID, 'wpg_update_term_usage') ):
     132                if( !in_array($post->ID, get_post_meta($glossary->ID, 'wpg_term_used')) ):
     133                    // Note this post against the glossary
     134                    add_post_meta( $glossary->ID, 'wpg_term_used', $post->ID );
     135                    // Note this post/page has glossary terms
     136                    update_post_meta( $post->ID, 'wpg_has_terms', current_time('mysql') );
     137                endif;
     138       endif;
     139        endif;
     140   
     141        //setup_postdata( $glossary );
    131142        $title = get_the_title( $glossary->ID );
    132143
     
    138149        switch( $tooltip_option ):
    139150            case 'full':
    140                 $tooltip = ($qtipstyle=='off') ? strip_tags(get_the_content()) : apply_filters('the_content', get_the_content());
     151                if( !$wpg_doing_shortcode ):
     152                    $wpg_doing_shortcode = true;
     153                    //$tooltip = ($qtipstyle=='off') ? strip_tags($glossary->post_content) : wpautop( do_shortcode($glossary->post_content) );
     154                    $tooltip = ($qtipstyle=='off') ? strip_tags(get_the_content()) : apply_filters('the_content', get_the_content());
     155                    $wpg_doing_shortcode = false;
     156                endif;
    141157                break;
    142158            case 'excerpt':
     
    153169
    154170        $link  = '<a class="' . $class . '" '.$target.' '.$href.' title="' . esc_attr($tooltip) . '" '.implode(' ',$jsdata).'>' . $text . '</a>';
    155         wp_reset_postdata();
     171        //wp_reset_postdata();
    156172        return '<span class="wp-glossary">' . $link . '</span>';
    157173    }
  • wp-glossary/trunk/readme.txt

    r714729 r715343  
    66Requires at least: 3.0
    77Tested up to: 3.6
    8 Stable tag: 2.3.1.1
     8Stable tag: 2.3.2
    99License: GPLv2 or later
    1010
     
    7373
    7474== Changelog ==
     75
     76= 2.3.2 =
     77* FIX Recursive loop-referencing glossary terms
    7578
    7679= 2.3.1 =
  • wp-glossary/trunk/wp-glossary.php

    r714729 r715343  
    55 * Description: Build a glossary of terms and link your post content to it.
    66 * Author: TCBarrett
    7  * Version: 2.3.1.1
     7 * Version: 2.3.2
    88 * Author URI: http://www.tcbarrett.com/
    99 * Text Domain: wp-glossary
     
    1212define( 'WPG_TEXTDOMAIN', 'wp-glossary' );
    1313
    14 global $wpg_glossary_count;
     14global $wpg_glossary_count, $wpg_doing_shortcode;
    1515$wpg_glossary_count = 0;
    1616
     
    2323new WPG_Admin();
    2424
    25 add_action( 'admin_init', 'tcb_wpg_test' );
    26 //endif;
     25// add_action( 'admin_init', 'tcb_wpg_test' );
    2726function tcb_wpg_test(){
    2827    if( $prefix = $_GET['populate'] ):
    29         for( $i = 1; $i < 30; $i++ ):
     28        for( $i = 1; $i < 99; $i++ ):
    3029            wp_insert_post( array('post_type'=>'glossary', 'post_title'=>$prefix . '-' . $i, 'post_status'=>'publish') );
    3130        endfor;
Note: See TracChangeset for help on using the changeset viewer.