- Joined
- Mar 16, 2017
- Messages
- 40
- Likes
- 102
- Degree
- 0
First I need to start off by saying two things:
Now that we got that out of the way, let's get started. Please note that this code isn't perfect and that I gave up on the email part. Also, if you're going to use this code you better have a child theme. Here's how to create a WordPress child theme for the BuSo Lightning theme.
In your child theme's functions.php file, I have this code for getting the current page's URL:
This is my modification of CCarter's code that I use on my posts page:
Here's my CSS (built it off of elements from the BuSo Lightning theme):
Below is an image of where I included the code in my child theme (notice the file too):
And this is how it looks. I have the comments disabled but comments would appear below them (I think).
I've sunk enough time into this... learning experience... for one night but I may revisit this later to procrastinate on a harder problem that comes up. If any of you fellas have the email part figured out or other platforms, please hook us up. Keep grinding.
- FUCK YOU PHP (lots of Googling and trial/error to make this for us)
- THANK YOU @CCarter (this post is my adaption of his code for PicoCMS/Twig)
Now that we got that out of the way, let's get started. Please note that this code isn't perfect and that I gave up on the email part. Also, if you're going to use this code you better have a child theme. Here's how to create a WordPress child theme for the BuSo Lightning theme.
In your child theme's functions.php file, I have this code for getting the current page's URL:
PHP:
function curPageURL() {
if(isset($_SERVER["HTTPS"]) && !empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != 'on' )) {
$url = 'https://'.$_SERVER["SERVER_NAME"];//https url
} else {
$url = 'http://'.$_SERVER["SERVER_NAME"];//http url
}
if(( $_SERVER["SERVER_PORT"] != 80 )) {
$url .= $_SERVER["SERVER_PORT"];
}
$url .= $_SERVER["REQUEST_URI"];
return $url;
}
This is my modification of CCarter's code that I use on my posts page:
PHP:
<!-- SOCIAL SHARING --><div>
<div class="facebook-button">
<?php echo '<a href="https://www.facebook.com/sharer/sharer.php?u=', curPageURL(); ?>" target="_blank"><i class="fa fa-facebook fa-lg"></i> Share</a></div>
<div class="twitter-button">
<?php echo '<a href="http://twitter.com/share" target="_blank" class="twitter-share-button" data-text=\'', curPageURL(); ?>' data-count="none"><i class="fa fa-twitter fa-lg"></i> Tweet</a></div>
<div class="reddit-button">
<a href="http://www.reddit.com/submit" onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent(window.location); return false"><i class="fa fa-reddit fa-lg"></i> Reddit</a></div>
</div><!-- END SOCIAL SHARING -->
Here's my CSS (built it off of elements from the BuSo Lightning theme):
Code:
.facebook-button {background-color: #3b5998;}
.twitter-button {background-color: #00aced;}
.reddit-button {background-color: #FF8b60;}
.facebook-button a, .twitter-button a, .reddit-button a {color:#fff;}
.facebook-button a, .twitter-button a, .reddit-button a {text-decoration: none}
.facebook-button:hover, .twitter-button:hover, .reddit-button:hover {
background-color: #2ecc71;
border: 1px solid #27ae60;}
.facebook-button, .twitter-button, .reddit-button {
display: inline-block;
height: 38px;
padding: 0 30px;
text-align: center;
font-size: 14px;
font-weight: 600;
line-height: 38px;
letter-spacing: .1rem;
text-transform: uppercase;
text-decoration: none;
white-space: nowrap;
border-radius: 4px;
border: 1px solid #ecf0f1;
cursor: pointer;
box-sizing: border-box;
}
Below is an image of where I included the code in my child theme (notice the file too):