| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shortcode Share Buttons |
| 4 |
* |
| 5 |
* @link https://codesupply.co |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package PowerKit |
| 9 |
* @subpackage PowerKit/shortcodes |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Share Buttons Shortcode |
| 14 |
* |
| 15 |
* @param array $atts User defined attributes in shortcode tag. |
| 16 |
* @param string $content Shorcode tag content. |
| 17 |
* @return string Shortcode result HTML. |
| 18 |
*/ |
| 19 |
function powerkit_share_buttons_shortcode( $atts, $content = '' ) { |
| 20 |
|
| 21 |
$params = powerkit_shortcode_atts( shortcode_atts( array( |
| 22 |
'accounts' => '', |
| 23 |
'total' => true, |
| 24 |
'icons' => true, |
| 25 |
'labels' => true, |
| 26 |
'counts' => true, |
| 27 |
'titles' => false, |
| 28 |
'title_location' => 'inside', |
| 29 |
'label_location' => 'inside', |
| 30 |
'count_location' => 'inside', |
| 31 |
'mode' => 'mixed', |
| 32 |
'layout' => 'default', |
| 33 |
'scheme' => 'default', |
| 34 |
), $atts ) ); |
| 35 |
|
| 36 |
$params['total'] = filter_var( $params['total'], FILTER_VALIDATE_BOOLEAN ); |
| 37 |
$params['labels'] = filter_var( $params['labels'], FILTER_VALIDATE_BOOLEAN ); |
| 38 |
$params['counts'] = filter_var( $params['counts'], FILTER_VALIDATE_BOOLEAN ); |
| 39 |
|
| 40 |
ob_start(); |
| 41 |
|
| 42 |
// Accounts. |
| 43 |
if ( $params['accounts'] ) { |
| 44 |
$params['accounts'] = explode( ',', $params['accounts'] ); |
| 45 |
|
| 46 |
if ( $params['accounts'] ) { |
| 47 |
foreach ( $params['accounts'] as $key => $val ) { |
| 48 |
$params['accounts'][ $key ] = trim( $val ); |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
// Get Shares. |
| 54 |
powerkit_share_buttons( $params['accounts'], $params['total'], $params['icons'], $params['titles'], $params['labels'], $params['counts'], $params['title_location'], $params['label_location'], $params['count_location'], $params['mode'], $params['layout'], $params['scheme'], '' ); |
| 55 |
|
| 56 |
return ob_get_clean(); |
| 57 |
} |
| 58 |
add_shortcode( 'powerkit_share_buttons', 'powerkit_share_buttons_shortcode' ); |
| 59 |
|