first commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Twitter block template
|
||||
*
|
||||
* @var $attributes - block attributes
|
||||
* @var $options - layout options
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
$params = array(
|
||||
'title' => esc_html__( 'Twitter Feed', 'powerkit' ),
|
||||
'username' => $attributes['username'],
|
||||
'number' => $attributes['number'],
|
||||
'header' => $attributes['showHeader'],
|
||||
'button' => $attributes['showFollowButton'],
|
||||
'replies' => $attributes['showReplies'],
|
||||
'retweets' => $attributes['showRetweets'],
|
||||
'template' => 'default',
|
||||
'is_block' => true,
|
||||
'block_attrs' => $attributes,
|
||||
);
|
||||
|
||||
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>';
|
||||
|
||||
// Instagram output.
|
||||
if ( $attributes['username'] ) {
|
||||
powerkit_twitter_get_recent( $params, 'powerkit_twitter_block_cache' );
|
||||
} else {
|
||||
powerkit_alert_warning( 'Twitter data is not set, please check the User Name.' );
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* The Gutenberg Block.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The initialize block.
|
||||
*/
|
||||
class Powerkit_Twitter_Block {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'block' ) );
|
||||
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the block's assets for the editor.
|
||||
*/
|
||||
public function block() {
|
||||
// Styles.
|
||||
wp_register_style(
|
||||
'powerkit-twitter-block-editor-style',
|
||||
plugins_url( 'css/public-powerkit-twitter.css', __FILE__ ),
|
||||
array( 'wp-edit-blocks' ),
|
||||
filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-twitter.css' )
|
||||
);
|
||||
|
||||
wp_style_add_data( 'powerkit-twitter-block-editor-style', 'rtl', 'replace' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register block
|
||||
*
|
||||
* @param array $blocks all registered blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function register_block_type( $blocks ) {
|
||||
$blocks[] = array(
|
||||
'name' => 'canvas/twitter',
|
||||
'title' => esc_html__( 'Twitter', 'powerkit' ),
|
||||
'description' => esc_html__( 'The block allows you to display feed from your twitter account.', 'powerkit' ),
|
||||
'category' => 'canvas',
|
||||
'keywords' => array(),
|
||||
'icon' => '
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M22 5.924C21.264 6.25 20.473 6.471 19.643 6.57C20.49 6.062 21.141 5.258 21.447 4.3C20.654 4.77 19.777 5.112 18.841 5.296C18.095 4.498 17.028 4 15.848 4C13.582 4 11.745 5.837 11.745 8.103C11.745 8.425 11.781 8.738 11.851 9.038C8.441 8.868 5.418 7.234 3.394 4.751C3.041 5.358 2.838 6.063 2.838 6.815C2.838 8.239 3.562 9.495 4.663 10.23C3.99 10.208 3.358 10.023 2.803 9.716V9.768C2.803 11.756 4.218 13.415 6.096 13.791C5.752 13.886 5.389 13.936 5.016 13.936C4.751 13.936 4.494 13.91 4.243 13.862C4.765 15.492 6.281 16.679 8.076 16.712C6.672 17.812 4.902 18.469 2.98 18.469C2.648 18.469 2.32 18.449 2 18.412C3.816 19.576 5.973 20.255 8.29 20.255C15.837 20.255 19.965 14.003 19.965 8.58C19.965 8.402 19.961 8.225 19.953 8.05C20.755 7.472 21.45 6.75 22 5.926V5.924Z" />
|
||||
</svg>
|
||||
',
|
||||
'supports' => array(
|
||||
'className' => true,
|
||||
'anchor' => true,
|
||||
'html' => false,
|
||||
'canvasSpacings' => true,
|
||||
'canvasBorder' => true,
|
||||
'canvasResponsive' => true,
|
||||
),
|
||||
'styles' => array(),
|
||||
'location' => array(),
|
||||
'sections' => array(
|
||||
'general' => array(
|
||||
'title' => esc_html__( 'Block Settings', 'powerkit' ),
|
||||
'priority' => 5,
|
||||
'open' => true,
|
||||
),
|
||||
'buttonSettings' => array(
|
||||
'title' => esc_html__( 'Button Settings', 'powerkit' ),
|
||||
'priority' => 50,
|
||||
),
|
||||
),
|
||||
'layouts' => array(),
|
||||
'fields' => array_merge(
|
||||
array(
|
||||
array(
|
||||
'key' => 'username',
|
||||
'label' => esc_html__( 'User Name', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'key' => 'showHeader',
|
||||
'label' => esc_html__( 'Display Header', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showFollowButton',
|
||||
'label' => esc_html__( 'Display Follow Button', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showReplies',
|
||||
'label' => esc_html__( 'Display Replies', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'key' => 'showRetweets',
|
||||
'label' => esc_html__( 'Display Retweets', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'key' => 'number',
|
||||
'label' => esc_html__( 'Number of Tweets', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'min' => 1,
|
||||
'max' => 12,
|
||||
'default' => 4,
|
||||
),
|
||||
), powerkit_get_gutenberg_button_fields(
|
||||
'button',
|
||||
'buttonSettings',
|
||||
array(
|
||||
array(
|
||||
'field' => 'showFollowButton',
|
||||
'operator' => '==',
|
||||
'value' => true,
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
|
||||
// enqueue registered scripts/styles.
|
||||
'editor_style' => 'powerkit-twitter-block-editor-style',
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Twitter_Block();
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*/
|
||||
class Powerkit_Twitter_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'init', array( $this, 'register_templates' ) );
|
||||
add_filter( 'powerkit_twitter_templates', array( $this, 'template_default' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Templates
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $templates List of Templates.
|
||||
*/
|
||||
public function register_templates( $templates = array() ) {
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/twitter-template.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Register Templates
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $templates List of Templates.
|
||||
*/
|
||||
public function template_default( $templates = array() ) {
|
||||
$templates = array(
|
||||
'default' => array(
|
||||
'name' => 'Default',
|
||||
'func' => 'powerkit_twitter_default_template',
|
||||
),
|
||||
);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-twitter', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-twitter.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-twitter', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Twitter
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/shortcodes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Twitter Shortcode
|
||||
*
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_twitter_shortcode( $atts, $content = '' ) {
|
||||
$params = powerkit_shortcode_atts( shortcode_atts( array(
|
||||
'title' => esc_html__( 'Twitter Feed', 'powerkit' ),
|
||||
'username' => '',
|
||||
'number' => 5,
|
||||
'template' => 'default',
|
||||
'header' => true,
|
||||
'button' => true,
|
||||
'replies' => false,
|
||||
'retweets' => false,
|
||||
), $atts ) );
|
||||
|
||||
ob_start();
|
||||
|
||||
powerkit_twitter_get_recent( $params, 'powerkit_twitter_shortcode_cache' );
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
add_shortcode( 'powerkit_twitter_feed', 'powerkit_twitter_shortcode' );
|
||||
|
||||
/**
|
||||
* Map Twitter Shortcode into the Basic Shortcodes Plugin
|
||||
*/
|
||||
if ( function_exists( 'powerkit_basic_shortcodes_register' ) ) :
|
||||
|
||||
$shortcode_map = array(
|
||||
'name' => 'twitter',
|
||||
'title' => esc_html__( 'Twitter Feed', 'powerkit' ),
|
||||
'priority' => 100,
|
||||
'base' => 'powerkit_twitter_feed',
|
||||
'autoregister' => false,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'username',
|
||||
'label' => esc_html__( 'Twitter user ID', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'number',
|
||||
'label' => esc_html__( 'Number of tweets to displays', 'powerkit' ),
|
||||
'default' => 5,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'header',
|
||||
'label' => esc_html__( 'Display header', 'powerkit' ),
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'button',
|
||||
'label' => esc_html__( 'Display follow button', 'powerkit' ),
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'replies',
|
||||
'label' => esc_html__( 'Include replies', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'retweets',
|
||||
'label' => esc_html__( 'Include retweets', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$templates = apply_filters( 'powerkit_twitter_templates', array() );
|
||||
|
||||
if ( count( (array) $templates ) > 1 ) {
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'select',
|
||||
'name' => 'template',
|
||||
'label' => esc_html__( 'Template', 'powerkit' ),
|
||||
'default' => 'default',
|
||||
'options' => powerkit_twitter_get_templates_options(),
|
||||
);
|
||||
}
|
||||
|
||||
powerkit_basic_shortcodes_register( $shortcode_map );
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Twitter
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget Twitter Class
|
||||
*/
|
||||
class Powerkit_Twitter_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$cache_timeout = (int) apply_filters( 'powerkit_twitter_cache_timeout', 60 );
|
||||
|
||||
$this->default_settings = apply_filters( 'powerkit_twitter_widget_settings', array(
|
||||
'title' => esc_html__( 'Twitter Feed', 'powerkit' ),
|
||||
'username' => '',
|
||||
'number' => 5,
|
||||
'template' => 'default',
|
||||
'header' => true,
|
||||
'button' => true,
|
||||
'retweets' => false,
|
||||
'replies' => false,
|
||||
'cache_time' => $cache_timeout,
|
||||
) );
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'powerkit_twitter_widget',
|
||||
'description' => esc_html__( 'A list of recent tweets.', 'powerkit' ),
|
||||
);
|
||||
parent::__construct( 'powerkit_twitter_widget', esc_html__( 'Twitter Feed', 'powerkit' ), $widget_details );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the content for the current widget instance.
|
||||
*
|
||||
* @param array $args Display arguments including 'before_title', 'after_title',
|
||||
* 'before_widget', and 'after_widget'.
|
||||
* @param array $instance Settings for the current widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS OK.
|
||||
?>
|
||||
|
||||
<div class="widget-body">
|
||||
<?php
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', wp_kses( $params['title'], 'pk-title' ), $instance, $this->id_base ) . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
powerkit_twitter_get_recent( $params, 'powerkit_twitter_widget_cache' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS OK.
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles updating settings for the current widget instance.
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via
|
||||
* WP_Widget::form().
|
||||
* @param array $old_instance Old settings for this instance.
|
||||
* @return array Settings to save or bool false to cancel saving.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = $new_instance;
|
||||
|
||||
// Display header.
|
||||
if ( ! isset( $instance['header'] ) ) {
|
||||
$instance['header'] = false;
|
||||
}
|
||||
|
||||
// Display follow button.
|
||||
if ( ! isset( $instance['button'] ) ) {
|
||||
$instance['button'] = false;
|
||||
}
|
||||
|
||||
// Include retweets.
|
||||
if ( ! isset( $instance['retweets'] ) ) {
|
||||
$instance['retweets'] = false;
|
||||
}
|
||||
|
||||
// Include replies.
|
||||
if ( ! isset( $instance['replies'] ) ) {
|
||||
$instance['replies'] = false;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
$templates = apply_filters( 'powerkit_twitter_templates', array() );
|
||||
?>
|
||||
<!-- Title -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $params['title'] ); ?>" /></p>
|
||||
|
||||
<!-- Twitter User ID -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php esc_html_e( 'Twitter user ID:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" type="text" value="<?php echo esc_attr( $params['username'] ); ?>" /></p>
|
||||
|
||||
<!-- Number of Tweets -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of tweets to display:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="number" value="<?php echo esc_attr( $params['number'] ); ?>" /></p>
|
||||
|
||||
<!-- Template -->
|
||||
<?php if ( count( (array) $templates ) > 1 ) : ?>
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'Template' ) ); ?>"><?php esc_html_e( 'Template:', 'powerkit' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>" class="widefat">
|
||||
<?php
|
||||
if ( $templates ) {
|
||||
foreach ( $templates as $key => $item ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $params['template'], $key ); ?>><?php echo esc_attr( $item['name'] ); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Display header -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'header' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'header' ) ); ?>" type="checkbox" <?php checked( (bool) $params['header'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'header' ) ); ?>"><?php esc_html_e( 'Display header', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Display follow button -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'button' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'button' ) ); ?>" type="checkbox" <?php checked( (bool) $params['button'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'button' ) ); ?>"><?php esc_html_e( 'Display follow button', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Display header -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'retweets' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'retweets' ) ); ?>" type="checkbox" <?php checked( (bool) $params['retweets'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'retweets' ) ); ?>"><?php esc_html_e( 'Include retweets', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Display follow button -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'replies' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'replies' ) ); ?>" type="checkbox" <?php checked( (bool) $params['replies'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'replies' ) ); ?>"><?php esc_html_e( 'Include replies', 'powerkit' ); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function powerkit_widget_init_twitter() {
|
||||
register_widget( 'Powerkit_Twitter_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'powerkit_widget_init_twitter' );
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-twitter-wrap {
|
||||
--pk-twitter-a-color: inherit;
|
||||
--pk-twitter-number-color: #000000;
|
||||
--pk-twitter-tweet-border-color: #eeeeee;
|
||||
--pk-twitter-a-font-family: inherit;
|
||||
--pk-twitter-username-font-size: 0.875rem;
|
||||
--pk-twitter-number-font-size: 0.875rem;
|
||||
--pk-twitter-number-font-weight: bold;
|
||||
--pk-twitter-content-font-size: 90%;
|
||||
--pk-twitter-counters-font-size: 80%;
|
||||
--pk-twitter-actions-font-size: 80%;
|
||||
--pk-twitter-label-font-size: 80%;
|
||||
--pk-twitter-count-font-size: 80%;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-twitter-wrap a {
|
||||
font-family: var(--pk-twitter-a-font-family);
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.pk-twitter-header {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-twitter-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-twitter-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: none;
|
||||
margin-left: 1rem;
|
||||
flex: 0 0 50px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-twitter-avatar {
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-twitter-info a {
|
||||
color: var(--pk-twitter-a-color);
|
||||
}
|
||||
|
||||
.pk-twitter-name {
|
||||
margin-bottom: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-twitter-username {
|
||||
font-size: var(--pk-twitter-username-font-size);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-twitter-counters {
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
font-size: var(--pk-twitter-counters-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-counters .counter + .counter {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-twitter-counters .number {
|
||||
color: var(--pk-twitter-number-color);
|
||||
font-weight: var(--pk-twitter-number-font-weight);
|
||||
font-size: var(--pk-twitter-number-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-tweet:after {
|
||||
display: table;
|
||||
clear: both;
|
||||
width: 100%;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.pk-twitter-content {
|
||||
font-size: var(--pk-twitter-content-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-twitter-count {
|
||||
margin-right: 0.25rem;
|
||||
font-size: var(--pk-twitter-count-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-label {
|
||||
margin-right: 0.25rem;
|
||||
font-size: var(--pk-twitter-label-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-count:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-twitter-time {
|
||||
display: block;
|
||||
float: right;
|
||||
margin-top: .25rem;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-twitter-time:before {
|
||||
font-family: "powerkit-icons";
|
||||
content: "\f099";
|
||||
margin-left: .25rem;
|
||||
}
|
||||
|
||||
.pk-twitter-actions {
|
||||
float: left;
|
||||
margin-top: .25rem;
|
||||
font-size: var(--pk-twitter-actions-font-size);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li {
|
||||
display: inline-block;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li:not(:last-child) {
|
||||
margin-left: .25rem;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li .pk-icon {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pk-twitter-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-twitter-footer .pk-twitter-btn {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-twitter-default .pk-twitter-tweet {
|
||||
padding-top: 1rem;
|
||||
margin-top: 1rem;
|
||||
border-top: 1px var(--pk-twitter-tweet-border-color) solid;
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-twitter-wrap {
|
||||
--pk-twitter-a-color: inherit;
|
||||
--pk-twitter-number-color: #000000;
|
||||
--pk-twitter-tweet-border-color: #eeeeee;
|
||||
--pk-twitter-a-font-family: inherit;
|
||||
--pk-twitter-username-font-size: 0.875rem;
|
||||
--pk-twitter-number-font-size: 0.875rem;
|
||||
--pk-twitter-number-font-weight: bold;
|
||||
--pk-twitter-content-font-size: 90%;
|
||||
--pk-twitter-counters-font-size: 80%;
|
||||
--pk-twitter-actions-font-size: 80%;
|
||||
--pk-twitter-label-font-size: 80%;
|
||||
--pk-twitter-count-font-size: 80%;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-twitter-wrap a {
|
||||
font-family: var(--pk-twitter-a-font-family);
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.pk-twitter-header {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-twitter-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-twitter-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: none;
|
||||
margin-right: 1rem;
|
||||
flex: 0 0 50px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-twitter-avatar {
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-twitter-info a {
|
||||
color: var(--pk-twitter-a-color);
|
||||
}
|
||||
|
||||
.pk-twitter-name {
|
||||
margin-bottom: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-twitter-username {
|
||||
font-size: var(--pk-twitter-username-font-size);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-twitter-counters {
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
font-size: var(--pk-twitter-counters-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-counters .counter + .counter {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-twitter-counters .number {
|
||||
color: var(--pk-twitter-number-color);
|
||||
font-weight: var(--pk-twitter-number-font-weight);
|
||||
font-size: var(--pk-twitter-number-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-tweet:after {
|
||||
display: table;
|
||||
clear: both;
|
||||
width: 100%;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.pk-twitter-content {
|
||||
font-size: var(--pk-twitter-content-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-twitter-count {
|
||||
margin-left: 0.25rem;
|
||||
font-size: var(--pk-twitter-count-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-label {
|
||||
margin-left: 0.25rem;
|
||||
font-size: var(--pk-twitter-label-font-size);
|
||||
}
|
||||
|
||||
.pk-twitter-count:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-twitter-time {
|
||||
display: block;
|
||||
float: left;
|
||||
margin-top: .25rem;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-twitter-time:before {
|
||||
font-family: "powerkit-icons";
|
||||
content: "\f099";
|
||||
margin-right: .25rem;
|
||||
}
|
||||
|
||||
.pk-twitter-actions {
|
||||
float: right;
|
||||
margin-top: .25rem;
|
||||
font-size: var(--pk-twitter-actions-font-size);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li {
|
||||
display: inline-block;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li:not(:last-child) {
|
||||
margin-right: .25rem;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.pk-twitter-actions ul li .pk-icon {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pk-twitter-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-twitter-footer .pk-twitter-btn {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-twitter-default .pk-twitter-tweet {
|
||||
padding-top: 1rem;
|
||||
margin-top: 1rem;
|
||||
border-top: 1px var(--pk-twitter-tweet-border-color) solid;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Twitter Template
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Template
|
||||
*
|
||||
* @param array $tweets List of tweets.
|
||||
* @param array $params Parameters.
|
||||
*/
|
||||
function powerkit_twitter_default_template( $tweets, $params ) {
|
||||
|
||||
$template = isset( $params['template'] ) ? $params['template'] : 'default';
|
||||
?>
|
||||
|
||||
<div class="pk-twitter-wrap pk-twitter-<?php echo esc_attr( $template ); ?>">
|
||||
|
||||
<?php
|
||||
if ( is_array( $tweets ) && $tweets ) {
|
||||
|
||||
$name = $tweets[0]->user->name;
|
||||
$screen_name = $tweets[0]->user->screen_name;
|
||||
$avatar = $tweets[0]->user->profile_image_url_https;
|
||||
$following = (int) $tweets[0]->user->friends_count;
|
||||
$followers = (int) $tweets[0]->user->followers_count;
|
||||
|
||||
$avatar_1x = str_replace( '_normal', '_normal', $avatar );
|
||||
$avatar_2x = str_replace( '_normal', '_reasonably_small', $avatar );
|
||||
|
||||
if ( $params['header'] ) {
|
||||
?>
|
||||
<div class="pk-twitter-header">
|
||||
<div class="pk-twitter-container">
|
||||
<?php if ( $avatar ) { ?>
|
||||
<a href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" class="pk-twitter-link" target="_blank">
|
||||
<?php
|
||||
$image_avatar = sprintf(
|
||||
'<img src="%s" srcset="%s" alt="avatar" class="pk-twitter-avatar">',
|
||||
esc_url( $avatar_1x ), esc_url( $avatar_1x ) . ' 1x, ' . esc_url( $avatar_2x ) . ' 2x'
|
||||
);
|
||||
|
||||
echo wp_kses_post( apply_filters( 'powerkit_lazy_process_images', $image_avatar ) );
|
||||
?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php $tag = apply_filters( 'powerkit_twitter_name_tag', 'h6' ); ?>
|
||||
|
||||
<div class="pk-twitter-info">
|
||||
<<?php echo esc_html( $tag ); ?> class="pk-twitter-name pk-title pk-font-heading">
|
||||
<a href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" target="_blank">
|
||||
<?php echo esc_html( $name ); ?>
|
||||
</a>
|
||||
</<?php echo esc_html( $tag ); ?>>
|
||||
|
||||
<?php if ( $name !== $screen_name ) { ?>
|
||||
<span class="pk-twitter-username pk-color-secondary">
|
||||
<a href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" target="_blank">
|
||||
@<?php echo wp_kses_post( $screen_name ); ?>
|
||||
</a>
|
||||
</span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pk-twitter-counters pk-color-secondary">
|
||||
<div class="counter following">
|
||||
<span class="number"><?php echo esc_html( powerkit_abridged_number( $following, 0 ) ); ?></span> <?php esc_html_e( 'Following', 'powerkit' ); ?>
|
||||
</div>
|
||||
<div class="counter followers">
|
||||
<span class="number"><?php echo esc_html( powerkit_abridged_number( $followers, 0 ) ); ?></span> <?php esc_html_e( 'Followers', 'powerkit' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="pk-tweets">
|
||||
|
||||
<?php
|
||||
foreach ( $tweets as $tweet ) {
|
||||
$retweets = $tweet->retweet_count > 0 ? $tweet->retweet_count : '';
|
||||
$tweet_id = $tweet->id_str;
|
||||
$time = powerkit_relative_time( $tweet->created_at );
|
||||
$text = powerkit_twitter_convert_links( $tweet->text );
|
||||
?>
|
||||
<div class="pk-twitter-tweet">
|
||||
|
||||
<div class="pk-twitter-content pk-color-secondary"><?php echo wp_kses_post( $text ); ?></div>
|
||||
<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>
|
||||
|
||||
<div class="pk-twitter-actions">
|
||||
<ul>
|
||||
<li>
|
||||
<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 ); ?>">
|
||||
<i class="pk-icon pk-icon-reply"></i>
|
||||
<span class="pk-twitter-label pk-twitter-reply"><?php esc_html_e( 'Reply', 'powerkit' ); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<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 ); ?>">
|
||||
<i class="pk-icon pk-icon-retweet"></i>
|
||||
<span class="pk-twitter-count"><?php echo wp_kses_post( $retweets ); ?></span>
|
||||
<span class="pk-twitter-label pk-twitter-retweet"><?php esc_html_e( 'Retweet', 'powerkit' ); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<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 ); ?>">
|
||||
<i class="pk-icon pk-icon-like"></i>
|
||||
<span class="pk-twitter-label pk-twitter-favorite"><?php esc_html_e( 'Favorite', 'powerkit' ); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ( $params['button'] ) {
|
||||
$href = sprintf( 'https://twitter.com/%s/', $screen_name );
|
||||
$text = apply_filters( 'powerkit_twitter_follow', esc_html__( 'Follow', 'powerkit' ) );
|
||||
|
||||
if ( isset( $params[ 'is_block' ] ) && isset( $params[ 'block_attrs' ] ) && $params[ 'is_block' ] ) {
|
||||
?>
|
||||
<div class="pk-twitter-footer">
|
||||
<?php powerkit_print_gutenberg_blocks_button( $text, $href, '_blank', 'button', $params[ 'block_attrs' ] ); ?>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<div class="pk-twitter-footer">
|
||||
<a class="pk-twitter-btn button" href="<?php echo esc_url( $href ); ?>" target="_blank">
|
||||
<span class="pk-twitter-follow"><?php echo wp_kses( $text, 'post' ); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<p><?php esc_html_e( 'Twitter user not found. Please check your Twitter User ID.', 'powerkit' ); ?></p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
Reference in New Issue
Block a user