Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from bootscore/Fix-return-Array
Browse files Browse the repository at this point in the history
Fix return array
  • Loading branch information
crftwrk authored Aug 29, 2024
2 parents bc2bed8 + 8bfe0a0 commit 1981ba0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
> [!IMPORTANT]
> This plugin has reached its end of life (EOL) and will no longer receive updates.

# bs Share Buttons

WordPress plugin to show share buttons in pages, posts, widgets or .php files.
Expand Down
47 changes: 42 additions & 5 deletions main.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php
/*Plugin Name: bS Share Buttons
/*Plugin Name: bs Share Buttons
Plugin URI: https://bootscore.me/plugins/bs-share-buttons/
Description: Share Buttons for bootScore theme https://bootscore.me. Use Shortcode [bs-share-buttons] to display buttons in content or widget. Use <?php echo do_shortcode("[bs-share-buttons]"); ?&gt; to display in .php files.
Version: 5.2.0
Version: 1.0.1
Tested up to: 6.6
Requires at least: 5.0
Requires PHP: 7.4
Author: bootScore
Author URI: https://bootscore.me
License: MIT License
Expand All @@ -25,9 +28,9 @@ function bs_share_buttons_scripts() {




// Function to handle the thumbnail request
function get_the_post_thumbnail_src($img)
{
function get_the_post_thumbnail_src($img) {
return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : '';
}
function bs_share_buttons($content) {
Expand Down Expand Up @@ -85,7 +88,7 @@ function bs_share_buttons($content) {
$content .= '</div>';

return $content;
}else{
} else{
// if not a post/page then don't include sharing button
return $content;
}
Expand All @@ -94,3 +97,37 @@ function bs_share_buttons($content) {

// This will create a wordpress shortcode [share-buttons].
add_shortcode('bs-share-buttons','bs_share_buttons');


// Roughly fix https://github.com/bootscore/bs-share-buttons/issues/3
function bs_share_buttons_inline_script() {
// Ensure jQuery is enqueued
wp_enqueue_script('jquery');

// Define the inline script
$inline_script = "
jQuery(document).ready(function($) {
// Function to recursively search and remove unwanted text nodes
function removeTextNodesWithText(node, textToRemove) {
$(node).contents().each(function() {
if (this.nodeType === 3) { // Text node
var text = $.trim(this.textContent);
if (text === textToRemove) {
$(this).remove(); // Remove text node
}
} else if (this.nodeType === 1) { // Element node
removeTextNodesWithText(this, textToRemove); // Recur for child nodes
}
});
}
// Call the function to remove 'Array' text nodes
removeTextNodesWithText($('body'), 'Array');
});
";

// Add the inline script
wp_add_inline_script('jquery', $inline_script);
}

add_action('wp_enqueue_scripts', 'bs_share_buttons_inline_script');
20 changes: 12 additions & 8 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
=== bS Share Buttons ===
=== bs Share Buttons ===

Contributors: craftwerk

Requires at least: 4.5
Tested up to: 5.8.1
Requires PHP: 5.6
Stable tag: 5.0.0
Stable tag: 1.0.1
Tested up to: 6.6
Requires at least: 5.0
Requires PHP: 7.4
License: MIT License
License URI: https://github.com/bootscore/bs5-share-buttons/blob/main/LICENSE
License URI: https://github.com/bootscore/bs-share-buttons/blob/main/LICENSE

Displays share buttons in bootScore WordPress Theme, Copyright 2020 Bastian Kreiter.

Expand Down Expand Up @@ -45,6 +45,10 @@ Remove buttons you do not want to display directly in main.php line 77 to 89 by

== Changelog ==

= 1.0.0 - January 02 2021 =
= 1.0.1 - August 29 2024 =

* Initial release
* Fix return Array

= 1.0.0 - January 02 2021 =

* Initial release

0 comments on commit 1981ba0

Please sign in to comment.