コード例 #1
0
function ol_feedburner_options_subpanel()
{
    global $ol_flash, $feedburner_settings, $_POST, $wp_rewrite;
    if (ol_is_authorized()) {
        // Easiest test to see if we have been submitted to
        if (isset($_POST['feedburner_url']) || isset($_POST['feedburner_comments_url'])) {
            // Now we check the hash, to make sure we are not getting CSRF
            if (fb_is_hash_valid($_POST['token'])) {
                if (isset($_POST['feedburner_url'])) {
                    $feedburner_settings['feedburner_url'] = $_POST['feedburner_url'];
                    update_option('feedburner_settings', $feedburner_settings);
                    $ol_flash = "Your settings have been saved.";
                }
                if (isset($_POST['feedburner_comments_url'])) {
                    $feedburner_settings['feedburner_comments_url'] = $_POST['feedburner_comments_url'];
                    update_option('feedburner_settings', $feedburner_settings);
                    $ol_flash = "Your settings have been saved.";
                }
            } else {
                // Invalid form hash, possible CSRF attempt
                $ol_flash = "Security hash missing.";
            }
            // endif fb_is_hash_valid
        }
        // endif isset(feedburner_url)
    } else {
        $ol_flash = "You don't have enough access rights.";
    }
    if ($ol_flash != '') {
        echo '<div id="message" class="updated fade"><p>' . $ol_flash . '</p></div>';
    }
    if (ol_is_authorized()) {
        $temp_hash = fb_generate_hash();
        fb_store_hash($temp_hash);
        echo '<div class="wrap">';
        echo '<h2>Set Up Your FeedBurner Feed</h2>';
        echo '<p>This plugin makes it easy to redirect 100% of traffic for your feeds to a FeedBurner feed you have created. FeedBurner can then track all of your feed subscriber traffic and usage and apply a variety of features you choose to improve and enhance your original WordPress feed.</p>
		<form action="" method="post">
		<input type="hidden" name="redirect" value="true" />
		<input type="hidden" name="token" value="' . fb_retrieve_hash() . '" />
		<ol>
		<li>To get started, <a href="https://www.feedburner.com/fb/a/addfeed?sourceUrl=' . get_bloginfo('url') . '" target="_blank">create a FeedBurner feed for ' . get_bloginfo('name') . '</a>. This feed will handle all traffic for your posts.</li>
		<li>Once you have created your FeedBurner feed, enter its address into the field below (http://feeds.feedburner.com/yourfeed):<br/><input type="text" name="feedburner_url" value="' . htmlentities($feedburner_settings['feedburner_url']) . '" size="45" /></li>
		<li>Optional: If you also want to handle your WordPress comments feed using FeedBurner, <a href="https://www.feedburner.com/fb/a/addfeed?sourceUrl=' . get_bloginfo('url') . '/wp-commentsrss2.php" target="_blank">create a FeedBurner comments feed</a> and then enter its address below:<br/><input type="text" name="feedburner_comments_url" value="' . htmlentities($feedburner_settings['feedburner_comments_url']) . '" size="45" />
		</ol>
		<p><input type="submit" value="Save" /></p></form>';
        echo '</div>';
    } else {
        echo '<div class="wrap"><p>Sorry, you are not allowed to access this page.</p></div>';
    }
}
コード例 #2
0
function ol_feedburner_options_subpanel() {
	global $ol_flash, $feedburner_settings, $_POST, $wp_rewrite, $category_count;
	$allcats=get_categories("orderby=id&hide_empty=0");
	$alltags = get_terms("post_tag","orderby=name&get=all");
	if (ol_is_authorized()) {
		
		$updates_field=array();
		
		foreach($allcats as $cat)
		{
			$field='feedburner_category_'.$cat->term_id;
			if (isset($_POST[$field]))
				$updates_field[$field]=$_POST[$field];
		}
		
		foreach($alltags as $tag)
		{
			$field = 'feedburner_tag_'.$tag->term_id;
			if (isset($_POST[$field]))
				$updates_field[$field]=$_POST[$field];
		}
		
		// Easiest test to see if we have been submitted to
		if(isset($_POST['feedburner_url']) || isset($_POST['feedburner_comments_url']) || (count($updates_field)>0)) {
			// Now we check the hash, to make sure we are not getting CSRF
			if(fb_is_hash_valid($_POST['token'])) {

				// update the category feeds
				if (count($updates_field)>0)
					foreach($updates_field as $key=>$val)
					{
						$feedburner_settings[$key] = $val;
						update_option('feedburner_settings',$feedburner_settings);
						$ol_flash = "Your settings have been saved.";
					}
				if (isset($_POST['feedburner_url'])) { 
					$feedburner_settings['feedburner_url'] = $_POST['feedburner_url'];
					update_option('feedburner_settings',$feedburner_settings);
					$ol_flash = "Your settings have been saved.";
				}
				if (isset($_POST['feedburner_comments_url'])) { 
					$feedburner_settings['feedburner_comments_url'] = $_POST['feedburner_comments_url'];
					update_option('feedburner_settings',$feedburner_settings);
					$ol_flash = "Your settings have been saved.";
				} 
			} else {
				// Invalid form hash, possible CSRF attempt
				$ol_flash = "Security hash missing.";
			} // endif fb_is_hash_valid
		} // endif isset(feedburner_url)
	} else {
		$ol_flash = "You don't have enough access rights.";
	}
	
	if ($ol_flash != '') echo '<div id="message" class="updated fade"><p>' . $ol_flash . '</p></div>';
	
	if (ol_is_authorized()) {
		wp_enqueue_script(‘jquery’);
		$temp_hash = fb_generate_hash();
		fb_store_hash($temp_hash);
		echo '<script type="text/javascript" src="'.WP_PLUGIN_URL.'/feedBurner-feedSmith-extend/jquery-ui.min.js"></script>
		      <link rel="stylesheet" href="'.WP_PLUGIN_URL.'/feedBurner-feedSmith-extend/jquery.custom.css" type="text/css"/>	';
		echo '<div class="wrap">';
		echo '<h2>FeedBurner FeedSmith Extend</h2>';
		echo '<p>This plugin makes it easy to redirect 100% of traffic for your feeds to a FeedBurner feed you have created. FeedBurner can then track all of your feed subscriber traffic and usage and apply a variety of features you choose to improve and enhance your original WordPress feed. Feeds for categories and tags could be set separately with the help of this plugin.</p>
		<form action="" method="post">
		<input type="hidden" name="redirect" value="true" />
		<input type="hidden" name="token" value="' . fb_retrieve_hash() . '" />
		<div id = "tabs">
		<ul><li><a href="#main">Main</a></li><li><a href="#categories">Categories</a></li><li><a href="#tags">Tags</a></li></ul>
		<div id="main">
		<strong>Main Feed: </strong> <input type="text" name="feedburner_url" value="' . htmlentities($feedburner_settings['feedburner_url']) . '" size="45" /><br/>
		<strong>Comments Feed: </strong><input type="text" name="feedburner_comments_url" value="' . htmlentities($feedburner_settings['feedburner_comments_url']) . '" size="45" />
		</div>';
		echo '<div id="categories">';
		echo 'You can set FeedBurner feeds for each categories here
		<div id="categoriesContent">
		';
		echo '<input type="button" value="Show All Sub-Category" name="showAll" onclick="showSubCat(this);"/><br/>';
		
		$cats=get_categories("orderby=id&hide_empty=0&parent=0");	
		foreach($cats as $cat)
			echo "<strong>$cat->name</strong> &nbsp;&nbsp;Feed:<input type=\"text\" name=\"feedburner_category_$cat->term_id\" value=\"" . htmlentities($feedburner_settings['feedburner_category_'.$cat->term_id]) . "\" size=\"45\" /><br/>";

		echo '</div>
		</div>
		<div id="tags">';
		$tags = get_terms("post_tag","orderby=name&get=all");
		foreach($tags as $tag)
			echo "<strong>$tag->name</strong> &nbsp;&nbsp;Feed:<input type=\"text\" name=\"feedburner_tag_$tag->term_id\" value=\"" . htmlentities($feedburner_settings['feedburner_tag_'.$tag->term_id]) . "\" size=\"45\" /><br/>";
		echo '</div>';
		echo '<p><input type="submit" value="Save" /></p></div>
		</form>';
		echo '</div>';
	} else {
		echo '<div class="wrap"><p>Sorry, you are not allowed to access this page.</p></div>';
	}
	?>
	<script type="text/javascript">
	var $myjQuery = jQuery.noConflict();
	
	window.onload = function(){
		$myjQuery("#tabs").tabs();
	}
	
	function showSubCat(obj){
		$myjQuery.post(ajaxurl,{action: 'my_action',show: obj.name},function(data){
				$myjQuery("#categoriesContent").html(data);
		});
	}	
	</script>
	<?php
}