Commit 7f3e6409 authored by Rafael Chaves Freitas's avatar Rafael Chaves Freitas

define a random GET parameter when users are logged in

parent fa2f0242
...@@ -14,19 +14,12 @@ add_action( 'admin_init', function(){ ...@@ -14,19 +14,12 @@ add_action( 'admin_init', function(){
<input name="admin_qs__use" id="admin_qs__use" type="checkbox" value="1" class="code" <?= checked( 1, get_option( 'admin_qs__use' ), false ) ?> /> <?php _e('Adicionar parâmetro GET nas urls para os editores.', 'guaraci') ?> <input name="admin_qs__use" id="admin_qs__use" type="checkbox" value="1" class="code" <?= checked( 1, get_option( 'admin_qs__use' ), false ) ?> /> <?php _e('Adicionar parâmetro GET nas urls para os editores.', 'guaraci') ?>
</label> </label>
</p> </p>
<p>
<label>
<?php _e('Nome do parâmetro get') ?><br>
<input name="admin_qs__param" id="admin_qs__param" type="text" value="<?= get_option('admin_qs__param', 'admin') ?>" class="code" />
</label>
</p>
<?php <?php
}, },
'general', 'general',
); );
register_setting( 'general', 'admin_qs__use' ); register_setting( 'general', 'admin_qs__use' );
register_setting( 'general', 'admin_qs__param' );
}); });
...@@ -36,7 +29,7 @@ add_action('wp', function (){ ...@@ -36,7 +29,7 @@ add_action('wp', function (){
$post_types = get_post_types(['public' => true]); $post_types = get_post_types(['public' => true]);
unset($post_types['attachment']); unset($post_types['attachment']);
$param = get_option('admin_qs__param', 'admin'); $param = base_convert (time() - strtotime (date('Y-m-d')), 10, 36);
add_filter('post_link', function($link, $post) use ($post_types, $param) { add_filter('post_link', function($link, $post) use ($post_types, $param) {
$link = urldecode($link); $link = urldecode($link);
...@@ -52,12 +45,9 @@ add_action('wp', function (){ ...@@ -52,12 +45,9 @@ add_action('wp', function (){
return $link; return $link;
} }
if(strpos($link, "?{$param}") > 0 || strpos($link, "&{$param}") > 0){ if(strpos($link, "?{$param}") > 0){
return $link; return $link;
} else if(strpos($link, '?') > 0){
return $link . "&{$param}";
} else { } else {
return $link . "?{$param}"; return $link . "?{$param}";
} }
...@@ -66,12 +56,9 @@ add_action('wp', function (){ ...@@ -66,12 +56,9 @@ add_action('wp', function (){
add_filter('term_link', function($link) use ($param) { add_filter('term_link', function($link) use ($param) {
$link = urldecode($link); $link = urldecode($link);
if(strpos($link, "?{$param}") > 0 || strpos($link, "&{$param}") > 0){ if(strpos($link, "?{$param}") > 0) {
return $link; return $link;
} else if(strpos($link, '?') > 0){
return $link . "&{$param}";
} else { } else {
return $link . "?{$param}"; return $link . "?{$param}";
} }
...@@ -79,12 +66,9 @@ add_action('wp', function (){ ...@@ -79,12 +66,9 @@ add_action('wp', function (){
add_filter('home_url', function($link) use ($param) { add_filter('home_url', function($link) use ($param) {
$link = urldecode($link); $link = urldecode($link);
if(strpos($link, "?{$param}") > 0 || strpos($link, "&{$param}") > 0){ if(strpos($link, "?") > 0){
return $link; return $link;
} else if(strpos($link, '?') > 0){
return $link . "&{$param}";
} else { } else {
return $link . "?{$param}"; return $link . "?{$param}";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment