Changeset 208464
- Timestamp:
- 02/20/2010 11:42:49 PM (16 years ago)
- Location:
- meemi-in-wordpress/trunk
- Files:
-
- 1 added
- 3 edited
-
inc/meemi_comment.php (modified) (2 diffs)
-
inc/meemi_content.php (added)
-
meemi_in_wordpress_3.php (modified) (13 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
meemi-in-wordpress/trunk/inc/meemi_comment.php
r177474 r208464 31 31 ## GET LAST MEME FOR MEMI COMMENT 32 32 class MeemiLastMeme { 33 34 function startElement($parser, $tagName, $attrs) { 35 if ($this->insideitem) { 36 $this->tag = $tagName; 37 } elseif ($tagName == "MEME") { 38 $this->insideitem = true; 39 $this->meme_id = $attrs['ID']; 40 } 41 } 42 43 function endElement($parser, $tagName) { 44 if ($tagName == "MEME") { 45 $id_meme = $this->meme_id; 46 47 global $wpdb; 48 $table_name = $wpdb->prefix . "tb_meemi_comment"; 49 $last_id = $wpdb->get_var("SELECT COUNT(*) FROM $table_name;"); 50 51 $update = "UPDATE ".$table_name." SET id_meme = '$id_meme' WHERE id = '$last_id'"; 52 $wpdb->query($update); 53 54 $this->meme_id = ""; 55 $this->insideitem = false; 56 57 } 58 } 59 60 function characterData($parser, $data) { 61 if ($this->insideitem) { 62 63 switch ($this->tag) { 64 case "MEME": 65 $this->meme_id .= $data; 66 break; 67 } 68 } 69 } 70 } 71 72 ## UPDATE MEME ID FOR MEEMI COMMENTS 73 class MeemiUpdateMeme { 33 74 34 75 function startElement($parser, $tagName, $attrs) { … … 207 248 } 208 249 250 251 function clean_caption($string){ 252 $stringa = ""; 253 preg_match_all('/[caption ([a-z A-Z \" - _ =])/', $string, $matches); 254 foreach ($matches as $text) { 255 // Provides: <body text='black'> 256 $stringa = str_replace($text, " ", $stringa); 257 } 258 259 return $stringa; 260 } 261 262 263 209 264 ## PARSE STRING OF MEMI COMMENT FOR CHAN AND USERS 210 265 function parse_meemi_comment($stringa, $nome) { -
meemi-in-wordpress/trunk/meemi_in_wordpress_3.php
r181314 r208464 5 5 Plugin URI: http://vincenzodibiaggio.net/tech/meemi-in-wordpress/ 6 6 Description: Plugin to display your meme (http://meemi.com/) on your blog and to send your post to Meemi. Work with 2.7.1 to 2.8.x 7 Version: 3.0. 17 Version: 3.0.2 8 8 Author: Enrico Scognamillo e Vincenzo Di Biaggio 9 9 Author URI: http://www.vincenzodibiaggio.net/tech … … 103 103 } 104 104 } 105 ##################### 106 105 106 ############################################################# MEEMI CONTENT 107 include('inc/meemi_content.php'); 107 108 ############################################################# BEGIN MEEMI COMMENT 108 109 include('inc/meemi_comment.php'); … … 249 250 echo '<tr valign="top">'; 250 251 echo '<th scope="row">Password</th>'; 251 echo '<td><input type=" text" name="meemi_pwd" value="'.get_option('meemi_pwd').'" /></td>';252 echo '<td><input type="password" name="meemi_pwd" value="'.get_option('meemi_pwd').'" /></td>'; 252 253 echo '</tr>'; 253 254 … … 408 409 $loc = $user->info['location']; 409 410 410 echo "<p>".__('Il mio Screen Name è','meemi_in_wordpress_3')." ".$sname.". ".__('seguo','meemi_in_wordpress_3')." ".$n_following." Meemers, ".$n_followers." ".__('mi seguono.','meemi_in_wordpress_3')."<br/> ".__('Il mio vero nome è','meemi_in_wordpress_3')." ".$rname." ".__('e sono a','meemi_in_wordpress_3')." ".$loc."</p>\n";411 echo "<p>".__('Il mio Screen Name è','meemi_in_wordpress_3')." ".$sname.". ".__('seguo','meemi_in_wordpress_3')." ".$n_following." Meemers, ".$n_followers." ".__('mi seguono.','meemi_in_wordpress_3')."<br/> ".__('Il mio vero nome è','meemi_in_wordpress_3')." ".$rname." ".__('e sono ','meemi_in_wordpress_3')." ".$loc."</p>\n"; 411 412 412 413 echo "<p><a href=\"http://meemi.com/".$sname."/profile\" target=\"_blank\" title=\"Il mio profilo su Meemi\">".__('Visita il mio profilo su Meemi','meemi_in_wordpress_3')."</a></p>"; … … 514 515 515 516 function send_to_meemi($post_ID) { 517 global $wpdb; 516 518 $meemi_screen_name = get_option('meemi_screen_name'); 517 519 $meemi_pwd = get_option('meemi_pwd'); … … 524 526 $posted = get_post($post_ID); 525 527 $thispostlink = get_permalink($post_ID); 526 527 528 $categories = get_the_category($posted->ID); 529 $authorId = $posted->post_author; 530 $author_nickname = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM $wpdb->users WHERE ID = '$authorId' LIMIT 1")); 531 528 532 $chan = ""; 529 533 $imeemi = 0; … … 560 564 "&channels=".$chan.", ".$meemi_blog_chan. 561 565 "&location=".$meemi_location. 562 "&text_content=[b]".$posted->post_title. '[/b] - '.$content_to_send.566 "&text_content=[b]".$posted->post_title."[/b]\n\n ".$content_to_send."\n\n[i]By: ".$author_nickname."[/i]". 563 567 "&"); // add POST fields 564 568 $result = curl_exec($ch); // run the whole process … … 592 596 # END MEEMI COMMENT 593 597 } 594 // post update - Non attivo meemi post, non serve 595 }elseif ($posted->post_date != $posted->post_modified and $posted->post_status == "publish" ) { 596 if ( $_REQUEST['aggiorna_meemi_post'] == "true" ) { 597 598 // resend post to meemi 599 }elseif ( $posted->post_date != $posted->post_modified and $posted->post_status == "publish" and $_POST['reinvia_meemi_post'] == "true" ) { 598 600 if($meemi_content == "part") { 601 $content_to_send = clean_caption($content_to_send); 599 602 $content_to_send = substr(strip_tags($posted->post_content),0,400); 600 603 }else { … … 616 619 "&channels=".$chan.", ".$meemi_blog_chan. 617 620 "&location=".$meemi_location. 618 "&text_content=[ i]".__('Ho aggiornato il post:','meemi_in_wordpress_3')." [/i] - [b]".$posted->post_title."[/b] - ".__('Leggilo qui:','meemi_in_wordpress_3')." ".$thispostlink.621 "&text_content=[b]".$posted->post_title."[/b]\n\n ".$content_to_send."\n\n[i]By: ".$author_nickname."[/i]". 619 622 "&"); // add POST fields 620 623 $result = curl_exec($ch); // run the whole process 621 624 625 curl_close($ch); 626 627 # MEEMI COMMENT 628 $meemi_comment = get_option('meemi_comment'); 629 if ($meemi_comment == "true") { 630 631 global $wpdb; 632 $table_name = $wpdb->prefix . "tb_meemi_comment"; 633 $insert_meme = "UPDATE ".$table_name." (id_post, id_meme) VALUES ('$post_ID', '00')"; 634 $wpdb->query($insert_meme); 635 636 $xml_parser = xml_parser_create(); 637 $meemi_parser = new MeemiUpdateMeme(); 638 xml_set_object($xml_parser,$meemi_parser); 639 xml_set_element_handler($xml_parser, "startElement", "endElement"); 640 xml_set_character_data_handler($xml_parser, "characterData"); 641 642 $screen_name = get_option('meemi_screen_name'); 643 $fp = fopen("http://meemi.com/api/".$screen_name."/c-".$meemi_blog_chan."/limit_1","r"); 644 645 while ($data = fread($fp, 100)) 646 xml_parse($xml_parser, $data, feof($fp)); 647 648 fclose($fp); 649 xml_parser_free($xml_parser); 650 } 651 # END MEEMI COMMENT 652 // post update - Non attivo meemi post, non serve 653 }elseif ($posted->post_date != $posted->post_modified and $posted->post_status == "publish" ) { 654 if ( $_REQUEST['aggiorna_meemi_post'] == "true" ) { 655 656 if($meemi_content == "part") { 657 $content_to_send = clean_caption($content_to_send); 658 $content_to_send = substr(strip_tags($posted->post_content),0,400); 659 }else { 660 $content_to_send = strip_tags($posted->post_content); 661 } 662 663 $ch = curl_init(); // initialize curl handle 664 curl_setopt($ch, CURLOPT_URL,"http://meemi.com/api/".$meemi_screen_name."/save"); // set url to post to 665 curl_setopt($ch, CURLOPT_FAILONERROR, 1); 666 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 667 curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s 668 curl_setopt($ch, CURLOPT_POST, 1); // set POST method 669 curl_setopt($ch, CURLOPT_POSTFIELDS, 670 "&app_key=28550b20478693975888f8cc5d1b72c97210a56e". 671 "&meemi_id=".$meemi_screen_name. 672 "&pwd=".hash("SHA256",$meemi_pwd). 673 "&meme_type=text". 674 "&fonte=via: ".$thispostlink. 675 "&channels=".$chan.", ".$meemi_blog_chan. 676 "&location=".$meemi_location. 677 "&text_content=[i]".__('Ho aggiornato il post:','meemi_in_wordpress_3')." [/i] \n\n [b]".$posted->post_title."[/b] - ".__('Leggilo qui:','meemi_in_wordpress_3')." ".$thispostlink. 678 "&"); // add POST fields 679 $result = curl_exec($ch); // run the whole process 680 622 681 curl_close($ch); 623 682 624 625 }elseif ( $_POST['aggiorna_meemi_post'] == "false" ) { 626 //none 683 627 684 628 685 ## scheduled post … … 638 695 639 696 if($meemi_content == "part") { 697 $content_to_send = clean_caption($content_to_send); 640 698 $content_to_send = substr(strip_tags($posted->post_content),0,400); 641 699 }else { … … 657 715 "&channels=".$chan.", ".$meemi_blog_chan. 658 716 "&location=".$meemi_location. 659 "&text_content=[b]".$posted->post_title. '[/b] - '.$content_to_send.717 "&text_content=[b]".$posted->post_title."[/b]\n\n ".$content_to_send."\n\n[i]By: ".$author_nickname."[/i]". 660 718 "&"); // add POST fields 661 719 $result = curl_exec($ch); // run the whole process … … 741 799 ?> 742 800 </select> 801 <br> 802 <label for="reinvia_meemi_post">Re-Invia post a Meemi?</label> 803 <select name="reinvia_meemi_post" id="aggiorna_meemi_post"> 804 <option value="true">Si</option> 805 <option value="false" selected="true">No</option> 806 ?> 807 </select> 743 808 <?php 744 809 } … … 767 832 add_action('admin_menu', 'my_post_options_box'); 768 833 834 # SHORTCODE FOR MEEMI CONTENT 835 add_shortcode('meemi_content', 'meemi_content_func'); 836 769 837 ?> -
meemi-in-wordpress/trunk/readme.txt
r181314 r208464 3 3 Tags: meme, meemi, meemi.com, post, widget, coment, comments 4 4 Requires at least: 2.7.1 5 Tested up to: 2. 8.66 Stable tag: 3. 0.25 Tested up to: 2.9.1 6 Stable tag: 3.1 7 7 8 8 Simple plugin to display your meme into your blog, send your post on Meemi, display Meemi's comments of your post in your blog and send comments to Meemi. … … 39 39 == Changelog == 40 40 41 = 3.1 = 42 * Added function to resend post to Meemi 43 * Added Meemi Content (Post content from Meemi with a simple shortocode like [meemi_content url="URL OF MEME"] 44 41 45 = 3.0.2 = 42 46 * little bugfix
Note: See TracChangeset
for help on using the changeset viewer.