Files
CHIEFSOFT\ameye e9e5c0546c first commit
2023-11-30 13:20:54 -05:00

104 lines
2.7 KiB
PHP

<?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;