Related Posts Thumbnails Plugin for WordPress - Version 1.9.0

Version Description

  • Please upgrade immediately - Introducing filters for developers to extend Related Posts

=

Download this release

Release Info

Developer hiddenpearls
Plugin Icon 128x128 Related Posts Thumbnails Plugin for WordPress
Version 1.9.0
Comparing to
See all releases

Code changes from version 1.8.3 to 1.9.0

assets/css/admin.css CHANGED
@@ -1,234 +1,293 @@
1
- #rpt_subscribe_btn{
2
- display: block;
3
- margin: 20px auto 0;
4
  }
 
5
  #relpoststh-settings .nav-tab-wrapper li a {
6
- float: none;
7
- margin:0;
8
- padding: 7px 20px;
9
- display: block;
10
- height: auto;
11
- background: none;
12
- }
13
- #relpoststh-settings .nav-tab-wrapper li{
14
- margin-bottom: 0;
15
- margin-left: -1px;
16
- }
17
- #relpoststh-settings::after{
18
- display: table;
19
- content: "";
20
- clear: both;
21
- }
22
- #relpoststh-settings{
23
- display: table;
24
- width: calc(100% - 2px);
25
- border:1px solid #ccc;
26
- margin: 0;
27
- }
28
- .relpoststh .wpbr-tabsWrapper{
29
- width: calc(100% - 265px);
30
- float: left;
31
- }
32
- #relpoststh-settings .nav-tab-wrapper{
33
- display: table-cell;
34
- vertical-align: top;
35
- width: 202px;
36
- }
37
- .relpoststh .form-table th:first-child{
38
- width: 110px;
39
- }
40
- .relpoststh #relpoststh-settings .metabox-holder{
41
- display: table-cell;
42
- padding: 10px;
43
- background: #fff;
44
- }
45
- #relpoststh-settings .nav-tab-wrapper li:first-child{
46
- margin-top: -1px;
47
- }
48
- #relpoststh-settings .nav-tab-wrapper li a.nav-tab-active{
49
- background: #fff;
50
- }
51
- #relpoststh-settings .nav-tab-wrapper li a.nav-tab-active{
52
- border-right: transparent;
53
- }
54
- #relpoststh-settings .nav-tab-wrapper li:last-child a{
55
- border-bottom: 1px solid #ccc;
56
- }
57
- .relpoststh #the-list .approve{
58
- display: block;
59
- }
60
- .relpoststh .postbox{
61
- padding: 10px;
62
- }
63
- .relpoststh .wpbr-sidebar{
64
- width: 255px !important;
65
- float: right;
66
- min-width: inherit;
67
- box-sizing: border-box;
68
- }
69
- .relpoststh .wpbr-sidebar .postbox{
70
- min-width: inherit;
71
- width: auto;
72
- }
73
- .relpoststh .wpbr-sidebar ul li a{
74
- width: 100%;
75
- display: block;
76
- }
77
- .relpoststh .wpbr-sidebar .wp-core-ui .button{
78
- position: relative;
79
- }
80
- .relpoststh .wpbr-sidebar .dashicons{
81
- position: absolute;
82
- right: 10px;
83
- margin-top: 3px;
84
- }
85
- .relpoststh .postbox ul li a{
86
- position: relative;
87
- }
88
- .relpoststh .wpbr-button-container{
89
- padding: 10px 0;
90
- overflow: hidden;
91
- }
92
- .relpoststh .wpbr-social-links a{
93
- text-decoration: none;
94
- }
95
- .relpoststh .wpbr-button-container{
96
- padding: 10px;
97
- overflow: hidden;
98
- border:1px solid #ccc;
99
- }
100
- .relpoststh .wpbr-button-container.top{
101
- border-bottom: 0;
102
- }
103
- .relpoststh .wpbr-button-container.bottom{
104
- border-top: 0;
105
- }
106
- .relpoststh .wpb-rpt-settings-submit{
107
- float:right;
108
- }
109
- .relpoststh .wpbr-sidebar h2{
110
- margin: 0;
111
- padding: 10px;
112
- border-bottom: 1px solid #ccc;
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  .relpoststh .wpbr-sidebar ul li .twitter .dashicons {
115
- color: #45b0e3;
116
  }
 
117
  .relpoststh .wpbr-sidebar ul li .facebook .dashicons {
118
- color: #3b5998;
119
  }
 
120
  .relpoststh .wpbr-sidebar ul li .wordpress .dashicons {
121
- color: #21759b;
122
  }
 
123
  .relpoststh .wpbr-sidebar ul li .rss .dashicons {
124
- color: #FF6600;
125
- }
126
- #relpoststh-settings p.submit{
127
- display: none;
128
- }
129
- .relpoststh #wpbr_custom_css .form-table th{
130
- width: 0;
131
- }
132
- .relpoststh #wpbr_custom_css .form-table td{
133
- width: 100%;
134
- }
135
- .relpoststh .wpbr-wrap:after{
136
- content: '';
137
- display: table;
138
- clear: both;
139
- }
140
- .relpoststh .metabox-holder{
141
- padding-top: 0 !important;
142
- padding-right: 15px !important;
143
- }
144
- .relpoststh .setting-notification{
145
- position: absolute;
146
- width: auto;
147
- padding: 16px 10px;
148
- left: 0;
149
- top: 0;
150
- background-color: #fcf8e3;
151
- color: #c09853;
152
- height: 100%;
153
- box-sizing: border-box;
154
- display: none;
155
- }
156
- #relpoststh-settings .postbox{
157
- border: 0px solid #e5e5e5;
158
- -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.0);
159
- box-shadow: 0 1px 1px rgba(0,0,0,.0);
160
- }
161
- #relpoststh-settings .nav-tab-wrapper{
162
- padding-top: 0;
163
- border-bottom: 0px solid #ccc;
164
- border-right: 1px solid #ccc;
165
- }
166
- #relpoststh-settings .nav-tab-wrapper li a.nav-tab-active{
167
- margin: 0 -1px 0 0;
168
- outline: none;
169
- box-shadow: none;
170
- }
171
- #relpoststh-settings .nav-tab-wrapper .nav-tab{
172
- border-right: 0;
173
- }
174
- .plugins_lists li{
175
- padding-bottom: 12px;
176
- line-height: 1.4;
177
- }
178
- .rpt-top-bar{
179
- background: #f3fbff;
180
- overflow: hidden;
181
- padding: 15px 0;
182
- }
183
- .rpt-top-bar img{
184
- float: left;
185
- width: 118px;
186
- }
187
- .rpt-top-bar-content{
188
- overflow: hidden;
189
- }
190
- .rpt-top-bar-content h3{
191
- margin: 10px 0;
192
- }
193
- .rpt-top-bar-content p{
194
- margin: 0;
195
- }
196
- .relposts-button-section{
197
- padding-top: 10px;
198
- }
199
- .process_custom_images{
200
- width: 210px;
201
- height: 162px;
202
- border-radius: 2.5px;
203
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  .wp-core-ui .button.relpoststh_set_plug_image {
205
- margin-left: 24px;
206
  }
 
207
  #relpoststh_customwidth {
208
- padding-right: 3px;
209
  }
 
210
  #custom_taxonomies {
211
- padding-top: 5px;
212
  }
 
213
  #relpoststh_cleanhtml {
214
- margin-left: 5px;
215
  }
216
- #relpoststh_cleanhtml input{
217
- margin-left: 1px;
 
218
  }
 
219
  #pt_page {
220
- margin-left: 10px;
221
  }
 
222
  #pt_attachment {
223
- margin-left: 10px;
224
  }
 
225
  .rpth-discription {
226
- display: inline;
227
  }
 
228
  .rpt-no-validate-error {
229
- font-style: italic;
230
- color: #b94444;
231
  }
 
232
  .rpth-setting-options th {
233
- color: #3e3838;
234
- }
1
+ #rpt_subscribe_btn {
2
+ display: block;
3
+ margin: 20px auto 0;
4
  }
5
+
6
  #relpoststh-settings .nav-tab-wrapper li a {
7
+ float: none;
8
+ margin: 0;
9
+ padding: 7px 20px;
10
+ display: block;
11
+ height: auto;
12
+ background: none;
13
+ }
14
+
15
+ #relpoststh-settings .nav-tab-wrapper li {
16
+ margin-bottom: 0;
17
+ margin-left: -1px;
18
+ }
19
+
20
+ #relpoststh-settings::after {
21
+ display: table;
22
+ content: "";
23
+ clear: both;
24
+ }
25
+
26
+ #relpoststh-settings {
27
+ display: table;
28
+ width: calc(100% - 2px);
29
+ border: 1px solid #ccc;
30
+ margin: 0;
31
+ }
32
+
33
+ .relpoststh .wpbr-tabsWrapper {
34
+ width: calc(100% - 265px);
35
+ float: left;
36
+ }
37
+
38
+ #relpoststh-settings .nav-tab-wrapper {
39
+ display: table-cell;
40
+ vertical-align: top;
41
+ width: 202px;
42
+ }
43
+
44
+ .relpoststh .form-table th:first-child {
45
+ width: 110px;
46
+ }
47
+
48
+ .relpoststh #relpoststh-settings .metabox-holder {
49
+ display: table-cell;
50
+ padding: 10px;
51
+ background: #fff;
52
+ }
53
+
54
+ #relpoststh-settings .nav-tab-wrapper li:first-child {
55
+ margin-top: -1px;
56
+ }
57
+
58
+ #relpoststh-settings .nav-tab-wrapper li a.nav-tab-active {
59
+ background: #fff;
60
+ }
61
+
62
+ #relpoststh-settings .nav-tab-wrapper li a.nav-tab-active {
63
+ border-right: transparent;
64
+ }
65
+
66
+ #relpoststh-settings .nav-tab-wrapper li:last-child a {
67
+ border-bottom: 1px solid #ccc;
68
+ }
69
+
70
+ .relpoststh #the-list .approve {
71
+ display: block;
72
+ }
73
+
74
+ .relpoststh .postbox {
75
+ padding: 10px;
76
+ }
77
+
78
+ .relpoststh .wpbr-sidebar {
79
+ width: 255px !important;
80
+ float: right;
81
+ min-width: inherit;
82
+ box-sizing: border-box;
83
+ }
84
+
85
+ .relpoststh .wpbr-sidebar .postbox {
86
+ min-width: inherit;
87
+ width: auto;
88
+ }
89
+
90
+ .relpoststh .wpbr-sidebar ul li a {
91
+ width: 100%;
92
+ display: block;
93
+ }
94
+
95
+ .relpoststh .wpbr-sidebar .wp-core-ui .button {
96
+ position: relative;
97
+ }
98
+
99
+ .relpoststh .wpbr-sidebar .dashicons {
100
+ position: absolute;
101
+ right: 10px;
102
+ margin-top: 3px;
103
+ }
104
+
105
+ .relpoststh .postbox ul li a {
106
+ position: relative;
107
+ }
108
+
109
+ .relpoststh .wpbr-button-container {
110
+ padding: 10px 0;
111
+ overflow: hidden;
112
+ }
113
+
114
+ .relpoststh .wpbr-social-links a {
115
+ text-decoration: none;
116
+ }
117
+
118
+ .relpoststh .wpbr-button-container {
119
+ padding: 10px;
120
+ overflow: hidden;
121
+ border: 1px solid #ccc;
122
+ }
123
+
124
+ .relpoststh .wpbr-button-container.top {
125
+ border-bottom: 0;
126
+ }
127
+
128
+ .relpoststh .wpbr-button-container.bottom {
129
+ border-top: 0;
130
+ }
131
+
132
+ .relpoststh .wpb-rpt-settings-submit {
133
+ float: right;
134
+ }
135
+
136
+ .relpoststh .wpbr-sidebar h2 {
137
+ margin: 0;
138
+ padding: 10px;
139
+ border-bottom: 1px solid #ccc;
140
+ }
141
+
142
  .relpoststh .wpbr-sidebar ul li .twitter .dashicons {
143
+ color: #45b0e3;
144
  }
145
+
146
  .relpoststh .wpbr-sidebar ul li .facebook .dashicons {
147
+ color: #3b5998;
148
  }
149
+
150
  .relpoststh .wpbr-sidebar ul li .wordpress .dashicons {
151
+ color: #21759b;
152
  }
153
+
154
  .relpoststh .wpbr-sidebar ul li .rss .dashicons {
155
+ color: #FF6600;
156
+ }
157
+
158
+ #relpoststh-settings p.submit {
159
+ display: none;
160
+ }
161
+
162
+ .relpoststh #wpbr_custom_css .form-table th {
163
+ width: 0;
164
+ }
165
+
166
+ .relpoststh #wpbr_custom_css .form-table td {
167
+ width: 100%;
168
+ }
169
+
170
+ .relpoststh .wpbr-wrap:after {
171
+ content: '';
172
+ display: table;
173
+ clear: both;
174
+ }
175
+
176
+ .relpoststh .metabox-holder {
177
+ padding-top: 0 !important;
178
+ padding-right: 15px !important;
179
+ }
180
+
181
+ .relpoststh .setting-notification {
182
+ position: absolute;
183
+ width: auto;
184
+ padding: 16px 10px;
185
+ left: 0;
186
+ top: 0;
187
+ background-color: #fcf8e3;
188
+ color: #c09853;
189
+ height: 100%;
190
+ box-sizing: border-box;
191
+ display: none;
192
+ }
193
+
194
+ #relpoststh-settings .postbox {
195
+ border: 0px solid #e5e5e5;
196
+ -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .0);
197
+ box-shadow: 0 1px 1px rgba(0, 0, 0, .0);
198
+ }
199
+
200
+ #relpoststh-settings .nav-tab-wrapper {
201
+ padding-top: 0;
202
+ border-bottom: 0px solid #ccc;
203
+ border-right: 1px solid #ccc;
204
+ }
205
+
206
+ #relpoststh-settings .nav-tab-wrapper li a.nav-tab-active {
207
+ margin: 0 -1px 0 0;
208
+ outline: none;
209
+ box-shadow: none;
210
+ }
211
+
212
+ #relpoststh-settings .nav-tab-wrapper .nav-tab {
213
+ border-right: 0;
214
+ }
215
+
216
+ .plugins_lists li {
217
+ padding-bottom: 12px;
218
+ line-height: 1.4;
219
+ }
220
+
221
+ .rpt-top-bar {
222
+ background: #f3fbff;
223
+ overflow: hidden;
224
+ padding: 15px 0;
225
+ }
226
+
227
+ .rpt-top-bar img {
228
+ float: left;
229
+ width: 118px;
230
+ }
231
+
232
+ .rpt-top-bar-content {
233
+ overflow: hidden;
234
+ }
235
+
236
+ .rpt-top-bar-content h3 {
237
+ margin: 10px 0;
238
+ }
239
+
240
+ .rpt-top-bar-content p {
241
+ margin: 0;
242
+ }
243
+
244
+ .relposts-button-section {
245
+ padding-top: 10px;
246
+ }
247
+
248
+ .process_custom_images {
249
+ width: 210px;
250
+ height: 162px;
251
+ border-radius: 2.5px;
252
+ }
253
+
254
  .wp-core-ui .button.relpoststh_set_plug_image {
255
+ margin-left: 24px;
256
  }
257
+
258
  #relpoststh_customwidth {
259
+ padding-right: 3px;
260
  }
261
+
262
  #custom_taxonomies {
263
+ padding-top: 5px;
264
  }
265
+
266
  #relpoststh_cleanhtml {
267
+ margin-left: 5px;
268
  }
269
+
270
+ #relpoststh_cleanhtml input {
271
+ margin-left: 1px;
272
  }
273
+
274
  #pt_page {
275
+ margin-left: 10px;
276
  }
277
+
278
  #pt_attachment {
279
+ margin-left: 10px;
280
  }
281
+
282
  .rpth-discription {
283
+ display: inline;
284
  }
285
+
286
  .rpt-no-validate-error {
287
+ font-style: italic;
288
+ color: #b94444;
289
  }
290
+
291
  .rpth-setting-options th {
292
+ color: #3e3838;
293
+ }
assets/css/front.css CHANGED
@@ -1,179 +1,203 @@
1
  .related-posts-nav {
2
- border: 0pt none;
3
- margin: 0pt;
4
- padding: 0pt;
5
  }
 
6
  .related-posts-nav:after {
7
- content: '';
8
- display: block;
9
- clear: both;
10
  }
 
11
  .related-posts-nav>li {
12
- list-style: none;
13
- padding: 0;
14
- margin: 0;
15
- float: left;
16
  }
 
17
  .related-posts-nav>li:after {
18
- content: '';
19
- display: block;
20
- clear: both;
21
  }
 
22
  .related-posts-nav>li:before {
23
- display: none;
24
  }
 
25
  .related-posts-nav>li>a {
26
- border-bottom: medium none;
27
- margin: 0pt;
28
- padding: 6px;
29
- display: block;
30
- float: left;
31
- text-decoration: none;
32
- text-align: center;
33
- cursor: pointer;
34
- border-right: #ddd;
35
- background-color: #fff;
36
  }
 
37
  .related-posts-nav>li>a:hover {
38
- background-color: #eeeeef;
39
  }
 
40
  .related-posts-nav>li>a>.related-post-list-item-inner-container {
41
- border: 0pt none;
42
- margin: 0pt;
43
- padding: 0pt;
44
- width: 150px;
45
- height: 225px;
46
  }
 
47
  .related-posts-nav>li>a>.related-post-list-item-inner-container>.related-post-list-item-img-container {
48
- border: 0pt none;
49
- margin: 0pt;
50
- padding: 0pt;
51
- width: 150px;
52
- height: 150px;
53
- background-size: cover;
54
- background-repeat: no-repeat;
55
- background-attachment: scroll;
56
- background-position: 0 0;
57
  }
 
58
  .related-posts-nav>li>a>.related-post-list-item-inner-container>.related-post-list-item-text-container {
59
- border: 0pt none;
60
- margin: 3px 0pt 0pt;
61
- padding: 0pt;
62
- font-style: normal;
63
- font-variant: normal;
64
- font-weight: normal;
65
- font-size: 12px;
66
- line-height: normal;
67
- font-stretch: normal;
68
- color: #333333;
69
  }
 
70
  .related-post-list-item-link {
71
- box-shadow: none !important;
72
  }
 
 
73
  /* Burhan */
 
74
  #related_posts_thumbnails {
75
- list-style-type: none;
76
- list-style-position: inside;
77
- padding: 0;
78
- margin: 0
79
  }
 
80
  #related_posts_thumbnails li {
81
- float: left;
82
- padding: 0;
83
- margin: 0;
84
- padding: 5px;
85
- display: block;
86
- max-width: 100%;
87
  }
 
88
  .relpost_content {
89
- display: block;
90
- overflow: hidden;
91
- font-style: normal;
92
- font-variant: normal;
93
- font-weight: normal;
94
- line-height: normal;
95
- font-stretch: normal;
96
- -x-system-font: none;
97
- text-decoration: none;
98
- max-width: 100%;
99
  }
 
100
  .relpost-post-image {
101
- padding: 0;
102
- margin: 0;
103
- border: 0 none;
104
- max-width: 100%;
105
- }
106
- .relpost-block-container{
107
- border: 0 none ;
108
- margin: 0;
109
- padding: 0;
110
- }
111
- .relpost-block-single{
112
- border-bottom: medium none;
113
- margin: 0;
114
- padding: 6px;
115
- display: block;
116
- float: left;
117
- text-decoration: none;
118
- text-align: center;
119
- cursor: pointer;
120
- margin-right: -1px;
121
- margin-bottom: 5px;
122
- overflow: hidden;
123
- border: 0 !important;
124
- }
125
- .relpost-block-single-image{
126
- border: 0 none ;
127
- margin: 0;
128
- padding: 0;
129
- -moz-background-clip: border;
130
- -moz-background-origin: padding;
131
- -moz-background-inline-policy: continuous;
132
- background-size: cover !important;
133
- max-width: 100%;
134
- }
135
- .relpost-block-single-text{
136
- border: 0 none;
137
- margin: 3px 0 0;
138
- padding: 0;
139
- font-style: normal;
140
- font-variant: normal;
141
- font-weight: normal;
142
- line-height: normal;
143
- font-stretch: normal;
144
- -x-system-font: none;
145
- }
146
- html[dir="rtl"] .relpost-block-single{
147
- float: right;
148
- }
149
- html[dir="rtl"] #related_posts_thumbnails li{
150
- float: right;
 
 
 
 
 
 
151
  }
152
 
153
  .relpost-align-left {
154
- float: left;
155
  }
156
 
157
- .relpost-align-right{
158
- float: right;
159
  }
160
 
161
  .relpost-align-center {
162
- float: none;
163
- text-align: center;
164
-
165
  }
166
- .relpost-align-center .relpost-block-single{
167
- display: inline-block;
168
- float: none;
 
169
  }
170
- .relpost-thumb-wrapper:after{
171
- content:"";
172
- display:block;
173
- clear:both;
 
174
  }
 
175
  .rpth_post_date {
176
- display: block;
177
- padding-top: 10px;
178
- font-size: 11px;
179
  }
1
  .related-posts-nav {
2
+ border: 0pt none;
3
+ margin: 0pt;
4
+ padding: 0pt;
5
  }
6
+
7
  .related-posts-nav:after {
8
+ content: '';
9
+ display: block;
10
+ clear: both;
11
  }
12
+
13
  .related-posts-nav>li {
14
+ list-style: none;
15
+ padding: 0;
16
+ margin: 0;
17
+ float: left;
18
  }
19
+
20
  .related-posts-nav>li:after {
21
+ content: '';
22
+ display: block;
23
+ clear: both;
24
  }
25
+
26
  .related-posts-nav>li:before {
27
+ display: none;
28
  }
29
+
30
  .related-posts-nav>li>a {
31
+ border-bottom: medium none;
32
+ margin: 0pt;
33
+ padding: 6px;
34
+ display: block;
35
+ float: left;
36
+ text-decoration: none;
37
+ text-align: center;
38
+ cursor: pointer;
39
+ border-right: #ddd;
40
+ background-color: #fff;
41
  }
42
+
43
  .related-posts-nav>li>a:hover {
44
+ background-color: #eeeeef;
45
  }
46
+
47
  .related-posts-nav>li>a>.related-post-list-item-inner-container {
48
+ border: 0pt none;
49
+ margin: 0pt;
50
+ padding: 0pt;
51
+ width: 150px;
52
+ height: 225px;
53
  }
54
+
55
  .related-posts-nav>li>a>.related-post-list-item-inner-container>.related-post-list-item-img-container {
56
+ border: 0pt none;
57
+ margin: 0pt;
58
+ padding: 0pt;
59
+ width: 150px;
60
+ height: 150px;
61
+ background-size: cover;
62
+ background-repeat: no-repeat;
63
+ background-attachment: scroll;
64
+ background-position: 0 0;
65
  }
66
+
67
  .related-posts-nav>li>a>.related-post-list-item-inner-container>.related-post-list-item-text-container {
68
+ border: 0pt none;
69
+ margin: 3px 0pt 0pt;
70
+ padding: 0pt;
71
+ font-style: normal;
72
+ font-variant: normal;
73
+ font-weight: normal;
74
+ font-size: 12px;
75
+ line-height: normal;
76
+ font-stretch: normal;
77
+ color: #333333;
78
  }
79
+
80
  .related-post-list-item-link {
81
+ box-shadow: none !important;
82
  }
83
+
84
+
85
  /* Burhan */
86
+
87
  #related_posts_thumbnails {
88
+ list-style-type: none;
89
+ list-style-position: inside;
90
+ padding: 0;
91
+ margin: 0
92
  }
93
+
94
  #related_posts_thumbnails li {
95
+ float: left;
96
+ padding: 0;
97
+ margin: 0;
98
+ padding: 5px;
99
+ display: block;
100
+ max-width: 100%;
101
  }
102
+
103
  .relpost_content {
104
+ display: block;
105
+ overflow: hidden;
106
+ font-style: normal;
107
+ font-variant: normal;
108
+ font-weight: normal;
109
+ line-height: normal;
110
+ font-stretch: normal;
111
+ -x-system-font: none;
112
+ text-decoration: none;
113
+ max-width: 100%;
114
  }
115
+
116
  .relpost-post-image {
117
+ padding: 0;
118
+ margin: 0;
119
+ border: 0 none;
120
+ max-width: 100%;
121
+ }
122
+
123
+ .relpost-block-container {
124
+ border: 0 none;
125
+ margin: 0;
126
+ padding: 0;
127
+ }
128
+
129
+ .relpost-block-single {
130
+ border-bottom: medium none;
131
+ margin: 0;
132
+ padding: 6px;
133
+ display: block;
134
+ float: left;
135
+ text-decoration: none;
136
+ text-align: center;
137
+ cursor: pointer;
138
+ margin-right: -1px;
139
+ margin-bottom: 5px;
140
+ overflow: hidden;
141
+ border: 0 !important;
142
+ }
143
+
144
+ .relpost-block-single-image {
145
+ border: 0 none;
146
+ margin: 0;
147
+ padding: 0;
148
+ -moz-background-clip: border;
149
+ -moz-background-origin: padding;
150
+ -moz-background-inline-policy: continuous;
151
+ background-size: cover !important;
152
+ max-width: 100%;
153
+ }
154
+
155
+ .relpost-block-single-text {
156
+ border: 0 none;
157
+ margin: 3px 0 0;
158
+ padding: 0;
159
+ font-style: normal;
160
+ font-variant: normal;
161
+ font-weight: normal;
162
+ line-height: normal;
163
+ font-stretch: normal;
164
+ -x-system-font: none;
165
+ }
166
+
167
+ html[dir="rtl"] .relpost-block-single {
168
+ float: right;
169
+ }
170
+
171
+ html[dir="rtl"] #related_posts_thumbnails li {
172
+ float: right;
173
  }
174
 
175
  .relpost-align-left {
176
+ float: left;
177
  }
178
 
179
+ .relpost-align-right {
180
+ float: right;
181
  }
182
 
183
  .relpost-align-center {
184
+ float: none;
185
+ text-align: center;
 
186
  }
187
+
188
+ .relpost-align-center .relpost-block-single {
189
+ display: inline-block;
190
+ float: none;
191
  }
192
+
193
+ .relpost-thumb-wrapper:after {
194
+ content: "";
195
+ display: block;
196
+ clear: both;
197
  }
198
+
199
  .rpth_post_date {
200
+ display: block;
201
+ padding-top: 10px;
202
+ font-size: 11px;
203
  }
assets/js/admin.js CHANGED
@@ -2,211 +2,206 @@
2
  (function($, window, document) {
3
 
4
 
5
- // Listen for the jQuery ready event on the document
6
- $(function() {
7
 
8
- // The DOM is ready!
9
 
10
- // colorpicker
11
- $('[name="relpoststh_background"], [name="relpoststh_hoverbackground"], [name="relpoststh_bordercolor"], [name="relpoststh_fontcolor"]').wpColorPicker();
12
 
13
- // datepicker
14
- $('.rpt_post_include').datepicker( {
15
- dateFormat: 'yy-mm-dd'
16
- } );
17
 
18
- // Clear datepicker value
19
- $('.rpt_clear_date').on('click', function(event) {
20
- event.preventDefault();
21
- $('.rpt_post_include').datepicker('setDate', null);
22
- });
23
 
24
 
25
- $('[name="relpoststh_number"],[name="relpoststh_customwidth"],[name="relpoststh_customheight"],[name="relpoststh_fontsize"],[name="relpoststh_textlength"],[name="relpoststh_excerptlength"],[name="relpoststh_textblockheight"]').keypress(function (e) {
26
- //if the letter is not digit then display error and don't type anything
27
- if (e.which !== 8 && e.which !== 0 && (e.which < 48 || e.which > 57)) {
28
- //display error message
29
- $(this).nextAll('.rpt-no-validate-error').show().delay(2000).fadeOut("400");
30
- return false;
31
- }
32
- });
33
-
34
 
35
- // $('#wpbr_rpt_relation_options').on('click', function(){
36
- //
37
- // $('.nav-tab').removeClass('nav-tab-active');
38
- // $(this).addClass('nav-tab-active');
39
- //
40
- // $('#content_general_options').hide();
41
- // $('#content_style_options').hide();
42
- // $('#content_thumbnail_options').hide();
43
- // $('#content_relation_options').show();
44
- //
45
- // });
46
- //
47
- // $('#wpbr_rpt_general_options').on('click', function(){
48
- //
49
- // $('.nav-tab').removeClass('nav-tab-active');
50
- // $(this).addClass('nav-tab-active');
51
- //
52
- // $('#content_general_options').show();
53
- // $('#content_style_options').hide();
54
- // $('#content_thumbnail_options').hide();
55
- // $('#content_relation_options').hide();
56
- //
57
- // });
58
- //
59
- //
60
- // $('#wpbr_rpt_style_options').on('click', function(){
61
- //
62
- // $('.nav-tab').removeClass('nav-tab-active');
63
- // $(this).addClass('nav-tab-active');
64
- //
65
- // $('#content_general_options').hide();
66
- // $('#content_style_options').show();
67
- // $('#content_thumbnail_options').hide();
68
- // $('#content_relation_options').hide();
69
- //
70
- // });
71
- //
72
- //
73
- // $('#wpbr_rpt_thumbnails_source').on('click', function(){
74
- //
75
- // $('.nav-tab').removeClass('nav-tab-active');
76
- // $(this).addClass('nav-tab-active');
77
- //
78
- // $('#content_general_options').hide();
79
- // $('#content_style_options').hide();
80
- // $('#content_thumbnail_options').show();
81
- // $('#content_relation_options').hide();
82
- //
83
- // });
84
 
85
- // Settings Tabs
86
- $(".select_all").click(function(){
87
- if (this.checked) {
88
- $(this).parent().find("div.select_specific").hide();
89
- }
90
- else {
91
- $(this).parent().find("div.select_specific").show();
92
- }
93
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
- // TODO Following is to be done with css.
96
- if ($('#relpoststh_thsource').val() == 'custom-field') {
97
- $('#relpoststh-post-thumbnails').hide();
98
- $('#relpoststh-custom-field').show();
99
- } else if($('#relpoststh_thsource').val() == 'post-thumbnails'){
100
- $('#relpoststh-post-thumbnails').show();
101
- $('#relpoststh-custom-field').hide();
102
- }
103
 
104
- $('#relpoststh_thsource').change(function(){
105
- if (this.value == 'post-thumbnails') {
106
- $('#relpoststh-post-thumbnails').show();
107
- $('#relpoststh-custom-field').hide();
108
- }
109
- else {
110
- $('#relpoststh-post-thumbnails').hide();
111
- $('#relpoststh-custom-field').show();
112
- }
113
- });
114
- $('#relpoststh_output_style').change(function(){
115
- if (this.value == 'list') {
116
- $('#relpoststh_cleanhtml').show();
117
- }
118
- else {
119
- $('#relpoststh_cleanhtml').hide();
120
  }
121
- });
122
- $("input[name='relpoststh_relation']").change(function(){
123
- if ($("input[name='relpoststh_relation']:checked").val() == 'custom') {
124
- $('#custom_taxonomies').show();
125
- }
126
- else {
127
- $('#custom_taxonomies').hide();
128
- }
129
- });
130
 
131
- // Ajax for subsriber
132
- $('#rpt_subscribe_btn').on('click', function(event) {
133
- event.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
- var subscriber_mail = $('#rpt_subscribe_mail').val();
136
- var name = $('#rpt_subscribe_name').val();
137
- if (!subscriber_mail) {
138
- $('.rpt_subscribe_warning').html('Please Enter Email');
139
- return;
140
- }
141
 
142
- $.ajax({
143
- url: 'https://wpbrigade.com/wp-json/wpbrigade/v1/subsribe-to-mailchimp',
144
- type: 'POST',
145
- data: {
146
- subscriber_mail : subscriber_mail,
147
- name : name,
148
- plugin_name : 'rpt'
149
- },
150
- beforeSend : function() {
151
- $('.rpt_subscribe_loader').show();
152
- $('#rpt_subscribe_btn').attr('disabled', 'disabled');
153
- }
154
- })
155
- .done(function(res) {
156
- $('.rpt_return_message').html(res);
157
- $('.rpt_subscribe_loader').hide();
158
- });
159
 
160
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
 
162
 
163
- // Switches option sections
164
- $('#relpoststh-settings .postbox').hide();
165
- var activetab = '';
166
- if (typeof(localStorage) != 'undefined' ) {
167
- activetab = localStorage.getItem("rpt-activetab");
168
- }
169
 
170
- //if url has section id as hash then set it as active or override the current local storage value
171
- if(window.location.hash){
172
- activetab = window.location.hash;
173
- if (typeof(localStorage) != 'undefined' ) {
174
- localStorage.setItem("rpt-activetab", activetab);
175
  }
176
- }
177
 
178
- if (activetab != '' && $(activetab).length ) {
179
- $(activetab).fadeIn();
180
- } else {
181
- $('#relpoststh-settings .postbox:first').fadeIn();
182
- }
183
- $('#relpoststh-settings .postbox .collapsed').each(function(){
184
- $(this).find('input:checked').parent().parent().parent().nextAll().each(
185
- function(){
186
- if ($(this).hasClass('last')) {
187
- $(this).removeClass('hidden');
188
- return false;
189
  }
190
- $(this).filter('.hidden').removeClass('hidden');
191
- });
192
- });
193
 
194
- if (activetab != '' && $(activetab + '-tab').length ) {
195
- $(activetab + '-tab').addClass('nav-tab-active');
 
 
196
  }
197
- else {
198
- $('.nav-tab-wrapper a:first').addClass('nav-tab-active');
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
  $('.nav-tab-wrapper a').click(function(evt) {
201
- $('.nav-tab-wrapper a').removeClass('nav-tab-active');
202
- $(this).addClass('nav-tab-active').blur();
203
- var clicked_group = $(this).attr('href');
204
- if (typeof(localStorage) != 'undefined' ) {
205
- localStorage.setItem("rpt-activetab", $(this).attr('href'));
206
- }
207
- $('#relpoststh-settings .postbox').hide();
208
- $(clicked_group).fadeIn();
209
- evt.preventDefault();
210
  });
211
 
212
  /// Gallery image selection script
@@ -230,34 +225,34 @@
230
  // }
231
  // }
232
  // });
233
- $('.relpoststh_set_def_image').on('click', function (event) {
234
- event.preventDefault();
235
- var self = $(this);
236
- var file_frame = wp.media.frames.file_frame = wp.media({
237
- title: self.data('uploader_title'),
238
- button: {
239
- text: self.data('uploader_button_text'),
240
- },
241
- multiple: false
242
- })
243
- .on('select', function () {
244
- attachment = file_frame.state().get('selection').first().toJSON();
245
- $('#relpoststh_default_image_prev').attr('src', attachment.url);
246
- $('#relpoststh_default_image').val(attachment.url);
247
- })
248
- .open();
249
  });
250
 
251
  $(document).on('click', '.relpoststh_set_plug_image', function(e) {
252
- e.preventDefault();
253
- var defValue = $(this).val();
254
- $('#relpoststh_default_image_prev').attr('src',defValue);
255
- $('#relpoststh_default_image').val(defValue);
256
  });
257
 
258
 
259
- }); // End of document ready
260
 
261
- // The rest of the code goes here!
262
 
263
- }(window.jQuery, window, document));
2
  (function($, window, document) {
3
 
4
 
5
+ // Listen for the jQuery ready event on the document
6
+ $(function() {
7
 
8
+ // The DOM is ready!
9
 
10
+ // colorpicker
11
+ $('[name="relpoststh_background"], [name="relpoststh_hoverbackground"], [name="relpoststh_bordercolor"], [name="relpoststh_fontcolor"]').wpColorPicker();
12
 
13
+ // datepicker
14
+ $('.rpt_post_include').datepicker({
15
+ dateFormat: 'yy-mm-dd'
16
+ });
17
 
18
+ // Clear datepicker value
19
+ $('.rpt_clear_date').on('click', function(event) {
20
+ event.preventDefault();
21
+ $('.rpt_post_include').datepicker('setDate', null);
22
+ });
23
 
24
 
25
+ $('[name="relpoststh_number"],[name="relpoststh_customwidth"],[name="relpoststh_customheight"],[name="relpoststh_fontsize"],[name="relpoststh_textlength"],[name="relpoststh_excerptlength"],[name="relpoststh_textblockheight"]').keypress(function(e) {
26
+ //if the letter is not digit then display error and don't type anything
27
+ if (e.which !== 8 && e.which !== 0 && (e.which < 48 || e.which > 57)) {
28
+ //display error message
29
+ $(this).nextAll('.rpt-no-validate-error').show().delay(2000).fadeOut("400");
30
+ return false;
31
+ }
32
+ });
 
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ // $('#wpbr_rpt_relation_options').on('click', function(){
36
+ //
37
+ // $('.nav-tab').removeClass('nav-tab-active');
38
+ // $(this).addClass('nav-tab-active');
39
+ //
40
+ // $('#content_general_options').hide();
41
+ // $('#content_style_options').hide();
42
+ // $('#content_thumbnail_options').hide();
43
+ // $('#content_relation_options').show();
44
+ //
45
+ // });
46
+ //
47
+ // $('#wpbr_rpt_general_options').on('click', function(){
48
+ //
49
+ // $('.nav-tab').removeClass('nav-tab-active');
50
+ // $(this).addClass('nav-tab-active');
51
+ //
52
+ // $('#content_general_options').show();
53
+ // $('#content_style_options').hide();
54
+ // $('#content_thumbnail_options').hide();
55
+ // $('#content_relation_options').hide();
56
+ //
57
+ // });
58
+ //
59
+ //
60
+ // $('#wpbr_rpt_style_options').on('click', function(){
61
+ //
62
+ // $('.nav-tab').removeClass('nav-tab-active');
63
+ // $(this).addClass('nav-tab-active');
64
+ //
65
+ // $('#content_general_options').hide();
66
+ // $('#content_style_options').show();
67
+ // $('#content_thumbnail_options').hide();
68
+ // $('#content_relation_options').hide();
69
+ //
70
+ // });
71
+ //
72
+ //
73
+ // $('#wpbr_rpt_thumbnails_source').on('click', function(){
74
+ //
75
+ // $('.nav-tab').removeClass('nav-tab-active');
76
+ // $(this).addClass('nav-tab-active');
77
+ //
78
+ // $('#content_general_options').hide();
79
+ // $('#content_style_options').hide();
80
+ // $('#content_thumbnail_options').show();
81
+ // $('#content_relation_options').hide();
82
+ //
83
+ // });
84
 
85
+ // Settings Tabs
86
+ $(".select_all").click(function() {
87
+ if (this.checked) {
88
+ $(this).parent().find("div.select_specific").hide();
89
+ } else {
90
+ $(this).parent().find("div.select_specific").show();
91
+ }
92
+ });
93
 
94
+ // TODO Following is to be done with css.
95
+ if ($('#relpoststh_thsource').val() == 'custom-field') {
96
+ $('#relpoststh-post-thumbnails').hide();
97
+ $('#relpoststh-custom-field').show();
98
+ } else if ($('#relpoststh_thsource').val() == 'post-thumbnails') {
99
+ $('#relpoststh-post-thumbnails').show();
100
+ $('#relpoststh-custom-field').hide();
 
 
 
 
 
 
 
 
 
101
  }
 
 
 
 
 
 
 
 
 
102
 
103
+ $('#relpoststh_thsource').change(function() {
104
+ if (this.value == 'post-thumbnails') {
105
+ $('#relpoststh-post-thumbnails').show();
106
+ $('#relpoststh-custom-field').hide();
107
+ } else {
108
+ $('#relpoststh-post-thumbnails').hide();
109
+ $('#relpoststh-custom-field').show();
110
+ }
111
+ });
112
+ $('#relpoststh_output_style').change(function() {
113
+ if (this.value == 'list') {
114
+ $('#relpoststh_cleanhtml').show();
115
+ } else {
116
+ $('#relpoststh_cleanhtml').hide();
117
+ }
118
+ });
119
+ $("input[name='relpoststh_relation']").change(function() {
120
+ if ($("input[name='relpoststh_relation']:checked").val() == 'custom') {
121
+ $('#custom_taxonomies').show();
122
+ } else {
123
+ $('#custom_taxonomies').hide();
124
+ }
125
+ });
126
 
127
+ // Ajax for subsriber
128
+ $('#rpt_subscribe_btn').on('click', function(event) {
129
+ event.preventDefault();
 
 
 
130
 
131
+ var subscriber_mail = $('#rpt_subscribe_mail').val();
132
+ var name = $('#rpt_subscribe_name').val();
133
+ if (!subscriber_mail) {
134
+ $('.rpt_subscribe_warning').html('Please Enter Email');
135
+ return;
136
+ }
 
 
 
 
 
 
 
 
 
 
 
137
 
138
+ $.ajax({
139
+ url: 'https://wpbrigade.com/wp-json/wpbrigade/v1/subsribe-to-mailchimp',
140
+ type: 'POST',
141
+ data: {
142
+ subscriber_mail: subscriber_mail,
143
+ name: name,
144
+ plugin_name: 'rpt'
145
+ },
146
+ beforeSend: function() {
147
+ $('.rpt_subscribe_loader').show();
148
+ $('#rpt_subscribe_btn').attr('disabled', 'disabled');
149
+ }
150
+ })
151
+ .done(function(res) {
152
+ $('.rpt_return_message').html(res);
153
+ $('.rpt_subscribe_loader').hide();
154
+ });
155
 
156
+ });
157
 
 
 
 
 
 
 
158
 
159
+ // Switches option sections
160
+ $('#relpoststh-settings .postbox').hide();
161
+ var activetab = '';
162
+ if (typeof(localStorage) != 'undefined') {
163
+ activetab = localStorage.getItem("rpt-activetab");
164
  }
 
165
 
166
+ //if url has section id as hash then set it as active or override the current local storage value
167
+ if (window.location.hash) {
168
+ activetab = window.location.hash;
169
+ if (typeof(localStorage) != 'undefined') {
170
+ localStorage.setItem("rpt-activetab", activetab);
 
 
 
 
 
 
171
  }
172
+ }
 
 
173
 
174
+ if (activetab != '' && $(activetab).length) {
175
+ $(activetab).fadeIn();
176
+ } else {
177
+ $('#relpoststh-settings .postbox:first').fadeIn();
178
  }
179
+ $('#relpoststh-settings .postbox .collapsed').each(function() {
180
+ $(this).find('input:checked').parent().parent().parent().nextAll().each(
181
+ function() {
182
+ if ($(this).hasClass('last')) {
183
+ $(this).removeClass('hidden');
184
+ return false;
185
+ }
186
+ $(this).filter('.hidden').removeClass('hidden');
187
+ });
188
+ });
189
+
190
+ if (activetab != '' && $(activetab + '-tab').length) {
191
+ $(activetab + '-tab').addClass('nav-tab-active');
192
+ } else {
193
+ $('.nav-tab-wrapper a:first').addClass('nav-tab-active');
194
  }
195
  $('.nav-tab-wrapper a').click(function(evt) {
196
+ $('.nav-tab-wrapper a').removeClass('nav-tab-active');
197
+ $(this).addClass('nav-tab-active').blur();
198
+ var clicked_group = $(this).attr('href');
199
+ if (typeof(localStorage) != 'undefined') {
200
+ localStorage.setItem("rpt-activetab", $(this).attr('href'));
201
+ }
202
+ $('#relpoststh-settings .postbox').hide();
203
+ $(clicked_group).fadeIn();
204
+ evt.preventDefault();
205
  });
206
 
207
  /// Gallery image selection script
225
  // }
226
  // }
227
  // });
228
+ $('.relpoststh_set_def_image').on('click', function(event) {
229
+ event.preventDefault();
230
+ var self = $(this);
231
+ var file_frame = wp.media.frames.file_frame = wp.media({
232
+ title: self.data('uploader_title'),
233
+ button: {
234
+ text: self.data('uploader_button_text'),
235
+ },
236
+ multiple: false
237
+ })
238
+ .on('select', function() {
239
+ attachment = file_frame.state().get('selection').first().toJSON();
240
+ $('#relpoststh_default_image_prev').attr('src', attachment.url);
241
+ $('#relpoststh_default_image').val(attachment.url);
242
+ })
243
+ .open();
244
  });
245
 
246
  $(document).on('click', '.relpoststh_set_plug_image', function(e) {
247
+ e.preventDefault();
248
+ var defValue = $(this).val();
249
+ $('#relpoststh_default_image_prev').attr('src', defValue);
250
+ $('#relpoststh_default_image').val(defValue);
251
  });
252
 
253
 
254
+ }); // End of document ready
255
 
256
+ // The rest of the code goes here!
257
 
258
+ }(window.jQuery, window, document));
inc/rpt-blocks.php CHANGED
@@ -4,14 +4,14 @@
4
  *
5
  */
6
  function enqueue_block_editor_assets() {
7
- $block_path = 'assets/blocks/js/blocks.editor.js';
8
- $style_path = 'assets/blocks/css/blocks.editor.min.css';
9
 
10
  // Enqueue the bundled block JS file
11
- wp_enqueue_script( 'rpt-blocks-js', RELATED_POSTS_THUMBNAILS_URI.$block_path, array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor'), RELATED_POSTS_THUMBNAILS_VERSION );
12
 
13
  // Enqueue optional editor only styles
14
- wp_enqueue_style( 'rpt-blocks-editor-css', RELATED_POSTS_THUMBNAILS_URI.$style_path, array(), RELATED_POSTS_THUMBNAILS_VERSION );
15
  }
16
 
17
  add_action('enqueue_block_editor_assets', 'enqueue_block_editor_assets');
@@ -49,31 +49,33 @@ add_action('plugins_loaded', 'register_rpt_dynamic_block');
49
  */
50
  function register_rpt_dynamic_block() {
51
  // Only load if Gutenberg is available.
52
- if (!function_exists('register_block_type')) {
53
- return;
54
- }
55
 
56
  // Hook server side rendering into render callback
57
- register_block_type('related-post-thumbnails/rpt-block', array(
58
- 'render_callback' => 'render_rpt_dynamic_block'
59
- ));
60
  }
61
 
62
  /**
63
- * Server rendering
 
 
64
  */
65
- function render_rpt_dynamic_block($atts) {
66
- $posts_number = 3;
67
- $posts_sort = 'random';
68
- $main_title = '';
69
 
70
- if ( ! empty( $atts ) ) {
71
- $posts_number = isset($atts['postNumber']) ? $atts['postNumber'] : $posts_number;
72
- $posts_sort = isset($atts['postSort']) ? $atts['postSort'] : $posts_sort;
73
- $main_title = isset($atts['mainTitle']) ? str_replace( ' ', '_', $atts['mainTitle'] ) : $main_title;
74
- }
75
 
76
- return do_shortcode( '[related-posts-thumbnails posts_number=' . $posts_number . ' posts_sort=' . $posts_sort . ' main_title=' . $main_title . ']' );
77
  }
78
 
79
  ?>
4
  *
5
  */
6
  function enqueue_block_editor_assets() {
7
+ $block_path = 'assets/blocks/js/blocks.editor.js';
8
+ $style_path = 'assets/blocks/css/blocks.editor.min.css';
9
 
10
  // Enqueue the bundled block JS file
11
+ wp_enqueue_script( 'rpt-blocks-js', RELATED_POSTS_THUMBNAILS_URI.$block_path, array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor'), RELATED_POSTS_THUMBNAILS_VERSION );
12
 
13
  // Enqueue optional editor only styles
14
+ wp_enqueue_style( 'rpt-blocks-editor-css', RELATED_POSTS_THUMBNAILS_URI.$style_path, array(), RELATED_POSTS_THUMBNAILS_VERSION );
15
  }
16
 
17
  add_action('enqueue_block_editor_assets', 'enqueue_block_editor_assets');
49
  */
50
  function register_rpt_dynamic_block() {
51
  // Only load if Gutenberg is available.
52
+ if (!function_exists('register_block_type')) {
53
+ return;
54
+ }
55
 
56
  // Hook server side rendering into render callback
57
+ register_block_type('related-post-thumbnails/rpt-block', array(
58
+ 'render_callback' => 'render_rpt_dynamic_block'
59
+ ));
60
  }
61
 
62
  /**
63
+ * Server rendering render_callback
64
+ * @param $atts block attributes.
65
+ *
66
  */
67
+ function render_rpt_dynamic_block( $atts ) {
68
+ $posts_number = 3;
69
+ $posts_sort = 'random';
70
+ $main_title = '';
71
 
72
+ if ( ! empty( $atts ) ) {
73
+ $posts_number = isset($atts['postNumber']) ? $atts['postNumber'] : $posts_number;
74
+ $posts_sort = isset($atts['postSort']) ? $atts['postSort'] : $posts_sort;
75
+ $main_title = isset($atts['mainTitle']) ? str_replace( ' ', '_', $atts['mainTitle'] ) : $main_title;
76
+ }
77
 
78
+ return do_shortcode( '[related-posts-thumbnails posts_number=' . $posts_number . ' posts_sort=' . $posts_sort . ' main_title=' . $main_title . ']' );
79
  }
80
 
81
  ?>
inc/rpt-settings.php CHANGED
@@ -16,13 +16,13 @@ if ( isset( $_POST[ 'action' ] ) && ( $_POST[ 'action' ] == 'update' ) ) {
16
  update_option( 'relpoststh_single_only', sanitize_text_field( wp_unslash( $_POST[ 'relpoststh_single_only' ] ) ) );
17
  } else {
18
  update_option( 'relpoststh_single_only', '0' );
19
- }
20
 
21
- if ( isset( $_POST[ 'relpoststh_mobile_view' ] ) ) {
22
- update_option( 'relpoststh_mobile_view', sanitize_text_field( wp_unslash( $_POST[ 'relpoststh_mobile_view' ] ) ) );
23
- } else {
24
- update_option( 'relpoststh_mobile_view', '0' );
25
- }
26
 
27
  if ( isset( $_POST[ 'relpoststh_post_types' ] ) ) {
28
  update_option( 'relpoststh_post_types', array_map( 'sanitize_text_field', wp_unslash( $_POST[ 'relpoststh_post_types' ] ) ) );
@@ -193,16 +193,31 @@ if ( isset( $_POST[ 'action' ] ) && ( $_POST[ 'action' ] == 'update' ) ) {
193
  }
194
  }
195
  $available_sizes = array(
196
- 'thumbnail' => 'thumbnail',
197
- 'medium' => 'medium'
198
  );
 
 
 
 
 
 
 
 
 
 
 
 
199
  if ( current_theme_supports( 'post-thumbnails' ) ) {
 
200
  global $_wp_additional_image_sizes;
201
- if ( is_array( $_wp_additional_image_sizes ) ) {
 
202
  $available_sizes = array_merge( $available_sizes, $_wp_additional_image_sizes );
203
  }
204
  }
205
 
 
206
  $relpoststh_single_only = get_option( 'relpoststh_single_only', $this->single_only );
207
  $relpoststh_auto = get_option( 'relpoststh_auto', $this->auto );
208
  $relpoststh_cleanhtml = get_option( 'relpoststh_cleanhtml', 0 );
@@ -212,7 +227,7 @@ $relpoststh_devmode = get_option( 'relpoststh_devmode', $this->devmod
212
  $relpoststh_categoriesall = get_option( 'relpoststh_categoriesall', $this->categories_all );
213
  $relpoststh_categories = get_option( 'relpoststh_categories' );
214
  // $relpoststh_show_date = get_option( 'relpoststh_show_date', '0' );
215
- $relpoststh_mobile_view = get_option( 'relpoststh_mobile_view' );
216
  $relpoststh_show_categories = get_option( 'relpoststh_show_categories', get_option( 'relpoststh_categories' ) );
217
  $relpoststh_show_categoriesall = get_option( 'relpoststh_show_categoriesall', $relpoststh_categoriesall );
218
  $onlywiththumbs = get_option( 'relpoststh_onlywiththumbs', false );
@@ -220,6 +235,7 @@ $relpoststh_startdate = explode( '-', get_option( 'relpoststh_startdate
220
  $relpoststh_output_style = get_option( 'relpoststh_output_style', $this->output_style );
221
  $thsources = array( 'post-thumbnails' => __( 'Post thumbnails', 'related_posts_thumbnails' ),'custom-field' => __( 'Custom field', 'related_posts_thumbnails' ) );
222
  $categories = get_categories();
 
223
  if ( $this->wp_version >= 3 ) {
224
  $post_types = get_post_types( array( 'public' => 1 ) );
225
  } else {
@@ -233,11 +249,11 @@ $output_styles = array(
233
  'list' => __( 'List', 'related-posts-thumbnails' ) );
234
 
235
  $relation_options = array(
236
- 'categories' => __( 'Categories', 'related-posts-thumbnails' ),
237
- 'tags' => __( 'Tags', 'related-posts-thumbnails' ),
238
- 'both' => __( 'Categories and Tags', 'related-posts-thumbnails' ),
239
- 'no' => __( 'Random', 'related-posts-thumbnails' ),
240
- 'custom' => __( 'Custom', 'related-posts-thumbnails' )
241
  );
242
 
243
  if ( $this->wp_version >= 3 ) {
@@ -273,41 +289,41 @@ if ( $this->wp_version >= 3 ) {
273
  <div class="wpbr-wrap"><div class="wpbr-tabsWrapper">
274
  <div class="wpbr-button-container top">
275
  <div class="setting-notification">
276
- <?php echo __( 'Settings have changed, you should save them!', 'related-posts-thumbnails' ); ?>
277
  </div>
278
  <input type="submit" name="Submit" class="wpb-rpt-settings-submit button button-primary button-big"
279
- value="<?php esc_html_e( 'Save Settings', 'related-posts-thumbnails' ); ?>" id="wpb_rpt_save_setting_top">
280
  </div>
281
 
282
  <div id="relpoststh-settings" class="">
283
  <ul class="nav-tab-wrapper">
284
- <li>
285
- <a href="#content_general_options" class="nav-tab" id="content_general_options-tab">
286
- <?php _e( 'General Display Options', 'related-posts-thumbnails' ); ?>
287
- </a>
288
- </li>
289
- <li>
290
- <a href="#content_thumbnail_options" class="nav-tab" id="content_thumbnail_options-tab">
291
- <?php _e( 'Thumbnails', 'related-posts-thumbnails' ); ?>
292
- </a>
293
- </li>
294
- <li>
295
- <a href="#content_style_options" class="nav-tab" id="content_style_options-tab">
296
- <?php _e( 'Style Options', 'related-posts-thumbnails' ); ?>
297
- </a>
298
- </li>
299
- <li>
300
- <a href="#content_relation_options" class="nav-tab" id="content_relation_options-tab">
301
- <?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>
302
- </a>
303
- </li>
304
  </ul>
305
 
306
  <div class="metabox-holder rpth-setting-options">
307
  <div class="postbox" style="padding: 20px" id="content_general_options">
308
  <h2>
309
- <?php _e( 'General Display Options', 'related-posts-thumbnails' ); ?>
310
- </h2>
311
 
312
  <table class="form-table">
313
  <tr valign="top">
@@ -318,7 +334,7 @@ if ( $this->wp_version >= 3 ) {
318
  <input type="checkbox" name="relpoststh_auto" id="relpoststh_auto" value="1"
319
  <?php
320
  if ( $relpoststh_auto ) {
321
- echo 'checked="checked"';
322
  }
323
  ?>
324
  />
@@ -338,132 +354,124 @@ if ( $this->wp_version >= 3 ) {
338
  <input type="checkbox" name="relpoststh_devmode" id="relpoststh_devmode" value="1"
339
  <?php
340
  if ( $relpoststh_devmode ) {
341
- echo 'checked="checked"';
342
  }
343
  ?>
344
  />
345
  <label for="relpoststh_devmode">
346
- <p class="description rpth-discription">
347
- <?php _e( 'This will add debugging information in HTML source', 'related-posts-thumbnails' ); ?>
348
- </p>
349
  </label>
350
  <br />
351
  </td>
352
  </tr>
353
  <tr valign="top">
354
  <th scope="row">
355
- <?php _e( 'Display related posts', 'related-posts-thumbnails' ); ?>:
356
- </th>
357
  <td>
358
- <input type="checkbox" name="relpoststh_single_only" id="relpoststh_single_only" value="1"
359
- <?php
360
- if ( $relpoststh_single_only ) {
361
- echo 'checked="checked"';
362
- }
363
- ?>
364
- />
365
- <label for="relpoststh_single_only">
366
- <?php _e( 'On single posts only', 'related-posts-thumbnails' ); ?>
367
- </label>
368
- <br />
369
  </td>
370
- </tr>
371
  <tr valign="top">
372
  <th scope="row">
373
- <?php _e( 'Post types', 'related-posts-thumbnails' ); ?>:
374
- </th>
375
  <td>
376
  <?php
377
- if ( is_array( $post_types ) && count( $post_types ) ):
378
- foreach ( $post_types as $post_type ):
379
- ?>
380
- <input type="checkbox" name="relpoststh_post_types[]"
381
- id="pt_<?php echo $post_type; ?>"
382
- value="<?php echo $post_type; ?>"
383
- <?php
384
- if ( in_array( $post_type, $relpoststh_post_types ) ) {
385
- echo 'checked="checked"';
386
- }
387
- ?>
388
- />
389
- <label for="pt_<?php echo $post_type; ?>">
390
- <?php echo $post_type; ?>
391
- </label>
392
-
393
- <?php
394
- endforeach;
395
- endif;
396
- ?>
397
  </td>
398
  </tr>
399
  <tr valign="top">
400
  <th scope="row">
401
- <?php _e( 'Display related posts on categories', 'related-posts-thumbnails' ); ?>:
402
- </th>
403
  <td>
404
- <?php
405
- $this->display_categories_list( $relpoststh_categoriesall, $categories, $relpoststh_categories, 'relpoststh_categoriesall', 'relpoststh_categories' );
406
- ?>
407
  </td>
408
  </tr>
409
  <tr valign="top">
410
  <th scope="row">
411
- <?php _e( 'Categories will appear in related posts', 'related-posts-thumbnails' ); ?>:
412
- </th>
413
  <td>
414
- <?php
415
- $this->display_categories_list( $relpoststh_show_categoriesall, $categories, $relpoststh_show_categories, 'relpoststh_show_categoriesall', 'relpoststh_show_categories' );
416
- ?>
417
  </td>
418
  </tr>
419
- <tr valign="top">
420
- <th scope="row">
421
- <?php _e( 'Mobile view', 'related-posts-thumbnails' ); ?>:
422
- </th>
423
- <td>
424
- <input type="checkbox" name="relpoststh_mobile_view" id="relpoststh_mobile_view" value="1"
425
- <?php
426
- if ( $relpoststh_mobile_view ) {
427
- echo 'checked="checked"';
428
- }
429
- ?>
430
- />
431
- <label for="relpoststh_mobile_view">
432
- <?php _e( 'Hide on mobile devices', 'related-posts-thumbnails' ); ?>
433
- </label>
434
- <br />
435
- </td>
436
  </tr>
437
-
438
  <!-- <tr valign="top">
439
  <th scope="row">
440
- <?php // _e( 'Show date under posts', 'related-posts-thumbnails' ); ?>:
441
- </th>
442
  <td>
443
  <input type="checkbox" name="relpoststh_show_date" id="relpoststh_show_date" value="1"
444
  <?php
445
- // if ( $relpoststh_show_date == '1' ) {
446
- // echo 'checked="checked"';
447
- // }
448
- ?>
449
- />
450
  </td>
451
  </tr> -->
452
  <tr>
453
  <th scope="row">
454
- <?php _e( 'Include posts after', 'related-posts-thumbnails' ); ?>:
455
- </th>
456
  <td>
457
- <input type="text" class="rpt_post_include" name="rpt_post_include"
458
- value="<?php echo get_option( 'relpoststh_startdate' ); ?>"
459
- >
460
  <button type="button" class="button rpt_clear_date">Clear</button>
461
  <label for="relpoststh_excerptlength">
462
  <p class="description">
463
- <?php _e( 'Leave empty for all posts dates', 'related-posts-thumbnails' ); ?>
464
  </p>
465
  </label>
466
- <br />
467
  </td>
468
  </tr>
469
  <tr>
@@ -493,23 +501,21 @@ if ( $this->wp_version >= 3 ) {
493
  </tr>
494
  <tr>
495
  <th scope="row">
496
- <?php _e( 'Top text', 'related-posts-thumbnails' ); ?>:
497
- </th>
498
  <td>
499
- <input type="text" name="relpoststh_top_text"
500
- value="<?php echo stripslashes( htmlspecialchars( get_option( 'relpoststh_top_text', $this->top_text ) ) ); ?>" size="50"/>
501
  </td>
502
  </tr>
503
  <tr>
504
  <th scope="row">
505
- <?php _e( 'Number of posts to display', 'related-posts-thumbnails' ); ?>:
506
- </th>
507
  <td>
508
- <input type="number" min="1" name="relpoststh_number"
509
- value="<?php echo get_option( 'relpoststh_number', $this->number ); ?>" size="2"/>
510
  <span class='rpt-no-validate-error' style="display:none;">
511
- <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
512
- </span>
513
  </td>
514
  </tr>
515
  <!-- <table class="form-table"> -->
@@ -545,7 +551,6 @@ if ( $this->wp_version >= 3 ) {
545
  </table>
546
  </div>
547
 
548
-
549
  <div class="postbox" style="padding: 20px; display:none;" id="content_thumbnail_options">
550
  <h2>
551
  <?php _e( 'Thumbnails', 'related-posts-thumbnails' ); ?>
@@ -577,485 +582,419 @@ if ( $this->wp_version >= 3 ) {
577
  <table class="form-table">
578
  <tr valign="top">
579
  <th scope="row">
580
- <?php _e( 'Related posts thumbnail size', 'related-posts-thumbnails' ); ?>:
581
- </th>
582
  <td>
583
  <select name="relpoststh_poststhname">
584
- <?php foreach ( $available_sizes as $size_name => $size ): ?>
585
- <option
586
- <?php
587
- if ( $size_name == get_option( 'relpoststh_poststhname', $this->poststhname ) ) {
588
- echo 'selected';
589
- }
590
- ?> >
591
- <?php echo $size_name; ?>
592
- </option>
593
- <?php endforeach; ?>
594
  </select>
595
- <?php if ( !current_theme_supports( 'post-thumbnails' ) ): ?>
596
- (<?php
597
- _e( 'Your theme has to support post-thumbnails to have more choices', 'related-posts-thumbnails' );
598
- ?>)
599
  <?php endif; ?>
600
  </td>
601
  </tr>
602
-
603
- <?php
604
- if ( current_theme_supports( 'post-thumbnails' ) ):
605
- ?>
606
- <tr>
607
- <th scope="row">
608
- <?php _e( 'Show posts with featured image', 'related-posts-thumbnails' ); ?>:
609
- </th>
610
- <td>
611
- <input type="checkbox" name="onlywiththumbs" id="onlywiththumbs" value="1"
612
- <?php
613
- if ( $onlywiththumbs ) {
614
- echo 'checked="checked"';
615
- }
616
- ?>
617
- />
618
- <label for="onlywiththumbs">
619
- <p class="description rpth-discription">
620
- <?php _e( 'Only those posts will be shown that has featured image', 'related-posts-thumbnails' ); ?>
621
- </p>
622
- </label>
623
- <br />
624
- </td>
625
- </tr>
626
- <?php endif; ?>
627
- </table>
628
- </div>
629
-
630
- <div id="relpoststh-custom-field">
631
- <table class="form-table">
632
- <tr valign="top">
633
- <th scope="row">
634
- <?php _e( 'Custom field name', 'related-posts-thumbnails' ); ?>:
635
- </th>
636
- <td>
637
- <input type="text" name="relpoststh_customfield"
638
- value="<?php echo get_option( 'relpoststh_customfield', $this->custom_field ); ?>" size="50"/>
639
- </td>
640
- </tr>
641
- <tr valign="top">
642
- <th scope="row">
643
- <?php _e( 'Size', 'related-posts-thumbnails' ); ?>:
644
- </th>
645
- <td>
646
- <label for="relpoststh_customwidth" id="relpoststh_customwidth">
647
- <?php _e( 'Width', 'related-posts-thumbnails' ); ?>:
648
- </label>
649
- <input type="number" min="1" name="relpoststh_customwidth"
650
- value="<?php echo get_option( 'relpoststh_customwidth', $this->custom_width ); ?>" size="3"/>
651
- <p class="description rpth-discription"><?php _e( ' px', 'related-posts-thumbnails' ); ?></p>
652
- <br>
653
- <label for="relpoststh_customheight">
654
- <?php _e( 'Height', 'related-posts-thumbnails' ); ?>:
655
- </label>
656
- <input type="number" min="1" name="relpoststh_customheight"
657
- value="<?php echo get_option( 'relpoststh_customheight', $this->custom_height );?>" size="3"/>
658
- <p class="description rpth-discription"><?php _e( ' px', 'related-posts-thumbnails' ); ?></p>
659
- <br>
660
- <span class='rpt-no-validate-error' style="display:none;">
661
- <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
662
- </span>
663
- </td>
664
- </tr>
665
- <tr valign="top">
666
- <th scope="row">
667
- <?php _e( 'Theme resize url', 'related-posts-thumbnails' ); ?>:
668
- </th>
669
- <td>
670
- <input type="text" name="relpoststh_theme_resize_url"
671
- value="<?php echo get_option( 'relpoststh_theme_resize_url', '' ); ?>" size="50"/>
672
- <p class='description rpth-discription'>
673
- <?php _e( 'If your theme resizes images, enter URL to its resizing PHP file', 'related-posts-thumbnails' ); ?>
674
- </p>
675
- </td>
676
- </tr>
677
- </table>
678
- </div>
679
-
680
- </div>
681
-
682
-
683
- <!-- DISPLAY SETTINGS -->
684
- <div class="postbox" style="padding: 20px; display:none;" id="content_style_options">
685
- <h2>
686
- <?php
687
- _e( 'Style Options', 'related-posts-thumbnails' );
688
- ?>
689
- </h2>
690
- <table class="form-table">
691
-
692
- <!-- calling layouts from pro -->
693
- <?php
694
- // do_action('rptp_style_layouts');
695
- ?>
696
-
697
- <tr>
698
- <th scope="row"><?php
699
- _e( 'Output style', 'related-posts-thumbnails' );
700
- ?>:</th>
701
- <td>
702
- <select name="relpoststh_output_style" id="relpoststh_output_style">
703
- <?php
704
- foreach ( $output_styles as $name => $title ):
705
- ?>
706
- <option value="<?php
707
- echo $name;
708
- ?>"
709
- <?php
710
- if ( $relpoststh_output_style == $name )
711
- {
712
- echo 'selected';
713
- }
714
- ?>
715
- ><?php
716
- echo $title;
717
- ?></option>
718
- <?php
719
- endforeach;
720
- ?>
721
- </select>
722
- <span id="relpoststh_cleanhtml" style="display:
723
- <?php
724
- if ( $relpoststh_output_style == 'list' )
725
- {
726
  echo 'inline';
727
- }
728
- else
729
- {
730
  echo 'none';
731
- }
732
- ?>
733
- ;"><?php
734
- _e( 'Turn off plugin styles', 'related-posts-thumbnails' );
735
- ?> <input type="checkbox" name="relpoststh_cleanhtml"
736
- <?php
737
- if ( $relpoststh_cleanhtml )
738
- {
739
- echo 'checked="checked"';
740
- }
741
- ?>
742
- /></span>
743
- </td>
744
- </tr>
745
- <tr valign="top">
746
- <th scope="row"><?php
747
- _e( 'Background color', 'related-posts-thumbnails' );
748
- ?>:</th>
749
- <td>
750
- <input type="text" name="relpoststh_background" value="<?php
751
- echo get_option( 'relpoststh_background', $this->background );
752
- ?>" data-default-color="<?php
753
- echo $this->background;
754
- ?>"/>
755
- </td>
756
- </tr>
757
- <tr valign="top">
758
- <th scope="row"><?php
759
- _e( 'Background color on mouse over', 'related-posts-thumbnails' );
760
- ?>:</th>
761
- <td>
762
- <input type="text" name="relpoststh_hoverbackground" value="<?php
763
- echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground );
764
- ?>" data-default-color="<?php
765
- echo $this->hoverbackground;
766
- ?>" />
767
- </td>
768
- </tr>
769
- <tr valign="top">
770
- <th scope="row"><?php
771
- _e( 'Border color', 'related-posts-thumbnails' );
772
- ?>:</th>
773
- <td>
774
- <input type="text" name="relpoststh_bordercolor" value="<?php
775
- echo get_option( 'relpoststh_bordercolor', $this->border_color );
776
- ?>" data-default-color="<?php
777
- echo $this->border_color;
778
- ?>"/>
779
- </td>
780
- </tr>
781
- <tr valign="top">
782
- <th scope="row"><?php
783
- _e( 'Font color', 'related-posts-thumbnails' );
784
- ?>:</th>
785
- <td>
786
- <input type="text" name="relpoststh_fontcolor" value="<?php
787
- echo get_option( 'relpoststh_fontcolor', $this->font_color );
788
- ?>" data-default-color="<?php
789
- echo $this->font_color;
790
- ?>"/>
791
- </td>
792
- </tr>
793
- <tr valign="top">
794
- <th scope="row"><?php
795
- _e( 'Font family', 'related-posts-thumbnails' );
796
- ?>:</th>
797
- <td>
798
- <input type="text" name="relpoststh_fontfamily" value="<?php
799
- echo stripslashes( htmlspecialchars( get_option( 'relpoststh_fontfamily', $this->font_family ) ) );
800
- ?>" size="50"/>
801
- </td>
802
- </tr>
803
- <tr valign="top">
804
- <th scope="row"><?php
805
- _e( 'Font size', 'related-posts-thumbnails' );
806
- ?>:</th>
807
- <td>
808
- <input type="number" min="1" name="relpoststh_fontsize" value="<?php
809
- echo get_option( 'relpoststh_fontsize', $this->font_size );
810
- ?>" size="7"/>
811
- <label for="relpoststh_fontsize"><p class="description rpth-discription"><?php
812
- _e( 'px', 'related-posts-thumbnails' );
813
- ?></p></label>
814
- <span class='rpt-no-validate-error' style="display:none;"><?php
815
- _e( 'Only Digits are allowed', 'related-posts-thumbnails' );
816
- ?></span>
817
- </td>
818
- </tr>
819
- <tr valign="top">
820
- <th scope="row"><?php
821
- _e( 'Text maximum length', 'related-posts-thumbnails' );
822
- ?>:</th>
823
- <td>
824
- <input type="number" min="0" name="relpoststh_textlength" value="<?php
825
- echo get_option( 'relpoststh_textlength', $this->text_length );
826
- ?>" size="7"/>
827
- <label for="relpoststh_textlength"><p class="description rpth-discription"><?php
828
- _e( 'Set 0 for no title', 'related-posts-thumbnails' );
829
- ?></p></label>
830
- <span class='rpt-no-validate-error' style="display:none;"><?php
831
- _e( 'Only Digits are allowed', 'related-posts-thumbnails' );
832
- ?></span>
833
- <br />
834
- </td>
835
- </tr>
836
- <tr valign="top">
837
- <th scope="row"><?php
838
- _e( 'Excerpt maximum length', 'related-posts-thumbnails' );
839
- ?>:</th>
840
- <td>
841
- <input type="number" min="0" name="relpoststh_excerptlength" value="<?php
842
- echo get_option( 'relpoststh_excerptlength', $this->excerpt_length );
843
- ?>" size="7"/>
844
- <label for="relpoststh_excerptlength"><p class="description rpth-discription" ><?php
845
- _e( 'Set 0 for no excerpt', 'related-posts-thumbnails' );
846
- ?></p></label>
847
- <span class='rpt-no-validate-error' style="display:none;"><?php
848
- _e( 'Only Digits are allowed', 'related-posts-thumbnails' );
849
- ?></span>
850
- <br />
851
- </td>
852
- </tr>
853
- <tr valign="top">
854
- <th scope="row"><?php
855
- _e( 'Text block height', 'related-posts-thumbnails' );
856
- ?>:</th>
857
- <td>
858
- <input type="number" min="0" name="relpoststh_textblockheight" value="<?php
859
- echo get_option( 'relpoststh_textblockheight', $this->text_block_height );
860
- ?>" size="7"/> <p class="description rpth-discription">px</p>
861
- <span class='rpt-no-validate-error' style="display:none;"><?php
862
- _e( 'Only Digits are allowed', 'related-posts-thumbnails' );
863
- ?></span>
864
- </td>
865
- </tr>
866
- </table>
867
- </div>
868
- <div class="postbox" style="padding: 20px; display:none;" id="content_relation_options">
869
- <h2><?php
870
- _e( 'Relation Builder Options', 'related-posts-thumbnails' );
871
- ?></h2>
872
- <table class="form-table">
873
- <tr valign="top">
874
- <th scope="row"><?php
875
- _e( 'Base relation on', 'related-posts-thumbnails' );
876
- ?>:</th>
877
- <td>
878
- <?php
879
- if ( is_array( $relation_options ) && count( $relation_options ) ):
880
- ?>
881
- <?php
882
- foreach ( $relation_options as $ro_key => $ro_name ):
883
- ?>
884
- <input type="radio" name="relpoststh_relation" id="relpoststh_relation_<?php
885
- echo $ro_key;
886
- ?>" value="<?php
887
- echo $ro_key;
888
- ?>"
889
- <?php
890
- if ( $relpoststh_relation == $ro_key )
891
- {
892
- echo 'checked="checked"';
893
- }
894
- ?>
895
- />
896
- <label for="relpoststh_relation_<?php
897
- echo $ro_key;
898
- ?>"><?php
899
- echo $ro_name;
900
- ?></label><br />
901
- <?php
902
  endforeach;
903
- ?>
904
- <?php
905
- endif;
906
- ?>
907
- <div id="custom_taxonomies" style="display:
908
- <?php
909
- if ( $relpoststh_relation == 'custom' )
910
- {
911
- echo 'inline';
912
- }
913
- else
914
- {
915
- echo 'none';
916
- }
917
- ?>
918
- ;">
919
- <?php
920
  if ( is_array( $custom_taxonomies ) && count( $custom_taxonomies ) ):
921
- ?>
922
- <?php
923
- foreach ( $custom_taxonomies as $custom_taxonomy ):
924
- ?>
925
- <input type="checkbox" name="relpoststh_custom_taxonomies[]" id="ct_<?php
926
- echo $custom_taxonomy;
927
- ?>" value="<?php
928
- echo $custom_taxonomy;
929
- ?>"
930
- <?php
931
- if ( in_array( $custom_taxonomy, $relpoststh_custom_taxonomies ) )
932
- {
933
- echo 'checked="checked"';
934
- }
935
- ?>
936
- />
937
- <label for="ct_<?php
938
- echo $custom_taxonomy;
939
- ?>"><?php
940
- echo $custom_taxonomy;
941
- ?></label>
942
- <?php
943
- endforeach;
944
- ?>
945
- <?php
946
  endif;
947
  ?>
948
- </div>
949
- </td>
950
- </tr>
951
- </table>
952
- </div>
953
- <!-- <input name="Submit" value="<?php
954
- _e( 'Save Changes', 'related-posts-thumbnails' );
955
- ?>" type="submit" class="button-primary"> -->
956
- </div>
957
- </div>
958
-
959
- <div class="wpbr-button-container bottom">
960
- <div class="wpbr-social-links alignleft">
961
- <a href="https://profiles.wordpress.org/hiddenpearls/" class="wordpress" target="_blank"><span class="dashicons dashicons-wordpress"></span></a>
962
- </div>
963
- <input type="submit" name="Submit" class="wpb-rpt-settings-submit button button-primary button-big" value="<?php
964
- esc_html_e( 'Save Settings', 'related-posts-thumbnails' );
965
- ?>" id="wpb_rpt_save_setting_bottom">
966
- </div>
967
- </div>
968
-
969
- <div class="metabox-holder wpbr-sidebar">
970
- <div class="sidebar postbox">
971
- <h2><?php
972
- esc_html_e( 'Spread the Word', 'related-posts-thumbnails' );
973
- ?></h2>
974
- <ul>
975
- <li>
976
- <a href="http://twitter.com/share?text=This is Best Related Post Thumbnails Plugin for WordPress&url=https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails" data-count="none" class="button twitter" target="_blank" title="Post to Twitter Now"><?php
977
- esc_html_e( 'Share on Twitter', 'related-posts-thumbnails' );
978
- ?><span class="dashicons dashicons-twitter"></span></a>
979
- </li>
980
-
981
- <li>
982
- <a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails" class="button facebook" target="_blank" title="Share with your facebook friends about this awesome plugin."><?php
983
- esc_html_e( 'Share on Facebook', 'related-posts-thumbnails' );
984
- ?><span class="dashicons dashicons-facebook"></span>
985
- </a>
986
- </li>
987
-
988
- <li>
989
- <a href="https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails?filter=5" class="button wordpress" target="_blank" title="Rate on Wordpress.org"><?php
990
- esc_html_e( 'Rate on Wordpress.org', 'related-posts-thumbnails' );
991
- ?><span class="dashicons dashicons-wordpress"></span>
992
- </a>
993
- </li>
994
- </ul>
995
- </div>
996
-
997
- <div class="sidebar postbox">
998
-
999
- <h2><?php
1000
- esc_html_e( 'Subscribe Newsletter', 'related-posts-thumbnails' );
1001
- ?></h2>
1002
- <ul>
1003
- <li>
1004
- <label for="">Email</label>
1005
- <input type="email" name="subscriber_mail" value="<?php
1006
- echo get_option( 'admin_email' );
1007
- ?>" id="rpt_subscribe_mail">
1008
- <p class='rpt_subscribe_warning'></p>
1009
- </li>
1010
- <li>
1011
- <label for="">Name</label>
1012
- <input type="text" name="subscriber_name" id="rpt_subscribe_name" value="<?php
1013
- echo wp_get_current_user()->display_name;
1014
- ?>" id="rpt_subscribe_mail">
1015
- </li>
1016
- <li>
1017
- <input type="submit" value="Subscribe Now" class="button button-primary button-big" id='rpt_subscribe_btn' />
1018
- <img src="<?php
1019
- echo admin_url( 'images/spinner.gif' );
1020
- ?>" class='rpt_subscribe_loader' style="display:none" />
1021
- </li>
1022
- <li>
1023
- <p class='rpt_return_message'></p>
1024
- </li>
1025
- </ul>
1026
- </div>
1027
-
1028
- <div class="sidebar postbox">
1029
- <h2><?php
1030
- esc_html_e( 'Recommended Plugins', 'related-posts-thumbnails' );
1031
- ?></h2>
1032
- <!-- <p>Following are the plugins highly recommend by Team WPBrigade.</p> -->
1033
- <ul class="plugins_lists">
1034
- <li>
1035
- <a href="https://wpbrigade.com/wordpress/plugins/loginpress-pro/?utm_source=related-posts-lite&utm_medium=sidebar&utm_campaign=pro-upgrade" data-count="none" target="_blank" title="Post to Twitter Now"><?php
1036
- esc_html_e( 'LoginPress - Login Customizer', 'related-posts-thumbnails' );
1037
- ?></a>
1038
- </li>
1039
-
1040
- <li>
1041
- <a href="https://analytify.io/ref/73/?utm_source=related-posts-lite&utm_medium=sidebar&utm_campaign=pro-upgrade" target="_blank" title="Share with your facebook friends about this awesome plugin."><?php
1042
- esc_html_e( 'Google Analytics by Analytify', 'related-posts-thumbnails' );
1043
- ?></span>
1044
- </a>
1045
- </li>
1046
-
1047
- <li>
1048
- <a href="http://wpbrigade.com/recommend/maintenance-mode" target="_blank" title="Under Construction & Maintenance mode"><?php
1049
- esc_html_e( 'Under Construction & Maintenance mode', 'related-posts-thumbnails' );
1050
- ?></span>
1051
- </a>
1052
- </li>
1053
- </ul>
1054
- </div>
1055
- </div>
1056
-
1057
- </div>
1058
- </form>
1059
- <p style="margin-top: 40px;"><small><?php
1060
- _e( 'If you experience some problems with this plugin please let me know about it on <a target="_blank" href="https://wpbrigade.com/wordpress/plugins/related-posts/">Plugin\'s homepage</a>. If you think this plugin is awesome please vote on <a target="_blank" href="https://wordpress.org/plugins/related-posts-thumbnails/">WordPress plugin page</a>. Thanks!', 'related-posts-thumbnails' );
1061
- ?></small></p>
16
  update_option( 'relpoststh_single_only', sanitize_text_field( wp_unslash( $_POST[ 'relpoststh_single_only' ] ) ) );
17
  } else {
18
  update_option( 'relpoststh_single_only', '0' );
19
+ }
20
 
21
+ if ( isset( $_POST[ 'relpoststh_mobile_view' ] ) ) {
22
+ update_option( 'relpoststh_mobile_view', sanitize_text_field( wp_unslash( $_POST[ 'relpoststh_mobile_view' ] ) ) );
23
+ } else {
24
+ update_option( 'relpoststh_mobile_view', '0' );
25
+ }
26
 
27
  if ( isset( $_POST[ 'relpoststh_post_types' ] ) ) {
28
  update_option( 'relpoststh_post_types', array_map( 'sanitize_text_field', wp_unslash( $_POST[ 'relpoststh_post_types' ] ) ) );
193
  }
194
  }
195
  $available_sizes = array(
196
+ 'thumbnail' => 'thumbnail',
197
+ 'medium' => 'medium'
198
  );
199
+
200
+ /**
201
+ * By using this filter, can modified the default options of 'Related posts thumbnail sizes'.
202
+ * To add WordPress standard size which is original image resolution (unmodified).
203
+ *
204
+ * @since 1.9.0
205
+ *
206
+ * @param array '$available_sizes' Associative array of post thumbnail sizes.
207
+ */
208
+
209
+ $available_sizes = apply_filters( 'rpt_thumbnailsizes', $available_sizes );
210
+
211
  if ( current_theme_supports( 'post-thumbnails' ) ) {
212
+
213
  global $_wp_additional_image_sizes;
214
+
215
+ if ( is_array( $_wp_additional_image_sizes ) ) {
216
  $available_sizes = array_merge( $available_sizes, $_wp_additional_image_sizes );
217
  }
218
  }
219
 
220
+ // Related posts get settings options
221
  $relpoststh_single_only = get_option( 'relpoststh_single_only', $this->single_only );
222
  $relpoststh_auto = get_option( 'relpoststh_auto', $this->auto );
223
  $relpoststh_cleanhtml = get_option( 'relpoststh_cleanhtml', 0 );
227
  $relpoststh_categoriesall = get_option( 'relpoststh_categoriesall', $this->categories_all );
228
  $relpoststh_categories = get_option( 'relpoststh_categories' );
229
  // $relpoststh_show_date = get_option( 'relpoststh_show_date', '0' );
230
+ $relpoststh_mobile_view = get_option( 'relpoststh_mobile_view' );
231
  $relpoststh_show_categories = get_option( 'relpoststh_show_categories', get_option( 'relpoststh_categories' ) );
232
  $relpoststh_show_categoriesall = get_option( 'relpoststh_show_categoriesall', $relpoststh_categoriesall );
233
  $onlywiththumbs = get_option( 'relpoststh_onlywiththumbs', false );
235
  $relpoststh_output_style = get_option( 'relpoststh_output_style', $this->output_style );
236
  $thsources = array( 'post-thumbnails' => __( 'Post thumbnails', 'related_posts_thumbnails' ),'custom-field' => __( 'Custom field', 'related_posts_thumbnails' ) );
237
  $categories = get_categories();
238
+
239
  if ( $this->wp_version >= 3 ) {
240
  $post_types = get_post_types( array( 'public' => 1 ) );
241
  } else {
249
  'list' => __( 'List', 'related-posts-thumbnails' ) );
250
 
251
  $relation_options = array(
252
+ 'categories' => __( 'Categories', 'related-posts-thumbnails' ),
253
+ 'tags' => __( 'Tags', 'related-posts-thumbnails' ),
254
+ 'both' => __( 'Categories and Tags', 'related-posts-thumbnails' ),
255
+ 'no' => __( 'Random', 'related-posts-thumbnails' ),
256
+ 'custom' => __( 'Custom', 'related-posts-thumbnails' )
257
  );
258
 
259
  if ( $this->wp_version >= 3 ) {
289
  <div class="wpbr-wrap"><div class="wpbr-tabsWrapper">
290
  <div class="wpbr-button-container top">
291
  <div class="setting-notification">
292
+ <?php _e( 'Settings have changed, you should save them!', 'related-posts-thumbnails' ); ?>
293
  </div>
294
  <input type="submit" name="Submit" class="wpb-rpt-settings-submit button button-primary button-big"
295
+ value="<?php esc_html_e( 'Save Settings', 'related-posts-thumbnails' ); ?>" id="wpb_rpt_save_setting_top">
296
  </div>
297
 
298
  <div id="relpoststh-settings" class="">
299
  <ul class="nav-tab-wrapper">
300
+ <li>
301
+ <a href="#content_general_options" class="nav-tab" id="content_general_options-tab">
302
+ <?php _e( 'General Display Options', 'related-posts-thumbnails' ); ?>
303
+ </a>
304
+ </li>
305
+ <li>
306
+ <a href="#content_thumbnail_options" class="nav-tab" id="content_thumbnail_options-tab">
307
+ <?php _e( 'Thumbnails', 'related-posts-thumbnails' ); ?>
308
+ </a>
309
+ </li>
310
+ <li>
311
+ <a href="#content_style_options" class="nav-tab" id="content_style_options-tab">
312
+ <?php _e( 'Style Options', 'related-posts-thumbnails' ); ?>
313
+ </a>
314
+ </li>
315
+ <li>
316
+ <a href="#content_relation_options" class="nav-tab" id="content_relation_options-tab">
317
+ <?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>
318
+ </a>
319
+ </li>
320
  </ul>
321
 
322
  <div class="metabox-holder rpth-setting-options">
323
  <div class="postbox" style="padding: 20px" id="content_general_options">
324
  <h2>
325
+ <?php _e( 'General Display Options', 'related-posts-thumbnails' ); ?>
326
+ </h2>
327
 
328
  <table class="form-table">
329
  <tr valign="top">
334
  <input type="checkbox" name="relpoststh_auto" id="relpoststh_auto" value="1"
335
  <?php
336
  if ( $relpoststh_auto ) {
337
+ echo 'checked="checked"';
338
  }
339
  ?>
340
  />
354
  <input type="checkbox" name="relpoststh_devmode" id="relpoststh_devmode" value="1"
355
  <?php
356
  if ( $relpoststh_devmode ) {
357
+ echo 'checked="checked"';
358
  }
359
  ?>
360
  />
361
  <label for="relpoststh_devmode">
362
+ <p class="description rpth-discription">
363
+ <?php _e( 'This will add debugging information in HTML source', 'related-posts-thumbnails' ); ?>
364
+ </p>
365
  </label>
366
  <br />
367
  </td>
368
  </tr>
369
  <tr valign="top">
370
  <th scope="row">
371
+ <?php _e( 'Display related posts', 'related-posts-thumbnails' ); ?>:
372
+ </th>
373
  <td>
374
+ <input type="checkbox" name="relpoststh_single_only" id="relpoststh_single_only" value="1"
375
+ <?php
376
+ if ( $relpoststh_single_only ) {
377
+ echo 'checked="checked"';
378
+ } ?>
379
+ />
380
+ <label for="relpoststh_single_only">
381
+ <?php _e( 'On single posts only', 'related-posts-thumbnails' ); ?>
382
+ </label>
383
+ <br />
 
384
  </td>
385
+ </tr>
386
  <tr valign="top">
387
  <th scope="row">
388
+ <?php _e( 'Post types', 'related-posts-thumbnails' ); ?>:
389
+ </th>
390
  <td>
391
  <?php
392
+ if ( is_array( $post_types ) && count( $post_types ) ):
393
+ foreach ( $post_types as $post_type ): ?>
394
+ <input type="checkbox" name="relpoststh_post_types[]"
395
+ id="pt_<?php esc_html_e( $post_type, 'related-posts-thumbnails'); ?>"
396
+ value="<?php echo $post_type; ?>"
397
+ <?php
398
+ if ( in_array( $post_type, $relpoststh_post_types ) ) {
399
+ echo 'checked="checked"';
400
+ }
401
+ ?>
402
+ />
403
+ <label for="pt_<?php esc_html_e( $post_type, 'related-posts-thumbnails') ?>">
404
+ <?php esc_html_e( $post_type, 'related-posts-thumbnails') ?>
405
+ </label>
406
+ <?php
407
+ endforeach;
408
+ endif;
409
+ ?>
 
 
410
  </td>
411
  </tr>
412
  <tr valign="top">
413
  <th scope="row">
414
+ <?php _e( 'Display related posts on categories', 'related-posts-thumbnails' ); ?>:
415
+ </th>
416
  <td>
417
+ <?php $this->display_categories_list( $relpoststh_categoriesall, $categories, $relpoststh_categories, 'relpoststh_categoriesall', 'relpoststh_categories' );
418
+ ?>
 
419
  </td>
420
  </tr>
421
  <tr valign="top">
422
  <th scope="row">
423
+ <?php _e( 'Categories will appear in related posts', 'related-posts-thumbnails' ); ?>:
424
+ </th>
425
  <td>
426
+ <?php $this->display_categories_list( $relpoststh_show_categoriesall, $categories, $relpoststh_show_categories, 'relpoststh_show_categoriesall', 'relpoststh_show_categories' );
427
+ ?>
 
428
  </td>
429
  </tr>
430
+ <tr valign="top">
431
+ <th scope="row">
432
+ <?php _e( 'Mobile view', 'related-posts-thumbnails' ); ?>:
433
+ </th>
434
+ <td>
435
+ <input type="checkbox" name="relpoststh_mobile_view" id="relpoststh_mobile_view" value="1"
436
+ <?php
437
+ if ( $relpoststh_mobile_view ) {
438
+ echo 'checked="checked"';
439
+ }
440
+ ?>
441
+ />
442
+ <label for="relpoststh_mobile_view">
443
+ <?php _e( 'Hide on mobile devices', 'related-posts-thumbnails' ); ?>
444
+ </label>
445
+ <br />
446
+ </td>
447
  </tr>
 
448
  <!-- <tr valign="top">
449
  <th scope="row">
450
+ <?php // _e( 'Show date under posts', 'related-posts-thumbnails' ); ?>:
451
+ </th>
452
  <td>
453
  <input type="checkbox" name="relpoststh_show_date" id="relpoststh_show_date" value="1"
454
  <?php
455
+ // if ( $relpoststh_show_date == '1' ) {
456
+ // echo 'checked="checked"';
457
+ // }
458
+ ?>
459
+ />
460
  </td>
461
  </tr> -->
462
  <tr>
463
  <th scope="row">
464
+ <?php _e( 'Include posts after', 'related-posts-thumbnails' ); ?>:
465
+ </th>
466
  <td>
467
+ <input type="text" class="rpt_post_include" name="rpt_post_include" value="<?php echo get_option( 'relpoststh_startdate' ); ?>" >
 
 
468
  <button type="button" class="button rpt_clear_date">Clear</button>
469
  <label for="relpoststh_excerptlength">
470
  <p class="description">
471
+ <?php _e( 'Leave empty for all posts dates', 'related-posts-thumbnails' ); ?>
472
  </p>
473
  </label>
474
+ <br />
475
  </td>
476
  </tr>
477
  <tr>
501
  </tr>
502
  <tr>
503
  <th scope="row">
504
+ <?php _e( 'Top text', 'related-posts-thumbnails' ); ?>:
505
+ </th>
506
  <td>
507
+ <input type="text" name="relpoststh_top_text" value="<?php echo stripslashes( htmlspecialchars( get_option( 'relpoststh_top_text', $this->top_text ) ) ); ?>" size="50"/>
 
508
  </td>
509
  </tr>
510
  <tr>
511
  <th scope="row">
512
+ <?php _e( 'Number of posts to display', 'related-posts-thumbnails' ); ?>:
513
+ </th>
514
  <td>
515
+ <input type="number" min="1" name="relpoststh_number" value="<?php echo get_option( 'relpoststh_number', $this->number ); ?>" size="2"/>
 
516
  <span class='rpt-no-validate-error' style="display:none;">
517
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
518
+ </span>
519
  </td>
520
  </tr>
521
  <!-- <table class="form-table"> -->
551
  </table>
552
  </div>
553
 
 
554
  <div class="postbox" style="padding: 20px; display:none;" id="content_thumbnail_options">
555
  <h2>
556
  <?php _e( 'Thumbnails', 'related-posts-thumbnails' ); ?>
582
  <table class="form-table">
583
  <tr valign="top">
584
  <th scope="row">
585
+ <?php _e( 'Related posts thumbnail size', 'related-posts-thumbnails' ); ?>:
586
+ </th>
587
  <td>
588
  <select name="relpoststh_poststhname">
589
+ <?php foreach ( $available_sizes as $size_name => $size ): ?>
590
+ <option <?php if ( $size_name == get_option( 'relpoststh_poststhname', $this->poststhname ) ) {
591
+ echo 'selected';
592
+ } ?> >
593
+ <?php echo $size_name; ?>
594
+ </option>
595
+ <?php endforeach; ?>
 
 
 
596
  </select>
597
+ <?php if ( !current_theme_supports( 'post-thumbnails' ) ): ?> (<?php
598
+ e( 'Your theme has to support post-thumbnails to have more choices', 'related-posts-thumbnails' ); ?>)
 
 
599
  <?php endif; ?>
600
  </td>
601
  </tr>
602
+ <?php if ( current_theme_supports( 'post-thumbnails' ) ): ?>
603
+ <tr>
604
+ <th scope="row">
605
+ <?php _e( 'Show posts with featured image', 'related-posts-thumbnails' ); ?>:
606
+ </th>
607
+ <td>
608
+ <input type="checkbox" name="onlywiththumbs" id="onlywiththumbs" value="1" <?php if ( $onlywiththumbs ) { echo 'checked="checked"'; } ?> />
609
+ <label for="onlywiththumbs">
610
+ <p class="description rpth-discription">
611
+ <?php _e( 'Only those posts will be shown that has featured image', 'related-posts-thumbnails' ); ?>
612
+ </p>
613
+ </label>
614
+ <br />
615
+ </td>
616
+ </tr>
617
+ <?php endif; ?>
618
+ </table>
619
+ </div>
620
+
621
+ <div id="relpoststh-custom-field">
622
+ <table class="form-table">
623
+ <tr valign="top">
624
+ <th scope="row">
625
+ <?php _e( 'Custom field name', 'related-posts-thumbnails' ); ?>:
626
+ </th>
627
+
628
+ <td>
629
+ <input type="text" name="relpoststh_customfield" value="<?php echo get_option( 'relpoststh_customfield', $this->custom_field ); ?>" size="50"/>
630
+ </td>
631
+ </tr>
632
+
633
+ <tr valign="top">
634
+ <th scope="row">
635
+ <?php _e( 'Size', 'related-posts-thumbnails' ); ?>:
636
+ </th>
637
+
638
+ <td>
639
+ <label for="relpoststh_customwidth" id="relpoststh_customwidth">
640
+ <?php _e( 'Width', 'related-posts-thumbnails' ); ?>:
641
+ </label>
642
+
643
+ <input type="number" min="1" name="relpoststh_customwidth" value="<?php echo get_option( 'relpoststh_customwidth', $this->custom_width ); ?>" size="3"/>
644
+
645
+ <p class="description rpth-discription">
646
+ <?php _e( ' px', 'related-posts-thumbnails' ); ?>
647
+ </p>
648
+ <br>
649
+
650
+ <label for="relpoststh_customheight">
651
+ <?php _e( 'Height', 'related-posts-thumbnails' ); ?>:
652
+ </label>
653
+
654
+ <input type="number" min="1" name="relpoststh_customheight" value="<?php echo get_option( 'relpoststh_customheight', $this->custom_height );?>" size="3"/>
655
+
656
+ <p class="description rpth-discription">
657
+ <?php _e( ' px', 'related-posts-thumbnails' ); ?>
658
+ </p>
659
+
660
+ <br>
661
+
662
+ <span class='rpt-no-validate-error' style="display:none;">
663
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
664
+ </span>
665
+ </td>
666
+ </tr>
667
+
668
+ <tr valign="top">
669
+ <th scope="row">
670
+ <?php _e( 'Theme resize url', 'related-posts-thumbnails' ); ?>:
671
+ </th>
672
+
673
+ <td>
674
+ <input type="text" name="relpoststh_theme_resize_url" value="<?php echo get_option( 'relpoststh_theme_resize_url', '' ); ?>" size="50"/>
675
+
676
+ <p class='description rpth-discription'>
677
+ <?php _e( 'If your theme resizes images, enter URL to its resizing PHP file', 'related-posts-thumbnails' ); ?>
678
+ </p>
679
+ </td>
680
+ </tr>
681
+ </table>
682
+ </div>
683
+ </div>
684
+
685
+
686
+ <!-- DISPLAY SETTINGS -->
687
+ <div class="postbox" style="padding: 20px; display:none;" id="content_style_options">
688
+ <h2>
689
+ <?php _e( 'Style Options', 'related-posts-thumbnails' ); ?>
690
+ </h2>
691
+
692
+ <table class="form-table">
693
+
694
+ <!-- calling layouts from pro -->
695
+ <?php // do_action('rptp_style_layouts'); ?>
696
+
697
+ <tr>
698
+ <th scope="row"><?php
699
+ _e( 'Output style', 'related-posts-thumbnails' ); ?>:
700
+ </th>
701
+
702
+ <td>
703
+ <select name="relpoststh_output_style" id="relpoststh_output_style">
704
+ <?php foreach ( $output_styles as $name => $title ): ?>
705
+ <option value="<?php echo $name; ?>"
706
+ <?php if ( $relpoststh_output_style == $name ) { echo 'selected'; } ?> >
707
+ <?php echo $title; ?>
708
+ </option>
709
+ <?php
710
+ endforeach; ?>
711
+ </select>
712
+ <span id="relpoststh_cleanhtml" style="display:
713
+ <?php
714
+ if ( $relpoststh_output_style == 'list' ) {
 
 
 
 
 
 
 
 
 
 
 
715
  echo 'inline';
716
+ } else {
 
 
717
  echo 'none';
718
+ } ?> ;">
719
+
720
+ <?php _e( 'Turn off plugin styles', 'related-posts-thumbnails' ); ?>
721
+ <input type="checkbox" name="relpoststh_cleanhtml" <?php if ( $relpoststh_cleanhtml ) { echo 'checked="checked"'; } ?> />
722
+ </span>
723
+ </td>
724
+ </tr>
725
+
726
+ <tr valign="top">
727
+
728
+ <th scope="row"><?php
729
+ _e( 'Background color', 'related-posts-thumbnails' ); ?>:
730
+ </th>
731
+
732
+ <td>
733
+ <input type="text" name="relpoststh_background" value="<?php echo get_option( 'relpoststh_background', $this->background ); ?>" data-default-color="<?php echo $this->background; ?>"/>
734
+ </td>
735
+ </tr>
736
+
737
+ <tr valign="top">
738
+ <th scope="row">
739
+ <?php _e( 'Background color on mouse over', 'related-posts-thumbnails' ); ?>:
740
+ </th>
741
+
742
+ <td>
743
+ <input type="text" name="relpoststh_hoverbackground" value="<?php echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground ); ?>" data-default-color="<?php echo $this->hoverbackground; ?>" />
744
+ </td>
745
+ </tr>
746
+
747
+ <tr valign="top">
748
+ <th scope="row">
749
+ <?php _e( 'Border color', 'related-posts-thumbnails' ); ?>:
750
+ </th>
751
+
752
+ <td>
753
+ <input type="text" name="relpoststh_bordercolor" value="<?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>" data-default-color="<?php echo $this->border_color; ?>"/>
754
+ </td>
755
+ </tr>
756
+
757
+ <tr valign="top">
758
+ <th scope="row">
759
+ <?php _e( 'Font color', 'related-posts-thumbnails' ); ?>:
760
+ </th>
761
+ <td>
762
+ <input type="text" name="relpoststh_fontcolor" value="<?php echo get_option( 'relpoststh_fontcolor', $this->font_color ); ?>" data-default-color="<?php echo $this->font_color; ?>"/>
763
+ </td>
764
+ </tr>
765
+
766
+ <tr valign="top">
767
+ <th scope="row">
768
+ <?php _e( 'Font family', 'related-posts-thumbnails' ); ?>:
769
+ </th>
770
+ <td>
771
+ <input type="text" name="relpoststh_fontfamily" value="<?php echo stripslashes( htmlspecialchars( get_option( 'relpoststh_fontfamily', $this->font_family ) ) ); ?>" size="50"/>
772
+ </td>
773
+ </tr>
774
+
775
+ <tr valign="top">
776
+ <th scope="row">
777
+ <?php _e( 'Font size', 'related-posts-thumbnails' ); ?>:
778
+ </th>
779
+ <td>
780
+ <input type="number" min="1" name="relpoststh_fontsize" value="<?php echo get_option( 'relpoststh_fontsize', $this->font_size ); ?>" size="7"/>
781
+ <label for="relpoststh_fontsize">
782
+ <p class="description rpth-discription"><?php _e( 'px', 'related-posts-thumbnails' ); ?></p>
783
+ </label>
784
+
785
+ <span class='rpt-no-validate-error' style="display:none;">
786
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
787
+ </span>
788
+ </td>
789
+ </tr>
790
+ <tr valign="top">
791
+ <th scope="row">
792
+ <?php _e( 'Text maximum length', 'related-posts-thumbnails' ); ?>:
793
+ </th>
794
+ <td>
795
+ <input type="number" min="0" name="relpoststh_textlength" value="<?php echo get_option( 'relpoststh_textlength', $this->text_length ); ?>" size="7"/>
796
+ <label for="relpoststh_textlength">
797
+ <p class="description rpth-discription">
798
+ <?php _e( 'Set 0 for no title', 'related-posts-thumbnails' ); ?>
799
+ </p>
800
+ </label>
801
+ <span class='rpt-no-validate-error' style="display:none;">
802
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
803
+ </span>
804
+ <br />
805
+ </td>
806
+ </tr>
807
+ <tr valign="top">
808
+ <th scope="row">
809
+ <?php _e( 'Excerpt maximum length', 'related-posts-thumbnails' ); ?>:
810
+ </th>
811
+ <td>
812
+ <input type="number" min="0" name="relpoststh_excerptlength" value="<?php echo get_option( 'relpoststh_excerptlength', $this->excerpt_length ); ?>" size="7"/>
813
+ <label for="relpoststh_excerptlength">
814
+ <p class="description rpth-discription" >
815
+ <?php _e( 'Set 0 for no excerpt', 'related-posts-thumbnails' ); ?>
816
+ </p>
817
+ </label>
818
+ <span class='rpt-no-validate-error' style="display:none;">
819
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
820
+ </span>
821
+ <br />
822
+ </td>
823
+ </tr>
824
+ <tr valign="top">
825
+ <th scope="row">
826
+ <?php _e( 'Text block height', 'related-posts-thumbnails' ); ?>:
827
+ </th>
828
+ <td>
829
+ <input type="number" min="0" name="relpoststh_textblockheight" value="<?php echo get_option( 'relpoststh_textblockheight', $this->text_block_height ); ?>" size="7"/>
830
+ <p class="description rpth-discription">px</p>
831
+ <span class='rpt-no-validate-error' style="display:none;">
832
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
833
+ </span>
834
+ </td>
835
+ </tr>
836
+ </table>
837
+ </div>
838
+
839
+ <div class="postbox" style="padding: 20px; display:none;" id="content_relation_options">
840
+ <h2>
841
+ <?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>
842
+ </h2>
843
+ <table class="form-table">
844
+
845
+ <tr valign="top">
846
+
847
+ <th scope="row">
848
+ <?php _e( 'Base relation on:', 'related-posts-thumbnails' ); ?>
849
+ </th>
850
+
851
+ <td>
852
+ <?php
853
+ if ( is_array( $relation_options ) && count( $relation_options ) ):
854
+ foreach ( $relation_options as $ro_key => $ro_name ): ?>
855
+ <input type="radio" name="relpoststh_relation" id="relpoststh_relation_<?php echo esc_html_e( $ro_key, 'related-posts-thumbnails' ); ?>" value="<?php echo $ro_key; ?>"
856
+ <?php if ( $relpoststh_relation == $ro_key ) { echo 'checked="checked"'; } ?>
857
+ />
858
+ <label for="relpoststh_relation_<?php _e( $ro_key, 'related-posts-thumbnails' ); ?>">
859
+ <?php _e( $ro_key, 'related-posts-thumbnails' ); ?>
860
+ </label>
861
+ <br />
862
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863
  endforeach;
864
+
865
+ endif;
866
+ ?>
867
+ <div id="custom_taxonomies" style="display:
868
+ <?php
869
+ if ( $relpoststh_relation == 'custom' ) {
870
+ echo 'inline';
871
+ } else {
872
+ echo 'none';
873
+ } ?> ;">
874
+ <?php
 
 
 
 
 
 
875
  if ( is_array( $custom_taxonomies ) && count( $custom_taxonomies ) ):
876
+ foreach ( $custom_taxonomies as $custom_taxonomy ): ?>
877
+ <input type="checkbox" name="relpoststh_custom_taxonomies[]" id="ct_<?php echo $custom_taxonomy; ?>" value="<?php echo $custom_taxonomy; ?>"
878
+ <?php
879
+ if ( in_array( $custom_taxonomy, $relpoststh_custom_taxonomies ) ) {
880
+ echo 'checked="checked"';
881
+ }
882
+ ?>
883
+ />
884
+ <label for="ct_<?php _e( $custom_taxonomy, 'related-posts-thumbnails' ); ?>">
885
+ <?php _e( $custom_taxonomy, 'related-posts-thumbnails' ); ?>
886
+ </label>
887
+ <?php
888
+ endforeach;
889
+
 
 
 
 
 
 
 
 
 
 
 
890
  endif;
891
  ?>
892
+ </div>
893
+ </td>
894
+ </tr>
895
+ </table>
896
+ </div>
897
+ <!-- <input name="Submit" value="<?php _e( 'Save Changes', 'related-posts-thumbnails' ); ?>" type="submit" class="button-primary"> -->
898
+ </div>
899
+ </div>
900
+
901
+ <div class="wpbr-button-container bottom">
902
+
903
+ <div class="wpbr-social-links alignleft">
904
+ <a href="https://profiles.wordpress.org/hiddenpearls/" class="wordpress" target="_blank">
905
+ <span class="dashicons dashicons-wordpress"> </span>
906
+ </a>
907
+ </div>
908
+ <input type="submit" name="Submit" class="wpb-rpt-settings-submit button button-primary button-big" value="<?php
909
+ esc_html_e( 'Save Settings', 'related-posts-thumbnails' );
910
+ ?>" id="wpb_rpt_save_setting_bottom">
911
+ </div>
912
+ </div>
913
+
914
+ <div class="metabox-holder wpbr-sidebar">
915
+ <div class="sidebar postbox">
916
+ <h2>
917
+ <?php esc_html_e( 'Spread the Word', 'related-posts-thumbnails' ); ?>
918
+ </h2>
919
+ <ul>
920
+ <li>
921
+ <?php ?>
922
+ <a href="https://twitter.com/share?text=This is Best Related Post Thumbnails Plugin for WordPress&url=https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails" data-count="none" class="button twitter" target="_blank" title="<?php _e( 'Post to Twitter Now', 'related-posts-thumbnails'); ?> ">
923
+ <?php esc_html_e( 'Share on Twitter', 'related-posts-thumbnails' ); ?>
924
+ <span class="dashicons dashicons-twitter"></span>
925
+ </a>
926
+ </li>
927
+
928
+ <li>
929
+ <a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails" class="button facebook" target="_blank" title="<?php _e( 'Share with your facebook friends about this awesome plugin.', 'related-posts-thumbnails'); ?>"><?php esc_html_e( 'Share on Facebook', 'related-posts-thumbnails' ); ?>
930
+ <span class="dashicons dashicons-facebook"></span>
931
+ </a>
932
+ </li>
933
+
934
+ <li>
935
+ <a href="https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails?filter=5" class="button wordpress" target="_blank" title="<?php esc_html_e( 'Rate on Wordpress.org', 'related-posts-thumbnails' ); ?>"><?php esc_html_e( 'Rate on Wordpress.org', 'related-posts-thumbnails' ); ?>
936
+ <span class="dashicons dashicons-wordpress"></span>
937
+ </a>
938
+ </li>
939
+ </ul>
940
+ </div>
941
+
942
+ <div class="sidebar postbox">
943
+
944
+ <h2>
945
+ <?php esc_html_e( 'Subscribe Newsletter', 'related-posts-thumbnails' ); ?>
946
+ </h2>
947
+ <ul>
948
+ <li>
949
+ <label for="Email"><?php esc_html_e( 'Email', 'related-posts-thumbnails' ); ?></label>
950
+ <input type="email" name="subscriber_mail" value="<?php echo get_option( 'admin_email' ); ?>" id="rpt_subscribe_mail">
951
+ <p class='rpt_subscribe_warning'></p>
952
+ </li>
953
+ <li>
954
+ <label for="Name"><?php esc_html_e( 'Name', 'related-posts-thumbnails' ); ?></label>
955
+ <input type="text" name="subscriber_name" id="rpt_subscribe_name" value="<?php echo wp_get_current_user()->display_name; ?>" id="rpt_subscribe_mail">
956
+ </li>
957
+ <li>
958
+ <input type="submit" value="<?php esc_html_e( 'Subscribe Now', 'related-posts-thumbnails' ); ?>" class="button button-primary button-big" id='rpt_subscribe_btn' />
959
+ <img src="<?php echo admin_url( 'images/spinner.gif' ); ?>" class='rpt_subscribe_loader' style="display:none" />
960
+ </li>
961
+ <li>
962
+ <p class='rpt_return_message'></p>
963
+ </li>
964
+ </ul>
965
+ </div>
966
+
967
+ <div class="sidebar postbox">
968
+ <h2>
969
+ <?php esc_html_e( 'Recommended Plugins', 'related-posts-thumbnails' ); ?>
970
+ </h2>
971
+ <!-- <p>Following are the plugins highly recommend by Team WPBrigade.</p> -->
972
+ <ul class="plugins_lists">
973
+ <li>
974
+ <a href="https://wpbrigade.com/wordpress/plugins/loginpress-pro/?utm_source=related-posts-lite&utm_medium=sidebar&utm_campaign=pro-upgrade" data-count="none" target="_blank" title="<?php esc_html_e( 'Post to Twitter Now', 'related-posts-thumbnails' ); ?>"><?php esc_html_e( 'LoginPress - Login Customizer', 'related-posts-thumbnails' ); ?> </a>
975
+ </li>
976
+
977
+ <li>
978
+ <a href="https://analytify.io/ref/73/?utm_source=related-posts-lite&utm_medium=sidebar&utm_campaign=pro-upgrade" target="_blank" title="<?php esc_html_e( 'Share with your facebook friends about this awesome plugin.', 'related-posts-thumbnails' ); ?>"><?php
979
+ esc_html_e( 'Google Analytics by Analytify', 'related-posts-thumbnails' );
980
+ ?></span>
981
+ </a>
982
+ </li>
983
+
984
+ <li>
985
+ <a href="https://wpbrigade.com/recommend/maintenance-mode" target="_blank" title="<?php esc_html_e( 'Under Construction & Maintenance mode', 'related-posts-thumbnails' ); ?>">
986
+ <?php esc_html_e( 'Under Construction & Maintenance mode', 'related-posts-thumbnails' ); ?>
987
+ </span>
988
+ </a>
989
+ </li>
990
+ </ul>
991
+ </div>
992
+ </div>
993
+
994
+ </div>
995
+ </form>
996
+ <p style="margin-top: 40px;">
997
+ <small>
998
+ <?php _e( 'If you experience some problems with this plugin please let me know about it on <a target="_blank" href="https://wpbrigade.com/wordpress/plugins/related-posts/">Plugin\'s homepage</a>. If you think this plugin is awesome please vote on <a target="_blank" href="https://wordpress.org/plugins/related-posts-thumbnails/">WordPress plugin page</a>. Thanks!', 'related-posts-thumbnails' ); ?>
999
+ </small>
1000
+ </p>
 
 
 
 
 
inc/rpt-widget.php CHANGED
@@ -1,7 +1,11 @@
1
  <?php
2
 
3
 
4
-
 
 
 
 
5
  function get_related_posts_thumbnails() {
6
  global $related_posts_thumbnails;
7
  echo $related_posts_thumbnails->get_html();
@@ -18,7 +22,13 @@ class RelatedPostsThumbnailsWidget extends WP_Widget {
18
  );
19
  parent::__construct( false, 'Related Posts Thumbnails', $args );
20
  }
21
-
 
 
 
 
 
 
22
  function widget( $args, $instance ) {
23
  if ( is_single() && ! is_page() ) { // display on post page only
24
  extract( $args );
@@ -30,7 +40,13 @@ class RelatedPostsThumbnailsWidget extends WP_Widget {
30
  echo $after_widget;
31
  }
32
  }
33
-
 
 
 
 
 
 
34
  function update( $new_instance, $old_instance ) {
35
  $instance = $old_instance;
36
  $instance['title'] = strip_tags( $new_instance['title'] );
1
  <?php
2
 
3
 
4
+ /**
5
+ * Get Related posts Thumbnails function to get the thumbnails
6
+ *
7
+ * @return void
8
+ */
9
  function get_related_posts_thumbnails() {
10
  global $related_posts_thumbnails;
11
  echo $related_posts_thumbnails->get_html();
22
  );
23
  parent::__construct( false, 'Related Posts Thumbnails', $args );
24
  }
25
+ /**
26
+ * Show Widget
27
+ *
28
+ * @param $args
29
+ * @param $instance
30
+ *
31
+ */
32
  function widget( $args, $instance ) {
33
  if ( is_single() && ! is_page() ) { // display on post page only
34
  extract( $args );
40
  echo $after_widget;
41
  }
42
  }
43
+ /**
44
+ * Widget Instance update
45
+ *
46
+ * @param $new_instance
47
+ * @param $old_instance
48
+ * @return $instance
49
+ */
50
  function update( $new_instance, $old_instance ) {
51
  $instance = $old_instance;
52
  $instance['title'] = strip_tags( $new_instance['title'] );
readme.txt CHANGED
@@ -3,10 +3,10 @@ Contributors: hiddenpearls, WPBrigade
3
  Donate link: https://wpbrigade.com/
4
  Tags: easy related posts, Related Posts thumbnails, Free Related Posts, related posts, similar related posts
5
  Requires at least: 3.6
6
- Tested up to: 5.4
7
- Stable tag: 1.8.3
8
  License: GPLv3 or later
9
- License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Related Posts by WPBrigade is The Best Customizable plugin, that nicely displays related posts thumbnails under the post.
12
 
@@ -25,16 +25,16 @@ You can specify number of related posts to display, start date, categories to sh
25
 
26
  Contributions:
27
 
28
- * Thanks to <a href="http://adnan.pk/?utm_source=related-posts-lite&utm_medium=readme&utm_campaign=xp">Adnan</a> for giving life to this plugin.
29
 
30
  Translations:
31
 
32
  * This plugin has Russian version
33
- * Thanks to <a href="http://www.li-an.fr/wpplugins/">Li-An</a> this plugin has French version
34
- * Thanks to <a href="http://gidibao.net/">Gidibao</a> this plugin has Italian version
35
- * Thanks to <a href="http://www.kuzublog.com/">Kuzu</a> this plugin has Turkish version
36
- * Thanks to <a href="http://www.meinblog.de/" title="MeinBlog.de - eigenes Tagebuch">Mirko</a> this plugin has German version
37
- * Thanks to <a href="http://bejana.com/">Bejana</a> for Indonesian translation
38
 
39
  Related Links:
40
 
@@ -57,7 +57,7 @@ If your theme does not support Post Thumbnail feature or post has no assigned th
57
 
58
  = Does plugin support external images, e.g. uploaded on Flickr? =
59
 
60
- There is no direct support of external images in the current version of the plugin. You can use custom field option. Or you can use http://wordpress.org/extend/plugins/generate-post-thumbnails/ or similar plugin to save external images as post thumbnails.
61
 
62
  = What is the default image URL? =
63
 
@@ -70,12 +70,17 @@ If there are no images of the specified size in the post, or file does not exist
70
  1. Plugin settings page
71
 
72
  == Upgrade Notice ==
73
-
74
- = 1.8.3 =
75
  * Please upgrade immediately - Introducing filters for developers to extend Related Posts
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
79
  = 1.8.3 - 2020-03-21 =
80
  * New Feature : Filter for related posts background image.
81
  * New Feature : Add option to disable related posts on mobile.
@@ -220,7 +225,7 @@ If there are no images of the specified size in the post, or file does not exist
220
  * tested with Wordpress 3.0
221
 
222
  = 1.2.1 =
223
- * Thanks to <a href="http://www.li-an.fr/wpplugins/">Li-An</a> it now has French version.
224
  * Excerpts will be generated if no excerpt were defined.
225
  * Developer mode to see debugging info in HTML source.
226
 
3
  Donate link: https://wpbrigade.com/
4
  Tags: easy related posts, Related Posts thumbnails, Free Related Posts, related posts, similar related posts
5
  Requires at least: 3.6
6
+ Tested up to: 5.7
7
+ Stable tag: 1.9.0
8
  License: GPLv3 or later
9
+ License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Related Posts by WPBrigade is The Best Customizable plugin, that nicely displays related posts thumbnails under the post.
12
 
25
 
26
  Contributions:
27
 
28
+ * Thanks to <a href="https://adnan.pk/?utm_source=related-posts-lite&utm_medium=readme&utm_campaign=xp">Adnan</a> for giving life to this plugin.
29
 
30
  Translations:
31
 
32
  * This plugin has Russian version
33
+ * Thanks to <a href="https://www.li-an.fr/wpplugins/">Li-An</a> this plugin has French version
34
+ * Thanks to <a href="https://gidibao.net/">Gidibao</a> this plugin has Italian version
35
+ * Thanks to <a href="https://www.kuzublog.com/">Kuzu</a> this plugin has Turkish version
36
+ * Thanks to <a href="https://www.meinblog.de/" title="MeinBlog.de - eigenes Tagebuch">Mirko</a> this plugin has German version
37
+ * Thanks to <a href="https://bejana.com/">Bejana</a> for Indonesian translation
38
 
39
  Related Links:
40
 
57
 
58
  = Does plugin support external images, e.g. uploaded on Flickr? =
59
 
60
+ There is no direct support of external images in the current version of the plugin. You can use custom field option. Or you can use https://wordpress.org/extend/plugins/generate-post-thumbnails/ or similar plugin to save external images as post thumbnails.
61
 
62
  = What is the default image URL? =
63
 
70
  1. Plugin settings page
71
 
72
  == Upgrade Notice ==
73
+ = 1.9.0 =
 
74
  * Please upgrade immediately - Introducing filters for developers to extend Related Posts
75
 
76
  == Changelog ==
77
 
78
+ = 1.9.0 - 2021-03-22 =
79
+ * New Feature : Filter to add custom sizes of thumbnails to choose from.
80
+ * New Feature : added 'rpt_exclude_post' filter to exclude posts from showing as Related Posts.
81
+ * Enhancement : Shortcode attribute to exclude posts from showing as Related Posts.
82
+ * Compatibility : Compatible with WordPress 5.7
83
+
84
  = 1.8.3 - 2020-03-21 =
85
  * New Feature : Filter for related posts background image.
86
  * New Feature : Add option to disable related posts on mobile.
225
  * tested with Wordpress 3.0
226
 
227
  = 1.2.1 =
228
+ * Thanks to <a href="https://www.li-an.fr/wpplugins/">Li-An</a> it now has French version.
229
  * Excerpts will be generated if no excerpt were defined.
230
  * Developer mode to see debugging info in HTML source.
231
 
related-posts-thumbnails.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: WordPress Related Posts Thumbnails
4
  * Plugin URI: https://wpbrigade.com/wordpress/plugins/related-posts/?utm_source=related-posts-lite&utm_medium=plugin-uri&utm_campaign=pro-upgrade-rp
5
  * Description: Showing related posts thumbnails under the posts.
6
- * Version: 1.8.3
7
  * Author: WPBrigade
8
  * Author URI: https://WPBrigade.com/?utm_source=related-posts-lite&utm_medium=author-link&utm_campaign=pro-upgrade-rp
9
  */
10
 
11
  /*
12
- Copyright 2010 - 2020
13
 
14
  This product was first developed by Maria I Shaldybina and later on maintained and developed by Adnan (WPBrigade.com)
15
 
@@ -51,70 +51,50 @@ class RelatedPostsThumbnails {
51
  public $custom_taxonomies = array();
52
  protected $wp_kses_rp_args = array( 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'strong' => array() );
53
 
54
- function __construct() {
55
- $this->constant();
56
- // initialization
57
- load_plugin_textdomain( 'related-posts-thumbnails', false, basename( dirname( __FILE__ ) ) . '/locale' );
58
- $this->default_image = esc_url( plugins_url( 'img/default.png', __FILE__ ) );
 
 
 
59
 
60
- add_action( 'admin_enqueue_scripts', array(
61
- $this,
62
- 'admin_scripts'
63
- ) );
64
 
65
- // Compatibility for old default image path.
66
- if ( $this->is_old_default_img() )
67
- update_option( 'relpoststh_default_image', $this->default_image );
68
 
69
- if ( get_option( 'relpoststh_auto', $this->auto ) ) {
70
- $priority = apply_filters( 'rpt_content_prioirty', 10 ); // Alter priority of the related post content
71
-
72
- if ( $this->prevent_on_editors() ) {
73
- return;
74
- }
75
 
76
- // Disable related posts on mobile view.
77
- if ( wp_is_mobile() && '1' == get_option( 'relpoststh_mobile_view', '0' ) ) {
78
- return;
79
- }
80
 
81
- add_filter( 'the_content', array(
82
- $this,
83
- 'auto_show'
84
- ), $priority );
85
- }
86
 
87
- add_action( 'admin_menu', array(
88
- $this,
89
- 'admin_menu'
90
- ) );
91
 
92
- $this->wp_version = get_bloginfo( 'version' );
93
 
94
- add_action( 'admin_footer', array(
95
- $this,
96
- 'add_deactive_modal'
97
- ) );
98
- add_action( 'wp_ajax_rpt_deactivate', array(
99
- $this,
100
- 'rpt_deactivate'
101
- ) );
102
 
103
- add_action( 'admin_init', array(
104
- $this,
105
- 'review_notice'
106
- ) );
107
- add_action( 'wp_enqueue_scripts', array(
108
- $this,
109
- 'front_scripts'
110
- ) );
111
 
112
- add_action( 'wp_head', array(
113
- $this,
114
- 'head_style'
115
- ) );
 
 
116
 
117
- add_shortcode( 'related-posts-thumbnails', array( $this, 'related_posts_shortcode' ) );
118
  }
119
 
120
  /**
@@ -134,65 +114,97 @@ class RelatedPostsThumbnails {
134
  if ( $value && isset( $_GET['et_fb'] ) ) {
135
  $return = true;
136
  }
137
-
138
- break;
139
  }
140
  }
141
 
142
  return $return;
143
  }
144
 
145
- function related_posts_shortcode( $atts ) {
146
- $atts = shortcode_atts( array(
147
- 'posts_number' => '3',
148
- 'posts_sort' => 'random',
149
- 'main_title' => ''
150
- ), $atts, 'related-posts-thumbnails'
151
- );
152
-
153
- $number = $atts['posts_number'];
154
-
155
- if ( $atts['posts_sort'] == 'random' ) {
156
- $sort = 'rand()';
157
- } elseif ( $atts['posts_sort'] == 'latest' ) {
158
- $sort = 'post_date';
159
- }
160
-
161
- if ( !is_numeric( $number ) ) {
162
- $number = 3;
163
- }
 
 
 
164
 
165
- $main_title = str_replace( '_', ' ', $atts['main_title'] );
 
 
 
 
 
166
 
167
- return $this->get_thumbnails( true, $number, $sort, $main_title );
168
- }
169
 
170
- function admin_scripts( $page ) {
171
- if ( 'toplevel_page_related-posts-thumbnails' === $page ) {
172
- wp_enqueue_media();
173
- wp_enqueue_style( 'rpt_admin_css', plugins_url( 'assets/css/admin.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
174
- wp_enqueue_style( 'jquery-ui', 'http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
175
- wp_enqueue_style( 'wp-color-picker' );
176
- wp_enqueue_script( 'rpt_admin_js', plugins_url( 'assets/js/admin.js', __FILE__ ), array(
177
- 'jquery',
178
- 'wp-color-picker',
179
- 'jquery-ui-datepicker'
180
- ), RELATED_POSTS_THUMBNAILS_VERSION );
181
- }
182
  }
183
 
184
- function front_scripts() {
185
- wp_enqueue_style( 'rpt_front_style', plugins_url( 'assets/css/front.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
186
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
188
- function constant() {
189
- define( 'RELATED_POSTS_THUMBNAILS_VERSION', '1.6.2' );
190
- define( 'RELATED_POSTS_THUMBNAILS_FEEDBACK_SERVER', 'https://wpbrigade.com/' );
191
- define( 'RELATED_POSTS_THUMBNAILS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  /**
195
- * Show the popup on pluing deactivate
196
  *
197
  * @since 1.6.2
198
  */
@@ -208,7 +220,7 @@ class RelatedPostsThumbnails {
208
 
209
 
210
  /**
211
- * Send the user responce to api.
212
  *
213
  * @since 1.6.2
214
  */
@@ -373,9 +385,9 @@ class RelatedPostsThumbnails {
373
  }
374
 
375
  /**
376
- * Check and Dismiss review message.
377
  *
378
- * @since 1.8.2
379
  */
380
  private function review_dismissal() {
381
  //delete_option( 'rpt_review_dismiss' );
@@ -389,6 +401,7 @@ class RelatedPostsThumbnails {
389
 
390
  /**
391
  * [is_old_default_img Check the compatibility for old default image path.]
 
392
  * @return boolean Return true if path is old.
393
  */
394
  function is_old_default_img() {
@@ -401,21 +414,42 @@ class RelatedPostsThumbnails {
401
  }
402
  }
403
 
 
 
 
 
 
 
 
404
  function auto_show( $content ) {
405
- // Automatically displaying related posts under post body
406
  return $content . $this->get_html( true );
407
  }
408
 
 
 
 
 
 
 
409
  function get_html( $show_top = false ) {
410
- // Getting related posts HTML
411
  if ( $this->is_relpoststh_show() ) {
412
  return $this->get_thumbnails( $show_top );
413
  }
414
 
415
  return '';
416
  }
417
-
418
- function get_thumbnails( $show_top = false, $posts_number = '', $sort_by = '', $main_title = '' ) {
 
 
 
 
 
 
 
 
 
 
419
  $output = '';
420
  $debug = 'Developer mode initialisation; Version: 1.2.9;';
421
  $time = microtime( true );
@@ -474,17 +508,17 @@ class RelatedPostsThumbnails {
474
  /* Get object terms */
475
  if ( $relation == 'categories' ) {
476
  $taxonomy = array(
477
- 'category'
478
  );
479
  } elseif ( $relation == 'tags' ) {
480
  $taxonomy = array(
481
- 'post_tag'
482
  );
483
  } elseif ( $relation == 'custom' ) {
484
  $taxonomy = get_option( 'relpoststh_custom_taxonomies', $this->custom_taxonomies );
485
  } else {
486
  $taxonomy = array(
487
- 'category',
488
  'post_tag'
489
  );
490
  }
@@ -529,7 +563,7 @@ class RelatedPostsThumbnails {
529
  $query_objects .= " AND term_taxonomy_id IN ('" . implode( "', '", $filter_taxonomy_a ) . "')";
530
  }
531
  }
532
-
533
  $relationships = $wpdb->get_results( $query_objects );
534
  $related_objects = array();
535
  if ( count( $relationships ) > 0 ) {
@@ -569,7 +603,7 @@ class RelatedPostsThumbnails {
569
  $random_posts = $wpdb->get_results( $query . $join . $where . $limit_order );
570
 
571
  /* Get posts by their IDs */
572
- if ( !is_array( $random_posts ) || count( $random_posts ) < 1 ) {
573
  $output = '';
574
  return $this->finish_process( $output, $debug . __( 'No posts matching relationships criteria;' ), $time );
575
  }
@@ -580,8 +614,31 @@ class RelatedPostsThumbnails {
580
  $posts_in[] = $random_post->ID;
581
  }
582
 
583
- $query = "SELECT ID, post_content, post_excerpt, post_title FROM $wpdb->posts WHERE ID IN ('" . implode( "', '", $posts_in ) . "') $order_query ";
584
- $posts = $wpdb->get_results( $query );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
 
586
  if ( !( is_array( $posts ) && count( $posts ) > 0 ) ) { // no posts
587
  $debug .= 'No posts found;';
@@ -596,7 +653,8 @@ class RelatedPostsThumbnails {
596
  $debug .= 'Custom sizes;';
597
  $width = get_option( 'relpoststh_customwidth', $this->custom_width );
598
  $height = get_option( 'relpoststh_customheight', $this->custom_height );
599
- } else { // post-thumbnails source
 
600
  if ( $poststhname == 'thumbnail' || $poststhname == 'medium' || $poststhname == 'large' ) { // get thumbnail size for basic sizes
601
  $debug .= 'Basic sizes;';
602
  $width = get_option( "{$poststhname}_size_w" );
@@ -632,14 +690,13 @@ class RelatedPostsThumbnails {
632
  $debug .= 'Got sizes ' . $width . 'x' . $height . ';';
633
 
634
  // rendering related posts HTML
635
-
636
  if ( $show_top ) {
637
- if ( ! empty( $main_title ) ) {
638
- $output .= '<p class="relpoststh-block-title">' . $main_title . '</p>';
639
- } else {
640
- $top_text = stripslashes( get_option( 'relpoststh_top_text', $this->top_text ) );
641
- $output .= stripslashes ( apply_filters( 'rpt_top_text', $top_text ) );
642
- }
643
  }
644
 
645
  $relpoststh_output_style = get_option( 'relpoststh_output_style', $this->output_style );
@@ -668,106 +725,106 @@ class RelatedPostsThumbnails {
668
  }
669
 
670
  foreach ( $posts as $post ) {
671
- $image = '';
672
- $url = '';
673
- $alt = '';
674
 
675
- if ( $thsource == 'custom-field' ) {
676
- $custom_field = get_option( 'relpoststh_customfield', $this->custom_field );
677
- $custom_field_meta = get_post_meta( $post->ID, $custom_field, true );
678
-
679
- if ( empty( $custom_field ) ) {
680
- $debug .= 'No custom field specifield, using default thumbnail image;';
681
- $url = $this->default_image;
682
- } elseif ( empty( $custom_field_meta ) && apply_filters( 'rpt_remove_empty_cfield', false ) ) {
683
- $debug .= 'Custom field meta is empty, using rpt_remove_empty_cfield filter;';
684
- continue;
685
- } elseif ( empty( $custom_field_meta ) ) {
686
- $debug .= 'Custom field meta is empty, using default thumbnail image;';
687
- $url = $this->default_image;
688
- } else {
689
- $debug .= 'Using custom field;';
690
- $url = $custom_field_meta;
691
- $theme_resize_url = get_option( 'relpoststh_theme_resize_url', '' );
692
-
693
- if ( strpos( $url, '/wp-content' ) !== false ) {
694
- $url = substr( $url, strpos( $url, '/wp-content' ) );
695
- }
696
-
697
- if ( !empty( $theme_resize_url ) ) {
698
- $url = $theme_resize_url . '?src=' . $url . '&w=' . $width . '&h=' . $height . '&zc=1&q=90';
699
- }
700
- }
701
- } else {
702
- $from_post_body = true;
703
- if ( current_theme_supports( 'post-thumbnails' ) ) { // using built in Wordpress feature
704
- $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
705
- $debug .= 'Post-thumbnails enabled in theme;';
706
- if ( !( empty( $post_thumbnail_id ) || $post_thumbnail_id === false ) ) { // post has thumbnail
707
- $debug .= 'Post has thumbnail ' . $post_thumbnail_id . ';';
708
- $debug .= 'Postthname: ' . $poststhname . ';';
709
- $image = wp_get_attachment_image_src( $post_thumbnail_id, $poststhname );
710
- $alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
711
- $url = $image[ 0 ];
712
- $from_post_body = false;
713
- } else {
714
- $debug .= 'Post has no thumbnail;';
715
- }
716
- }
717
-
718
- // Theme does not support post-thumbnails, or post does not have assigned thumbnail
719
- if ( $from_post_body ) {
720
- $debug .= 'Getting image from post body;';
721
- $wud = wp_upload_dir();
722
-
723
- // search the first uploaded image in content
724
- preg_match_all( '|<img.*?src=[\'"](' . $wud[ 'baseurl' ] . '.*?)[\'"].*?>|i', $post->post_content, $matches );
725
-
726
- if ( isset( $matches ) && isset( $matches[ 1 ][ 0 ] ) ) {
727
- $image = $matches[ 1 ][ 0 ];
728
- $html = $matches[ 0 ][ 0 ];
729
-
730
- if ( !empty( $html ) ) {
731
- preg_match( '/alt="([^"]*)"/i', $html, $array );
732
-
733
- if ( !empty( $array ) && is_array( $array ) ) {
734
- $explode_tag = explode( '"', $array[ 0 ] );
735
- $alt = $explode_tag[ 1 ];
736
- }
737
- }
738
-
739
- } else {
740
- $debug .= 'No image was found;';
741
- }
742
-
743
- if ( strlen( trim( $image ) ) > 0 ) {
744
- $image_sizes = @getimagesize( $image );
745
-
746
- if ( $image_sizes === false ) {
747
- $debug .= 'Unable to determine parsed image size';
748
- }
749
-
750
- if ( ( $image_sizes !== false && isset( $image_sizes[ 0 ] ) ) && $image_sizes[ 0 ] == $width ) {
751
- // if this image is the same size
752
- $debug .= 'Image used is the required size;';
753
- $url = $image;
754
- }
755
- elseif ( apply_filters( 'rpt_prevent_img_size_check', false ) && $image_sizes[ 0 ] < $width ) {
756
- // if this image is samll than required size
757
- $debug .= 'Image used is smaller than the required size, rpt_prevent_img_size_check filter is active;';
758
- $url = $image;
759
- }
760
- else {
761
- // search for resized thumbnail according to Wordpress thumbnails naming function
762
- $debug .= 'Changing image according to Wordpress standards;';
763
- $url = preg_replace( '/(-[0-9]+x[0-9]+)?(\.[^\.]*)$/', '-' . $width . 'x' . $height . '$2', $image );
764
- }
765
-
766
- } else {
767
- $debug .= 'Found wrong formatted image: ' . $image . ';';
768
- }
769
 
 
 
 
 
 
 
 
 
 
 
770
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
771
  }
772
 
773
  if ( strpos( $url, '/' ) === 0 ) {
@@ -823,15 +880,15 @@ class RelatedPostsThumbnails {
823
  $output .= '/></a>';
824
 
825
  if ( $text_height != '0' ) {
826
- $output .= '<a href="' . $link . '" class="relpost_content"';
827
 
828
- if ( !$relpoststh_cleanhtml ) {
829
- $output .= ' style="width: ' . $width . 'px;height: ' . $text_height . 'px; font-family: ' . $fontface . '; "';
830
- }
831
 
832
- // $output .= '><span class="rpth_list_content">' . $title . $excerpt . '</span>' . $date . '</a></li>';
833
- $output .= '><span class="rpth_list_content">' . $title . $excerpt . '</span>' . $after_content . '</a></li>';
834
- }
835
  } else {
836
  $rpt_single_background = apply_filters( 'rpt-single-background', 'background: transparent url(' . esc_url( $url ) . ') no-repeat scroll 0% 0%; width: ' . $width . 'px; height: ' . $height . 'px;' );
837
 
@@ -844,7 +901,7 @@ class RelatedPostsThumbnails {
844
  $output .= '</div>';
845
  $output .= '</a>';
846
  }
847
- }
848
 
849
  } // end foreach
850
  if ( $relpoststh_output_style == 'list' ) {
@@ -878,6 +935,15 @@ class RelatedPostsThumbnails {
878
  // return $response['response']['code'];
879
  // }
880
 
 
 
 
 
 
 
 
 
 
881
  function finish_process( $output, $debug, $time ) {
882
  $devmode = get_option( 'relpoststh_devmode', $this->devmode );
883
  if ( $devmode ) {
@@ -901,18 +967,23 @@ class RelatedPostsThumbnails {
901
  }
902
  }
903
 
 
 
 
 
 
904
  function is_relpoststh_show() {
905
  // Checking display options
906
  if ( !is_single() && get_option( 'relpoststh_single_only', $this->single_only ) ) { // single only
907
  return false;
908
  }
909
- /* Check post type */
910
  $post_types = get_option( 'relpoststh_post_types', $this->post_types );
911
  $post_type = get_post_type();
912
  if ( !in_array( $post_type, $post_types ) ) {
913
  return false;
914
  }
915
- /* Check categories */
916
  $id = get_the_ID();
917
  $categories_all = get_option( 'relpoststh_categoriesall', $this->categories_all );
918
  if ( $categories_all != '1' ) { // only specific categories were selected
@@ -933,107 +1004,90 @@ class RelatedPostsThumbnails {
933
  return true;
934
  }
935
 
 
 
 
 
 
936
  function admin_menu() {
937
- $page = add_menu_page( __( 'Related Posts Thumbnails', 'related-posts-thumbnails' ), __( 'Related Posts', 'related-posts-thumbnails' ), 'administrator', 'related-posts-thumbnails', array(
938
- $this,
939
- 'admin_interface'
940
- ), 'dashicons-screenoptions' );
941
  }
942
 
 
 
 
 
 
943
  function admin_interface() {
944
  include_once RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . '/inc/rpt-settings.php';
945
  }
946
-
 
 
 
 
 
 
 
 
947
  function display_categories_list( $categoriesall, $categories, $selected_categories, $all_name, $specific_name ) { ?>
948
- <input id="<?php
949
- echo $all_name;
950
- ?>" class="select_all" type="checkbox" name="<?php
951
- echo $all_name;
952
- ?>" value="1" <?php
953
- if ( $categoriesall == '1' ) {
954
- echo 'checked="checked"';
955
- }
956
- ?>/>
957
- <label for="<?php
958
- echo $all_name;
959
- ?>"><?php
960
- _e( 'All', 'related-posts-thumbnails' );
961
- ?></label>
962
  <div class="select_specific" <?php
963
- if ( $categoriesall == '1' ):
964
- ?> style="display:none" <?php
965
- endif;
966
- ?>>
967
- <?php
968
- foreach ( $categories as $category ):
969
- ?>
970
- <input type="checkbox" name="<?php
971
- echo $specific_name;
972
- ?>[]" id="<?php
973
- echo $specific_name;
974
- ?>_<?php
975
- echo $category->category_nicename;
976
- ?>" value="<?php
977
- echo $category->cat_ID;
978
- ?>" <?php
979
- if ( in_array( $category->cat_ID, (array) $selected_categories ) ) {
980
- echo 'checked="checked"';
981
- }
982
- ?>/>
983
- <label for="<?php
984
- echo $specific_name;
985
- ?>_<?php
986
- echo $category->category_nicename;
987
- ?>"><?php
988
- echo $category->cat_name;
989
- ?></label><br />
990
- <?php
991
  endforeach;
992
  ?>
993
  </div>
994
 
995
  <?php
996
  }
997
-
 
 
 
 
998
  function head_style() { ?>
999
  <style>
1000
  #related_posts_thumbnails li{
1001
- border-right: 1px solid <?php
1002
- echo get_option( 'relpoststh_bordercolor', $this->border_color );
1003
- ?>;
1004
- background-color: <?php
1005
- echo get_option( 'relpoststh_background', $this->background );
1006
- ?>
1007
  }
1008
  #related_posts_thumbnails li:hover{
1009
- background-color: <?php
1010
- echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground );
1011
- ?>;
1012
  }
1013
  .relpost_content{
1014
- font-size: <?php
1015
- echo get_option( 'relpoststh_fontsize', $this->font_size ) . 'px';
1016
- ?>;
1017
- color: <?php
1018
- echo get_option( 'relpoststh_fontcolor', $this->font_color );
1019
- ?>;
1020
  }
1021
  .relpost-block-single{
1022
- background-color: <?php
1023
- echo get_option( 'relpoststh_background', $this->background );
1024
- ?>;
1025
- border-right: 1px solid <?php
1026
- echo get_option( 'relpoststh_bordercolor', $this->border_color );
1027
- ?>;
1028
- border-left: 1px solid <?php
1029
- echo get_option( 'relpoststh_bordercolor', $this->border_color );
1030
- ?>;
1031
  margin-right: -1px;
1032
  }
1033
  .relpost-block-single:hover{
1034
- background-color: <?php
1035
- echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground );
1036
- ?>;
1037
  }
1038
  </style>
1039
 
@@ -1041,6 +1095,10 @@ class RelatedPostsThumbnails {
1041
  }
1042
  }
1043
 
 
 
 
 
1044
  add_action( 'init', 'related_posts_thumbnails' );
1045
 
1046
  function related_posts_thumbnails() {
3
  * Plugin Name: WordPress Related Posts Thumbnails
4
  * Plugin URI: https://wpbrigade.com/wordpress/plugins/related-posts/?utm_source=related-posts-lite&utm_medium=plugin-uri&utm_campaign=pro-upgrade-rp
5
  * Description: Showing related posts thumbnails under the posts.
6
+ * Version: 1.9.0
7
  * Author: WPBrigade
8
  * Author URI: https://WPBrigade.com/?utm_source=related-posts-lite&utm_medium=author-link&utm_campaign=pro-upgrade-rp
9
  */
10
 
11
  /*
12
+ Copyright 2010 - 2021
13
 
14
  This product was first developed by Maria I Shaldybina and later on maintained and developed by Adnan (WPBrigade.com)
15
 
51
  public $custom_taxonomies = array();
52
  protected $wp_kses_rp_args = array( 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'strong' => array() );
53
 
54
+ /**
55
+ * Function Constructor
56
+ */
57
+ function __construct() {
58
+ $this->constant();
59
+ // Load text domain for translation
60
+ load_plugin_textdomain( 'related-posts-thumbnails', false, basename( dirname( __FILE__ ) ) . '/locale' );
61
+ $this->default_image = esc_url( plugins_url( 'img/default.png', __FILE__ ) );
62
 
63
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
 
 
 
64
 
65
+ // Compatibility for old default image path.
66
+ if ( $this->is_old_default_img() )
67
+ update_option( 'relpoststh_default_image', $this->default_image );
68
 
69
+ if ( get_option( 'relpoststh_auto', $this->auto ) ) {
70
+ $priority = apply_filters( 'rpt_content_prioirty', 10 ); // Alter priority of the related post content
 
 
 
 
71
 
72
+ if ( $this->prevent_on_editors() ) {
73
+ return;
74
+ }
 
75
 
76
+ // Disable related posts on mobile view.
77
+ if ( wp_is_mobile() && '1' == get_option( 'relpoststh_mobile_view', '0' ) ) {
78
+ return;
79
+ }
 
80
 
81
+ add_filter( 'the_content', array( $this, 'auto_show' ), $priority );
82
+ }
 
 
83
 
84
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
85
 
86
+ $this->wp_version = get_bloginfo( 'version' );
 
 
 
 
 
 
 
87
 
88
+ add_action( 'admin_footer', array( $this, 'add_deactive_modal' ) );
89
+ add_action( 'wp_ajax_rpt_deactivate', array( $this, 'rpt_deactivate' ) );
 
 
 
 
 
 
90
 
91
+ add_action( 'admin_init', array( $this, 'review_notice' ) );
92
+ add_action( 'wp_enqueue_scripts', array( $this, 'front_scripts' ) );
93
+
94
+ add_action( 'wp_head', array( $this, 'head_style' ) );
95
+
96
+ add_shortcode( 'related-posts-thumbnails', array( $this, 'related_posts_shortcode' ) );
97
 
 
98
  }
99
 
100
  /**
114
  if ( $value && isset( $_GET['et_fb'] ) ) {
115
  $return = true;
116
  }
117
+ break;
 
118
  }
119
  }
120
 
121
  return $return;
122
  }
123
 
124
+ /**
125
+ * callback for shortcode related_posts_shortcode
126
+ *
127
+ * @param array $atts attributes of shortcode
128
+ * @version 1.9.0
129
+ */
130
+ function related_posts_shortcode( $atts ) {
131
+ $atts = shortcode_atts( array(
132
+ 'posts_number' => '3',
133
+ 'posts_sort' => 'random',
134
+ 'main_title' => '',
135
+ 'exclude_post' => ''
136
+ ), $atts, 'related-posts-thumbnails'
137
+ );
138
+
139
+ $number = $atts['posts_number'];
140
+
141
+ if ( $atts['posts_sort'] == 'random' ) {
142
+ $sort = 'rand()';
143
+ } elseif ( $atts['posts_sort'] == 'latest' ) {
144
+ $sort = 'post_date';
145
+ }
146
 
147
+ //sanitization through regex expression to know if a string is consisting of numeric values.
148
+ $regex = '/^\d+(?:,\d+)*$/';
149
+ $excluded_posts_array = preg_match( $regex, $atts['exclude_post'] ) ? $atts['exclude_post'] : array();
150
+ if ( !is_numeric( $number ) ) {
151
+ $number = 3;
152
+ }
153
 
154
+ $main_title = str_replace( '_', ' ', $atts['main_title'] );
 
155
 
156
+ return $this->get_thumbnails( true, $number, $sort, $main_title, $excluded_posts_array );
157
+
 
 
 
 
 
 
 
 
 
 
158
  }
159
 
160
+ /**
161
+ * Function to enqueue admin styles and scripts.
162
+ *
163
+ * @param $page
164
+ * @return void
165
+ * @since 1.7.0
166
+ * @version 1.9.0
167
+ *
168
+ */
169
+ function admin_scripts( $page ) {
170
+ if ( 'toplevel_page_related-posts-thumbnails' === $page ) {
171
+ wp_enqueue_media();
172
+ wp_enqueue_style( 'rpt_admin_css', plugins_url( 'assets/css/admin.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
173
+ wp_enqueue_style( 'jquery-ui', 'https://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
174
+ wp_enqueue_style( 'wp-color-picker' );
175
+ wp_enqueue_script( 'rpt_admin_js', plugins_url( 'assets/js/admin.js', __FILE__ ), array(
176
+ 'jquery',
177
+ 'wp-color-picker',
178
+ 'jquery-ui-datepicker'
179
+ ), RELATED_POSTS_THUMBNAILS_VERSION );
180
+ }
181
+ }
182
 
183
+ /**
184
+ * Function to enqueue front styles and scripts.
185
+ *
186
+ * @param $page
187
+ * @return void
188
+ * @since 1.7.0
189
+ * @version 1.9.0
190
+ *
191
+ */
192
+ function front_scripts() {
193
+ wp_enqueue_style( 'rpt_front_style', plugins_url( 'assets/css/front.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
194
+ }
195
+ /**
196
+ * Function to define plugin Constants
197
+ *
198
+ * @return void
199
+ */
200
+ function constant() {
201
+ define( 'RELATED_POSTS_THUMBNAILS_VERSION', '1.9.0' );
202
+ define( 'RELATED_POSTS_THUMBNAILS_FEEDBACK_SERVER', 'https://wpbrigade.com/' );
203
+ define( 'RELATED_POSTS_THUMBNAILS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
204
+ }
205
 
206
  /**
207
+ * Show the popup modal on plugin deactivate
208
  *
209
  * @since 1.6.2
210
  */
220
 
221
 
222
  /**
223
+ * Send the deactivate user response to api.
224
  *
225
  * @since 1.6.2
226
  */
385
  }
386
 
387
  /**
388
+ * Check and Dismiss review message.
389
  *
390
+ * @since 1.8.2
391
  */
392
  private function review_dismissal() {
393
  //delete_option( 'rpt_review_dismiss' );
401
 
402
  /**
403
  * [is_old_default_img Check the compatibility for old default image path.]
404
+ *
405
  * @return boolean Return true if path is old.
406
  */
407
  function is_old_default_img() {
414
  }
415
  }
416
 
417
+ /**
418
+ * Automatically displaying related posts under post body
419
+ *
420
+ * @param $content
421
+ *
422
+ * @return void
423
+ */
424
  function auto_show( $content ) {
 
425
  return $content . $this->get_html( true );
426
  }
427
 
428
+ /**
429
+ * Getting related posts HTML
430
+ *
431
+ * @param boolean $show_top
432
+ *
433
+ */
434
  function get_html( $show_top = false ) {
 
435
  if ( $this->is_relpoststh_show() ) {
436
  return $this->get_thumbnails( $show_top );
437
  }
438
 
439
  return '';
440
  }
441
+ /**
442
+ * function responsible for Thumbnail creation
443
+ *
444
+ * @param boolean $show_top Position of the thumbnails
445
+ * @param string $posts_number Number of posts to display
446
+ * @param string $sort_by sort the thumbnails by
447
+ * @param string $main_title thumbnail title
448
+ * @param string $exclude post_ids to exclude from related posts thumbnails
449
+ *
450
+ * @return void
451
+ */
452
+ function get_thumbnails( $show_top = false, $posts_number = '', $sort_by = '', $main_title = '', $exclude ='' ) {
453
  $output = '';
454
  $debug = 'Developer mode initialisation; Version: 1.2.9;';
455
  $time = microtime( true );
508
  /* Get object terms */
509
  if ( $relation == 'categories' ) {
510
  $taxonomy = array(
511
+ 'category'
512
  );
513
  } elseif ( $relation == 'tags' ) {
514
  $taxonomy = array(
515
+ 'post_tag'
516
  );
517
  } elseif ( $relation == 'custom' ) {
518
  $taxonomy = get_option( 'relpoststh_custom_taxonomies', $this->custom_taxonomies );
519
  } else {
520
  $taxonomy = array(
521
+ 'category',
522
  'post_tag'
523
  );
524
  }
563
  $query_objects .= " AND term_taxonomy_id IN ('" . implode( "', '", $filter_taxonomy_a ) . "')";
564
  }
565
  }
566
+
567
  $relationships = $wpdb->get_results( $query_objects );
568
  $related_objects = array();
569
  if ( count( $relationships ) > 0 ) {
603
  $random_posts = $wpdb->get_results( $query . $join . $where . $limit_order );
604
 
605
  /* Get posts by their IDs */
606
+ if ( !is_array( $random_posts ) || count( $random_posts ) < 1 ) {
607
  $output = '';
608
  return $this->finish_process( $output, $debug . __( 'No posts matching relationships criteria;' ), $time );
609
  }
614
  $posts_in[] = $random_post->ID;
615
  }
616
 
617
+ if( $exclude == ! "" ) {
618
+
619
+ $exclude_post_ids = explode( ",", $exclude );
620
+ $posts_in = array_diff( $posts_in, $exclude_post_ids );
621
+
622
+ }
623
+ /**
624
+ *
625
+ * Filter rpt_exclude_post to exclude post from RPT thumbnails
626
+ *
627
+ * @since 1.9.0
628
+ *
629
+ */
630
+ $exclude_by_filter = apply_filters( 'rpt_exclude_post', '' );
631
+
632
+ if( $exclude_by_filter !== '' ) {
633
+ $regex = '/^\d+(?:,\d+)*$/';
634
+ $exclude_by_filter = preg_match( $regex, $exclude_by_filter ) ? $exclude_by_filter : array();
635
+ $exclude_by_filter_ids = explode( ",", $exclude_by_filter );
636
+ $posts_in = array_diff( $posts_in, $exclude_by_filter_ids );
637
+
638
+ }
639
+
640
+ $query = "SELECT ID, post_content, post_excerpt, post_title FROM $wpdb->posts WHERE ID IN ('" . implode( "', '", $posts_in ) . "') $order_query ";
641
+ $posts = $wpdb->get_results( $query );
642
 
643
  if ( !( is_array( $posts ) && count( $posts ) > 0 ) ) { // no posts
644
  $debug .= 'No posts found;';
653
  $debug .= 'Custom sizes;';
654
  $width = get_option( 'relpoststh_customwidth', $this->custom_width );
655
  $height = get_option( 'relpoststh_customheight', $this->custom_height );
656
+ } else {
657
+ // post-thumbnails source
658
  if ( $poststhname == 'thumbnail' || $poststhname == 'medium' || $poststhname == 'large' ) { // get thumbnail size for basic sizes
659
  $debug .= 'Basic sizes;';
660
  $width = get_option( "{$poststhname}_size_w" );
690
  $debug .= 'Got sizes ' . $width . 'x' . $height . ';';
691
 
692
  // rendering related posts HTML
 
693
  if ( $show_top ) {
694
+ if ( ! empty( $main_title ) ) {
695
+ $output .= '<p class="relpoststh-block-title">' . $main_title . '</p>';
696
+ } else {
697
+ $top_text = stripslashes( get_option( 'relpoststh_top_text', $this->top_text ) );
698
+ $output .= stripslashes ( apply_filters( 'rpt_top_text', $top_text ) );
699
+ }
700
  }
701
 
702
  $relpoststh_output_style = get_option( 'relpoststh_output_style', $this->output_style );
725
  }
726
 
727
  foreach ( $posts as $post ) {
728
+ $image = '';
729
+ $url = '';
730
+ $alt = '';
731
 
732
+ if ( $thsource == 'custom-field' ) {
733
+ $custom_field = get_option( 'relpoststh_customfield', $this->custom_field );
734
+ $custom_field_meta = get_post_meta( $post->ID, $custom_field, true );
735
+
736
+ if ( empty( $custom_field ) ) {
737
+ $debug .= 'No custom field specifield, using default thumbnail image;';
738
+ $url = $this->default_image;
739
+ } elseif ( empty( $custom_field_meta ) && apply_filters( 'rpt_remove_empty_cfield', false ) ) {
740
+ $debug .= 'Custom field meta is empty, using rpt_remove_empty_cfield filter;';
741
+ continue;
742
+ } elseif ( empty( $custom_field_meta ) ) {
743
+ $debug .= 'Custom field meta is empty, using default thumbnail image;';
744
+ $url = $this->default_image;
745
+ } else {
746
+ $debug .= 'Using custom field;';
747
+ $url = $custom_field_meta;
748
+ $theme_resize_url = get_option( 'relpoststh_theme_resize_url', '' );
749
+
750
+ if ( strpos( $url, '/wp-content' ) !== false ) {
751
+ $url = substr( $url, strpos( $url, '/wp-content' ) );
752
+ }
753
+
754
+ if ( !empty( $theme_resize_url ) ) {
755
+ $url = $theme_resize_url . '?src=' . $url . '&w=' . $width . '&h=' . $height . '&zc=1&q=90';
756
+ }
757
+ }
758
+ } else {
759
+ $from_post_body = true;
760
+ if ( current_theme_supports( 'post-thumbnails' ) ) { // using built in Wordpress feature
761
+ $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
762
+ $debug .= 'Post-thumbnails enabled in theme;';
763
+ if ( !( empty( $post_thumbnail_id ) || $post_thumbnail_id === false ) ) { // post has thumbnail
764
+ $debug .= 'Post has thumbnail ' . $post_thumbnail_id . ';';
765
+ $debug .= 'Postthname: ' . $poststhname . ';';
766
+ $image = wp_get_attachment_image_src( $post_thumbnail_id, $poststhname );
767
+ $alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
768
+ $url = $image[ 0 ];
769
+ $from_post_body = false;
770
+ } else {
771
+ $debug .= 'Post has no thumbnail;';
772
+ }
773
+ }
774
+
775
+ // Theme does not support post-thumbnails, or post does not have assigned thumbnail
776
+ if ( $from_post_body ) {
777
+ $debug .= 'Getting image from post body;';
778
+ $wud = wp_upload_dir();
779
+
780
+ // search the first uploaded image in content
781
+ preg_match_all( '|<img.*?src=[\'"](' . $wud[ 'baseurl' ] . '.*?)[\'"].*?>|i', $post->post_content, $matches );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
782
 
783
+ if ( isset( $matches ) && isset( $matches[ 1 ][ 0 ] ) ) {
784
+ $image = $matches[ 1 ][ 0 ];
785
+ $html = $matches[ 0 ][ 0 ];
786
+
787
+ if ( !empty( $html ) ) {
788
+ preg_match( '/alt="([^"]*)"/i', $html, $array );
789
+
790
+ if ( !empty( $array ) && is_array( $array ) ) {
791
+ $explode_tag = explode( '"', $array[ 0 ] );
792
+ $alt = $explode_tag[ 1 ];
793
  }
794
+ }
795
+
796
+ } else {
797
+ $debug .= 'No image was found;';
798
+ }
799
+
800
+ if ( strlen( trim( $image ) ) > 0 ) {
801
+ $image_sizes = @getimagesize( $image );
802
+
803
+ if ( $image_sizes === false ) {
804
+ $debug .= 'Unable to determine parsed image size';
805
+ }
806
+
807
+ if ( ( $image_sizes !== false && isset( $image_sizes[ 0 ] ) ) && $image_sizes[ 0 ] == $width ) {
808
+ // if this image is the same size
809
+ $debug .= 'Image used is the required size;';
810
+ $url = $image;
811
+ }
812
+ elseif ( apply_filters( 'rpt_prevent_img_size_check', false ) && $image_sizes[ 0 ] < $width ) {
813
+ // if this image is samll than required size
814
+ $debug .= 'Image used is smaller than the required size, rpt_prevent_img_size_check filter is active;';
815
+ $url = $image;
816
+ }
817
+ else {
818
+ // search for resized thumbnail according to Wordpress thumbnails naming function
819
+ $debug .= 'Changing image according to Wordpress standards;';
820
+ $url = preg_replace( '/(-[0-9]+x[0-9]+)?(\.[^\.]*)$/', '-' . $width . 'x' . $height . '$2', $image );
821
+ }
822
+
823
+ } else {
824
+ $debug .= 'Found wrong formatted image: ' . $image . ';';
825
+ }
826
+
827
+ }
828
  }
829
 
830
  if ( strpos( $url, '/' ) === 0 ) {
880
  $output .= '/></a>';
881
 
882
  if ( $text_height != '0' ) {
883
+ $output .= '<a href="' . $link . '" class="relpost_content"';
884
 
885
+ if ( !$relpoststh_cleanhtml ) {
886
+ $output .= ' style="width: ' . $width . 'px;height: ' . $text_height . 'px; font-family: ' . $fontface . '; "';
887
+ }
888
 
889
+ // $output .= '><span class="rpth_list_content">' . $title . $excerpt . '</span>' . $date . '</a></li>';
890
+ $output .= '><span class="rpth_list_content">' . $title . $excerpt . '</span>' . $after_content . '</a></li>';
891
+ }
892
  } else {
893
  $rpt_single_background = apply_filters( 'rpt-single-background', 'background: transparent url(' . esc_url( $url ) . ') no-repeat scroll 0% 0%; width: ' . $width . 'px; height: ' . $height . 'px;' );
894
 
901
  $output .= '</div>';
902
  $output .= '</a>';
903
  }
904
+ }
905
 
906
  } // end foreach
907
  if ( $relpoststh_output_style == 'list' ) {
935
  // return $response['response']['code'];
936
  // }
937
 
938
+ /**
939
+ * This will add debugging information in HTML source
940
+ *
941
+ * @param $output
942
+ * @param $debug
943
+ * @param int $time time took to create the thumbnails
944
+ *
945
+ * @return $output debugged information
946
+ */
947
  function finish_process( $output, $debug, $time ) {
948
  $devmode = get_option( 'relpoststh_devmode', $this->devmode );
949
  if ( $devmode ) {
967
  }
968
  }
969
 
970
+ /**
971
+ * Function to check th options to show the thumbnails according to the post types, categories etc.
972
+ *
973
+ * @return boolean
974
+ */
975
  function is_relpoststh_show() {
976
  // Checking display options
977
  if ( !is_single() && get_option( 'relpoststh_single_only', $this->single_only ) ) { // single only
978
  return false;
979
  }
980
+ // Check post type
981
  $post_types = get_option( 'relpoststh_post_types', $this->post_types );
982
  $post_type = get_post_type();
983
  if ( !in_array( $post_type, $post_types ) ) {
984
  return false;
985
  }
986
+ // Check categories
987
  $id = get_the_ID();
988
  $categories_all = get_option( 'relpoststh_categoriesall', $this->categories_all );
989
  if ( $categories_all != '1' ) { // only specific categories were selected
1004
  return true;
1005
  }
1006
 
1007
+ /**
1008
+ * Admin Menu page
1009
+ *
1010
+ * @return void
1011
+ */
1012
  function admin_menu() {
1013
+ $page = add_menu_page( __( 'Related Posts Thumbnails', 'related-posts-thumbnails' ), __( 'Related Posts', 'related-posts-thumbnails' ), 'administrator', 'related-posts-thumbnails', array( $this, 'admin_interface' ), 'dashicons-screenoptions' );
 
 
 
1014
  }
1015
 
1016
+ /**
1017
+ * Related post thumbnail settings page load
1018
+ *
1019
+ * @return void
1020
+ */
1021
  function admin_interface() {
1022
  include_once RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . '/inc/rpt-settings.php';
1023
  }
1024
+ /**
1025
+ * Category List in Settings
1026
+ *
1027
+ * @param $categoriesall
1028
+ * @param $categories
1029
+ * @param $selected_categories
1030
+ * @param $all_name
1031
+ * @param $specific_name
1032
+ */
1033
  function display_categories_list( $categoriesall, $categories, $selected_categories, $all_name, $specific_name ) { ?>
1034
+ <input id="<?php echo $all_name; ?>" class="select_all" type="checkbox" name="<?php echo $all_name; ?>" value="1" <?php
1035
+ if ( $categoriesall == '1' ) {
1036
+ echo 'checked="checked"';
1037
+ } ?>
1038
+ />
1039
+ <label for="<?php echo $all_name; ?>">
1040
+ <?php _e( 'All', 'related-posts-thumbnails' ); ?>
1041
+ </label>
 
 
 
 
 
 
1042
  <div class="select_specific" <?php
1043
+ if ( $categoriesall == '1' ): ?>
1044
+ style="display:none"
1045
+ <?php endif; ?> >
1046
+ <?php foreach ( $categories as $category ): ?>
1047
+ <input type="checkbox" name="<?php echo $specific_name; ?>[]" id="<?php echo $specific_name; ?>_<?php echo $category->category_nicename;
1048
+ ?>" value="<?php echo $category->cat_ID; ?>"
1049
+ <?php
1050
+ if ( in_array( $category->cat_ID, (array) $selected_categories ) ) {
1051
+ echo 'checked="checked"';
1052
+ }
1053
+ ?>/>
1054
+ <label for="<?php echo $specific_name; ?>_<?php echo $category->category_nicename; ?>">
1055
+ <?php echo $category->cat_name; ?>
1056
+ </label>
1057
+ <br />
1058
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
1059
  endforeach;
1060
  ?>
1061
  </div>
1062
 
1063
  <?php
1064
  }
1065
+ /**
1066
+ * Related posts Thumbnails styling.
1067
+ *
1068
+ * @return void
1069
+ */
1070
  function head_style() { ?>
1071
  <style>
1072
  #related_posts_thumbnails li{
1073
+ border-right: 1px solid <?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>;
1074
+ background-color: <?php echo get_option( 'relpoststh_background', $this->background ); ?>
 
 
 
 
1075
  }
1076
  #related_posts_thumbnails li:hover{
1077
+ background-color: <?php echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground ); ?>;
 
 
1078
  }
1079
  .relpost_content{
1080
+ font-size: <?php echo get_option( 'relpoststh_fontsize', $this->font_size ) . 'px'; ?>;
1081
+ color: <?php echo get_option( 'relpoststh_fontcolor', $this->font_color ); ?>;
 
 
 
 
1082
  }
1083
  .relpost-block-single{
1084
+ background-color: <?php echo get_option( 'relpoststh_background', $this->background ); ?>;
1085
+ border-right: 1px solid <?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>;
1086
+ border-left: 1px solid <?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>;
 
 
 
 
 
 
1087
  margin-right: -1px;
1088
  }
1089
  .relpost-block-single:hover{
1090
+ background-color: <?php echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground ); ?>;
 
 
1091
  }
1092
  </style>
1093
 
1095
  }
1096
  }
1097
 
1098
+ /**
1099
+ *
1100
+ * Create the Object of Related Posts thumbnails.
1101
+ */
1102
  add_action( 'init', 'related_posts_thumbnails' );
1103
 
1104
  function related_posts_thumbnails() {