PluginProbe
Powerkit – Supercharge your WordPress Site / 3.0.4
Powerkit – Supercharge your WordPress Site v3.0.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 3.0.4, at modules/twitter/public/twitter-template.php

155 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * X (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 if ( $params['header'] ) {
28 ?>
29 <div class="pk-twitter-header">
30 <div class="pk-twitter-container">
31 <?php if ( $tweets['avatar_1x'] ) { ?>
32 <a href="<?php echo esc_url( sprintf( 'https://x.com/%s/', $tweets['username'] ) ); ?>" class="pk-twitter-link" target="_blank">
33 <?php
34 $image_avatar = sprintf(
35 '<img src="%s" srcset="%s" alt="avatar" class="pk-twitter-avatar">',
36 esc_url( $tweets['avatar_1x'] ), esc_url( $tweets['avatar_1x'] ) . ' 1x, ' . esc_url( $tweets['avatar_2x'] ) . ' 2x'
37 );
38
39 echo wp_kses_post( apply_filters( 'powerkit_lazy_process_images', $image_avatar ) );
40 ?>
41 </a>
42 <?php } ?>
43
44 <?php $tag = apply_filters( 'powerkit_twitter_name_tag', 'h6' ); ?>
45
46 <div class="pk-twitter-info">
47 <<?php echo esc_html( $tag ); ?> class="pk-twitter-name pk-title pk-font-heading">
48 <a href="<?php echo esc_url( sprintf( 'https://x.com/%s/', $tweets['username'] ) ); ?>" target="_blank">
49 <?php echo esc_html( $tweets['name'] ); ?>
50 </a>
51 </<?php echo esc_html( $tag ); ?>>
52
53 <?php if ( $tweets['name'] !== $tweets['username'] ) { ?>
54 <span class="pk-twitter-username pk-color-secondary">
55 <a href="<?php echo esc_url( sprintf( 'https://x.com/%s/', $tweets['username'] ) ); ?>" target="_blank">
56 @<?php echo wp_kses_post( $tweets['username'] ); ?>
57 </a>
58 </span>
59 <?php } ?>
60 </div>
61 </div>
62
63 <div class="pk-twitter-counters pk-color-secondary">
64 <div class="counter following">
65 <span class="number"><?php echo esc_html( powerkit_abridged_number( $tweets['following'], 0 ) ); ?></span> <?php esc_html_e( 'Following', 'powerkit' ); ?>
66 </div>
67 <div class="counter followers">
68 <span class="number"><?php echo esc_html( powerkit_abridged_number( $tweets['followers'], 0 ) ); ?></span> <?php esc_html_e( 'Followers', 'powerkit' ); ?>
69 </div>
70 </div>
71 </div>
72 <?php
73 }
74 ?>
75
76 <div class="pk-tweets">
77 <?php
78 if ( isset( $tweets['items'] ) && $tweets['items'] ) {
79 $counter = 1;
80 foreach ( $tweets['items'] as $tweet ) {
81
82 if ( $counter > $params['number'] ) {
83 break;
84 }
85
86 $time = powerkit_relative_time( $tweet['date'] );
87 $text = powerkit_twitter_convert_links( $tweet['text'] );
88 ?>
89 <div class="pk-twitter-tweet">
90 <div class="pk-twitter-content pk-color-secondary"><?php echo wp_kses_post( $text ); ?></div>
91 <a href="https://x.com/<?php echo esc_attr( $tweets['username'] ); ?>/status/<?php echo esc_attr( $tweet['tweet_id'] ); ?>" class="pk-twitter-time pk-font-secondary timestamp" target="_blank"><?php echo esc_html( $time ); ?></a>
92
93 <div class="pk-twitter-actions">
94 <ul>
95 <li>
96 <a onClick="window.open('https://x.com/intent/tweet?in_reply_to=<?php echo esc_attr( $tweet['tweet_id'] ); ?>','X','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-reply" href="https://x.com/intent/tweet?in_reply_to=<?php echo esc_attr( $tweet['tweet_id'] ); ?>">
97 <i class="pk-icon pk-icon-reply"></i>
98 <span class="pk-twitter-label pk-twitter-reply"><?php esc_html_e( 'Reply', 'powerkit' ); ?></span>
99 </a>
100 </li>
101 <li>
102 <a onClick="window.open('https://x.com/intent/retweet?tweet_id=<?php echo esc_attr( $tweet['tweet_id'] ); ?>','X','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-retweet" href="https://x.com/intent/retweet?tweet_id=<?php echo esc_attr( $tweet['tweet_id'] ); ?>">
103 <i class="pk-icon pk-icon-retweet"></i>
104 <span class="pk-twitter-count"><?php echo wp_kses_post( $tweet['retweets'] ? $tweet['retweets'] : '' ); ?></span>
105 <span class="pk-twitter-label pk-twitter-retweet"><?php esc_html_e( 'Retweet', 'powerkit' ); ?></span>
106 </a>
107 </li>
108 <li>
109 <a onClick="window.open('https://x.com/intent/favorite?tweet_id=<?php echo esc_attr( $tweet['tweet_id'] ); ?>','X','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-favorite" href="https://x.com/intent/favorite?tweet_id=<?php echo esc_attr( $tweet['tweet_id'] ); ?>">
110 <i class="pk-icon pk-icon-like"></i>
111 <span class="pk-twitter-label pk-twitter-favorite"><?php esc_html_e( 'Favorite', 'powerkit' ); ?></span>
112 </a>
113 </li>
114 </ul>
115 </div>
116
117 </div>
118 <?php
119 ++$counter;
120 }
121 } else {
122 powerkit_alert_warning( sprintf( __( 'The list is empty. To display the feed, add elements on the <a href="%s" target="_blank">settings page</a>.', 'powerkit' ), admin_url( 'options-general.php?page=powerkit_connect&tab=twitter' ) ) );
123 }
124 ?>
125 </div>
126
127 <?php
128 if ( $params['button'] ) {
129 $href = sprintf( 'https://x.com/%s/', $tweets['username'] );
130 $text = apply_filters( 'powerkit_twitter_follow', esc_html__( 'Follow', 'powerkit' ) );
131
132 if ( isset( $params['is_block'] ) && isset( $params['block_attrs'] ) && $params['is_block'] ) {
133 ?>
134 <div class="pk-twitter-footer">
135 <?php powerkit_print_gutenberg_blocks_button( $text, $href, '_blank', 'button', $params['block_attrs'] ); ?>
136 </div>
137 <?php
138 } else {
139 ?>
140 <div class="pk-twitter-footer">
141 <a class="pk-twitter-btn button" href="<?php echo esc_url( $href ); ?>" target="_blank">
142 <span class="pk-twitter-follow"><?php echo wp_kses( $text, 'post' ); ?></span>
143 </a>
144 </div>
145 <?php
146 }
147 }
148 } else {
149 powerkit_alert_warning( sprintf( __( 'No data found, please fill in the fields on the <a href="%s" target="_blank">settings page</a>.', 'powerkit' ), admin_url( 'options-general.php?page=powerkit_connect&tab=twitter' ) ) );
150 }
151 ?>
152 </div>
153 <?php
154 }
155