';
if ( !empty( $media ) ) {
foreach ( $media as $name ) {
$slug = !empty( $name['slug'] ) ? $name['slug'] : '';
$label = !empty( $name['label'] ) ? $name['label'] : '';
$content = !empty( $name['content'] ) ? $name['content'] : '';
if ( !empty( $content ) ) {
$icon = SPACEXCHIMP_P005_URL . "inc/img/social-media-icons/$slug.png";
$toolbar_arr[] = '
';
}
}
}
$toolbar_arr[] = '';
// Add script for buttons
if ( !empty( $options['tooltips'] ) ) {
$js = "";
} else {
$js = '';
}
if ( count( $toolbar_arr ) > 0 ) {
array_unshift( $toolbar_arr, $caption );
array_push( $toolbar_arr, $js );
}
// Return the content of array
return $toolbar_arr;
}
/**
* Create the shortcode "[smbtoolbar]"
*/
function spacexchimp_p005_shortcode() {
return implode(PHP_EOL, spacexchimp_p005_tollbar());
}
add_shortcode( 'smbtoolbar', 'spacexchimp_p005_shortcode' );
/**
* Allow shortcodes in the text widget
*/
add_filter( 'widget_text', 'do_shortcode' );
/**
* Add buttons to the beginning of each post or/and page.
*/
function spacexchimp_p005_addContent( $content ) {
$options = get_option( SPACEXCHIMP_P005_SETTINGS . '_settings' );
if ( is_single() ) {
if ( !empty( $options['show_posts'] ) && $options['show_posts'] == "on" ) {
$content = $content . spacexchimp_p005_shortcode();
}
}
if ( is_page() ) {
if ( !empty( $options['show_pages'] ) && $options['show_pages'] == "on" ) {
$content = $content . spacexchimp_p005_shortcode();
}
}
// Returns the content.
return $content;
}
add_action( 'the_content', 'spacexchimp_p005_addContent' );