' . __('Settings') . ''; array_unshift($links, $settings_link); } return $links; } $afterRead_plugin = plugin_basename(__FILE__); add_filter("plugin_action_links_$afterRead_plugin", 'afterRead_settings_link' ); //registers a afterRead function to be ran when wordpress is generating the post for display to the user, is generated everytime the page is called unless otherwise cached add_filter( "the_content", "afterRead_main"); //Runs afterRead_activation() when the plugin is activated register_activation_hook(__FILE__, 'afterRead_activation'); function afterRead_activation(){ //the afterRead settings page will save a blank option by default if the field is not populated. Thus the option is by default populated here when the user activates the plugin $afterRead_secure = mt_rand(); add_option( 'afterRead_secure', $afterRead_secure, '', 'no'); update_option( 'afterRead_secure', $afterRead_secure ); add_option( 'afterRead_suggestion_name', 'default', '', 'yes'); add_option( 'afterRead_custom_html', '
Go to the main page
', '', 'yes'); //Because save_guggestion.php, the file the handles writing out the "add new suggestion" admin option, cannot call the database we have to keep the key someplace where it can access it. It is saved in a php file so that a stranger cannot call the key file as they would be be able to if it was a .txt $afterRead_file_to_write = ''; $afterRead_name_to_write = dirname(__file__).'/afterRead_key_store.php'; $afterRead_fh = @fopen($afterRead_name_to_write, 'w') or die("Can't open file"); @fwrite($afterRead_fh, $afterRead_file_to_write); @fclose($afterRead_fh); } //the main function, it will php_include the sugestion template allowing the template to contain php, it then returns the results. function afterRead_main($afterRead_content) { if(is_single()){ //retrives the suggestion's name or defaults to "default" should it be false. $afterRead_sugestion_name = get_option( 'afterRead_suggestion_name', 'default' ); //formate the full file name by adding the extension and the template folder to the stored path $afterRead_sugestion_php = 'suggestions/'.$afterRead_sugestion_name.'.php'; //include the suggestion's code so that it can define suggestion stored in the $afterRead_sugestion varible include $afterRead_sugestion_php; $afterRead_plugin_tag=''; //merge the wordpress post(afterRead_content) with the suggestion ($afterRead_sugestion) and the afterRead tag $afterRead_content = $afterRead_content.$afterRead_plugin_tag.$afterRead_sugestion; //return the content for further proccesing by wordpress return $afterRead_content; } else { //since this post is being proccessed for display on the frontpage we do not want to include the afterRead suggestion but we still have to return the content return $afterRead_content; } } //This tells wordpress to add the afterRead page to the 'settings' menu add_action('admin_menu', 'afterRead_menu'); function afterRead_menu() { add_options_page('afterRead Options', 'afterRead', 'administrator', 'afterRead_options', 'afterRead_options'); add_action( 'admin_init', 'register_afterReadsettings' ); } //This is a required wordpress function that tells wordpress what options afterRead so that wordpress can do a bunch of backend stuff, saving me time and a headache function register_afterReadsettings() { register_setting( 'afterRead-settings-group-1', 'afterRead_suggestion_name' ); register_setting( 'afterRead-settings-group-2', 'afterRead_custom_html' ); register_setting( 'afterRead-settings-group-2', 'afterRead_option_ichi' ); register_setting( 'afterRead-settings-group-2', 'afterRead_option_ni' ); register_setting( 'afterRead-settings-group-2', 'afterRead_option_san' ); } //This is the function that creates the afterRead admin/settings page, sadly wordpress has really poor documentation for creating admin pages, or it is hidden waaaayyy too well, either way this part was a headache and a halve and required digging through otehr plugin setting pages to get looking right function afterRead_options() { ?>

afterRead

""

This plugin was developed by Warll Dressler, if there is something you think afterRead needs please email me or leave a comment here.