Changeset 622


Ignore:
Timestamp:
03/07/2011 12:56:36 AM (15 months ago)
Author:
ofer
Message:

Add tp shortcode support, see http://trac.transposh.org/wiki/ShortCodes should close #145

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/transposh.php

    r621 r622  
    166166        add_filter('wp_redirect', array(&$this, 'on_wp_redirect'), 10, 2); 
    167167        add_filter('redirect_canonical', array(&$this, 'on_redirect_canonical'), 10, 2); 
     168 
     169        // support shortcodes 
     170        add_shortcode('tp', array(&$this, 'tp_shortcode')); 
    168171        // 
    169172        // FUTURE add_action('update-custom_transposh', array(&$this, 'update')); 
     
    515518            // redirect bots away from edit pages to avoid double indexing 
    516519            if (transposh_utils::is_bot()) { 
    517                 $this->tp_redirect(transposh_utils::rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, transposh_utils::get_language_from_url($_SERVER["REQUEST_URI"], $this->home_url), false)); //."&stop=y"); 
     520                $this->tp_redirect(transposh_utils::rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, transposh_utils::get_language_from_url($_SERVER["REQUEST_URI"], $this->home_url), false), 301); 
    518521                exit; 
    519522            } 
     
    10941097    } 
    10951098 
     1099    /** 
     1100     * Support for tp shortcodes - [tp] 
     1101     * @see http://trac.transposh.org/wiki/ShortCodes 
     1102     * @param array $atts 
     1103     * @param string $content 
     1104     * @return string  
     1105     */ 
     1106    function tp_shortcode($atts, $content = null) { 
     1107        $only_class = ''; 
     1108        $lang = ''; 
     1109        $nt_class = ''; 
     1110 
     1111        if (isset($atts['not_in'])) { 
     1112            if (stripos($atts['not_in'], $this->target_language) !== false) { 
     1113                return; 
     1114            } 
     1115        } 
     1116 
     1117        if (isset($atts['lang'])) { 
     1118            $lang = ' lang="' . $atts['lang'] . '"'; 
     1119        } 
     1120 
     1121        if (isset($atts['only'])) { 
     1122            $only_class = ' class="' . ONLY_THISLANGUAGE_CLASS . '"'; 
     1123        } 
     1124 
     1125        if (isset($atts['no_translate'])) { 
     1126            $nt_class = ' class="' . NO_TRANSLATE_CLASS . '"'; 
     1127        } 
     1128 
     1129        if ($lang || $only_class || $nt_class) { 
     1130            return '<span '.$only_class.$nt_class.$lang.'>' . do_shortcode($content) . '</span>'; 
     1131        } else { 
     1132            return do_shortcode($content); 
     1133        } 
     1134    } 
     1135 
    10961136} 
    10971137 
Note: See TracChangeset for help on using the changeset viewer.