PluginProbe
Powerkit – Supercharge your WordPress Site / 2.4.4
Powerkit – Supercharge your WordPress Site v2.4.4
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / twitter / public / twitter-template.php

twitter-template.php in Powerkit – Supercharge your WordPress Site 2.4.4, at modules/twitter/public/twitter-template.php

160 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Twitter Template
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package PowerKit
9 * @subpackage PowerKit/templates
10 */
11
12 /**
13 * Default Template
14 *
15 * @param array $tweets List of tweets.
16 * @param array $params Parameters.
17 */
18 function powerkit_twitter_default_template( $tweets, $params ) {
19
20 $template = isset( $params['template'] ) ? $params['template'] : 'default';
21 ?>
22
23 <div class="pk-twitter-wrap pk-twitter-<?php echo esc_attr( $template ); ?>">
24
25 <?php
26 if ( is_array( $tweets ) && $tweets ) {
27
28 $name = $tweets[0]->user->name;
29 $screen_name = $tweets[0]->user->screen_name;
30 $avatar = $tweets[0]->user->profile_image_url_https;
31 $following = (int) $tweets[0]->user->friends_count;
32 $followers = (int) $tweets[0]->user->followers_count;
33
34 $avatar_1x = str_replace( '_normal', '_normal', $avatar );
35 $avatar_2x = str_replace( '_normal', '_reasonably_small', $avatar );
36
37 if ( $params['header'] ) {
38 ?>
39 <div class="pk-twitter-header">
40 <div class="pk-twitter-container">
41 <?php if ( $avatar ) { ?>
42 <a href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" class="pk-twitter-link" target="_blank">
43 <?php
44 $image_avatar = sprintf(
45 '<img src="%s" srcset="%s" alt="avatar" class="pk-twitter-avatar">',
46 esc_url( $avatar_1x ), esc_url( $avatar_1x ) . ' 1x, ' . esc_url( $avatar_2x ) . ' 2x'
47 );
48
49 echo wp_kses_post( apply_filters( 'powerkit_lazy_process_images', $image_avatar ) );
50 ?>
51 </a>
52 <?php } ?>
53
54 <?php $tag = apply_filters( 'powerkit_twitter_name_tag', 'h6' ); ?>
55
56 <div class="pk-twitter-info">
57 <<?php echo esc_html( $tag ); ?> class="pk-twitter-name pk-title pk-font-heading">
58 <a href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" target="_blank">
59 <?php echo esc_html( $name ); ?>
60 </a>
61 </<?php echo esc_html( $tag ); ?>>
62
63 <?php if ( $name !== $screen_name ) { ?>
64 <span class="pk-twitter-username pk-color-secondary">
65 <a href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" target="_blank">
66 @<?php echo wp_kses_post( $screen_name ); ?>
67 </a>
68 </span>
69 <?php } ?>
70 </div>
71 </div>
72
73 <div class="pk-twitter-counters pk-color-secondary">
74 <div class="counter following">
75 <span class="number"><?php echo esc_html( powerkit_abridged_number( $following, 0 ) ); ?></span> <?php esc_html_e( 'Following', 'powerkit' ); ?>
76 </div>
77 <div class="counter followers">
78 <span class="number"><?php echo esc_html( powerkit_abridged_number( $followers, 0 ) ); ?></span> <?php esc_html_e( 'Followers', 'powerkit' ); ?>
79 </div>
80 </div>
81 </div>
82 <?php
83 }
84 ?>
85
86 <div class="pk-tweets">
87
88 <?php
89 foreach ( $tweets as $tweet ) {
90 $retweets = $tweet->retweet_count > 0 ? $tweet->retweet_count : '';
91 $tweet_id = $tweet->id_str;
92 $time = powerkit_relative_time( $tweet->created_at );
93 $text = powerkit_twitter_convert_links( $tweet->text );
94 ?>
95 <div class="pk-twitter-tweet">
96
97 <div class="pk-twitter-content pk-color-secondary"><?php echo wp_kses_post( $text ); ?></div>
98 <a href="https://twitter.com/<?php echo esc_attr( $screen_name ); ?>/status/<?php echo esc_attr( $tweet_id ); ?>" class="pk-twitter-time pk-font-secondary timestamp" target="_blank"><?php echo esc_html( $time ); ?></a>
99
100 <div class="pk-twitter-actions">
101 <ul>
102 <li>
103 <a onClick="window.open('https://twitter.com/intent/tweet?in_reply_to=<?php echo esc_attr( $tweet_id ); ?>','Twitter','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-reply" href="https://twitter.com/intent/tweet?in_reply_to=<?php echo esc_attr( $tweet_id ); ?>">
104 <i class="pk-icon pk-icon-reply"></i>
105 <span class="pk-twitter-label pk-twitter-reply"><?php esc_html_e( 'Reply', 'powerkit' ); ?></span>
106 </a>
107 </li>
108 <li>
109 <a onClick="window.open('https://twitter.com/intent/retweet?tweet_id=<?php echo esc_attr( $tweet_id ); ?>','Twitter','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-retweet" href="https://twitter.com/intent/retweet?tweet_id=<?php echo esc_attr( $tweet_id ); ?>">
110 <i class="pk-icon pk-icon-retweet"></i>
111 <span class="pk-twitter-count"><?php echo wp_kses_post( $retweets ); ?></span>
112 <span class="pk-twitter-label pk-twitter-retweet"><?php esc_html_e( 'Retweet', 'powerkit' ); ?></span>
113 </a>
114 </li>
115 <li>
116 <a onClick="window.open('https://twitter.com/intent/favorite?tweet_id=<?php echo esc_attr( $tweet_id ); ?>','Twitter','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-favorite" href="https://twitter.com/intent/favorite?tweet_id=<?php echo esc_attr( $tweet_id ); ?>">
117 <i class="pk-icon pk-icon-like"></i>
118 <span class="pk-twitter-label pk-twitter-favorite"><?php esc_html_e( 'Favorite', 'powerkit' ); ?></span>
119 </a>
120 </li>
121 </ul>
122 </div>
123
124 </div>
125 <?php
126 }
127 ?>
128 </div>
129
130 <?php
131 if ( $params['button'] ) {
132 $href = sprintf( 'https://twitter.com/%s/', $screen_name );
133 $text = apply_filters( 'powerkit_twitter_follow', esc_html__( 'Follow', 'powerkit' ) );
134
135 if ( isset( $params[ 'is_block' ] ) && isset( $params[ 'block_attrs' ] ) && $params[ 'is_block' ] ) {
136 ?>
137 <div class="pk-twitter-footer">
138 <?php powerkit_print_gutenberg_blocks_button( $text, $href, '_blank', 'button', $params[ 'block_attrs' ] ); ?>
139 </div>
140 <?php
141 } else {
142 ?>
143 <div class="pk-twitter-footer">
144 <a class="pk-twitter-btn button" href="<?php echo esc_url( $href ); ?>" target="_blank">
145 <span class="pk-twitter-follow"><?php echo wp_kses( $text, 'post' ); ?></span>
146 </a>
147 </div>
148 <?php
149 }
150 }
151 } else {
152 ?>
153 <p><?php esc_html_e( 'Twitter user not found. Please check your Twitter User ID.', 'powerkit' ); ?></p>
154 <?php
155 }
156 ?>
157 </div>
158 <?php
159 }
160