这个功能是很实用的,历经2.6到现在2.7依然可以使用,游客在未登录情况下不能下载免费的资源,只能购买付费资源,登陆后可以下载免费资源,是群里豆浆大神的杰作(再次致敬一下),好,香烧完了,我们继续往下讲:
加入2.8.1以上版本的方法,代码在最后
第一种方法
找到/rizhuti/inc/functions-widgets.php 这个文件,复制下面的代码,替换原来文件的全部代码
效果
'widget-download' ) ); } function widget( $args, $instance ) { extract( $args ); global $post; $type = get_post_meta($post->ID,'wppay_type',true); $price = (get_post_meta($post->ID,'wppay_price',true)) ? get_post_meta($post->ID,'wppay_price',true) : 0 ; $down = get_post_meta($post->ID,'wppay_down',true); $info = get_post_meta($post->ID,'wppay_down_info',true); $post_auth = get_post_meta($post->ID,'wppay_vip_auth',true); if($type >= 3){ $user_id = is_user_logged_in() ? wp_get_current_user()->ID : 0; $wppay = new WPAY($post->ID, $user_id); // 检测当前用户是否已购买 if($wppay->is_paid()){ $then_down_url = get_stylesheet_directory_uri().'/action/download.php?postid='.$post->ID; $content_pay=' 立即下载'; }else{ if (_hui('no_loginpay') == 0 && !is_user_logged_in()) { $content_pay=' 登录购买'; }else{ if ($type == 4){ //如果是免费资源 就判断是否登录 if (!is_user_logged_in()){ //用户没有登录 显示要登录 $content_pay=' 登录后可下载'; }else{ //用户登录了就显示下载 $then_down_url = get_stylesheet_directory_uri().'/action/download.php?postid='.$post->ID; $content_pay=' 立即下载'; } }else{ $content_pay=' 立即购买'; } } } if (intval($post_auth) == 1) { $vip_infotext= '月费会员免费'; }elseif (intval($post_auth) == 2) { $vip_infotext= '年费会员免费'; }elseif (intval($post_auth) == 3) { $vip_infotext= '终身会员免费'; }elseif ($type == 4) { $vip_infotext= '限时免费'; }else{ $vip_infotext= '暂无优惠'; } $infoArr = array('wppay_demourl' => get_post_meta($post->ID,'wppay_demourl',true), 'wppay_info_v' => get_post_meta($post->ID,'wppay_info_v',true),'wppay_info_g' =>get_post_meta($post->ID,'wppay_info_g',true) ,'wppay_info_d' =>get_post_meta($post->ID,'wppay_info_d',true)); if($infoArr['wppay_demourl']){ $wppay_demourl= ' 演示地址'; }else{ $wppay_demourl=''; } if($infoArr['wppay_info_v']){ $wppay_info_v= ' 当前版本: '.$infoArr['wppay_info_v'].' '; }else{ $wppay_info_v=''; } if($infoArr['wppay_info_g']){ $wppay_info_g= ' 文件格式: '.$infoArr['wppay_info_g'].' '; }else{ $wppay_info_g=''; } if($infoArr['wppay_info_d']){ $wppay_info_d= ' 文件大小: '.$infoArr['wppay_info_d'].' '; }else{ $wppay_info_d=''; } $content = ''.$price.'元'.$vip_infotext.''.$content_pay.$wppay_demourl.'最近更新:'.get_the_modified_time('Y年m月d日').''.$wppay_info_v.$wppay_info_g.$wppay_info_d.' 在线咨询'; echo $before_widget; echo $content; echo $after_widget; } } }class widget_asst extends WP_Widget { function __construct(){ parent::__construct( 'widget_asst', _the_theme_name().': 广告', array( 'classname' => 'widget-asst' ) ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_name', $instance['title']); $code = $instance['code']; $nophone = isset($instance['nophone']) ? $instance['nophone'] : ''; if( $nophone && wp_is_mobile() ){ }else{ echo $before_widget; echo $code; echo $after_widget; } } function form($instance) { $defaults = array( 'title' => __('广告', 'haoui').' '.date('m-d'), 'code' => '', 'nophone' => '' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <input style="vertical-align:-3px;margin-right:4px;" class="checkbox" type="checkbox" id="get_field_id('nophone'); ?>" name="get_field_name('nophone'); ?>">不在手机端显示 'widget-comments' ) ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_name', $instance['title']); $limit = $instance['limit']; $outer = $instance['outer']; if( !$outer ){ $outer = -1; } echo $before_widget; echo $before_title.$title.$after_title; $output = ''; global $wpdb; $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,60) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE user_id!='".$outer."' AND comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date DESC LIMIT $limit"; $comments = $wpdb->get_results($sql); foreach ( $comments as $comment ) { $output .= 'ID).'#comment-'.$comment->comment_ID.'" title="'.$comment->post_title.__('上的评论', 'haoui').'">'; $output .= _get_user_avatar($comment->comment_author_email); $output .= ''.strip_tags($comment->comment_author).''.( $comment->comment_date ).''.str_replace(' src=', ' data-src=', convert_smilies(strip_tags($comment->com_excerpt))).''; $output .= ''; } echo ''. $output .''; echo $after_widget; } function form($instance) { $defaults = array( 'title' => __('最新评论', 'haoui'), 'limit' => 8, 'outer' => '' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> 'widget-postlist' ) ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_name', $instance['title']); $limit = $instance['limit']; $cat = isset($instance['cat']) ? $instance['cat'] : ''; $orderby = $instance['orderby']; // $showstyle = $instance['showstyle']; // $img = $instance['img']; // $style = ' class="'.$showstyle.'"'; echo $before_widget; echo $before_title.$title.$after_title; echo ''; $args = array( 'order' => 'DESC', 'cat' => $cat, 'orderby' => $orderby, 'showposts' => $limit, 'ignore_sticky_posts' => 1 ); query_posts($args); while (have_posts()) : the_post(); echo ''; /*if( $showstyle!=='items-03' ){ }*/ echo ''._get_post_thumbnail().''; echo ' '最新文章', 'limit' => 6, 'orderby' => 'date', // 'showstyle' => '' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <option value="comment_count" > <option value="date" > <option value="rand" > ? 'widget-textasst' ) ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_name', $instance['title']); $tag = $instance['tag']; $content = $instance['content']; $link = $instance['link']; $style = $instance['style']; $blank = isset($instance['blank']) ? $instance['blank'] : ''; $lank = ''; if( $blank ) $lank = ' target="_blank"'; echo $before_widget; echo ''; echo ''.$tag.''; echo ''.$title.''; echo ''.$content.''; echo ''; echo $after_widget; } function form($instance) { $defaults = array( 'title' => '如此简单的下载', 'tag' => 'WpayTheme', 'content' => '扁平化、简洁风、多功能配置,优秀的电脑、平板、手机支持,响应式布局,不同设备不同展示效果...', 'link' => 'https://ylit.cc/', 'style' => 'style01', 'blank' => 'on', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> 名称: 描述: 标签: 链接: 样式: <option value="style01" >蓝色 <option value="style02" >橘红色 <option value="style03" >绿色 <option value="style04" >紫色 <input style="vertical-align:-3px;margin-right:4px;" class="checkbox" type="checkbox" id="get_field_id('blank'); ?>" name="get_field_name('blank'); ?>">新打开浏览器窗口 <?php } }
第二种方法
后台或者ftp找到这个文件/rizhuti/inc/functions-widgets.php删除,从本站下载修改好的文件上传替换,下载链接在右边。
以下代码是2.8.1以上版本
全部评论 / 0