Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2013 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5730886 to your computer and use it in GitHub Desktop.
Save anonymous/5730886 to your computer and use it in GitHub Desktop.
Refactored the unn_admin(), because let's face it... It needed it!
<?php
function unn_admin() {
$options = array(
'noindex_date' => '', 'noindex_search' => '', 'noindex_cat' => '', 'noindex_tags' => '', 'noindex_auth' => '', 'noindex_login' => '', 'noindex_pages' => '',
'noindex_admin' => '', 'nofollow_archives' => '', 'nofollow_cats' => '', 'nofollow_pages' => '', 'nofollow_register' => '', 'nofollow_login' => ''
);
if( isset($_POST['unn_hidden']) && $_POST['unn_hidden'] == 'Y') :
//Form data sent
foreach ($options as $opt => $value) {
if ( isset($_POST[$opt]) ) {
$options[$opt] = $_POST["unn_$opt"];
update_option($opt, $_POST["unn_$opt"]);
}
}
?>
<div class="updated"><p><strong><?php _e('Options saved.' ); ?></strong></p></div>
<?php
else :
//Normal page display
$textarea = array('noindex_pages','nofollow_pages');
foreach ($options as $opt => $value) {
$val = get_option("unn_$opt");
if ( isset($val) && !empty($val) ) $options[$opt] = $val;
else if(! in_array($opt,$textarea) ) $options[$opt] = 'unchecked';
}
endif;
extract($options);
?>
<div class="wrap">
<h2><?php _e('Ultimate Noindex Nofollow Options') ?></h2>
<form name="unn_admin_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
<input type="hidden" name="unn_hidden" value="Y">
<table>
<tr>
<td colspan="2">
<h3>Noindex</h3>
<p>Enter page ID's of the pages you want noindexed. Separate multiple page ID's with a comma.</p>
<textarea name="unn_noindex_pages"><?php echo $noindex_pages; ?></textarea>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_noindex_date" type="checkbox" value="yes" <?php checked('yes', get_option('unn_noindex_date')); ?> /></td>
<td><?php _e("Add noindex meta tag to date based archives." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_noindex_search" type="checkbox" value="yes" <?php checked('yes', get_option('unn_noindex_search')); ?> /></td>
<td><?php _e("Add noindex meta tag to search result pages." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_noindex_cat" type="checkbox" value="yes" <?php checked('yes', get_option('unn_noindex_cat')); ?> /></td>
<td><?php _e("Add noindex meta tag to category pages." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_noindex_tags" type="checkbox" value="yes" <?php checked('yes', get_option('unn_noindex_tags')); ?> /></td>
<td><?php _e("Add noindex meta tag to tag pages." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_noindex_auth" type="checkbox" value="yes" <?php checked('yes', get_option('unn_noindex_auth')); ?> /></td>
<td><?php _e("Add noindex meta tag to author pages." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_noindex_login" type="checkbox" value="yes" <?php checked('yes', get_option('unn_noindex_login')); ?> /></td>
<td><?php _e("Add noindex meta tag to login page." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_noindex_admin" type="checkbox" value="yes" <?php checked('yes', get_option('unn_noindex_admin')); ?> /></td>
<td><?php _e("Add noindex meta tag to admin pages." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<h3>Nofollow</h3>
<p>Enter page ID's or page slugs of the pages you want nofollowed. Separate multiple page ID's <br>
or page slugs with a comma.</p>
<p><small><strong>Note:</strong> Page ID's and page slugs are not interchangable here. You must use one or the other <br>
depending on how your permalinks are structured.</small></p>
<textarea name="unn_nofollow_pages"><?php echo $nofollow_pages; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<p><small>Choose only one of these, as you probably don't want to nofollow both categories and archives.</small></p>
</td>
</tr>
<tr>
<td><input name="unn_nofollow_archives" type="checkbox" value="yes" <?php checked('yes', get_option('unn_nofollow_archives')); ?> /></td>
<td><?php _e("Nofollow the archive links in your theme." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_nofollow_cats" type="checkbox" value="yes" <?php checked('yes', get_option('unn_nofollow_cats')); ?> /></td>
<td><?php _e("Nofollow the category links in your theme." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_nofollow_register" type="checkbox" value="yes" <?php checked('yes', get_option('unn_nofollow_register')); ?> /></td>
<td><?php _e("Nofollow the register link in your theme." ); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="unn_nofollow_login" type="checkbox" value="yes" <?php checked('yes', get_option('unn_nofollow_login')); ?> /></td>
<td><?php _e("Nofollow the login link in your theme." ); ?></td>
</tr>
<tr>
<td colspan="2"><p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options') ?>" /></p></td>
</tr>
</table>
</form>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment