Changeset 508
- Timestamp:
- 08/16/2010 12:54:50 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/wp/transposh_postpublish.php
r500 r508 73 73 74 74 /** 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 /** 75 88 * Loop through all the post phrases and return them in json formatted script 76 89 * @param int $postID … … 79 92 // Some security, to avoid others from seeing private posts 80 93 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 89 109 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); 93 113 94 // Merge the two arrays for traversing95 $phrases = array_merge($phrases, $phrases2);114 // Merge the two arrays for traversing 115 $phrases = array_merge($phrases, $phrases2); 96 116 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 } 106 127 } 107 128 } 108 109 129 foreach ($phrases as $key) { 110 130 foreach (explode(',', $this->transposh->options->get_editable_langs()) as $lang) {
Note: See TracChangeset
for help on using the changeset viewer.
