• Resolved 610216

    (@610216-1)


    plugin code:

    function nofollow_create_menu() {
    
    	//create new option submenu
    	add_options_page('WordPress SEO nofollow plugin Settings', 'WordPress SEO nofollow', 'manage_options',__FILE__,'nofollow_settings_page');
    
    	//call register settings function
    	add_action( 'admin_init', 'register_nofollowsettings' );
    }
    
    add_action('admin_menu', 'nofollow_create_menu');
    
    function register_nofollowsettings() {
    	//register our settings
    	register_setting( 'nofollow-settings-group', 'comments_popup_link_nofollow' );
    	register_setting( 'nofollow-settings-group', 'more_link_nofollow' );
    	register_setting( 'nofollow-settings-group', 'pagination_add_nofollow' );
    	register_setting( 'nofollow-settings-group', 'external_nofollow' );
    }
    
    function nofollow_settings_page() {
    ?>
    
    <div class="wrap">
    	<?php //screen_icon(); ?>
    	<h2><?php _e('WordPress SEO nofollow');?></h2>
    	<form method="post" action="options.php" enctype="multipart/form-data">
    		<?php settings_fields( 'nofollow-settings-group' ); ?>
    		<?php do_settings_sections( 'nofollow-settings-group' ); ?>
    		<table class="form-table">
    			<tr valign="top">
    				<th scope="row"><?php _e('评论链接'); ?></th>
    				<td>
    					<label>
    						<input name="comments_popup_link_nofollow" type="radio" value="enable"<?php if (get_option('comments_popup_link_nofollow') == 'enable') { ?> checked="checked"<?php } ?> />
    				<?php _e('开启'); ?>
    					</label>
    					<label>
    						<input name="comments_popup_link_nofollow" type="radio" value="disable"<?php if (get_option('comments_popup_link_nofollow') == 'disable') { ?> checked="checked"<?php } ?> />
    					<?php _e('关闭'); ?>
    					</label>
    					<p><?php _e('有多少条评论的链接会加上rel="nofollow",推荐开启。');?></p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row"><?php _e('阅读全文'); ?></th>
    				<td>
    					<label>
    						<input name="more_link_nofollow" type="radio" value="enable"<?php if (get_option('more_link_nofollow') == 'enable') { ?> checked="checked"<?php } ?> />
    				<?php _e('开启'); ?>
    					</label>
    					<label>
    						<input name="more_link_nofollow" type="radio" value="disable"<?php if (get_option('more_link_nofollow') == 'disable') { ?> checked="checked"<?php } ?> />
    					<?php _e('关闭'); ?>
    					</label>
    					<p><?php _e('阅读全文链接加上rel="nofollow",推荐开启。');?></p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row"><?php _e('分页链接'); ?></th>
    				<td>
    					<label>
    						<input name="pagination_add_nofollow" type="radio" value="enable"<?php if (get_option('pagination_add_nofollow') == 'enable') { ?> checked="checked"<?php } ?> />
    				<?php _e('开启'); ?>
    					</label>
    					<label>
    						<input name="pagination_add_nofollow" type="radio" value="disable"<?php if (get_option('pagination_add_nofollow') == 'disable') { ?> checked="checked"<?php } ?> />
    					<?php _e('关闭'); ?>
    					</label>
    					<p><?php _e('分页链接rel="nofollow",推荐开启。');?></p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row"><?php _e('站外域'); ?></th>
    				<td>
    					<label>
    						<input name="external_nofollow" type="radio" value="enable"<?php if (get_option('external_nofollow') == 'enable') { ?> checked="checked"<?php } ?> />
    				<?php _e('开启'); ?>
    					</label>
    					<label>
    						<input name="external_nofollow" type="radio" value="disable"<?php if (get_option('external_nofollow') == 'disable') { ?> checked="checked"<?php } ?> />
    					<?php _e('关闭'); ?>
    					</label>
    					<p><?php _e('在文章中站外的域名链接加上rel="external nofollow",此功能开启导出链接将瞬间减少,建议SEO高手使用。');?></p>
    				</td>
    			</tr>
    		</table>
    		<?php submit_button(); ?>
    	</form>
    	<h2><?php _e('友情提示');?></h2>
    	<p><?php _e('插件只针对有SEO经验或专业人士使用。');?></p>
    	<h2><?php _e('捐赠共勉');?></h2>
    	<p><?php _e('支付宝:[email protected],多少随意。');?></p>
    	<p><img src="<?php echo plugins_url('/images/qr-alipay.png', __FILE__);?>"></p>
    </div>
    <?php }?>
    
    <?php
    
    // 评论链接
    if (get_option('comments_popup_link_nofollow') == 'enable') {
    	function add_nofollow_to_comments_popup_link(){
    		return ' rel="nofollow" ';
    	}
    	add_filter('comments_popup_link_attributes', 'add_nofollow_to_comments_popup_link');
    }
    
    // 阅读全文
    if (get_option('more_link_nofollow') == 'enable') {
    	function add_nofollow_to_link($link) {
    		return str_replace('<a', '<a rel="nofollow" target="_blank"', $link);
    	}
    	add_filter('the_content_more_link','add_nofollow_to_link', 0);
    }
    
    // 分页链接
    if (get_option('pagination_add_nofollow') == 'enable') {
    	function pagination_add_nofollow($content) {
    		return 'rel="nofollow"';
    	}
    	add_filter('next_posts_link', 'pagination_add_nofollow' );
    	add_filter('previous_posts_link', 'pagination_add_nofollow' );
    }
    
    // 站外域
    if (get_option('external_nofollow') == 'enable') {
    	add_filter('the_content','the_content_external',999);
    	function the_content_external($content){
    		preg_match_all('/href="(.*?)"/',$content,$matches);
    		if($matches){
    			foreach($matches[1] as $val){
    				if( strpos($val,$_SERVER['HTTP_HOST'])===false ) $content=str_replace("href=\"$val\"", "href=\"$val\" rel=\"external nofollow\" class=\"external\" ",$content);
    			}
    		}
    		return $content;
    	}
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘The plugin generated xxxx characters of unexpected output during activation’ is closed to new replies.