PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.4
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.4
4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 All 183 releases
elementskit-lite / widgets / post-list / post-list-handler.php
post-list-handler.php
64 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4
5 class ElementsKit_Widget_Post_List_Handler extends \ElementsKit_Lite\Core\Handler_Widget{
6
7 public function wp_init(){
8 // post view count based on single page visit
9 add_action( 'wp_head', array($this, 'ekit_track_post_views'));
10 }
11
12 public function ekit_track_post_views ($post_id) {
13 if ( !is_single() ) return;
14 if ( empty ( $post_id) ) {
15 global $post;
16 $post_id = $post->ID;
17 }
18 $this->ekit_set_post_views($post_id);
19 }
20
21
22 public function ekit_set_post_views($postID) {
23 $count_key = 'ekit_post_views_count';
24 $count = get_post_meta($postID, $count_key, true);
25 if($count==''){
26 $count = 1;
27 delete_post_meta($postID, $count_key);
28 add_post_meta($postID, $count_key, '1');
29 }else{
30 $count++;
31 update_post_meta($postID, $count_key, $count);
32 }
33 }
34
35 static function get_name() {
36 return 'elementskit-post-list';
37 }
38
39
40 static function get_title() {
41 return esc_html__( 'Post List', 'elementskit-lite' );
42 }
43
44
45 static function get_icon() {
46 return 'ekit ekit-widget-icon ekit-post-list';
47 }
48
49 static function get_keywords() {
50 return ['ekit', 'list', 'post list', 'post', 'elementskit post list'];
51 }
52
53 static function get_categories() {
54 return [ 'elementskit' ];
55 }
56
57 static function get_dir() {
58 return \ElementsKit_Lite::widget_dir() . 'post-list/';
59 }
60
61 static function get_url() {
62 return \ElementsKit_Lite::widget_url() . 'post-list/';
63 }
64 }