Navigation Menu

Skip to content

Commit

Permalink
added rewrite_rule for example.com/humans.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle committed Mar 1, 2012
1 parent 72f62d6 commit 6f5a569
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions humanstxt.php
@@ -1,9 +1,9 @@
<?php <?php
/* /*
Plugin Name: humans.txt Plugin Name: humans.txt
Plugin URI: http://notizblog.org/ Plugin URI: https://github.com/pfefferle/humanstxt
Description: humans.txt for WordPress Description: humans.txt for WordPress
Version: 0.1 Version: 0.2
Author: pfefferle Author: pfefferle
Author URI: http://notizblog.org/ Author URI: http://notizblog.org/
*/ */
Expand Down Expand Up @@ -54,11 +54,11 @@ function humanstxt_query_vars($vars) {
* @param object $wp_rewrite WP_Rewrite object * @param object $wp_rewrite WP_Rewrite object
*/ */
function humanstxt_rewrite_rules($wp_rewrite) { function humanstxt_rewrite_rules($wp_rewrite) {
$wellKnownRules = array( $rewrite_rules = array(
'humans.txt' => 'index.php?humanstxt' 'humans.txt' => 'index.php?humanstxt=true'
); );


$wp_rewrite->rules = $wellKnownRules + $wp_rewrite->rules; $wp_rewrite->rules = $rewrite_rules + $wp_rewrite->rules;
} }
add_action('generate_rewrite_rules', 'humanstxt_rewrite_rules'); add_action('generate_rewrite_rules', 'humanstxt_rewrite_rules');


Expand All @@ -68,7 +68,8 @@ function humanstxt_rewrite_rules($wp_rewrite) {
* @param object $wp WP instance for the current request * @param object $wp WP instance for the current request
*/ */
function humanstxt_parse_request($wp) { function humanstxt_parse_request($wp) {
if(isset($_GET['humanstxt'])) { global $wp;
if(array_key_exists('humanstxt', $wp->query_vars)) {
humanstxt_write(); humanstxt_write();
} }
} }
Expand Down Expand Up @@ -105,4 +106,14 @@ function humanstxt_default_team_data($data, $user) {


return $data; return $data;
} }
add_filter('humanstxt_team_data', 'humanstxt_default_team_data', 1, 2); add_filter('humanstxt_team_data', 'humanstxt_default_team_data', 1, 2);

/**
* reset rewrite rules
*/
function humanstxt_flush_rewrite_rules() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
register_activation_hook(__FILE__, 'humanstxt_flush_rewrite_rules');
register_deactivation_hook(__FILE__, 'humanstxt_flush_rewrite_rules');

0 comments on commit 6f5a569

Please sign in to comment.