Changeset 508


Ignore:
Timestamp:
08/16/2010 12:54:50 AM (18 months ago)
Author:
ofer
Message:

Allow mass translate to translate tags

File:
1 edited

Legend:

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

    r500 r508  
    7373 
    7474    /** 
     75     * Function to allow mass translate of tags 
     76     * @return array list of tags 
     77     */ 
     78    function get_tags() { 
     79        $tags = get_terms('post_tag'); // Always query top tags 
     80        $phrases = array(); 
     81        foreach ($tags as $tag) { 
     82            $phrases[] = $tag->name; 
     83        } 
     84        return $phrases; 
     85    } 
     86 
     87    /** 
    7588     * Loop through all the post phrases and return them in json formatted script 
    7689     * @param int $postID 
     
    7992        // Some security, to avoid others from seeing private posts 
    8093        if (!current_user_can('edit_post', $postID)) return; 
    81         $post = get_post($postID); 
    82         // Display filters 
    83         $title = apply_filters('the_title', $post->post_title); 
    84         $content = apply_filters('the_content', $post->post_content); 
    85         // TODO - grab phrases from rss excerpt 
    86         //$output = get_the_excerpt(); 
    87         // echo apply_filters('the_excerpt_rss', $output); 
    88         //TODO - get comments text 
     94        // fake post for tags 
     95        if ($postID == -555) { 
     96            $phrases = $this->get_tags(); 
     97            $title = "tags"; 
     98        } 
     99        // a normal post 
     100        else { 
     101            $post = get_post($postID); 
     102            // Display filters 
     103            $title = apply_filters('the_title', $post->post_title); 
     104            $content = apply_filters('the_content', $post->post_content); 
     105            // TODO - grab phrases from rss excerpt 
     106            //$output = get_the_excerpt(); 
     107            // echo apply_filters('the_excerpt_rss', $output); 
     108            //TODO - get comments text 
    89109 
    90         $parser = new parser(); 
    91         $phrases = $parser->get_phrases_list($content); 
    92         $phrases2 = $parser->get_phrases_list($title); 
     110            $parser = new parser(); 
     111            $phrases = $parser->get_phrases_list($content); 
     112            $phrases2 = $parser->get_phrases_list($title); 
    93113 
    94         // Merge the two arrays for traversing 
    95         $phrases = array_merge($phrases, $phrases2); 
     114            // Merge the two arrays for traversing 
     115            $phrases = array_merge($phrases, $phrases2); 
    96116 
    97         // Add phrases from permalink 
    98         if ($this->transposh->options->get_enable_url_translate()) { 
    99             $permalink = get_permalink($postID); 
    100             $permalink = substr($permalink, strlen($this->transposh->home_url) + 1); 
    101             $parts = explode('/', $permalink); 
    102             foreach ($parts as $part) { 
    103                 if (!$part || is_numeric($part)) continue; 
    104                 $part = str_replace('-', ' ', $part); 
    105                 $phrases[] = urldecode($part); 
     117            // Add phrases from permalink 
     118            if ($this->transposh->options->get_enable_url_translate()) { 
     119                $permalink = get_permalink($postID); 
     120                $permalink = substr($permalink, strlen($this->transposh->home_url) + 1); 
     121                $parts = explode('/', $permalink); 
     122                foreach ($parts as $part) { 
     123                    if (!$part || is_numeric($part)) continue; 
     124                    $part = str_replace('-', ' ', $part); 
     125                    $phrases[] = urldecode($part); 
     126                } 
    106127            } 
    107128        } 
    108  
    109129        foreach ($phrases as $key) { 
    110130            foreach (explode(',', $this->transposh->options->get_editable_langs()) as $lang) { 
Note: See TracChangeset for help on using the changeset viewer.