• 0点赞

  • 0收藏

首页 > 技术运营 > 正文
微慕启用激励视频后,网页需要扫码阅读,二维码居中代码,如下路径中文件,修改文末4处
/wp-content/plugins/rest-api-to-wechat/includes/filter/raw-custom-content.php

$excerpt .="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";xin'ban

 

 

新版:

$_content .="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";

并删除

$qrcode
<?php
//禁止直接访问
if ( ! defined( 'ABSPATH' ) ) exit;
//解析腾讯视频,只支持一个腾讯视频
function custocm_content_filter($content) {
    $_content=$content;
   
    if(is_single())
    {
        $vcontent =RAW_Util::get_post_qq_video($content);
        if(!empty($vcontent))
        {
            $_content=$vcontent;
            
        }
            
    }    
    $category = get_the_category();
    $categoryId=0;
    if(!empty($category))
    {
      $categoryId =$category[0]->cat_ID;  
    }
    if(empty($categoryId))
    {

        return $_content;

    }

    
    
    $postId = get_the_ID();


    

    $excitation=empty(get_post_meta($postId,'_excitation',true))?0:(int)get_post_meta($postId,'_excitation',true);
    global $wpdb; 
    $wpdb->minapper_product= $wpdb->prefix.'minapper_product';
    $sql ="select count(1) from ".$wpdb->minapper_product." where productid=".$categoryId." and productype='catsubscribe'";
    $catcount = $wpdb->get_var($sql);

    $sql ="select count(1) from ".$wpdb->minapper_product." where productid=".$postId." and productype='postpayment'";
    $postcount = $wpdb->get_var($sql);
    $post=get_post($postId);
    $link="";
    $title="";
    if(!empty($post))
    {
        $excerpt =empty($post->post_excerpt)?"":$post->post_excerpt;
        $title=  $post->post_title;
        $link=get_permalink($postId);
    }
    $payexcerpt=empty(get_post_meta($postId, '_payexcerpt',true))?'':get_post_meta($postId, '_payexcerpt',true);  
    if(strlen($excerpt)<1 &&  strlen($_content)>0)
    {
        $excerpt=RAW_Util::rewrite_content($_content,500);
    }
    $payexcerpt=empty($payexcerpt)?$excerpt:$payexcerpt;
  
    $display_qrcode=empty(get_option('raw_detail_bottom_display_qrcode'))?'0':get_option('raw_detail_bottom_display_qrcode');
    $h5_to_minapp=empty(get_option("raw_h5_to_minapp"))?'0':get_option("raw_h5_to_minapp");
   
    $webname=get_option("raw_webname");
    $isPayFlag=false;
    $path="/pages/index/index.html";  
    if($catcount==1 ||$postcount==1 || $excitation==1) 
    {        
        $isPayFlag=true;
    }
    else
    {
        if(is_single())
        {
           
           
            $vid=get_post_meta($postId, '_raw_video_vid1',true);  
            if(!empty($vid))
            {
                $_content .='<p> <iframe frameborder="0" src="https://v.qq.com/txp/iframe/player.html?vid=' . $vid . '" allowFullScreen="true" width="100%" height="500px"></iframe></p>';

            }
            //获取上传视频
            $videoUrl =empty(get_post_meta($postId, '_videoUrl',true))?"":get_post_meta($postId, '_videoUrl',true);
            $video_poster =empty(get_post_meta($postId, '_video_poster',true))?get_option('raw_default_videoposter_image'):get_post_meta($postId, '_video_poster',true);
                if(!empty($videoUrl))
            {
                $_content .='<p> <video src="'.$videoUrl.'" controls="controls" width="100%" height="100%" poster="'.$video_poster.'"></video>';


            }

            //获取百度网盘信息
            $baiduPanlink=empty(get_post_meta($postId,'_baiduPanlink',true))?'':get_post_meta($postId,'_baiduPanlink',true);
            $baiduPankey=empty(get_post_meta($postId,'_baiduPankey',true))?'':get_post_meta($postId,'_baiduPankey',true);
            
            $baiduPan="<p>  百度网盘地址:<a href='".$baiduPanlink."' target='_blank'>".$baiduPanlink."</a></p> ";
            $baiduPan .="<p> 提取码:".$baiduPankey."</p>";

            
            if(!empty($baiduPanlink) && !empty($baiduPankey))
            {
                $_content .=$baiduPan;
            }
           

        }
        
    }
   $qrcode="";
   if(is_single() && ($display_qrcode=='1' ||  $isPayFlag ))
   { 
    $url =get_option('siteurl').'/wp-json/minapper/v1/posts/'.$postId.'/qrcode'; 
    $path="/pages/detail/detail.html?id=".$postId;
  
      $response = wp_remote_get($url);
      if(is_array( $response ) && !is_wp_error($response) && $response['response']['code'] == '200')
      {
          $body= json_decode( $response['body'], true );
          $qrcode="<p><img  width='150' src='".$body['qrcodeurl']."' ></p>";
          
      }
   }


    //如果是微信浏览器
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
        if(is_single())
        {
            $images =RAW_Util::getPostImages($content, $postId);
            $imgUrl=$images['post_thumbnail_image'];
            $desc=wp_filter_nohtml_kses($payexcerpt);
            $wxcofig=RAW()->wxapi->get_wxconfig($title,$desc,$link,$imgUrl);
        }
         //如果是单页设置了在h5里打开小程序     
        if(is_single() && $h5_to_minapp=='1')
        {
            
           
            //不是小程序里web-view浏览器,也不是pc版的微信和小程序
            if(!strpos($_SERVER['HTTP_USER_AGENT'], 'miniProgram') && !strpos($_SERVER['HTTP_USER_AGENT'], 'WindowsWechat') && !strpos($_SERVER['HTTP_USER_AGENT'], 'wxwork') )
            {               
                $wx_open_launch_weapp = RAW()->wxapi->get_h5_open_app($path,$webname);
                if($isPayFlag && !empty($wx_open_launch_weapp) )
                {
                    $message='本文需要付费阅读,请点击下方按钮打开文章';
                    if($excitation==1)
                    {
                        $message='本文观看激励视频广告才可以阅读,请点击下方按钮打开文章';
                    }
                    $payexcerpt .="<div style='width:100%,margin-top:20px;text-align:center;'><br/>".$message."<br/>".$wxcofig.$wx_open_launch_weapp."<br/><br/>".$qrcode."</div><br/>";
                    $_content =$payexcerpt;
                }
                if(!$isPayFlag && $display_qrcode=='1')
                {
                    
                  
                    $message='微信扫描下方的二维码阅读更多精彩内容';
                    $_content.="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$wxcofig.$message."</div>";

                }

            }
            else
            {

                if($isPayFlag)
                {
                    if($display_qrcode=='1')
                    {
                        $message='本文需要付费阅读,请微信扫描下方的二维码阅读';
                        if($excitation==1)
                        {
                            $message='本文观看激励视频广告才可以阅读,请微信扫描下方的二维码阅读';
                        }
                        $payexcerpt .="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$wxcofig.$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";

                    }
                    $_content = $payexcerpt; 
                }
                else
                {
                    if($display_qrcode=='1')
                    {
                        $message='微信扫描下方的二维码阅读更多精彩内容';
                        $_content.="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$wxcofig.$message."</div>";
                    }
                    
                }

            }
            
        }
        else if(is_single() && $h5_to_minapp=='0')
        {

            if($isPayFlag)
            {

                if($display_qrcode=='1')
                {
                    $message='本文需要付费阅读,请微信扫描下方的二维码阅读';
                    if($excitation==1)
                    {
                        $message='本文观看激励视频广告才可以阅读,请微信扫描下方的二维码阅读';
                    }
                    $payexcerpt .="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$wxcofig.$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";
                    

                }
               $_content = $payexcerpt;   

            }
            else
            {
                if($display_qrcode=='1')
                {
                    $message='微信扫描下方的二维码阅读更多精彩内容';
                    $_content.="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$wxcofig.$message."</div>";
                }
                
            }

        }
    } //非微信浏览器
    else
    {
            if(is_single() )
            {

                $URLScheme= RAW()->wxapi->get_URLScheme($postId);  
                if($isPayFlag)//付费阅读
                { 
                    if (!empty($URLScheme))  //手机浏览器
                    {
                        $message='本文需要付费阅读,请点击下方按钮打开文章';
                        if($excitation==1)
                        {
                            $message='本文观看激励视频广告才可以阅读,请点击下方按钮打开文章';
                        }

                        $payexcerpt .="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";
                        $payexcerpt .=$URLScheme;

                    }
                    else //非手机浏览器
                    {
                        
                        $message='本文需要付费阅读,请微信扫描下方的二维码阅读';
                            if($excitation==1)
                            {
                                $message='本文观看激励视频广告才可以阅读,请微信扫描下方的二维码阅读';
                            }

                            $payexcerpt .="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";
                    }
                    
                
                $_content = $payexcerpt;  
                }
                else  //非付费内容
                {

                    if (!empty($URLScheme))//手机浏览器
                    {
                        $message ='点击下方按钮阅读更多精彩内容';
                        $_content .="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";
                        $_content.=$URLScheme;
                    }
                    else
                    {
                        if($display_qrcode=='1'){ //非手机浏览器

                            $message='微信扫描下方的二维码阅读更多精彩内容';
                            $_content.="<div style='width:100%,margin-top:20px;text-align:center;'><br/><br/>".$message."<p><div><img src='".$body['qrcodeurl']."' style='margin: 0 auto;width: 200px;'><div></p></div>";
                        }
        
                    }
                    
                    

                }

            }
            else
            {
                if($isPayFlag)//付费阅读
                {
                    $_content = $payexcerpt;  
                }
                
            }
            
    }
    return $_content;      


}

 

版权声明:橙逸所提供的文章、图片等内容均为用户发布或互联网整理而来,仅供学习参考,如有侵犯您的版权,请联系我们微信:jalonw删除。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论信息

TOP