Files
profile/popularnode.php
Andrey Kuvshinov 8fc8cbae32 add files
2025-07-09 21:21:17 +03:00

22 lines
696 B
PHP

<?php
/*
Template Name: Popular node
*/
$posts = json_decode(get_option('ppp_options'));
$ratios = array_slice(array_map(function($obj){$obj->rate = get_post_meta($obj->id,'popular_hide', true) == 1 ? 0 : get_post_meta($obj->id,'popular_ratio', true); return $obj;}, $posts), 0, 10);
$rates = array();
foreach ($ratios as $item){
$rate = 100 * $item->rate/array_sum(array_map(function($obj){return $obj->rate;}, $ratios));
$rates[$item->id] = $rate;
}
$count = (int)get_option('popularnode_count');
$count = $count+1;
update_option('popularnode_count', $count);
wp_redirect(get_permalink(chance($rates)), 301);
exit;
?>