%s
',
'https://wp-statistics.com/product/wp-statistics-mini-chart?utm_source=wp_statistics&utm_medium=display&utm_campaign=wordpress',
__('Unlock!', 'wp-statistics'),
WP_STATISTICS_URL . 'assets/images/mini-chart-posts-preview.png'
);
echo apply_filters("wp_statistics_before_hit_column_{$post_type}", $preview_chart_unlock_html, $post_id, $post_type);
echo sprintf('%s',
Menus::admin_url('pages', array('ID' => $post_id, 'type' => $post_type)),
number_format($hit_number)
);
}
}
}
/**
* Added Sortable Params
*
* @param $columns
* @return mixed
*/
public function modify_sortable_columns($columns)
{
$columns['wp-statistics-post-hits'] = 'hits';
return $columns;
}
/**
* Sort Post By Hits
*
* @param $clauses
* @param $query
*/
public function modify_order_by_hits($clauses, $query)
{
global $wpdb;
// Check in Admin
if (!is_admin()) {
return;
}
// If order-by.
if (isset($query->query_vars['orderby']) and isset($query->query_vars['order']) and $query->query_vars['orderby'] == 'hits') {
// Get global Variable
$order = $query->query_vars['order'];
// Select Field
$clauses['fields'] .= ", (select SUM(" . DB::table("pages") . ".count) from " . DB::table("pages") . " where (" . DB::table("pages") . ".type = 'page' OR " . DB::table("pages") . ".type = 'post' OR " . DB::table("pages") . ".type = 'product') AND {$wpdb->posts}.ID = " . DB::table("pages") . ".id) as post_hits_sortable ";
// And order by it.
$clauses['orderby'] = " coalesce(post_hits_sortable, 0) $order";
}
return $clauses;
}
/**
* Delete All Post Hits When Post is Deleted
*
* @param $post_id
*/
public static function modify_delete_post($post_id)
{
global $wpdb;
$wpdb->query("DELETE FROM `" . DB::table('pages') . "` WHERE `id` = " . esc_sql($post_id) . " AND (`type` = 'post' OR `type` = 'page' OR `type` = 'product');");
}
/**
* Add Post Hit Number in Publish Meta Box in WordPress Edit a post/page
*/
public function post_hit_misc()
{
global $post;
if ($post->post_status == 'publish') {
echo "";
}
}
/**
* Define Hit Chart Meta Box
*/
public function define_post_meta_box()
{
// Get MetaBox information
$metaBox = Meta_Box::getList(self::$hits_chart_post_meta_box);
// Add MEtaBox To all Post Type
foreach (Helper::get_list_post_type() as $screen) {
add_meta_box(Meta_Box::getMetaBoxKey(self::$hits_chart_post_meta_box), $metaBox['name'], Meta_Box::LoadMetaBox(self::$hits_chart_post_meta_box), $screen, 'normal', 'high', array('__block_editor_compatible_meta_box' => true, '__back_compat_meta_box' => false));
}
}
}
new Admin_Post;