ad code, related post, optional custom paragraph or technorati tags to the end of every posts. All options can be fully customized though Add Post Footer tab in the option panel within wordpress admin. It's also possible overide the setting for specific post by adding custom field key and value. Please refer to the tips and addtional info provided at the Add Post Footer Page. Version: 1.1 Date: November 18th, 2008 Author: freetime Author URI: http://www.freetimefoto.com Contributors: */ /* (C)Copyright, 2008 Chaiyot Kosuwanpipat (contact: http://www.freetimefoto.com/contact) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see */ // The apf_add_tags function are improved version of SimpleTags Plugin by Broobles (http://www.broobles.com/scripts/simpletags/) // Admin Panel function apf_add_pages() { add_options_page('Post Footer Options', 'Post Footer', 9, __FILE__, 'apf_options_page'); } function apf_show_info_msg($msg) { echo '

' . $msg . '

'; } function apf_options_page() { if (isset($_POST['info_update'])) { $options = array( "apf_set_order" => $_POST["apf_set_order"], "apf_add_ad_code" => $_POST["apf_add_ad_code"], "apf_ad_code" => $_POST["apf_ad_code"], "apf_add_relpost" => $_POST["apf_add_relpost"], "apf_relpost_title" => $_POST["apf_relpost_title"], "apf_relpost_no" => $_POST["apf_relpost_no"], "apf_optional_txt" => $_POST["apf_optional_txt"], "apf_add_tag" => $_POST["apf_add_tag"], "apf_tag_label" => $_POST["apf_tag_label"], "apf_show_all" => $_POST["apf_show_all"], "apf_add_credit" => $_POST["apf_add_credit"], ); update_option("add_post_footer_opts", $options); apf_show_info_msg("Add-Post-Footer options saved."); } elseif (isset($_POST["info_reset"])) { delete_option("add_post_footer_opts"); apf_show_info_msg("Add-Post-Footer options deleted from the WordPress database."); } else { $options = get_option("add_post_footer_opts"); } // Configuration Page _e('

Add-Post-Footer

This is where you can configure the Add-Post-Footer plugin to add Technorati Tags, Related Post List, Sponsor Paragraph or even Advertisement Script to the end of your post.

If you love this plugin and found it useful please make some donation using button above. This small donation will be fund for us to develop and improve this plugin. If you find any difficulty, any questions , suggestion or bug when use this plugin please feel free to share with us at Add-Post-Footer page.

Configuration

Ad Code:


Copy and paste your ad code provided from your ad network in text area below to show the ad at the end of every posts. It\'s also possible to override the ad showing in some posts, force ad to show or enter special ad for particular post by using custom field. more info

Add Ad before Related Post: '. $options["apf_set_order"] . '  If "No" Related Post List will show before Ad.

Add following Ad. code to the end of post: '. $options["apf_add_ad_code"] . ' 

Ad Code Script:

Related Post List:


Turn on this option will show related post by post category to the end of the post. You can also customize the header (default is "Related Articles:") and also maximum post to show in the list (Default is 5).

To override the post showing for particular post, use custom field Key: apf_relate_post and value 0 (force to hide post list) or 1 (show post list).

You can customize style of post list by adding "#apf_post_footer" and "li.apf_post_footer" to your main CSS file. more info

Add related post list: '. $options["apf_add_relpost"] . ' 

Maximum number of post in the list: default is 5 posts.

The header text for post list: for example ("Related Articles:").

Optional Text:


Insert option text or html code to the end of the post (for example credit or sponsor link). This section will place just before technorati tags. Use custom field Key: "apf_option_txt" to add custom paragraph to particular post. more info

Technorati Tags:


Turn on this option to create a list of Technorati tags just like SimpleTags plugin. The tag will retrieve from word that surrounded by [tag] or [tags] tags in each post. You can customize style of tag list by adding .simpletags class in your main CSS file.

Show Technorati Tags to the end of post: '. $options["apf_add_tag"] . ' 

The label for the tag list: for example ("<b>Technorati Tags: </b>")

Addtional Option:


Show Footer Every Where: '. $options["apf_show_all"] . ' 
Footer will show only in single post by default. Change this option to "Yes" to force the plug-in to show the footer every where when the post are shown. Including index page.

Keep Plugin credit: '. $options["apf_add_credit"] . ' 

Please refer to Add Post Footer Plugin page for complete list of custom field key and value

Reset Plugin

By pressing the "Reset" button, the plugin will be reset. This means that the stored options will be deleted from the WordPress database. Although it is not necessary, you should consider doing this before uninstalling the plugin, so no trace is left behind.

'); } function apf_get_option($option_name) { $option_name = stripslashes($option_name); $option_name = trim($option_name); return $option_name; } function apf_add_tags($taged_text) { $options = get_option("add_post_footer_opts"); $apf_tag_label = $options["apf_tag_label"]; if (empty($apf_tag_label)){ $pre_replacement = '
'; } else { $pre_replacement = '
' . apf_get_option($apf_tag_label); } $post_replacement = '
'; $tag_url = "http://technorati.com/tag/"; $tag_pattern = '/(\[tag\](.*?)\[\/tag\])/i'; $tags_pattern = '/((?:

)?\s*\[tags\](.*?)\[\/tags\]\s*(?:<\/p>)?)/i'; $tags_count = 0; $taglist_exists = 0; # Check for in-post [tag] [/tag] if (preg_match_all ($tag_pattern, $taged_text, $matches)) { unset($technotags); $technotags = $pre_replacement; for ($m=0; $m

if (empty($apf_relpost_txt)) { $apf_relpost_txt = '

Related Articles:

'. PHP_EOL .'
    '; }else{ $apf_relpost_txt = '

    ' . trim($options["apf_relpost_title"]) . '

    '. PHP_EOL .'
      '; } //Assign Max. Post if (empty($apf_relpost_no)) $apf_relpost_no = '5'; //Get category list foreach((get_the_category()) as $category) { $apf_catid .= '&category=' . $category->cat_ID; } //Query Post $apf_myposts = get_posts('numberposts=' . $apf_relpost_no . $apf_catid . '&orderby=post_date'); //Assign posts to list foreach($apf_myposts as $post) : setup_postdata($post); $apf_list_post_id = $post->ID; if ($apf_dis_id != $apf_list_post_id) { $apf_list_post_title = $post->post_title; $apf_list_post_link = $post->guid; $apf_relpost_txt .= ''; } endforeach; //Point back to current post $apf_dis_id = intval($apf_dis_id); $apf_myposts = apff_get_posts('post_id='.$apf_dis_id); foreach($apf_myposts as $post) : setup_postdata($post); endforeach; //=========================== $apf_relpost_txt .= ''; //close list and div $apf_relpost_txt .= '
    '; // kill variable unset($apf_catid, $apf_myposts); return $apf_relpost_txt; } function apf_ad_code() { global $posts; $options = get_option("add_post_footer_opts"); $apf_add_ad_code = $options["apf_add_ad_code"]; //add ad code if ($apf_add_ad_code != 'No'){ $apf_cusfld_ad_code = get_post_meta($posts[0]->ID, 'apf_ad_code' , true); if ($apf_cusfld_ad_code == '0'){ $apf_ad_code = ''; }elseif (!empty($apf_cusfld_ad_code)){ $apf_ad_code = '

    '. $apf_cusfld_ad_code . '

    '; }else{ $apf_ad_code = '

    '. $options["apf_ad_code"] . '

    '; } if (!empty($apf_ad_code)) $apf_ad_code = apf_get_option($apf_ad_code); } return $apf_ad_code; } function apf_rel_post(){ global $posts; $options = get_option("add_post_footer_opts"); //add related posts $apf_add_relpost = $options["apf_add_relpost"]; $apf_cusfld_relpost = trim(get_post_meta($posts[0]->ID, 'apf_relate_post' , true)); if (($apf_add_relpost != 'No') || ($apf_cusfld_relpost == '1')){ if ($apf_cusfld_relpost != '0') { $apf_rel_post = apf_get_relate_post($posts[0]->ID); } } return $apf_rel_post; } function add_post_footer($text) { global $posts; //get apf options. $options = get_option("add_post_footer_opts"); $apf_show_all = $options["apf_show_all"]; if (is_single() || ($apf_show_all == 'Yes')){ $apf_set_order = $options["apf_set_order"]; if ($apf_set_order == 'Yes'){ $text .= apf_ad_code(); $text .= apf_rel_post(); } else { $text .= apf_rel_post(); $text .= apf_ad_code(); } //add optional text $apf_optional_txt = $options["apf_optional_txt"]; $apf_cusfld_option_txt = get_post_meta($posts[0]->ID, 'apf_option_txt' , true); if ($apf_cusfld_option_txt != '0'){ if (empty($apf_cusfld_option_txt)){ if (!empty($apf_optional_txt)) $text .= apf_get_option($apf_optional_txt); }else{ $text .= $apf_cusfld_option_txt; } } } //add simple tags $apf_add_tag = $options["apf_add_tag"]; if ($apf_add_tag != 'No'){ $text = apf_add_tags($text); } $apf_add_credit = $options["apf_add_credit"]; if ($apf_add_credit != 'No'){ $text .= '

    Post Footer automatically generated by Add Post Footer Plugin for wordpress.

    '; } return $text; } add_action('admin_menu', 'apf_add_pages'); add_action('the_content', 'add_post_footer',0); ?>