WP ULike - Version 1.0

Version Description

Download this release

Release Info

Developer alimir
Plugin Icon 128x128 WP ULike
Version 1.0
Comparing to
See all releases

Version 1.0

assets/css/add-rtl.png ADDED
Binary file
assets/css/add.png ADDED
Binary file
assets/css/wp-ulike-rtl.css ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wpulike {
2
+ display: inline;
3
+ }
4
+
5
+ .wpulike .counter a {
6
+ cursor: pointer;
7
+ display:inline !important;
8
+ text-decoration:none;
9
+
10
+ }
11
+
12
+ .wpulike .counter a.image {
13
+ background: #eaeff2 url(add-rtl.png) center center no-repeat;
14
+ padding: 1px 20px;
15
+ border: 1px solid #cbd3e8;
16
+ border-radius: 3px;
17
+ }
18
+
19
+ .wpulike .counter a.text {
20
+ background: #eaeff2;
21
+ padding: 2px 15px;
22
+ border: 1px solid #cbd3e8;
23
+ border-radius: 3px;
24
+ color: #5557a1;
25
+ }
26
+
27
+ .wpulike .count-box {
28
+ position: relative;
29
+ background: #fff;
30
+ border: 1px solid #ddd;
31
+ padding: 1px 6px;
32
+ border-radius: 3px;
33
+ margin-right: 8px;
34
+ font-size: 16px;
35
+ }
36
+
37
+ .wpulike .count-box:before {
38
+ content: "";
39
+ position: absolute;
40
+ top: 7px;
41
+ right: -3px;
42
+ width: 4px;
43
+ height: 4px;
44
+ border-width: 1px 1px 0 0;
45
+ border-style: solid;
46
+ border-color: #ddd;
47
+ background: #fff;
48
+ -webkit-transform: rotate(45deg);
49
+ -moz-transform: rotate(45deg);
50
+ -ms-transform: rotate(45deg);
51
+ -o-transform: rotate(45deg);
52
+ }
53
+ .sr-only {
54
+ position: absolute;
55
+ width: 1px;
56
+ height: 1px;
57
+ margin: -1px;
58
+ padding: 0;
59
+ overflow: hidden;
60
+ clip: rect(0, 0, 0, 0);
61
+ border: 0;
62
+ }
63
+ .sr-only-focusable:active,
64
+ .sr-only-focusable:focus {
65
+ position: static;
66
+ width: auto;
67
+ height: auto;
68
+ margin: 0;
69
+ overflow: visible;
70
+ clip: auto;
71
+ }
72
+ .alert {
73
+ padding: 15px;
74
+ margin-bottom: 20px;
75
+ border: 1px solid transparent;
76
+ border-radius: 4px;
77
+ }
78
+ .alert h4 {
79
+ margin-top: 0;
80
+ color: inherit;
81
+ }
82
+ .alert .alert-link {
83
+ font-weight: bold;
84
+ }
85
+ .alert > p,
86
+ .alert > ul {
87
+ margin-bottom: 0;
88
+ }
89
+ .alert > p + p {
90
+ margin-top: 5px;
91
+ }
92
+ .alert-dismissable,
93
+ .alert-dismissible {
94
+ padding-left: 35px;
95
+ }
96
+ .alert-dismissable .close,
97
+ .alert-dismissible .close {
98
+ position: relative;
99
+ top: -2px;
100
+ left: -21px;
101
+ color: inherit;
102
+ }
103
+ .alert-success {
104
+ background-color: #dff0d8;
105
+ border-color: #d6e9c6;
106
+ color: #3c763d;
107
+ }
108
+ .alert-success hr {
109
+ border-top-color: #c9e2b3;
110
+ }
111
+ .alert-success .alert-link {
112
+ color: #2b542c;
113
+ }
114
+ .alert-info {
115
+ background-color: #d9edf7;
116
+ border-color: #bce8f1;
117
+ color: #31708f;
118
+ }
119
+ .alert-info hr {
120
+ border-top-color: #a6e1ec;
121
+ }
122
+ .alert-info .alert-link {
123
+ color: #245269;
124
+ }
125
+ .alert-warning {
126
+ background-color: #fcf8e3;
127
+ border-color: #faebcc;
128
+ color: #8a6d3b;
129
+ }
130
+ .alert-warning hr {
131
+ border-top-color: #f7e1b5;
132
+ }
133
+ .alert-warning .alert-link {
134
+ color: #66512c;
135
+ }
136
+ .alert-danger {
137
+ background-color: #f2dede;
138
+ border-color: #ebccd1;
139
+ color: #a94442;
140
+ }
141
+ .alert-danger hr {
142
+ border-top-color: #e4b9c0;
143
+ }
144
+ .alert-danger .alert-link {
145
+ color: #843534;
146
+ }
147
+ .close {
148
+ float: left;
149
+ font-size: 21px;
150
+ font-weight: bold;
151
+ line-height: 1;
152
+ color: #000000;
153
+ text-shadow: 0 1px 0 #ffffff;
154
+ opacity: 0.2;
155
+ filter: alpha(opacity=20);
156
+ }
157
+ .close:hover,
158
+ .close:focus {
159
+ color: #000000;
160
+ text-decoration: none;
161
+ cursor: pointer;
162
+ opacity: 0.5;
163
+ filter: alpha(opacity=50);
164
+ }
165
+ button.close {
166
+ padding: 0;
167
+ cursor: pointer;
168
+ background: transparent;
169
+ border: 0;
170
+ -webkit-appearance: none;
171
+ }
172
+ .fade {
173
+ opacity:0;
174
+ -webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;
175
+ transition:opacity .15s linear
176
+ }
177
+ .fade.in {
178
+ opacity:1
179
+ }
assets/css/wp-ulike.css ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wpulike {
2
+ display: inline;
3
+ }
4
+
5
+ .wpulike .counter a {
6
+ cursor: pointer;
7
+ text-decoration:none;
8
+ display:inline !important;
9
+
10
+ }
11
+
12
+ .wpulike .counter a.image {
13
+ background: #f1f1f1 url(add.png) center center no-repeat;
14
+ padding: 1px 20px;
15
+ border: 1px solid #ddd;
16
+ border-radius: 3px;
17
+ }
18
+
19
+ .wpulike .counter a.text {
20
+ background: #f7f7f7;
21
+ padding: 2px 15px;
22
+ border: 1px solid #cdcdcd;
23
+ border-radius: 3px;
24
+ color: #606060;
25
+ }
26
+
27
+ .wpulike .count-box {
28
+ position: relative;
29
+ background: #fff;
30
+ border: 1px solid #ddd;
31
+ padding: 1px 6px;
32
+ border-radius: 3px;
33
+ margin-left: 8px;
34
+ font-size: 16px;
35
+ font-family: Arial;
36
+ }
37
+
38
+ .wpulike .count-box:before {
39
+ content: "";
40
+ position: absolute;
41
+ top: 7px;
42
+ left: -3px;
43
+ width: 4px;
44
+ height: 4px;
45
+ border-width: 0 0 1px 1px;
46
+ border-style: solid;
47
+ border-color: #ddd;
48
+ background: #fff;
49
+ -webkit-transform: rotate(45deg);
50
+ -moz-transform: rotate(45deg);
51
+ -ms-transform: rotate(45deg);
52
+ -o-transform: rotate(45deg);
53
+ }
54
+
55
+ .sr-only {
56
+ position: absolute;
57
+ width: 1px;
58
+ height: 1px;
59
+ margin: -1px;
60
+ padding: 0;
61
+ overflow: hidden;
62
+ clip: rect(0, 0, 0, 0);
63
+ border: 0;
64
+ }
65
+ .sr-only-focusable:active,
66
+ .sr-only-focusable:focus {
67
+ position: static;
68
+ width: auto;
69
+ height: auto;
70
+ margin: 0;
71
+ overflow: visible;
72
+ clip: auto;
73
+ }
74
+ .alert {
75
+ padding: 15px;
76
+ margin-bottom: 20px;
77
+ border: 1px solid transparent;
78
+ border-radius: 4px;
79
+ }
80
+ .alert h4 {
81
+ margin-top: 0;
82
+ color: inherit;
83
+ }
84
+ .alert .alert-link {
85
+ font-weight: bold;
86
+ }
87
+ .alert > p,
88
+ .alert > ul {
89
+ margin-bottom: 0;
90
+ }
91
+ .alert > p + p {
92
+ margin-top: 5px;
93
+ }
94
+ .alert-dismissable,
95
+ .alert-dismissible {
96
+ padding-right: 35px;
97
+ }
98
+ .alert-dismissable .close,
99
+ .alert-dismissible .close {
100
+ position: relative;
101
+ top: -2px;
102
+ right: -21px;
103
+ color: inherit;
104
+ }
105
+ .alert-success {
106
+ background-color: #dff0d8;
107
+ border-color: #d6e9c6;
108
+ color: #3c763d;
109
+ }
110
+ .alert-success hr {
111
+ border-top-color: #c9e2b3;
112
+ }
113
+ .alert-success .alert-link {
114
+ color: #2b542c;
115
+ }
116
+ .alert-info {
117
+ background-color: #d9edf7;
118
+ border-color: #bce8f1;
119
+ color: #31708f;
120
+ }
121
+ .alert-info hr {
122
+ border-top-color: #a6e1ec;
123
+ }
124
+ .alert-info .alert-link {
125
+ color: #245269;
126
+ }
127
+ .alert-warning {
128
+ background-color: #fcf8e3;
129
+ border-color: #faebcc;
130
+ color: #8a6d3b;
131
+ }
132
+ .alert-warning hr {
133
+ border-top-color: #f7e1b5;
134
+ }
135
+ .alert-warning .alert-link {
136
+ color: #66512c;
137
+ }
138
+ .alert-danger {
139
+ background-color: #f2dede;
140
+ border-color: #ebccd1;
141
+ color: #a94442;
142
+ }
143
+ .alert-danger hr {
144
+ border-top-color: #e4b9c0;
145
+ }
146
+ .alert-danger .alert-link {
147
+ color: #843534;
148
+ }
149
+ .close {
150
+ float: right;
151
+ font-size: 21px;
152
+ font-weight: bold;
153
+ line-height: 1;
154
+ color: #000000;
155
+ text-shadow: 0 1px 0 #ffffff;
156
+ opacity: 0.2;
157
+ filter: alpha(opacity=20);
158
+ }
159
+ .close:hover,
160
+ .close:focus {
161
+ color: #000000;
162
+ text-decoration: none;
163
+ cursor: pointer;
164
+ opacity: 0.5;
165
+ filter: alpha(opacity=50);
166
+ }
167
+ button.close {
168
+ padding: 0;
169
+ cursor: pointer;
170
+ background: transparent;
171
+ border: 0;
172
+ -webkit-appearance: none;
173
+ }
174
+ .fade {
175
+ opacity:0;
176
+ -webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;
177
+ transition:opacity .15s linear
178
+ }
179
+ .fade.in {
180
+ opacity:1
181
+ }
assets/js/function.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function likeThis(postId) {
2
+ if (postId != '') {
3
+ jQuery('#wp-ulike-' + postId + ' .counter').html('<a class="text">' + ulike_obj.likeText + '</a><span class="count-box">...</span>');
4
+
5
+ jQuery.ajax({
6
+ type:'POST',
7
+ url: ulike_obj.ajaxurl,
8
+ data:{
9
+ action:'ulikeprocess',
10
+ id: postId
11
+ },
12
+ success: function(value) {
13
+ jQuery('#wp-ulike-' + postId + ' .counter').html('<a class="text">' + ulike_obj.likeText + '</a><span class="count-box">'+value+ '</span>');
14
+ }
15
+ });
16
+ }
17
+ }
assets/js/wp-ulike.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ if("undefined"==typeof jQuery)throw new Error("WP Ulike's JavaScript requires jQuery");+function(t){"use strict";function n(){var t=document.createElement("bootstrap"),n={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var r in n)if(void 0!==t.style[r])return{end:n[r]};return!1}t.fn.emulateTransitionEnd=function(n){var r=!1,e=this;t(this).one("bsTransitionEnd",function(){r=!0});var i=function(){r||t(e).trigger(t.support.transition.end)};return setTimeout(i,n),this},t(function(){t.support.transition=n(),t.support.transition&&(t.event.special.bsTransitionEnd={bindType:t.support.transition.end,delegateType:t.support.transition.end,handle:function(n){return t(n.target).is(this)?n.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery);
2
+ if("undefined"==typeof jQuery)throw new Error("WP Ulike's JavaScript requires jQuery");+function(t){"use strict";function e(e){return this.each(function(){var r=t(this),n=r.data("bs.alert");n||r.data("bs.alert",n=new a(this)),"string"==typeof e&&n[e].call(r)})}var r='[data-dismiss="alert"]',a=function(e){t(e).on("click",r,this.close)};a.VERSION="3.2.0",a.prototype.close=function(e){function r(){s.detach().trigger("closed.bs.alert").remove()}var a=t(this),n=a.attr("data-target");n||(n=a.attr("href"),n=n&&n.replace(/.*(?=#[^\s]*$)/,""));var s=t(n);e&&e.preventDefault(),s.length||(s=a.hasClass("alert")?a:a.parent()),s.trigger(e=t.Event("close.bs.alert")),e.isDefaultPrevented()||(s.removeClass("in"),t.support.transition&&s.hasClass("fade")?s.one("bsTransitionEnd",r).emulateTransitionEnd(150):r())};var n=t.fn.alert;t.fn.alert=e,t.fn.alert.Constructor=a,t.fn.alert.noConflict=function(){return t.fn.alert=n,this},t(document).on("click.bs.alert.data-api",r,a.prototype.close)}(jQuery);
3
+ function likeThis(e){""!=e&&(jQuery("#wp-ulike-"+e+" .counter").html('<a class="text">'+ulike_obj.likeText+'</a><span class="count-box">...</span>'),jQuery.ajax({type:"POST",url:ulike_obj.ajaxurl,data:{action:"ulikeprocess",id:e},success:function(a){jQuery("#wp-ulike-"+e+" .counter").html('<a class="text">'+ulike_obj.likeText+'</a><span class="count-box">'+a+"</span>")}}))}
inc/wp-options.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function wp_ulike_adminMenu() {
4
+ add_options_page(__( 'WP Ulike', 'alimir' ), __( 'WP Ulike', 'alimir' ), 'administrator', __FILE__, 'wp_ulike_settings_page', __FILE__);
5
+ add_action('admin_init', 'wp_ulike_register_mysettings');
6
+ }
7
+ add_action('admin_menu', 'wp_ulike_adminMenu');
8
+
9
+ function wp_ulike_register_mysettings() { // whitelist options
10
+ register_setting( 'wp_ulike_options', 'wp_ulike_onPage' );
11
+ register_setting( 'wp_ulike_options', 'wp_ulike_textOrImage' );
12
+ register_setting( 'wp_ulike_options', 'wp_ulike_text' );
13
+ register_setting( 'wp_ulike_options', 'wp_ulike_btn_text' );
14
+ register_setting( 'wp_ulike_options', 'wp_ulike_onlyRegistered' );
15
+ }
16
+
17
+
18
+ function wp_ulike_settings_page() {
19
+ ?>
20
+ <div class="wrap">
21
+
22
+ <h3><?php _e('Configuration','alimir'); ?></h3>
23
+ <form method="post" action="options.php">
24
+ <?php settings_fields('wp_ulike_options'); ?>
25
+ <?php do_settings_sections( 'wp_ulike_options' ); ?>
26
+ <table class="form-table">
27
+ <tr valign="top">
28
+ <th scope="row"><?php _e('Image or text?', 'alimir'); ?></th>
29
+ <td>
30
+ <label for="wp_ulike_textOrImage" style="padding:3px 20px 3px; background: url(<?php echo plugins_url('assets/css/add.png', dirname(__FILE__)); ?>) no-repeat right center;">
31
+ <?php echo get_option('wp_ulike_textOrImage') == 'image' ? '<input type="radio" name="wp_ulike_textOrImage" id="wp_ulike_textOrImage" value="image" checked="checked">' : '<input type="radio" name="wp_ulike_textOrImage" id="wp_ulike_textOrImage" value="image">'; ?>
32
+ </label>
33
+ <label for="wp_ulike_text">
34
+ <?php echo get_option('wp_ulike_textOrImage') == 'text' ? '<input type="radio" name="wp_ulike_textOrImage" id="wp_ulike_textOrImage" value="text" checked="checked">' : '<input type="radio" name="wp_ulike_textOrImage" id="wp_ulike_textOrImage" value="text">'; ?>
35
+ <input type="text" name="wp_ulike_text" id="wp_ulike_text" value="<?php echo get_option('wp_ulike_text'); ?>" />
36
+ </label>
37
+ </td>
38
+ </tr>
39
+ <tr valign="top">
40
+ <th scope="row"><?php _e('Liked Text?', 'alimir'); ?></th>
41
+ <td>
42
+ <label for="wp_ulike_btn_text">
43
+ <input type="text" name="wp_ulike_btn_text" id="wp_ulike_btn_text" value="<?php echo get_option('wp_ulike_btn_text'); ?>" />
44
+ </label>
45
+ </td>
46
+ </tr>
47
+ <tr valign="top">
48
+ <th scope="row"><?php _e('Automatic display', 'alimir'); ?></th>
49
+ <td>
50
+ <label for="wp_ulike_onPage">
51
+ <?php echo get_option('wp_ulike_onPage') == '1' ? '<input type="checkbox" name="wp_ulike_onPage" id="wp_ulike_onPage" value="1" checked="checked">' : '<input type="checkbox" name="wp_ulike_onPage" id="wp_ulike_onPage" value="1">'; ?>
52
+ <?php _e('<strong>On all posts</strong> (home, archives, search) at the bottom of the post', 'alimir'); ?>
53
+ </label>
54
+ <p class="description"><?php _e('If you disable this option, you have to put manually the code', 'alimir'); ?><code dir="ltr">&lt;?php if(function_exists('wp_ulike')) wp_ulike('get'); ?&gt;</code> <?php _e('wherever you want in your template.', 'alimir'); ?></p>
55
+ </td>
56
+ </tr>
57
+ <tr valign="top">
58
+ <th scope="row"><?php _e('Only registered Users', 'alimir'); ?></th>
59
+ <td>
60
+ <label for="wp_ulike_onlyRegistered">
61
+ <?php echo get_option('wp_ulike_onlyRegistered') == '1' ? '<input type="checkbox" name="wp_ulike_onlyRegistered" id="wp_ulike_onlyRegistered" value="1" checked="checked">' : '<input type="checkbox" name="wp_ulike_onlyRegistered" id="wp_ulike_onlyRegistered" value="1">'; ?>
62
+ <?php _e('<strong>Active</strong> this option.', 'alimir'); ?>
63
+ </label>
64
+ <p class="description"><?php _e('<strong>Only</strong> registered users have permission to like posts.', 'alimir'); ?></p>
65
+ </td>
66
+ </tr>
67
+ </table>
68
+ <?php submit_button(); ?>
69
+ </form>
70
+
71
+
72
+ <div id="poststuff" class="ui-sortable meta-box-sortables">
73
+ <div class="postbox">
74
+ <h3><?php _e('Like this plugin?','alimir'); ?></h3>
75
+ <div class="inside">
76
+ <p>
77
+ <?php _e('Show your support by Rating 5 Star in <a href="http://wordpress.org/plugins/wp-ulike"> Plugin Directory reviews</a>','alimir'); ?><br />
78
+ <?php _e('Follow me on <a href="https://www.facebook.com/alimir.ir"> Facebook</a>','alimir'); ?><br />
79
+ <?php _e('Plugin Author Blog: <a href="http://alimir.ir"> Wordpress & Programming World.</a>','alimir'); ?>
80
+ </p>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <?php
86
+ }
inc/wp-script.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //Scripts
3
+ function enqueueScripts() {
4
+
5
+ wp_enqueue_script( 'jquery' );
6
+ wp_enqueue_script('wp_ulike', plugins_url('assets/js/wp-ulike.js', dirname(__FILE__)), array('jquery'));
7
+
8
+ wp_localize_script( 'wp_ulike', 'ulike_obj', array(
9
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
10
+ 'likeText' => get_option('wp_ulike_btn_text')
11
+ ));
12
+ add_action('wp_ajax_ulikeprocess','wp_ulike_process');
13
+ add_action('wp_ajax_nopriv_ulikeprocess', 'wp_ulike_process');
14
+ }
15
+
16
+ function enqueueStyle() {
17
+ if(!is_rtl())
18
+ wp_enqueue_style( 'wp-ulike', plugins_url('assets/css/wp-ulike.css', dirname(__FILE__)) );
19
+ else
20
+ wp_enqueue_style( 'wp-ulike', plugins_url('assets/css/wp-ulike-rtl.css', dirname(__FILE__)) );
21
+ }
22
+
23
+ add_action('init', 'enqueueScripts');
24
+ add_action('wp_print_styles', 'enqueueStyle');
inc/wp-widget.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Creating the widget
3
+ class wp_ulike_widget extends WP_Widget {
4
+
5
+ function __construct() {
6
+ parent::__construct(
7
+ 'wp_ulike',
8
+ __('WP Ulike Widget', 'alimir'),
9
+ array( 'description' => __( 'This plugin allows your visitors to simply like your posts instead of comment it.', 'alimir' ))
10
+ );
11
+ }
12
+
13
+ public function most_liked_posts($numberOf, $before, $after, $show_count) {
14
+ global $wpdb;
15
+
16
+ $request = "SELECT ID, post_title, meta_value FROM $wpdb->posts, $wpdb->postmeta";
17
+ $request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id";
18
+ $request .= " AND post_status='publish' AND meta_key='_liked'";
19
+ $request .= " ORDER BY $wpdb->postmeta.meta_value+0 DESC LIMIT $numberOf";
20
+ $posts = $wpdb->get_results($request);
21
+
22
+ foreach ($posts as $post) {
23
+ $post_title = stripslashes($post->post_title);
24
+ $permalink = get_permalink($post->ID);
25
+ $post_count = $post->meta_value;
26
+
27
+ echo $before.'<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">' . $post_title . '</a>';
28
+ echo $show_count == '1' ? ' ('.$post_count.')' : '';
29
+ echo $after;
30
+ }
31
+ }
32
+
33
+ public function widget( $args, $instance ) {
34
+ $title = apply_filters('widget_title', $instance['title'] );
35
+ $numberOf = $instance['count'];
36
+ $show_count = (isset($instance['show_count']) == true ) ? 1 : 0;
37
+
38
+ echo $args['before_widget'];
39
+ if ( ! empty( $title ) )
40
+ echo $args['before_title'] . $title . $args['after_title'];
41
+ echo '<ul class="mostlikedposts">';
42
+ echo $this->most_liked_posts($numberOf, '<li>', '</li>', $show_count);
43
+ echo '</ul>';
44
+ echo $args['after_widget'];
45
+ }
46
+
47
+
48
+
49
+ public function form( $instance ) {
50
+ //Set up some default widget settings.
51
+ $defaults = array( 'title' => __('Most liked posts', 'alimir'), 'count' => 15, 'show_count' => true );
52
+ $instance = wp_parse_args( (array) $instance, $defaults );
53
+ ?>
54
+ <p>
55
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'alimir'); ?></label>
56
+ <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
57
+ </p>
58
+
59
+ <p>
60
+ <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e('Number of posts to show:', 'alimir'); ?><small> (max. 15)</small></label>
61
+ <input id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo $instance['count']; ?>" style="width:100%;" />
62
+ </p>
63
+
64
+ <p>
65
+ <input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_count' ); ?>" name="<?php echo $this->get_field_name( 'show_count' ); ?>" <?php if($instance['show_count'] == true) echo 'checked="checked"'; ?> />
66
+ <label for="<?php echo $this->get_field_id( 'show_count' ); ?>"><?php _e('Show post count', 'alimir'); ?></label>
67
+ </p>
68
+ <?php
69
+ }
70
+
71
+ public function update( $new_instance, $old_instance ) {
72
+ $instance = $old_instance;
73
+
74
+ $instance['title'] = strip_tags( $new_instance['title'] );
75
+ $instance['count'] = strip_tags( $new_instance['count'] );
76
+ $instance['show_count'] = $new_instance['show_count'];
77
+
78
+ return $instance;
79
+ }
80
+ }
81
+
82
+ function wp_ulike_load_widget() {
83
+ register_widget( 'wp_ulike_widget' );
84
+ }
85
+ add_action( 'widgets_init', 'wp_ulike_load_widget' );
86
+ ?>
lang/alimir-fa_IR.mo ADDED
Binary file
lang/alimir-fa_IR.po ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: I-Like-This\n"
4
+ "POT-Creation-Date: 2014-08-28 11:21+0330\n"
5
+ "PO-Revision-Date: 2014-08-28 11:21+0330\n"
6
+ "Last-Translator: Alimir <info@alimir.ir>\n"
7
+ "Language-Team: alimir.ir <info@alimir.ir>\n"
8
+ "Language: Persian\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.4\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+ "X-Poedit-SearchPath-1: ..\n"
18
+
19
+ #: ../wp-ulike.php:16
20
+ msgid "WP ULike"
21
+ msgstr "وردپرس یولایک"
22
+
23
+ #: ../wp-ulike.php:17
24
+ msgid ""
25
+ "WP ULike plugin allows to integrate Like Button into your WordPress website "
26
+ "to allow your visitors to like pages and posts. Its very simple to use and "
27
+ "support a widget to display the most liked posts."
28
+ msgstr ""
29
+ "یولایک، یک افزونه ساده و سبک برای راه اندازی سیستم \"لایک مطالب\" در وبلاگ "
30
+ "یا وبسایت شماست :) - این پلاگین توسط علی میرزائی و در دنیای وردپرس و برنامه "
31
+ "نویسی منتشر شده است."
32
+
33
+ #: ../wp-ulike.php:81
34
+ msgid "You need to login in order to like this post: "
35
+ msgstr "برای امتیاز دهی به این مطلب، لطفا وارد شوید: "
36
+
37
+ #: ../wp-ulike.php:81
38
+ msgid "click here"
39
+ msgstr "برای ورود کلیک کنید"
40
+
41
+ #: ../inc/wp-options.php:4
42
+ msgid "WP Ulike"
43
+ msgstr "تنظیمات یولایک"
44
+
45
+ #: ../inc/wp-options.php:22
46
+ msgid "Configuration"
47
+ msgstr "پیکربندی"
48
+
49
+ #: ../inc/wp-options.php:28
50
+ msgid "Image or text?"
51
+ msgstr "متن یا تصویر؟"
52
+
53
+ #: ../inc/wp-options.php:40
54
+ msgid "Liked Text?"
55
+ msgstr "متن دکمه پس از لایک"
56
+
57
+ #: ../inc/wp-options.php:48
58
+ msgid "Automatic display"
59
+ msgstr "نمایش خودکار"
60
+
61
+ #: ../inc/wp-options.php:52
62
+ msgid ""
63
+ "<strong>On all posts</strong> (home, archives, search) at the bottom of the "
64
+ "post"
65
+ msgstr ""
66
+ "<strong>نمایش در تمامی پست ها</strong> (خانه, بایگانی, جستجو)در بخش زیرین "
67
+ "مطالب."
68
+
69
+ #: ../inc/wp-options.php:54
70
+ msgid "If you disable this option, you have to put manually the code"
71
+ msgstr "اگر این قابلیت را غیر فعال کنید، باید به صورت دستی این کد را "
72
+
73
+ #: ../inc/wp-options.php:54
74
+ msgid "wherever you want in your template."
75
+ msgstr "در قالب خود قرار دهید."
76
+
77
+ #: ../inc/wp-options.php:58
78
+ msgid "Only registered Users"
79
+ msgstr "محدودسازی لایک کاربران"
80
+
81
+ #: ../inc/wp-options.php:62
82
+ msgid "<strong>Active</strong> this option."
83
+ msgstr "<strong>فعال کردن</strong> این قابلیت."
84
+
85
+ #: ../inc/wp-options.php:64
86
+ msgid "<strong>Only</strong> registered users have permission to like posts."
87
+ msgstr "<strong>تنها</strong> کاربران عضو شده، می توانند مطالب را لایک کنند.."
88
+
89
+ #: ../inc/wp-options.php:74
90
+ msgid "Like this plugin?"
91
+ msgstr "این پلاگین چندتا لایک داره؟!؟ :)"
92
+
93
+ #: ../inc/wp-options.php:77
94
+ msgid ""
95
+ "Show your support by Rating 5 Star in <a href=\"http://wordpress.org/plugins/"
96
+ "wp-ulike\"> Plugin Directory reviews</a>"
97
+ msgstr ""
98
+ "حمایتتون رو از این افزونه، با امتیاز 5 ستاره در <a href=\"http://wordpress."
99
+ "org/plugins/wp-ulike\">مخزن وردپرس</a> مشخص کنید..."
100
+
101
+ #: ../inc/wp-options.php:78
102
+ msgid ""
103
+ "Follow me on <a href=\"https://www.facebook.com/alimir.ir\"> Facebook</a>"
104
+ msgstr ""
105
+ "دنیای وردپرس و برنامه نویسی را در <a href=\"https://www.facebook.com/alimir."
106
+ "ir\"> فیسبوک</a> دنبال کنید..."
107
+
108
+ #: ../inc/wp-options.php:79
109
+ msgid ""
110
+ "Plugin Author Blog: <a href=\"http://alimir.ir\"> Wordpress & Programming "
111
+ "World.</a>"
112
+ msgstr ""
113
+ "صفحه سازنده افزونه <a href=\"http://alimir.ir\"> دنیای وردپرس و برنامه "
114
+ "نویسی</a>."
115
+
116
+ #: ../inc/wp-widget.php:8
117
+ msgid "WP Ulike Widget"
118
+ msgstr "ابزارک یولایک"
119
+
120
+ #: ../inc/wp-widget.php:9
121
+ msgid ""
122
+ "This plugin allows your visitors to simply like your posts instead of "
123
+ "comment it."
124
+ msgstr "یک پلاگین ساده و سبک برای راه اندازی سیستم لایک در وبلاگ شما"
125
+
126
+ #: ../inc/wp-widget.php:51
127
+ msgid "Most liked posts"
128
+ msgstr "بیشترین مطالب لایک شده"
129
+
130
+ #: ../inc/wp-widget.php:55
131
+ msgid "Title:"
132
+ msgstr "عنوان:"
133
+
134
+ #: ../inc/wp-widget.php:60
135
+ msgid "Number of posts to show:"
136
+ msgstr "تعداد مطالب قابل نمایش:"
137
+
138
+ #: ../inc/wp-widget.php:66
139
+ msgid "Show post count"
140
+ msgstr "نمایش شمارشگر"
141
+
142
+ #~ msgid "Save Options"
143
+ #~ msgstr "ذخیره تغییرات"
144
+
145
+ #~ msgid "jQuery framework"
146
+ #~ msgstr "چارچوب جی کوئری"
147
+
148
+ #~ msgid "Enabled"
149
+ #~ msgstr "فعال"
150
+
151
+ #~ msgid "Disabled"
152
+ #~ msgstr "غیر فعال"
153
+
154
+ #~ msgid ""
155
+ #~ "Disable it if you already have the jQuery framework enabled in your theme."
156
+ #~ msgstr ""
157
+ #~ "اگر پیش ازاین، از چارچوب جی کوئری در قالب خود استفاده کرده اید، این "
158
+ #~ "قابلیت را غیر فعال کنید."
159
+
160
+ #~ msgid "I Like This"
161
+ #~ msgstr "افزونه لایک وردپرس"
162
+
163
+ #~ msgid "Translated in"
164
+ #~ msgstr "فارسی سازی در "
165
+
166
+ #~ msgid "wp and programming world"
167
+ #~ msgstr "دنیای وردپرس و برنامه نویسی"
lang/alimir-fr_FR.mo ADDED
Binary file
lang/alimir-fr_FR.po ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP ULike\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-08-28 11:21+0330\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: Alimir <info@alimir.ir>\n"
8
+ "Language-Team: \n"
9
+ "Language: France\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Generator: Poedit 1.5.4\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+ "X-Poedit-SearchPath-1: ..\n"
18
+
19
+ #: ../wp-ulike.php:16
20
+ msgid "WP ULike"
21
+ msgstr ""
22
+
23
+ #: ../wp-ulike.php:17
24
+ msgid ""
25
+ "WP ULike plugin allows to integrate Like Button into your WordPress website "
26
+ "to allow your visitors to like pages and posts. Its very simple to use and "
27
+ "support a widget to display the most liked posts."
28
+ msgstr ""
29
+
30
+ #: ../wp-ulike.php:81
31
+ msgid "You need to login in order to like this post: "
32
+ msgstr ""
33
+
34
+ #: ../wp-ulike.php:81
35
+ msgid "click here"
36
+ msgstr ""
37
+
38
+ #: ../inc/wp-options.php:4
39
+ msgid "WP Ulike"
40
+ msgstr ""
41
+
42
+ #: ../inc/wp-options.php:22
43
+ msgid "Configuration"
44
+ msgstr "Configuration"
45
+
46
+ #: ../inc/wp-options.php:28
47
+ msgid "Image or text?"
48
+ msgstr "Image ou texte?"
49
+
50
+ #: ../inc/wp-options.php:40
51
+ msgid "Liked Text?"
52
+ msgstr ""
53
+
54
+ #: ../inc/wp-options.php:48
55
+ msgid "Automatic display"
56
+ msgstr "Affichage automatique"
57
+
58
+ #: ../inc/wp-options.php:52
59
+ msgid ""
60
+ "<strong>On all posts</strong> (home, archives, search) at the bottom of the "
61
+ "post"
62
+ msgstr ""
63
+ "<strong>Pour tous les articles</strong> (accueil, archives, recherche) au "
64
+ "fond de l'article."
65
+
66
+ #: ../inc/wp-options.php:54
67
+ msgid "If you disable this option, you have to put manually the code"
68
+ msgstr ""
69
+ "Si vous désactivez cette option, vous devez ajouter manuellement le code"
70
+
71
+ #: ../inc/wp-options.php:54
72
+ msgid "wherever you want in your template."
73
+ msgstr "n'importe où vous le souhaitez dans votre thème."
74
+
75
+ #: ../inc/wp-options.php:58
76
+ msgid "Only registered Users"
77
+ msgstr ""
78
+
79
+ #: ../inc/wp-options.php:62
80
+ msgid "<strong>Active</strong> this option."
81
+ msgstr ""
82
+
83
+ #: ../inc/wp-options.php:64
84
+ msgid "<strong>Only</strong> registered users have permission to like posts."
85
+ msgstr ""
86
+
87
+ #: ../inc/wp-options.php:74
88
+ msgid "Like this plugin?"
89
+ msgstr "Vous aimez ce plugin?"
90
+
91
+ #: ../inc/wp-options.php:77
92
+ msgid ""
93
+ "Show your support by Rating 5 Star in <a href=\"http://wordpress.org/plugins/"
94
+ "wp-ulike\"> Plugin Directory reviews</a>"
95
+ msgstr ""
96
+
97
+ #: ../inc/wp-options.php:78
98
+ msgid ""
99
+ "Follow me on <a href=\"https://www.facebook.com/alimir.ir\"> Facebook</a>"
100
+ msgstr ""
101
+
102
+ #: ../inc/wp-options.php:79
103
+ msgid ""
104
+ "Plugin Author Blog: <a href=\"http://alimir.ir\"> Wordpress & Programming "
105
+ "World.</a>"
106
+ msgstr ""
107
+
108
+ #: ../inc/wp-widget.php:8
109
+ msgid "WP Ulike Widget"
110
+ msgstr ""
111
+
112
+ #: ../inc/wp-widget.php:9
113
+ msgid ""
114
+ "This plugin allows your visitors to simply like your posts instead of "
115
+ "comment it."
116
+ msgstr ""
117
+
118
+ #: ../inc/wp-widget.php:51
119
+ msgid "Most liked posts"
120
+ msgstr ""
121
+
122
+ #: ../inc/wp-widget.php:55
123
+ msgid "Title:"
124
+ msgstr "Titre:"
125
+
126
+ #: ../inc/wp-widget.php:60
127
+ msgid "Number of posts to show:"
128
+ msgstr "Nombre d'articles à afficher:"
129
+
130
+ #: ../inc/wp-widget.php:66
131
+ msgid "Show post count"
132
+ msgstr "Afficher le nombre d'articles"
133
+
134
+ #~ msgid "Save Options"
135
+ #~ msgstr "Enregistrer les options"
136
+
137
+ #~ msgid "jQuery framework"
138
+ #~ msgstr "Librairie jQuery"
139
+
140
+ #~ msgid "Enabled"
141
+ #~ msgstr "Activé"
142
+
143
+ #~ msgid "Disabled"
144
+ #~ msgstr "Désactivé"
145
+
146
+ #~ msgid ""
147
+ #~ "Disable it if you already have the jQuery framework enabled in your theme."
148
+ #~ msgstr ""
149
+ #~ "Désactivez cette option si vous avez déjà la librairie jQuery activée "
150
+ #~ "dans votre thème."
readme.txt ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP ULike ===
2
+ Contributors: alimir
3
+ Donate link: http://alimir.ir
4
+ Author: Ali Mirzaei
5
+ Tags: wp ulike, wordpress youlike plugin, like button, rating, vote, voting, most liked posts, wordpress like page, wordpress like post, wordpress vote page, wordpress vote post, wp like page, wp like post, wp like plugin
6
+ Requires at least: 3.1
7
+ Tested up to: 3.9.2
8
+ Stable tag: 1.0
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ WP ULike plugin allows to integrate Ajax Like Button into your WordPress website to allow your visitors to like pages and posts.
13
+
14
+ == Description ==
15
+
16
+ WP ULike plugin allows to integrate a beautiful Ajax Like Button into your wordPress website to allow your visitors to like pages and posts. Its very simple to use and support a widget to display the most liked posts.
17
+
18
+ = Demo =
19
+
20
+ <a target="_blank" href="http://preview.alimir.ir/wp-ulike-plugin">Click Here</a>
21
+
22
+ = Features =
23
+
24
+ * A counter/button to submit and display the number of likes.
25
+ * A widget and a function to display the most liked posts.
26
+ * Simple configuration panel.
27
+ * Full RTL support.
28
+ * And so on...
29
+
30
+ = How To Use? =
31
+ * Just install the plugin and use `<?php if(function_exists('wp_ulike')) wp_ulike('get'); ?>` function or activate the "automatic display" in plugin setting panel.
32
+
33
+ = Translations =
34
+ * English
35
+ * Persian
36
+ * France
37
+
38
+ = Plugin Author =
39
+ Website: <a href="http://about.alimir.ir" target="_blank">Ali Mirzaei</a><br />
40
+ Follow on <a href="https://www.facebook.com/alimir.ir" target="_blank">facebook</a>
41
+
42
+ == Installation ==
43
+
44
+ 1. Upload plugin folder to the `/wp-content/plugins/` directory.
45
+ 2. Activate the plugin through the `Plugins` menu in WordPress.
46
+
47
+ == Screenshots ==
48
+
49
+ Screenshots are available in <a href="http://preview.alimir.ir/wp-ulike-plugin" target="_blank">here</a>
50
+
51
+ == Changelog ==
52
+
53
+ = 1.0.0 =
54
+ * The initial version
55
+
56
+ == Upgrade Notice ==
57
+
58
+ = 1.0.0 =
59
+ The initial version
wp-ulike.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name:WP ULike
4
+ Plugin URI: http://wordpress.org/plugins/wp-ulike
5
+ Description: WP ULike plugin allows to integrate Like Button into your WordPress website to allow your visitors to like pages and posts. Its very simple to use and support a widget to display the most liked posts.
6
+ Version: 1.0
7
+ Author: Ali Mirzaei
8
+ Author URI: http://alimir.ir
9
+ Text Domain: alimir
10
+ Domain Path: /lang/
11
+ License: GPL2
12
+ */
13
+
14
+ //Load Translations
15
+ load_plugin_textdomain( 'alimir', false, dirname( plugin_basename( __FILE__ ) ) .'/lang/' );
16
+ __('WP ULike', 'alimir');
17
+ __('WP ULike plugin allows to integrate Like Button into your WordPress website to allow your visitors to like pages and posts. Its very simple to use and support a widget to display the most liked posts.', 'alimir');
18
+
19
+ //Load Widget
20
+ include( plugin_dir_path( __FILE__ ) . 'inc/wp-widget.php');
21
+ //Load Options
22
+ include( plugin_dir_path( __FILE__ ) . 'inc/wp-options.php');
23
+ //Load Scripts
24
+ include( plugin_dir_path( __FILE__ ) . 'inc/wp-script.php');
25
+
26
+ function wp_ulike_options() {
27
+ add_option('wp_ulike_onPage', '1', '', 'yes');
28
+ add_option('wp_ulike_onlyRegistered', '0', '', 'yes');
29
+ add_option('wp_ulike_textOrImage', 'image', '', 'yes');
30
+ add_option('wp_ulike_text', 'Like', '', 'yes');
31
+ add_option('wp_ulike_btn_text', 'You Liked Before', '', 'yes');
32
+ }
33
+
34
+ register_activation_hook(__FILE__, 'wp_ulike_options');
35
+
36
+ function wp_ulike_unsetOptions() {
37
+
38
+ delete_option('wp_ulike_onPage');
39
+ delete_option('wp_ulike_textOrImage');
40
+ delete_option('wp_ulike_text');
41
+ delete_option('wp_ulike_btn_text');
42
+ delete_option('wp_ulike_onlyRegistered');
43
+ }
44
+
45
+ register_uninstall_hook(__FILE__, 'wp_ulike_unsetOptions');
46
+
47
+ //main function
48
+ function wp_ulike($arg) {
49
+ global $post;
50
+ $post_ID = $post->ID;
51
+ $liked = get_post_meta($post_ID, '_liked', true) != '' ? '+' . get_post_meta($post_ID, '_liked', true) : '0';
52
+
53
+
54
+ if ( (get_option('wp_ulike_onlyRegistered') != '1') or (get_option('wp_ulike_onlyRegistered') == '1' && is_user_logged_in()) ){
55
+
56
+ if (!isset($_COOKIE['liked-'.$post_ID])) {
57
+ if (get_option('wp_ulike_textOrImage') == 'image') {
58
+ $counter = '<a onclick="likeThis('.$post_ID.');" class="image"></a><span class="count-box">'.$liked.'</span>';
59
+ }
60
+ else {
61
+ $counter = '<a onclick="likeThis('.$post_ID.');" class="text">'.get_option('wp_ulike_text').'</a><span class="count-box">'.$liked.'</span>';
62
+ }
63
+ }
64
+ else {
65
+ $counter = '<a class="text">'.get_option('wp_ulike_btn_text').'</a><span class="count-box">'.$liked.'</span>';
66
+ }
67
+
68
+
69
+ $wp_ulike = '<div id="wp-ulike-'.$post_ID.'" class="wpulike">';
70
+ $wp_ulike .= '<div class="counter">'.$counter.'</div>';
71
+ $wp_ulike .= '</div>';
72
+
73
+ if ($arg == 'put') {
74
+ return $wp_ulike;
75
+ }
76
+ else {
77
+ echo $wp_ulike;
78
+ }
79
+ }
80
+ else if (get_option('wp_ulike_onlyRegistered') == '1' && !is_user_logged_in()){
81
+ return '<p class="alert alert-info fade in" role="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'.__('You need to login in order to like this post: ','alimir').'<a href="'.wp_login_url().'"> '.__('click here','alimir').' </a></p>';
82
+ }
83
+ }
84
+
85
+ //Process function
86
+ function wp_ulike_process(){
87
+ $post_ID = $_POST['id'];
88
+ $like = get_post_meta($post_ID, '_liked', true);
89
+
90
+ if($post_ID != '') {
91
+
92
+ if (!isset($_COOKIE['liked-'.$post_ID])) {
93
+ $newLike = $like + 1;
94
+ update_post_meta($post_ID, '_liked', $newLike);
95
+
96
+ setcookie('liked-'.$post_ID, time(), time()+3600*24*365, '/');
97
+
98
+ echo '+' . $newLike;
99
+ }
100
+ else {
101
+ echo $like;
102
+ }
103
+ }
104
+ die();
105
+ }
106
+
107
+ //add to post/pages
108
+ if (get_option('wp_ulike_onPage') == '1') {
109
+ function wp_put_ulike($content) {
110
+ if(!is_feed() && !is_page()) {
111
+ $content.= wp_ulike('put');
112
+ }
113
+ return $content;
114
+ }
115
+
116
+ add_filter('the_content', 'wp_put_ulike');
117
+ }