Skip to content

Commit 06b44f5

Browse files
committed
Share button added
1 parent a9d8a20 commit 06b44f5

File tree

9 files changed

+483
-74
lines changed

9 files changed

+483
-74
lines changed

assets/css/wbitly.css

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
1-
.copy_bitly_tooltip {
2-
position: relative;
3-
display: inline-block;
1+
th.manage-column.column-wbitly_url {
2+
text-align: center;
3+
}
4+
button.generate_bitly.generate_bitly_disable.wbitly {
5+
opacity: 0.7;
6+
pointer-events: none;
7+
transition: 1s all ease;
8+
}
9+
10+
11+
th#wbitly_url {
12+
text-align: center;
13+
}
14+
15+
.wbitly-social-share-buttons-wrapper p {
16+
text-align: center;
17+
}
18+
19+
.wbitly-social-share-buttons-wrapper p:after {content: '';width: 30px;height: 1px;display: block;background: #9E9E9E;margin: auto;}
20+
21+
.wbitly_tooltip {
22+
position: relative;
23+
display: block;
24+
}
25+
26+
.wbitly_tooltip p {
27+
text-align: center;
428
}
529

6-
.copy_bitly_tooltip .copy_bitly_tooltiptext {
30+
.wbitly_tooltip .wbitly_tooltiptext {
731
visibility: hidden;
832
width: 140px;
933
background-color: #555;
@@ -20,7 +44,7 @@
2044
transition: opacity 0.3s;
2145
}
2246

23-
.copy_bitly_tooltip .copy_bitly_tooltiptext::after {
47+
.wbitly_tooltip .wbitly_tooltiptext::after {
2448
content: "";
2549
position: absolute;
2650
top: 100%;
@@ -31,17 +55,68 @@
3155
border-color: #555 transparent transparent transparent;
3256
}
3357

34-
.copy_bitly_tooltip:hover .copy_bitly_tooltiptext {
58+
.wbitly_tooltip:hover .wbitly_tooltiptext {
3559
visibility: visible;
3660
opacity: 1;
3761
}
3862

39-
.copy_bitly_tooltip button {
63+
.wbitly_tooltip button {
4064
background: #9e9e9e42;
4165
outline: 0;
4266
width: 100%;
4367
text-align: center;
4468
border: 1px solid #eee !important;
4569
font-size: 10px;
4670
cursor: pointer;
47-
}
71+
}
72+
73+
74+
.wbitly-social-share-buttons {
75+
display: -webkit-box;
76+
display: -ms-flexbox;
77+
display: flex;
78+
-webkit-box-orient: horizontal;
79+
-webkit-box-direction: normal;
80+
-ms-flex-flow: row wrap;
81+
flex-flow: row wrap;
82+
box-sizing: inherit;
83+
margin-top: 10px;
84+
align-items: center;
85+
justify-content: center;
86+
}
87+
88+
.wbitly-share-button {
89+
font-size: 14px;
90+
-webkit-box-flex: 1;
91+
-ms-flex-positive: 1;
92+
line-height: 34px;
93+
text-align: center;
94+
color: #fff;
95+
background: #D14836;
96+
margin-right: 5px;
97+
border-radius: 6px;
98+
padding: 0;
99+
-webkit-transition: 0.2s all linear;
100+
transition: 0.2s all linear;
101+
width: 30px !important;
102+
height: 30px;
103+
}
104+
105+
.wbitly-share-button.wbitly-facebook {
106+
background: #1877F2;
107+
}
108+
109+
.wbitly-share-button.wbitly-twitter {
110+
background: #1DA1F2;
111+
}
112+
113+
.wbitly-share-button a {
114+
color: inherit;
115+
display: block;
116+
}
117+
118+
.wbitly-share-button a svg {
119+
vertical-align: -2px;
120+
fill: currentColor;
121+
outline: none;
122+
}

assets/js/wbitly.js

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,63 @@
22

33

44
$(".copy_bitly").mouseout(function(){
5-
$('.copy_bitly_tooltiptext').html("Click to Copy");
5+
$('.wbitly_tooltiptext').html("Click to Copy");
66
});
77

88

99
$('body').on('click', '.copy_bitly', function(event) {
1010
event.preventDefault();
11-
$url = $(this).parent().find('p').html();
11+
$url = $(this).find('.copy_bitly_link').html();
1212
var $temp = $("<input>");
1313
$("body").append($temp);
1414
$temp.val($url).select();
1515
document.execCommand("copy");
1616
$temp.remove();
17-
$('.copy_bitly_tooltiptext').html("Copied: "+$url);
17+
$(this).find('.wbitly_tooltiptext').html("Copied: "+$url);
18+
19+
});
20+
21+
22+
23+
24+
25+
$('body').on('click', '.generate_bitly', function(event) {
26+
event.preventDefault();
27+
28+
$wbitly_generate_button = $(this);
29+
let wbitly_post_id = $(this).attr('data-post_id');
30+
31+
32+
if(!wbitly_post_id){
33+
34+
$('.generate_bitly').addClass('generate_bitly_disable');
35+
}
36+
37+
38+
$.ajax({
39+
url : wbitlyJS.ajaxurl,
40+
data : {'action' : 'generate_wbitly_url_via_ajax' , 'post_id' : wbitly_post_id},
41+
method : 'POST', //Post method
42+
beforeSend: function(){
43+
$('.generate_bitly').addClass('generate_bitly_disable');
44+
},
45+
success : function( response ){
46+
var data = JSON.parse(response);
47+
48+
if(data.status){
49+
50+
$main_container = $wbitly_generate_button.parent().parent();
51+
$main_container.html('').html(data.bitly_link_html)
52+
}
53+
54+
},
55+
error : function(error){
56+
$('.generate_bitly').removeClass('generate_bitly_disable');
57+
},
58+
complete: function(){
59+
$('.generate_bitly').removeClass('generate_bitly_disable');
60+
}
61+
})
1862

1963
});
2064

codehaveli-bitly-url-shortener.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: Codehaveli Bitly URL Shortener
55
Plugin URI: https://github.com/codehaveli/
66
Description: This Plugin is used for shorten the newly published post url, Plugin use the api functionality of https://bitly.com/ to achive this URL shorten process.
7-
Version: 1.0
7+
Version: 1.1
88
Author: Codehaveli
99
Author URI: https://www.codehaveli.com/
1010
License: GPLv2 or later
@@ -16,20 +16,27 @@
1616

1717
define( 'WBITLY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
1818
define( 'WBITLY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
19-
define( 'WBITLY_PLUGIN_VERSION', '1.0' );
19+
define( 'WBITLY_PLUGIN_VERSION', '1.1' );
2020
define( 'WBITLY_API_URL', 'https://api-ssl.bitly.com' );
2121
define( 'WBITLY_BASENAME', plugin_basename( __FILE__ ) );
2222
define( 'WBITLY_SETTINGS_URL', admin_url( 'tools.php?page=wbitly' ) );
2323

2424

2525

26+
2627
/**
2728
* Load Admin Assets
2829
*/
2930

3031
require_once 'inc/wbitly-assets.php';
3132

3233

34+
/**
35+
* Load Util Functions
36+
*/
37+
38+
require_once 'inc/wbitly-util.php';
39+
3340

3441
/**
3542
* Load Settings file
@@ -45,4 +52,13 @@
4552
*/
4653

4754

48-
require_once 'inc/wbitly-integration.php';
55+
require_once 'inc/wbitly-integration.php';
56+
57+
58+
59+
/**
60+
* Load WordPress related hooks
61+
*/
62+
63+
64+
require_once 'inc/wbitly-wp-functions.php';

inc/wbitly-assets.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
* @Last Modified by: Codehaveli
77
* @Website: www.codehaveli.com
88
* @Email: hello@codehaveli.com
9-
* @Last Modified time: 2020-05-19 10:09:48
9+
* @Last Modified time: 2020-06-29 19:57:26
1010
*/
1111

1212

1313
function wbitly_load_admin_script() {
1414
wp_enqueue_script( 'wbitly-js', WBITLY_PLUGIN_URL . '/assets/js/wbitly.js', array( 'jquery' ), WBITLY_PLUGIN_VERSION , true );
1515
wp_enqueue_style( 'wbitly-css', WBITLY_PLUGIN_URL . '/assets/css/wbitly.css',[], WBITLY_PLUGIN_VERSION , 'all' );
16+
wp_localize_script( 'wbitly-js', 'wbitlyJS' , ['ajaxurl' => admin_url( 'admin-ajax.php' )]);
17+
18+
1619
}
1720
add_action('admin_enqueue_scripts', 'wbitly_load_admin_script');

0 commit comments

Comments
 (0)