Skip to content

Commit 57c89e5

Browse files
committed
2.3.1
1 parent cc78177 commit 57c89e5

File tree

11 files changed

+310
-84
lines changed

11 files changed

+310
-84
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<img src="sc/banner-1544x500.png?raw=true">
33
</p>
44

5-
# Codehaveli Bitly URL Shortener
5+
#Bitly URL Shortener
66

77
### Description
88

9-
[Codehaveli Bitly URL Shortener](https://wordpress.org/plugins/codehaveli-bitly-url-shortener/) uses the functionality of Bitly API to generate the short link automatically from your WordPress dashboard.
9+
[Bitly URL Shortener](https://wordpress.org/plugins/codehaveli-bitly-url-shortener/) uses the functionality of Bitly API to generate the short link automatically from your WordPress dashboard.
1010

11-
Codehaveli Bitly URL Shortener allows you to connect your WordPress Website to the Bitly API via access code.
11+
Bitly URL Shortener allows you to connect your WordPress Website to the Bitly API via access code.
1212

1313
### Terms of Use
1414

@@ -20,7 +20,7 @@ Please read [privacy](https://bitly.com/pages/privacy) and [terms of service](ht
2020

2121
### Bug reports
2222

23-
Bug reports for Codehaveli Bitly URL Shortener are welcomed in our Codehaveli Bitly URL Shortener [repository on GitHub](https://github.com/codehaveli/codehaveli-bitly-url-shortener). Please note that GitHub is not a support forum, and that issues that are not properly qualified as bugs will be closed.
23+
Bug reports for Bitly URL Shortener are welcomed in our Bitly URL Shortener [repository on GitHub](https://github.com/codehaveli/codehaveli-bitly-url-shortener). Please note that GitHub is not a support forum, and that issues that are not properly qualified as bugs will be closed.
2424

2525
### Further Reading
2626

assets/css/wbitly.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.wbitly-mt-5{
2+
margin-top: 25px;
3+
}
4+
.wbitly-meta-bg-link{
5+
background: #eee;
6+
padding: 5px 20px;
7+
}
18
th.manage-column.column-wbitly_url {
29
text-align: center;
310
}
@@ -119,4 +126,8 @@ th#wbitly_url {
119126
vertical-align: -2px;
120127
fill: currentColor;
121128
outline: none;
129+
outline: none;
130+
display: block;
131+
margin: auto;
132+
height: 30px;
122133
}

assets/js/wbitly.js

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,52 @@
1-
( function( $, window, undefined ) {
1+
(function($, window, undefined) {
22

3-
4-
$(".copy_bitly").mouseout(function(){
5-
$('.wbitly_tooltiptext').html("Click to Copy");
3+
$(".copy_bitly").mouseout(function() {
4+
$('.wbitly_tooltiptext').html("Click to Copy");
65
});
76

8-
97
$('body').on('click', '.copy_bitly', function(event) {
10-
event.preventDefault();
11-
$url = $(this).find('.copy_bitly_link').html();
12-
var $temp = $("<input>");
13-
$("body").append($temp);
14-
$temp.val($url).select();
15-
document.execCommand("copy");
16-
$temp.remove();
17-
$(this).find('.wbitly_tooltiptext').html("Copied: "+$url);
18-
8+
event.preventDefault();
9+
$url = $(this).find('.copy_bitly_link').html();
10+
var $temp = $("<input>");
11+
$("body").append($temp);
12+
$temp.val($url).select();
13+
document.execCommand("copy");
14+
$temp.remove();
15+
$(this).find('.wbitly_tooltiptext').html("Copied: " + $url);
1916
});
2017

21-
22-
23-
24-
2518
$('body').on('click', '.generate_bitly', function(event) {
2619
event.preventDefault();
27-
28-
$wbitly_generate_button = $(this);
20+
$wbitly_generate_button = $(this);
2921
let wbitly_post_id = $(this).attr('data-post_id');
30-
31-
32-
if(!wbitly_post_id){
33-
22+
if (!wbitly_post_id) {
3423
$('.generate_bitly').addClass('generate_bitly_disable');
3524
}
36-
37-
3825
$.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-
})
62-
26+
url: wbitlyJS.ajaxurl,
27+
data: {
28+
'action': 'generate_wbitly_url_via_ajax',
29+
'post_id': wbitly_post_id
30+
},
31+
method: 'POST',
32+
//Post method
33+
beforeSend: function() {
34+
$('.generate_bitly').addClass('generate_bitly_disable');
35+
},
36+
success: function(response) {
37+
var data = JSON.parse(response);
38+
if (data.status) {
39+
$main_container = $wbitly_generate_button.parent().parent();
40+
$main_container.html('').html(data.bitly_link_html)
41+
}
42+
},
43+
error: function(error) {
44+
$('.generate_bitly').removeClass('generate_bitly_disable');
45+
},
46+
complete: function() {
47+
$('.generate_bitly').removeClass('generate_bitly_disable');
48+
}
49+
})
6350
});
64-
65-
}( jQuery, window ));
51+
52+
}(jQuery, window));

codehaveli-bitly-url-shortener.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
<?php
22

33
/*
4-
Plugin Name: Codehaveli Bitly URL Shortener
4+
Plugin Name: Bitly URL Shortener
55
Plugin URI: https://github.com/codehaveli/
6-
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.1.3
6+
Description: Codehaveli Bitly URL Shortener uses the functionality of Bitly API to generate Bitly short link without leaving your WordPress site.
7+
Version: 1.3.1
88
Author: Codehaveli
99
Author URI: https://www.codehaveli.com/
1010
License: GPLv2 or later
1111
Text Domain: wbitly
1212
*/
1313

14-
14+
if ( ! defined( 'ABSPATH' ) ) {
15+
exit; // Exit if accessed directly.
16+
}
1517

1618

1719
define( 'WBITLY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
1820
define( 'WBITLY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
19-
define( 'WBITLY_PLUGIN_VERSION', '1.1.3' );
21+
define( 'WBITLY_PLUGIN_VERSION', '1.2.2' );
2022
define( 'WBITLY_API_URL', 'https://api-ssl.bitly.com' );
2123
define( 'WBITLY_BASENAME', plugin_basename( __FILE__ ) );
2224
define( 'WBITLY_SETTINGS_URL', admin_url( 'tools.php?page=wbitly' ) );
@@ -61,4 +63,7 @@
6163

6264
require_once 'inc/wbitly-wp-functions.php';
6365

64-
66+
/**
67+
* Meta Box
68+
*/
69+
require_once 'inc/wbitly-metabox.php';

inc/wbitly-assets.php

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,43 @@
66
* @Last Modified by: Codehaveli
77
* @Website: www.codehaveli.com
88
9-
* @Last Modified time: 2020-06-29 19:57:26
9+
* @Last Modified time: 2021-02-07 22:42:08
1010
*/
1111

1212

13+
if ( ! defined( 'ABSPATH' ) ) {
14+
exit; // Exit if accessed directly.
15+
}
16+
17+
1318
function wbitly_load_admin_script() {
14-
wp_enqueue_script( 'wbitly-js', WBITLY_PLUGIN_URL . '/assets/js/wbitly.js', array( 'jquery' ), WBITLY_PLUGIN_VERSION , true );
15-
wp_enqueue_style( 'wbitly-css', WBITLY_PLUGIN_URL . '/assets/css/wbitly.css',[], WBITLY_PLUGIN_VERSION , 'all' );
19+
20+
wp_enqueue_script( 'wbitly-js', WBITLY_PLUGIN_URL . 'assets/js/wbitly.js', array( 'jquery' ), WBITLY_PLUGIN_VERSION , true );
21+
wp_enqueue_style( 'wbitly-css', WBITLY_PLUGIN_URL . 'assets/css/wbitly.css',[], WBITLY_PLUGIN_VERSION , 'all' );
1622
wp_localize_script( 'wbitly-js', 'wbitlyJS' , ['ajaxurl' => admin_url( 'admin-ajax.php' )]);
1723

18-
1924
}
20-
add_action('admin_enqueue_scripts', 'wbitly_load_admin_script');
25+
add_action('admin_enqueue_scripts', 'wbitly_load_admin_script');
26+
27+
28+
add_action('wp_footer', 'wbitly_add_click_to_copy_script', PHP_INT_MAX);
29+
function wbitly_add_click_to_copy_script() {
30+
31+
$default_roles = ['administrator'];
32+
$allowed_roles = apply_filters( 'wbitly_script_for_allowed_roles', $default_roles );
33+
34+
foreach ($allowed_roles as $role) {
35+
if( current_user_can( $role ) ){
36+
37+
?>
38+
39+
<script>
40+
(function($) {
41+
$(".wbitly-copy-class").on("click",function(t){if(t.preventDefault(),$wbitly_link_a=$(this).find("a"),$wbitly_link=$wbitly_link_a.attr("href"),$wbitly_link_title=$wbitly_link_a.attr("title"),$wbitly_link){var i=$("<textarea />");i.val($wbitly_link).css({width:"1px",height:"1px"}).appendTo("body"),i.select(),document.execCommand("copy")&&(i.remove(),$wbitly_link_a.html("Copied: "+$wbitly_link),setTimeout(function(){$wbitly_link_a.html($wbitly_link_title)},2100))}});
42+
})(jQuery);
43+
</script>
44+
45+
<?php
46+
}
47+
}
48+
}

inc/wbitly-integration.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
* @Last Modified by: Codehaveli
77
* @Website: www.codehaveli.com
88
9-
* @Last Modified time: 2020-09-27 19:25:49
9+
* @Last Modified time: 2020-11-22 21:26:53
1010
*/
1111

12+
if ( ! defined( 'ABSPATH' ) ) {
13+
exit; // Exit if accessed directly.
14+
}
1215

1316
/**
1417
* Generate short URL from permalink
@@ -138,9 +141,7 @@ function wbitly_shorten_url ($permalink) {
138141
if(!$access_token || !$guid){
139142

140143
$plugin_url = admin_url( 'tools.php?page=wbitly');
141-
echo ' <a class="wbitly_settings" href="'.$plugin_url .'">
142-
Setup Bitly URL
143-
</a>';
144+
echo '<a class="wbitly_settings" href="'.$plugin_url .'">Get Started</a>';
144145
}else{
145146

146147
echo '<div class="wbitly_column_container">';

0 commit comments

Comments
 (0)