WordPress.org

Plugin Directory

Changeset 624636


Ignore:
Timestamp:
11/13/12 15:23:56 (5 years ago)
Author:
ecolosites
Message:

EELV share post v0.1.3

Location:
eelv-share-post/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • eelv-share-post/trunk/readme.txt

    r624508 r624636  
    3333== Changelog == 
    3434 
     350.1.3 
     36fix : performances optimisation 
     37 
    35380.1.2 
    3639fix : performances optimisation 
  • eelv-share-post/trunk/share.php

    r624508 r624636  
    44Plugin URI: http://ecolosites.eelv.fr/eelv-share-post/ 
    55Description: Share a post link from a blog to another blog on the same WP multisite network and include the post content ! 
    6 Version: 0.1.2 
     6Version: 0.1.3 
    77Author: bastho, n4thaniel // EELV 
    88License: CC BY-NC 3.0 
     
    7272       
    7373    }   
     74     
     75/* IN THE LOOP */    
     76     
     77         
    7478    remove_filter('get_the_excerpt', 'wp_trim_excerpt'); 
    75     remove_filter('get_the_excerpt', 'wp_trim_excerpt',100); 
    76     remove_filter('get_the_excerpt', 'wp_trim_excerpt',1000);   
     79    remove_filter('get_the_excerpt', 'wp_trim_excerpt',100);   
    7780    //add_filter('get_the_excerpt', 'new_wp_trim_excerpt');  
    7881       
    7982      $serv = str_replace('.','\.',DOMAIN_CURRENT_SITE); 
    80     wp_embed_register_handler( 'embedInMultiSite_p', '#<p>http://(.+)?'.$serv.'/\?p=(\d+)</p>#i', 'eelv_embed_locals' ); 
    81     wp_embed_register_handler( 'embedInMultiSite', '#http://(.+)?'.$serv.'/\?p=(\d+)#i', 'eelv_embed_locals' ); 
    82     wp_embed_register_handler( 'embedInMultiSite_link', '#(.+)??http://(.+)?'.$serv.'/\?p=(\d+)(.+)??>(.+)?</(.+)>#i', 'eelv_embed_locals' ); 
     83       
    8384    add_filter('the_excerpt','eelv_embed_exerpt',999); 
    84       //add_filter('excerpt_more','eelv_embed_exerpt'); 
     85    //add_filter('excerpt_more','eelv_embed_exerpt'); 
    8586    add_filter('the_content_rss','eelv_embed_exerpt'); 
    8687       
     
    115116          $val="<div class='embeelv_excerpt'><p>".substr(strip_tags($blog_post->post_content),0,400)."...</p></div>"; 
    116117          $excerpt=str_replace($match,$val,$excerpt);  
    117                 
    118118        } 
    119119      } 
     
    144144          $val="<div class='embeelv_excerpt'>".$tumb."<p>".substr(strip_tags($blog_post->post_content),0,400)."...</p></div>"; 
    145145          $excerpt=str_replace($match,$val,$excerpt);  
    146                
    147146        } 
    148147      } 
     
    153152        foreach($yout[0] as $id=>$match){ 
    154153           
    155           $val="<iframe class='embeelv_iframe' src='http://www.youtube.com/embed/".$yout[1][$id]."' width='250' height='150'>vidéo</iframe>"; 
     154          $val="<iframe class='embeelv_iframe' src='http://www.youtube.com/embed/".$yout[1][$id]."' width='250' height='150'>video</iframe>"; 
    156155          $tumb.= $val; 
    157156          $excerpt=str_replace($match,strip_tags($val),$excerpt);       
     
    163162      if(is_array($dail)){ 
    164163        foreach($dail[0] as $id=>$match){       
    165           $val="<iframe class='embeelv_iframe' src='http://www.dailymotion.com/embed/video/".$dail[1][$id]."' width='250' height='150'>vidéo</iframe>"; 
     164          $val="<iframe class='embeelv_iframe' src='http://www.dailymotion.com/embed/video/".$dail[1][$id]."' width='250' height='150'>video</iframe>"; 
    166165          $tumb.= $val; 
    167166          $excerpt=str_replace($match,strip_tags($val),$excerpt);       
     
    178177         $parser = new htmlParser($twit->html); 
    179178    $twitxt = $parser->toArray(); 
    180           // print_r($twitxt); 
    181179          $val="<div class='embeelv_twit'>@".$twi[1][$id]." &laquo;".$twitxt[0]['innerHTML']."&raquo;</div>"; 
    182           //echo $val; 
    183180          $excerpt=str_replace($match,$val,$excerpt);       
    184181        } 
    185182      } 
    186183       
    187       //echo '<p>'.$tumb.'</p>'; 
    188184       
    189185      if($sharer==false){ 
    190         // $excerpt.="<a href=\"var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".$blogurl."/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u=&t=".$post->post_title."&s=".$post->guid."&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'));};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)\"></a>";  
    191       } 
    192       return $excerpt; 
    193        
     186        //$excerpt.="<a href=\"var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".$blogurl."/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u=&t=".$post->post_title."&s=".$post->guid."&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'));};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)\">#</a>";  
     187      } 
     188      return $excerpt;     
    194189    }  
    195        
     190     
     191     
     192     
     193     
     194     
     195/* SINGLE PAGE */    
     196     
     197    wp_embed_register_handler( 'embedInMultiSite_p', '/<p[^>]*>http:\/\/(.+)?'.$serv.'\/\?p=(\d+)<\/p>/i', 'eelv_embed_locals' ); 
     198    wp_embed_register_handler( 'embedInMultiSite', '#http://(.+)?'.$serv.'/\?p=(\d+)#i', 'eelv_embed_locals' ); 
     199    /*wp_embed_register_handler( 'embedInMultiSite_link', '#(.+)??http://(.+)?'.$serv.'/\?p=(\d+)(.+)??>(.+)?</(.+)>#i', 'eelv_embed_locals' );*/ 
     200     
    196201    function eelv_embed_locals( $matches, $attr, $url, $rawattr ) { 
    197202      $matches[1]=str_replace('.','',$matches[1]); 
     
    224229        $embed.=trim(str_replace('"','\"',$blog_post->post_title)); 
    225230        $embed.='[/h4][p]'; 
    226         $embed.=trim(str_replace(" 
    227 ","&nbsp;",str_replace('"','\"',substr(strip_tags($blog_post->post_content),0,250)))); 
     231         
     232        $w=0; 
     233        $txt = trim(strip_tags($blog_post->post_content)); 
     234        $txts=explode("\n",$txt); 
     235         
     236        $emtxt=''; 
     237        foreach($txts as $str){ 
     238            $str=str_replace('"','\"',trim($str));   
     239            $w+=strlen($str); 
     240            $emtxt.=$str.' '; 
     241            if($w>250) break; 
     242        } 
     243        if(strlen($txt)>$emtxt) $emtxt.='...'; 
     244        $embed.=$emtxt; 
     245         
     246        //$embed.=trim(str_replace(array("","\n",),array('&nbsp;','&nbsp;',),substr(strip_tags($blog_post->post_content),0,250))); 
    228247        if(isset($matches[3]) && !empty($matches[3])){ 
    229248          $embed.='[/p][p]'.trim(str_replace(" 
    230249","&nbsp;",str_replace('"','\"',strip_tags($matches[3])))); 
    231250        } 
    232         $embed.='...[/p][p][u]'.$blog_post->guid.'[/u][div class=\"clear\"][/div][/p]'; 
     251        $embed.='[/p][p][u]'.$blog_post->guid.'[/u][div style=\"clear:both\"][/div][/p]'; 
    233252      } 
    234253      else{ 
     
    238257      $embed.='while(str_'.$matches[2].'_'.$it.'_'.$matches[1].'.indexOf("[") != -1){str_'.$matches[2].'_'.$it.'_'.$matches[1].' = str_'.$matches[2].'_'.$it.'_'.$matches[1].'.replace("[","<");}'; 
    239258      $embed.='while (str_'.$matches[2].'_'.$it.'_'.$matches[1].'.indexOf("]") != -1){str_'.$matches[2].'_'.$it.'_'.$matches[1].' = str_'.$matches[2].'_'.$it.'_'.$matches[1].'.replace("]",">");}'; 
    240       $embed.='document.getElementById("'.$matches[2].'_'.$it.'_'.$matches[1].'").innerHTML=str_'.$matches[2].'_'.$it.'_'.$matches[1].';</script>'; 
     259      $embed.='document.getElementById("'.$matches[2].'_'.$it.'_'.$matches[1].'").innerHTML=str_'.$matches[2].'_'.$it.'_'.$matches[1].';document.getElementById("wp-admin-bar-embed_post_menu").style.display="none";</script>'; 
    241260      $it++;   
    242261      return $embed; 
     
    271290              'parent' => 'embed_post_menu', 
    272291              'meta' => array('class' => 'Embed_post_menu') 
    273             ); 
    274    
    275   $n++;     
     292            );   
     293    $n++;     
    276294  }       
    277295    $wp_admin_bar->add_group($args); 
     
    287305        $site=$_REQUEST['site']; 
    288306        $blog_id=get_current_blog_id(); 
    289          $blog_details = get_blog_details($blog_id); 
    290          $domain=$blog_details->siteurl; 
     307        $blog_details = get_blog_details($blog_id); 
     308        $domain=$blog_details->siteurl; 
    291309         
    292310        $post_id=get_the_ID(); 
    293311         
    294312        $link=$domain.'/?p='.$post_id; 
    295         echo $link; 
    296       echo '<script>'; 
    297      
    298     echo"var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://".$site."/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u=&t=".str_replace("&rsquo;","\\'",$title)."&s=".$link."&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'));};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)"; 
    299    
    300   echo'</script>'; 
     313        //echo $link; 
     314    echo '<script>';     
     315    echo"var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://".$site."/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u=&t=".str_replace(array("&rsquo;"),array("\\'"),$title)."&s=...%0A%0A".$link."%0A&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'));};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)";   
     316   echo'</script>'; 
    301317  }  
    302318} 
Note: See TracChangeset for help on using the changeset viewer.