OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33
Information System : 365 * 10, 'metric' => 'visitors', 'global' => false, ]; $args = shortcode_atts($default_args, $args, self::SHORTCODE); $args['days'] = abs((int) $args['days']); $id = $args['global'] && $args['global'] !== 'false' && $args['global'] !== '0' ? 0 : (int) get_the_ID(); $start_date_str = $args['days'] === 0 ? 'today midnight' : "-{$args['days']} days"; $start_date = create_local_datetime($start_date_str)->format('Y-m-d'); $end_date = create_local_datetime('tomorrow midnight')->format('Y-m-d'); $cache_key = 'ka_counter_' . $id . $args['metric'][0] . $args['days']; $count = get_transient($cache_key); if (!$count) { $stats = new Stats(); $totals = $stats->get_totals($start_date, $end_date, $id); $count = $args['metric'] === 'pageviews' ? $totals->pageviews : $totals->visitors; set_transient($cache_key, $count, 60); } return '' . $count . ''; } }