Skip to content

Commit d9c185e

Browse files
author
Istiaq Ahmmed Nirab
committed
add shortcode feature
1 parent 0222f13 commit d9c185e

File tree

4 files changed

+144
-3
lines changed

4 files changed

+144
-3
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,39 @@ A Simple Plugin used for social sharing in wordpress. Got These Design From [Tor
1717

1818
[![SEbcH.png](https://b.imge.to/2019/08/27/SEbcH.png)](https://imge.to/i/SEbcH)
1919

20+
### ShortCode
21+
22+
You can use 2-shortcode .
23+
24+
1. `[cdx_social_share]` :- this shortcode can display share buttons on posts & pages .
25+
26+
2. ```[cdxSocialLinks fb="facebook_url" tw="twitter_url" yt="youtube_url" ins="instagram_url" lkin="linkedIn_url" email="email_address" be="behance_url" dr="dribbble_url" gt="github_url" pin="pinterest_url" tum="tumblr_url" sound="soundcloud_url" cpen="codepen_url"]```
27+
28+
This second shortcode can display some social buttons . Attributes are :-
29+
30+
* **fb (facebook)**
31+
* **tw (twitter)**
32+
* **ins (Instagram)**
33+
* **lkin (LinkedIn)**
34+
* **email (Email)**
35+
* **be (Behance)**
36+
* **dr (dribbble)**
37+
* **gt (Github)**
38+
* **pin (Pinterest)**
39+
* **tum (tumblr)**
40+
* **sound (SoundCloud)**
41+
* **cpen (codepen)**
42+
43+
> This attributes are not required . if you use 2 or 3 , Display only these 2 or 3 , others will be hide.
44+
2045

2146
## Release Notes
2247

23-
### 1.0.0
48+
### 1.1
49+
50+
Add shortcode feature
51+
52+
### 1.0
2453

2554
Initial release of ...
2655

index.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
include('widgets/social_links.php');
1515
include('widgets/enqueue.php');
1616
include('share/post-share.php');
17+
include('shortcode/share.php');
18+
include('shortcode/links.php');
1719

18-
add_action('wp_enqueue_scripts', 'codenrx_register_style_file',9999 );
20+
add_action('wp_enqueue_scripts', 'codenrx_register_style_file', 9999);
1921
add_action('widgets_init', function () {
2022
register_widget('codenrx_social_share_widget');
2123
});
22-
add_filter( "the_content", "codenrx_wp_after_post_content" );
24+
add_filter("the_content", "codenrx_wp_after_post_content");
25+
add_shortcode('cdx_social_share', 'codenrx_social_share_shortcode');
26+
add_shortcode('cdxSocialLinks', 'codenrx_social_links_shortcode');

shortcode/links.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
function codenrx_social_links_shortcode($array, $content = null)
4+
{
5+
if (isset($array['fb'])) {
6+
$content .= '
7+
<a href="' . $array['fb'] . '" target="_blank" class="icon-link round-corner facebook fill"><i class="fa fa-facebook"></i></a>
8+
';
9+
}
10+
11+
if (isset($array['tw'])) {
12+
$content .= '
13+
<a href="' . $array['tw'] . '" target="_blank" class="icon-link round-corner twitter fill"><i class="fa fa-twitter"></i></a>
14+
';
15+
}
16+
17+
if (isset($array['yt'])) {
18+
$content .= '
19+
<a href="' . $array['yt'] . '" target="_blank" class="icon-link round-corner youtube fill"><i class="fa fa-youtube"></i></a>
20+
';
21+
}
22+
23+
if (isset($array['ins'])) {
24+
$content .= '
25+
<a href="' . $array['ins'] . '" target="_blank" class="icon-link round-corner instagram fill"><i class="fa fa-instagram"></i></a>
26+
';
27+
}
28+
29+
if (isset($array['lkin'])) {
30+
$content .= '
31+
<a href="' . $array['lkin'] . '" target="_blank" class="icon-link round-corner linkedin fill"><i class="fa fa-linkedin"></i></a>
32+
';
33+
}
34+
35+
if (isset($array['email'])) {
36+
$content .= '
37+
<a href="' . $array['email'] . '" target="_blank" class="icon-link round-corner envelope fill"><i class="fa fa-envelope"></i></a>
38+
';
39+
}
40+
41+
if (isset($array['be'])) {
42+
$content .= '
43+
<a href="' . $array['be'] . '" target="_blank" class="icon-link round-corner behance fill"><i class="fa fa-behance"></i></a>
44+
';
45+
}
46+
47+
if (isset($array['dr'])) {
48+
$content .= '
49+
<a href="' . $array['dr'] . '" target="_blank" class="icon-link round-corner dribbble fill"><i class="fa fa-dribbble"></i></a>
50+
';
51+
}
52+
53+
if (isset($array['gt'])) {
54+
$content .= '
55+
<a href="' . $array['gt'] . '" target="_blank" class="icon-link round-corner github fill"><i class="fa fa-github"></i></a>
56+
';
57+
}
58+
59+
if (isset($array['pin'])) {
60+
$content .= '
61+
<a href="' . $array['pin'] . '" target="_blank" class="icon-link round-corner pinterest fill"><i class="fa fa-pinterest"></i></a>
62+
';
63+
}
64+
65+
if (isset($array['tum'])) {
66+
$content .= '
67+
<a href="' . $array['tum'] . '" target="_blank" class="icon-link round-corner tumblr fill"><i class="fa fa-tumblr"></i></a>
68+
';
69+
}
70+
71+
if (isset($array['sound'])) {
72+
$content .= '
73+
<a href="' . $array['sound'] . '" target="_blank" class="icon-link round-corner soundcloud fill"><i class="fa fa-soundcloud"></i></a>
74+
';
75+
}
76+
77+
if (isset($array['cpen'])) {
78+
$content .= '
79+
<a href="' . $array['cpen'] . '" target="_blank" class="icon-link round-corner codepen fill"><i class="fa fa-codepen"></i></a>
80+
';
81+
}
82+
83+
return $content;
84+
}

shortcode/share.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
function codenrx_social_share_shortcode($array, $content = null)
4+
{
5+
$content .= '
6+
<br>
7+
<div class="social-share-container">
8+
<a class="facebook-share social-share-a" href="https://www.facebook.com/sharer/sharer.php?u=' . get_the_permalink() . '&title=' . get_the_title() . '" target="_blank"><i class="fa fa-facebook social-share-icon" ></i> Share</a>
9+
10+
<a class="twitter-share social-share-a" href="https://twitter.com/intent/tweet?status=' . get_the_title() . '+' . get_the_permalink() . '" target="_blank"><i class="fa fa-twitter social-share-icon"></i> Tweet</a>
11+
12+
<a class="linkedin-share social-share-a" href="https://www.linkedin.com/shareArticle?url=' . get_the_permalink() . '&title=' . get_the_title() . '" target="_blank"><i class="fa fa-linkedin social-share-icon" ></i> Share</a>
13+
14+
<a class="pinterest-share social-share-a" href="https://pinterest.com/pin/create/bookmarklet/?url=' . get_the_permalink() . '&is_video=false&description=' . get_the_title() . '" target="_blank"><i class="fa fa-pinterest-p social-share-icon"></i> Pin</a>
15+
16+
<a class="reddit-share social-share-a" href="https://reddit.com/submit?url=' . get_the_permalink() . '&title=' . get_the_title() . '" target="_blank"><i class="fa fa-reddit social-share-icon"></i> Share</a>
17+
18+
<a class="instagram-share social-share-a" href="https://www.instagram.com/?url=' . get_the_permalink() . '" target="_blank"><i class="fa fa-instagram social-share-icon"></i> Share</a>
19+
20+
</div>
21+
<br>
22+
';
23+
return $content;
24+
}

0 commit comments

Comments
 (0)