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

Commit 1981ba0

Browse files
authored
Merge pull request #4 from bootscore/Fix-return-Array
Fix return array
2 parents bc2bed8 + 8bfe0a0 commit 1981ba0

File tree

3 files changed

+58
-13
lines changed

3 files changed

+58
-13
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
> [!IMPORTANT]
2+
> This plugin has reached its end of life (EOL) and will no longer receive updates.
3+
4+
15
# bs Share Buttons
26

37
WordPress plugin to show share buttons in pages, posts, widgets or .php files.

main.php

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<?php
2-
/*Plugin Name: bS Share Buttons
2+
/*Plugin Name: bs Share Buttons
33
Plugin URI: https://bootscore.me/plugins/bs-share-buttons/
44
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.
5-
Version: 5.2.0
5+
Version: 1.0.1
6+
Tested up to: 6.6
7+
Requires at least: 5.0
8+
Requires PHP: 7.4
69
Author: bootScore
710
Author URI: https://bootscore.me
811
License: MIT License
@@ -25,9 +28,9 @@ function bs_share_buttons_scripts() {
2528

2629

2730

31+
2832
// Function to handle the thumbnail request
29-
function get_the_post_thumbnail_src($img)
30-
{
33+
function get_the_post_thumbnail_src($img) {
3134
return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : '';
3235
}
3336
function bs_share_buttons($content) {
@@ -85,7 +88,7 @@ function bs_share_buttons($content) {
8588
$content .= '</div>';
8689

8790
return $content;
88-
}else{
91+
} else{
8992
// if not a post/page then don't include sharing button
9093
return $content;
9194
}
@@ -94,3 +97,37 @@ function bs_share_buttons($content) {
9497

9598
// This will create a wordpress shortcode [share-buttons].
9699
add_shortcode('bs-share-buttons','bs_share_buttons');
100+
101+
102+
// Roughly fix https://github.com/bootscore/bs-share-buttons/issues/3
103+
function bs_share_buttons_inline_script() {
104+
// Ensure jQuery is enqueued
105+
wp_enqueue_script('jquery');
106+
107+
// Define the inline script
108+
$inline_script = "
109+
jQuery(document).ready(function($) {
110+
// Function to recursively search and remove unwanted text nodes
111+
function removeTextNodesWithText(node, textToRemove) {
112+
$(node).contents().each(function() {
113+
if (this.nodeType === 3) { // Text node
114+
var text = $.trim(this.textContent);
115+
if (text === textToRemove) {
116+
$(this).remove(); // Remove text node
117+
}
118+
} else if (this.nodeType === 1) { // Element node
119+
removeTextNodesWithText(this, textToRemove); // Recur for child nodes
120+
}
121+
});
122+
}
123+
124+
// Call the function to remove 'Array' text nodes
125+
removeTextNodesWithText($('body'), 'Array');
126+
});
127+
";
128+
129+
// Add the inline script
130+
wp_add_inline_script('jquery', $inline_script);
131+
}
132+
133+
add_action('wp_enqueue_scripts', 'bs_share_buttons_inline_script');

readme.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
=== bS Share Buttons ===
1+
=== bs Share Buttons ===
22

33
Contributors: craftwerk
44

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

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

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

4646
== Changelog ==
4747

48-
= 1.0.0 - January 02 2021 =
48+
= 1.0.1 - August 29 2024 =
4949

50-
* Initial release
50+
* Fix return Array
51+
52+
= 1.0.0 - January 02 2021 =
53+
54+
* Initial release

0 commit comments

Comments
 (0)