Version Description
- Please upgrade immediately
=
Download this release
Release Info
Developer | hiddenpearls |
Plugin | Related Posts Thumbnails Plugin for WordPress |
Version | 1.6.3 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 1.6.3
- assets/css/admin.css +14 -0
- assets/css/front.css +20 -1
- assets/js/admin.js +47 -0
- inc/rpt-settings.php +71 -38
- inc/rpt-widget.php +1 -1
- readme.txt +16 -3
- related-posts-thumbnails.php +32 -15
assets/css/admin.css
CHANGED
@@ -193,3 +193,17 @@
|
|
193 |
.rpt-top-bar-content p{
|
194 |
margin: 0;
|
195 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
assets/css/front.css
CHANGED
@@ -120,6 +120,7 @@
|
|
120 |
margin-right: -1px;
|
121 |
margin-bottom: 5px;
|
122 |
overflow: hidden;
|
|
|
123 |
}
|
124 |
.relpost-block-single-image{
|
125 |
border: 0 none ;
|
@@ -128,7 +129,7 @@
|
|
128 |
-moz-background-clip: border;
|
129 |
-moz-background-origin: padding;
|
130 |
-moz-background-inline-policy: continuous;
|
131 |
-
background-size: cover;
|
132 |
max-width: 100%;
|
133 |
}
|
134 |
.relpost-block-single-text{
|
@@ -148,3 +149,21 @@ html[dir="rtl"] .relpost-block-single{
|
|
148 |
html[dir="rtl"] #related_posts_thumbnails li{
|
149 |
float: right;
|
150 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ;
|
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{
|
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 |
+
}
|
assets/js/admin.js
CHANGED
@@ -199,6 +199,53 @@
|
|
199 |
evt.preventDefault();
|
200 |
});
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
}); // End of document ready
|
203 |
|
204 |
// The rest of the code goes here!
|
199 |
evt.preventDefault();
|
200 |
});
|
201 |
|
202 |
+
/// Gallery image selection script
|
203 |
+
// jQuery(document).ready(function() {
|
204 |
+
// var $ = jQuery;
|
205 |
+
// if ($('.relpoststh_set_def_image').length > 0) {
|
206 |
+
// if ( typeof wp !== 'undefined' && wp.media && wp.media.editor) {
|
207 |
+
// $(document).on('click', '.relpoststh_set_def_image', function(e) {
|
208 |
+
// e.preventDefault();
|
209 |
+
// var button = $(this);
|
210 |
+
// var id = button.prev();
|
211 |
+
// wp.media.editor.send.attachment = function(props, attachment) {
|
212 |
+
// // console.log(attachment);
|
213 |
+
// // id.val(attachment.url);
|
214 |
+
// id.attr('src', attachment.url);
|
215 |
+
// $('#relpoststh_default_image').val(attachment.url);
|
216 |
+
// };
|
217 |
+
// wp.media.editor.open(button);
|
218 |
+
// return false;
|
219 |
+
// });
|
220 |
+
// }
|
221 |
+
// }
|
222 |
+
// });
|
223 |
+
$('.relpoststh_set_def_image').on('click', function (event) {
|
224 |
+
event.preventDefault();
|
225 |
+
var self = $(this);
|
226 |
+
var file_frame = wp.media.frames.file_frame = wp.media({
|
227 |
+
title: self.data('uploader_title'),
|
228 |
+
button: {
|
229 |
+
text: self.data('uploader_button_text'),
|
230 |
+
},
|
231 |
+
multiple: false
|
232 |
+
})
|
233 |
+
.on('select', function () {
|
234 |
+
attachment = file_frame.state().get('selection').first().toJSON();
|
235 |
+
$('#relpoststh_default_image_prev').attr('src', attachment.url);
|
236 |
+
$('#relpoststh_default_image').val(attachment.url);
|
237 |
+
})
|
238 |
+
.open();
|
239 |
+
});
|
240 |
+
|
241 |
+
$(document).on('click', '.relpoststh_set_plug_image', function(e) {
|
242 |
+
e.preventDefault();
|
243 |
+
var defValue = $(this).val();
|
244 |
+
$('#relpoststh_default_image_prev').attr('src',defValue);
|
245 |
+
$('#relpoststh_default_image').val(defValue);
|
246 |
+
});
|
247 |
+
|
248 |
+
|
249 |
}); // End of document ready
|
250 |
|
251 |
// The rest of the code goes here!
|
inc/rpt-settings.php
CHANGED
@@ -166,6 +166,11 @@ if ( isset( $_POST['action'] ) && ($_POST['action'] == 'update') ) {
|
|
166 |
update_option( 'relpoststh_custom_taxonomies', array() );
|
167 |
}
|
168 |
|
|
|
|
|
|
|
|
|
|
|
169 |
echo "<div class='updated fade'><p>" . __( 'Settings updated', 'related-posts-thumbnails' ) . '</p></div>';
|
170 |
} else {
|
171 |
echo "<div class='error fade'><p>" . __( 'Settings update failed', 'related-posts-thumbnails' ) . '. ' . $error . '</p></div>';
|
@@ -231,10 +236,10 @@ if ( $this->wp_version >= 3 ) {
|
|
231 |
<div class="wrap relpoststh">
|
232 |
|
233 |
<div class="rpt-top-bar">
|
234 |
-
<a href="https://wpbrigade.com/"><img src="<?php echo plugins_url( 'assets/images/rpt-logo.png', dirname( __FILE__ ) ); ?>" alt="Related Post Thumbnails"></a>
|
235 |
<div class="rpt-top-bar-content">
|
236 |
-
<h3
|
237 |
-
<p><?php _e( '<strong>Related Post Thumbnails</strong> by <strong><a href="https://wpbrigade.com/">WPBrigade</a></strong>.', 'related-posts-thumbnails' ); ?></p>
|
238 |
</div>
|
239 |
</div>
|
240 |
|
@@ -255,10 +260,10 @@ if ( $this->wp_version >= 3 ) {
|
|
255 |
|
256 |
<div id="relpoststh-settings" class="">
|
257 |
<ul class="nav-tab-wrapper">
|
258 |
-
<li> <a href="#content_general_options" class="nav-tab" id="content_general_options-tab"
|
259 |
-
<li> <a href="#content_thumbnail_options" class="nav-tab" id="content_thumbnail_options-tab"
|
260 |
-
<li> <a href="#content_style_options" class="nav-tab" id="content_style_options-tab"
|
261 |
-
<li> <a href="#content_relation_options" class="nav-tab" id="content_relation_options-tab"
|
262 |
</ul>
|
263 |
|
264 |
<div class="metabox-holder">
|
@@ -291,7 +296,7 @@ if ( $this->wp_version >= 3 ) {
|
|
291 |
</td>
|
292 |
</tr>
|
293 |
<tr valign="top">
|
294 |
-
<th scope="row"><?php _e( '
|
295 |
<td>
|
296 |
<input type="checkbox" name="relpoststh_single_only" id="relpoststh_single_only" value="1"
|
297 |
<?php
|
@@ -299,7 +304,7 @@ if ( $this->wp_version >= 3 ) {
|
|
299 |
echo 'checked="checked"'; }
|
300 |
?>
|
301 |
/>
|
302 |
-
<label for="relpoststh_single_only"><?php _e( '
|
303 |
</td>
|
304 |
</tr>
|
305 |
<tr valign="top">
|
@@ -319,22 +324,22 @@ if ( $this->wp_version >= 3 ) {
|
|
319 |
</td>
|
320 |
</tr>
|
321 |
<tr valign="top">
|
322 |
-
<th scope="row"><?php _e( '
|
323 |
<td>
|
324 |
<?php $this->display_categories_list( $relpoststh_categoriesall, $categories, $relpoststh_categories, 'relpoststh_categoriesall', 'relpoststh_categories' ); ?>
|
325 |
</td>
|
326 |
</tr>
|
327 |
<tr valign="top">
|
328 |
-
<th scope="row"><?php _e( 'Categories
|
329 |
<td>
|
330 |
<?php $this->display_categories_list( $relpoststh_show_categoriesall, $categories, $relpoststh_show_categories, 'relpoststh_show_categoriesall', 'relpoststh_show_categories' ); ?>
|
331 |
</td>
|
332 |
</tr>
|
333 |
<tr>
|
334 |
-
<th scope="row"><?php _e( 'Include
|
335 |
<td>
|
336 |
<input type="text" class="rpt_post_include" name="rpt_post_include" value="<?php echo get_option( 'relpoststh_startdate' ); ?>">
|
337 |
-
<button type="button" class="rpt_clear_date">Clear</button>
|
338 |
<label for="relpoststh_excerptlength"><?php _e( 'Leave empty for all posts dates', 'related-posts-thumbnails' ); ?></label><br />
|
339 |
</td>
|
340 |
</tr>
|
@@ -345,20 +350,31 @@ if ( $this->wp_version >= 3 ) {
|
|
345 |
</td>
|
346 |
</tr>
|
347 |
<tr>
|
348 |
-
<th scope="row"><?php _e( 'Number of
|
349 |
<td>
|
350 |
-
<input type="
|
351 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
352 |
</td>
|
353 |
</tr>
|
354 |
<tr>
|
355 |
-
<th scope="row"><?php _e( 'Default image
|
356 |
<td>
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
</td>
|
359 |
</tr>
|
360 |
<tr>
|
361 |
-
<th scope="row"><?php _e( 'Thumbnails
|
362 |
<td>
|
363 |
<select name="relpoststh_thsource" id="relpoststh_thsource">
|
364 |
<?php foreach ( $thsources as $name => $title ) : ?>
|
@@ -381,10 +397,10 @@ if ( $this->wp_version >= 3 ) {
|
|
381 |
if ( $relpoststh_thsource != 'post-thumbnails' ) :
|
382 |
?>
|
383 |
style="display:none" <?php endif; ?>>
|
384 |
-
<h2><?php _e( 'Thumbnails
|
385 |
<table class="form-table">
|
386 |
<tr valign="top">
|
387 |
-
<th scope="row"><?php _e( '
|
388 |
<td>
|
389 |
<select name="relpoststh_poststhname">
|
390 |
<?php foreach ( $available_sizes as $size_name => $size ) : ?>
|
@@ -403,7 +419,7 @@ if ( $this->wp_version >= 3 ) {
|
|
403 |
</tr>
|
404 |
<?php if ( current_theme_supports( 'post-thumbnails' ) ) : ?>
|
405 |
<tr>
|
406 |
-
<th scope="row"><?php _e( 'Show posts
|
407 |
<td>
|
408 |
<input type="checkbox" name="onlywiththumbs" id="onlywiththumbs" value="1"
|
409 |
<?php
|
@@ -411,7 +427,7 @@ if ( $this->wp_version >= 3 ) {
|
|
411 |
echo 'checked="checked"'; }
|
412 |
?>
|
413 |
/>
|
414 |
-
<label for="onlywiththumbs"><?php _e( 'Only posts
|
415 |
</td>
|
416 |
</tr>
|
417 |
<?php endif; ?>
|
@@ -433,8 +449,16 @@ if ( $this->wp_version >= 3 ) {
|
|
433 |
<tr valign="top">
|
434 |
<th scope="row"><?php _e( 'Size', 'related-posts-thumbnails' ); ?>:</th>
|
435 |
<td>
|
436 |
-
|
437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
439 |
</td>
|
440 |
</tr>
|
@@ -449,20 +473,28 @@ if ( $this->wp_version >= 3 ) {
|
|
449 |
</div>
|
450 |
</div>
|
451 |
|
|
|
|
|
452 |
<div class="postbox" style="padding: 20px; display:none;" id="content_style_options">
|
453 |
-
<h2><?php _e( 'Style
|
454 |
<table class="form-table">
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
<tr>
|
456 |
<th scope="row"><?php _e( 'Output style', 'related-posts-thumbnails' ); ?>:</th>
|
457 |
<td>
|
458 |
<select name="relpoststh_output_style" id="relpoststh_output_style">
|
459 |
<?php foreach ( $output_styles as $name => $title ) : ?>
|
460 |
<option value="<?php echo $name; ?>"
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
?>
|
465 |
-
><?php echo $title; ?></option>
|
466 |
<?php endforeach; ?>
|
467 |
</select>
|
468 |
<span id="relpoststh_cleanhtml" style="display:
|
@@ -476,8 +508,8 @@ if ( $this->wp_version >= 3 ) {
|
|
476 |
<?php
|
477 |
if ( $relpoststh_cleanhtml ) {
|
478 |
echo 'checked="checked"'; }
|
479 |
-
?>
|
480 |
-
|
481 |
</td>
|
482 |
</tr>
|
483 |
<tr valign="top">
|
@@ -513,14 +545,15 @@ if ( $this->wp_version >= 3 ) {
|
|
513 |
<tr valign="top">
|
514 |
<th scope="row"><?php _e( 'Font size', 'related-posts-thumbnails' ); ?>:</th>
|
515 |
<td>
|
516 |
-
<input type="
|
517 |
-
|
|
|
518 |
</td>
|
519 |
</tr>
|
520 |
<tr valign="top">
|
521 |
<th scope="row"><?php _e( 'Text maximum length', 'related-posts-thumbnails' ); ?>:</th>
|
522 |
<td>
|
523 |
-
<input type="
|
524 |
<label for="relpoststh_textlength"><?php _e( 'Set 0 for no title', 'related-posts-thumbnails' ); ?></label>
|
525 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
526 |
<br />
|
@@ -529,7 +562,7 @@ if ( $this->wp_version >= 3 ) {
|
|
529 |
<tr valign="top">
|
530 |
<th scope="row"><?php _e( 'Excerpt maximum length', 'related-posts-thumbnails' ); ?>:</th>
|
531 |
<td>
|
532 |
-
<input type="
|
533 |
<label for="relpoststh_excerptlength"><?php _e( 'Set 0 for no excerpt', 'related-posts-thumbnails' ); ?></label>
|
534 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
535 |
<br />
|
@@ -538,7 +571,7 @@ if ( $this->wp_version >= 3 ) {
|
|
538 |
<tr valign="top">
|
539 |
<th scope="row"><?php _e( 'Text block height', 'related-posts-thumbnails' ); ?>:</th>
|
540 |
<td>
|
541 |
-
<input type="
|
542 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
543 |
</td>
|
544 |
</tr>
|
@@ -548,7 +581,7 @@ if ( $this->wp_version >= 3 ) {
|
|
548 |
<h2><?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>:</h2>
|
549 |
<table class="form-table">
|
550 |
<tr valign="top">
|
551 |
-
<th scope="row"><?php _e( '
|
552 |
<td>
|
553 |
<?php if ( is_array( $relation_options ) && count( $relation_options ) ) : ?>
|
554 |
<?php foreach ( $relation_options as $ro_key => $ro_name ) : ?>
|
166 |
update_option( 'relpoststh_custom_taxonomies', array() );
|
167 |
}
|
168 |
|
169 |
+
// Updating layout option
|
170 |
+
// if ( isset( $_POST['relpoststh_layout_style'] ) ) {
|
171 |
+
// update_option( 'relpoststh_layout_style', sanitize_text_field( $_POST['relpoststh_layout_style'] ) );
|
172 |
+
// }
|
173 |
+
|
174 |
echo "<div class='updated fade'><p>" . __( 'Settings updated', 'related-posts-thumbnails' ) . '</p></div>';
|
175 |
} else {
|
176 |
echo "<div class='error fade'><p>" . __( 'Settings update failed', 'related-posts-thumbnails' ) . '. ' . $error . '</p></div>';
|
236 |
<div class="wrap relpoststh">
|
237 |
|
238 |
<div class="rpt-top-bar">
|
239 |
+
<a href="<?php echo esc_url( 'https://wpbrigade.com/' ); ?>"><img src="<?php echo plugins_url( 'assets/images/rpt-logo.png', dirname( __FILE__ ) ); ?>" alt="<?php echo esc_attr( 'Related Post Thumbnails' ); ?>"></a>
|
240 |
<div class="rpt-top-bar-content">
|
241 |
+
<h3><?php _e( 'Related Post Thumbnails - Settings', 'related-posts-thumbnails' ); ?>:</h3>
|
242 |
+
<p><?php _e( '<strong>Related Post Thumbnails</strong> by <strong><a href=" '. esc_url( "https://wpbrigade.com/" ) .' ">WPBrigade</a></strong>.', 'related-posts-thumbnails' ); ?></p>
|
243 |
</div>
|
244 |
</div>
|
245 |
|
260 |
|
261 |
<div id="relpoststh-settings" class="">
|
262 |
<ul class="nav-tab-wrapper">
|
263 |
+
<li> <a href="#content_general_options" class="nav-tab" id="content_general_options-tab"><?php _e( 'General Display Options', 'related-posts-thumbnails' ) ?></a> </li>
|
264 |
+
<li> <a href="#content_thumbnail_options" class="nav-tab" id="content_thumbnail_options-tab"><?php _e( 'Thumbnails Source', 'related-posts-thumbnails' ) ?></a> </li>
|
265 |
+
<li> <a href="#content_style_options" class="nav-tab" id="content_style_options-tab"><?php _e( 'Style Options:', 'related-posts-thumbnails' ) ?></a> </li>
|
266 |
+
<li> <a href="#content_relation_options" class="nav-tab" id="content_relation_options-tab"><?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ) ?></a> </li>
|
267 |
</ul>
|
268 |
|
269 |
<div class="metabox-holder">
|
296 |
</td>
|
297 |
</tr>
|
298 |
<tr valign="top">
|
299 |
+
<th scope="row"><?php _e( 'Display related posts', 'related-posts-thumbnails' ); ?>:</th>
|
300 |
<td>
|
301 |
<input type="checkbox" name="relpoststh_single_only" id="relpoststh_single_only" value="1"
|
302 |
<?php
|
304 |
echo 'checked="checked"'; }
|
305 |
?>
|
306 |
/>
|
307 |
+
<label for="relpoststh_single_only"><?php _e( 'On single posts only', 'related-posts-thumbnails' ); ?></label><br />
|
308 |
</td>
|
309 |
</tr>
|
310 |
<tr valign="top">
|
324 |
</td>
|
325 |
</tr>
|
326 |
<tr valign="top">
|
327 |
+
<th scope="row"><?php _e( 'Display related posts on categories', 'related-posts-thumbnails' ); ?>:</th>
|
328 |
<td>
|
329 |
<?php $this->display_categories_list( $relpoststh_categoriesall, $categories, $relpoststh_categories, 'relpoststh_categoriesall', 'relpoststh_categories' ); ?>
|
330 |
</td>
|
331 |
</tr>
|
332 |
<tr valign="top">
|
333 |
+
<th scope="row"><?php _e( 'Categories will appear in related posts', 'related-posts-thumbnails' ); ?>:</th>
|
334 |
<td>
|
335 |
<?php $this->display_categories_list( $relpoststh_show_categoriesall, $categories, $relpoststh_show_categories, 'relpoststh_show_categoriesall', 'relpoststh_show_categories' ); ?>
|
336 |
</td>
|
337 |
</tr>
|
338 |
<tr>
|
339 |
+
<th scope="row"><?php _e( 'Include posts after', 'related-posts-thumbnails' ); ?>:</th>
|
340 |
<td>
|
341 |
<input type="text" class="rpt_post_include" name="rpt_post_include" value="<?php echo get_option( 'relpoststh_startdate' ); ?>">
|
342 |
+
<button type="button" class="button rpt_clear_date">Clear</button>
|
343 |
<label for="relpoststh_excerptlength"><?php _e( 'Leave empty for all posts dates', 'related-posts-thumbnails' ); ?></label><br />
|
344 |
</td>
|
345 |
</tr>
|
350 |
</td>
|
351 |
</tr>
|
352 |
<tr>
|
353 |
+
<th scope="row"><?php _e( 'Number of posts to display', 'related-posts-thumbnails' ); ?>:</th>
|
354 |
<td>
|
355 |
+
<input type="number" min="1" name="relpoststh_number" value="<?php echo get_option( 'relpoststh_number', $this->number ); ?>" size="2"/>
|
356 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
357 |
</td>
|
358 |
</tr>
|
359 |
<tr>
|
360 |
+
<th scope="row"><?php _e( 'Default image', 'related-posts-thumbnails' ); ?>:</th>
|
361 |
<td>
|
362 |
+
<?php
|
363 |
+
// $imgid =(isset( $instance[ 'imgid' ] )) ? $instance[ 'imgid' ] : "";
|
364 |
+
// $img = wp_get_attachment_image_src($imgid, 'thumbnail');
|
365 |
+
// var_dump($img);
|
366 |
+
?>
|
367 |
+
<!-- <input type="text" value="<?php // echo get_option( 'relpoststh_default_image', $this->default_image ); ?>" class="regular-text process_custom_images" id="process_custom_images" name=""> -->
|
368 |
+
<img src="<?php echo get_option( 'relpoststh_default_image', $this->default_image ); ?>" id="relpoststh_default_image_prev" class="regular-text process_custom_images" height="200" width="30">
|
369 |
+
<div class="relposts-button-section">
|
370 |
+
<button class="relpoststh_set_def_image button"><?php _e( 'Set Image', 'related-posts-thumbnails' ); ?></button>
|
371 |
+
<button value="<?php echo esc_url( plugins_url( '../img/default.png', __FILE__ ) ); ?>" class="relpoststh_set_plug_image button"><?php _e( 'Default Image', 'related-posts-thumbnails' ); ?></button>
|
372 |
+
<input type="hidden" name="relpoststh_default_image" id="relpoststh_default_image" value="<?php echo get_option( 'relpoststh_default_image', $this->default_image ); ?>" size="50"/>
|
373 |
+
</div>
|
374 |
</td>
|
375 |
</tr>
|
376 |
<tr>
|
377 |
+
<th scope="row"><?php _e( 'Thumbnails Source', 'related-posts-thumbnails' ); ?>:</th>
|
378 |
<td>
|
379 |
<select name="relpoststh_thsource" id="relpoststh_thsource">
|
380 |
<?php foreach ( $thsources as $name => $title ) : ?>
|
397 |
if ( $relpoststh_thsource != 'post-thumbnails' ) :
|
398 |
?>
|
399 |
style="display:none" <?php endif; ?>>
|
400 |
+
<h2><?php _e( 'Thumbnails Source', 'related-posts-thumbnails' ); ?>:</h2>
|
401 |
<table class="form-table">
|
402 |
<tr valign="top">
|
403 |
+
<th scope="row"><?php _e( 'Related posts thumbnail size', 'related-posts-thumbnails' ); ?>:</th>
|
404 |
<td>
|
405 |
<select name="relpoststh_poststhname">
|
406 |
<?php foreach ( $available_sizes as $size_name => $size ) : ?>
|
419 |
</tr>
|
420 |
<?php if ( current_theme_supports( 'post-thumbnails' ) ) : ?>
|
421 |
<tr>
|
422 |
+
<th scope="row"><?php _e( 'Show posts with featured image', 'related-posts-thumbnails' ); ?>:</th>
|
423 |
<td>
|
424 |
<input type="checkbox" name="onlywiththumbs" id="onlywiththumbs" value="1"
|
425 |
<?php
|
427 |
echo 'checked="checked"'; }
|
428 |
?>
|
429 |
/>
|
430 |
+
<label for="onlywiththumbs"><?php _e( 'Only those posts will be shown that has featured image', 'related-posts-thumbnails' ); ?></label><br />
|
431 |
</td>
|
432 |
</tr>
|
433 |
<?php endif; ?>
|
449 |
<tr valign="top">
|
450 |
<th scope="row"><?php _e( 'Size', 'related-posts-thumbnails' ); ?>:</th>
|
451 |
<td>
|
452 |
+
<label for="relpoststh_customwidth" id="relpoststh_customwidth">
|
453 |
+
<?php _e( 'Width', 'related-posts-thumbnails' ); ?>:
|
454 |
+
</label>
|
455 |
+
<input type="number" min="1" name="relpoststh_customwidth" value="<?php echo get_option( 'relpoststh_customwidth', $this->custom_width ); ?>" size="3"/><?php _e( ' px', 'related-posts-thumbnails' ) ?>
|
456 |
+
<br>
|
457 |
+
<label for="relpoststh_customheight">
|
458 |
+
<?php _e( 'Height', 'related-posts-thumbnails' ); ?>:
|
459 |
+
</label>
|
460 |
+
<input type="number" min="1" name="relpoststh_customheight" value="<?php echo get_option( 'relpoststh_customheight', $this->custom_height ); ?>" size="3"/><?php _e( ' px', 'related-posts-thumbnails' ) ?>
|
461 |
+
<br>
|
462 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
463 |
</td>
|
464 |
</tr>
|
473 |
</div>
|
474 |
</div>
|
475 |
|
476 |
+
|
477 |
+
<!-- DISPLAY SETTINGS -->
|
478 |
<div class="postbox" style="padding: 20px; display:none;" id="content_style_options">
|
479 |
+
<h2><?php _e( 'Style Options', 'related-posts-thumbnails' ); ?>:</h2>
|
480 |
<table class="form-table">
|
481 |
+
|
482 |
+
<!-- calling layouts from pro -->
|
483 |
+
<?php
|
484 |
+
// do_action('rptp_style_layouts');
|
485 |
+
?>
|
486 |
+
|
487 |
<tr>
|
488 |
<th scope="row"><?php _e( 'Output style', 'related-posts-thumbnails' ); ?>:</th>
|
489 |
<td>
|
490 |
<select name="relpoststh_output_style" id="relpoststh_output_style">
|
491 |
<?php foreach ( $output_styles as $name => $title ) : ?>
|
492 |
<option value="<?php echo $name; ?>"
|
493 |
+
<?php
|
494 |
+
if ( $relpoststh_output_style == $name ) {
|
495 |
+
echo 'selected'; }
|
496 |
+
?>
|
497 |
+
><?php echo $title; ?></option>
|
498 |
<?php endforeach; ?>
|
499 |
</select>
|
500 |
<span id="relpoststh_cleanhtml" style="display:
|
508 |
<?php
|
509 |
if ( $relpoststh_cleanhtml ) {
|
510 |
echo 'checked="checked"'; }
|
511 |
+
?>
|
512 |
+
/></span>
|
513 |
</td>
|
514 |
</tr>
|
515 |
<tr valign="top">
|
545 |
<tr valign="top">
|
546 |
<th scope="row"><?php _e( 'Font size', 'related-posts-thumbnails' ); ?>:</th>
|
547 |
<td>
|
548 |
+
<input type="number" min="1" name="relpoststh_fontsize" value="<?php echo get_option( 'relpoststh_fontsize', $this->font_size ); ?>" size="7"/>
|
549 |
+
<label for="relpoststh_fontsize"><?php _e( 'px', 'related-posts-thumbnails' ); ?></label>
|
550 |
+
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
551 |
</td>
|
552 |
</tr>
|
553 |
<tr valign="top">
|
554 |
<th scope="row"><?php _e( 'Text maximum length', 'related-posts-thumbnails' ); ?>:</th>
|
555 |
<td>
|
556 |
+
<input type="number" min="0" name="relpoststh_textlength" value="<?php echo get_option( 'relpoststh_textlength', $this->text_length ); ?>" size="7"/>
|
557 |
<label for="relpoststh_textlength"><?php _e( 'Set 0 for no title', 'related-posts-thumbnails' ); ?></label>
|
558 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
559 |
<br />
|
562 |
<tr valign="top">
|
563 |
<th scope="row"><?php _e( 'Excerpt maximum length', 'related-posts-thumbnails' ); ?>:</th>
|
564 |
<td>
|
565 |
+
<input type="number" min="0" name="relpoststh_excerptlength" value="<?php echo get_option( 'relpoststh_excerptlength', $this->excerpt_length ); ?>" size="7"/>
|
566 |
<label for="relpoststh_excerptlength"><?php _e( 'Set 0 for no excerpt', 'related-posts-thumbnails' ); ?></label>
|
567 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
568 |
<br />
|
571 |
<tr valign="top">
|
572 |
<th scope="row"><?php _e( 'Text block height', 'related-posts-thumbnails' ); ?>:</th>
|
573 |
<td>
|
574 |
+
<input type="number" min="0" name="relpoststh_textblockheight" value="<?php echo get_option( 'relpoststh_textblockheight', $this->text_block_height ); ?>" size="7"/> px
|
575 |
<span class='rpt-no-validate-error' style="display:none;color:red;"><?php _e( 'Only Digits are allow', 'related-posts-thumbnails' ); ?></span>
|
576 |
</td>
|
577 |
</tr>
|
581 |
<h2><?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>:</h2>
|
582 |
<table class="form-table">
|
583 |
<tr valign="top">
|
584 |
+
<th scope="row"><?php _e( 'Base relation on', 'related-posts-thumbnails' ); ?>:</th>
|
585 |
<td>
|
586 |
<?php if ( is_array( $relation_options ) && count( $relation_options ) ) : ?>
|
587 |
<?php foreach ( $relation_options as $ro_key => $ro_name ) : ?>
|
inc/rpt-widget.php
CHANGED
@@ -38,7 +38,7 @@ class RelatedPostsThumbnailsWidget extends WP_Widget {
|
|
38 |
}
|
39 |
|
40 |
function form( $instance ) {
|
41 |
-
$title = esc_attr( $instance['title'] );
|
42 |
?>
|
43 |
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
|
44 |
<?php
|
38 |
}
|
39 |
|
40 |
function form( $instance ) {
|
41 |
+
$title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
|
42 |
?>
|
43 |
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
|
44 |
<?php
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpbrigade.com/
|
|
4 |
Tags: related, posts, thumbnails, Related Content, related posts, pages, similar posts, shortcodes, widgets, related thumbs
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -67,11 +67,24 @@ If there are no images of the specified size in the post, or file does not exist
|
|
67 |
|
68 |
== Upgrade Notice ==
|
69 |
|
70 |
-
= 1.6.
|
71 |
-
*
|
72 |
|
73 |
== Changelog ==
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
= 1.6.2 - 2018-02-27 =
|
76 |
* Feature : Change inline style to class.
|
77 |
* Feature : Add RTL support.
|
4 |
Tags: related, posts, thumbnails, Related Content, related posts, pages, similar posts, shortcodes, widgets, related thumbs
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 1.6.3
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
67 |
|
68 |
== Upgrade Notice ==
|
69 |
|
70 |
+
= 1.6.3 =
|
71 |
+
* Please upgrade immediately
|
72 |
|
73 |
== Changelog ==
|
74 |
|
75 |
+
= 1.6.3 - 2018-03-26 =
|
76 |
+
* Feature : Multilingual Compatible. All text is now translateable.
|
77 |
+
* Feature : Add filter to left, right or center align Related Posts.
|
78 |
+
* Feature : Add filter to change priority of Related Posts under posts content.
|
79 |
+
* Enhancement : Add ALT tag in Related Posts thumbnails.
|
80 |
+
* Enhancement : Replace input types of some fields form text to number.
|
81 |
+
* Enhancement : Replace default image URL to gallery image selection.
|
82 |
+
* Enhancement : Replace some ambiguous field's titles with more clear titles.
|
83 |
+
* Bug Fix : Fix the undefined index notice on widget title.
|
84 |
+
* Bug Fix : Fix the image issue in widget.
|
85 |
+
* Bug Fix : Fix the image issue in thumbnails of Related Posts.
|
86 |
+
|
87 |
+
|
88 |
= 1.6.2 - 2018-02-27 =
|
89 |
* Feature : Change inline style to class.
|
90 |
* Feature : Add RTL support.
|
related-posts-thumbnails.php
CHANGED
@@ -3,15 +3,15 @@
|
|
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.6.
|
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 to
|
13 |
|
14 |
-
This product was first developed by Maria I Shaldybina and later on maintained by Adnan (WPBrigade)
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
@@ -75,7 +75,8 @@ class RelatedPostsThumbnails {
|
|
75 |
update_option( 'relpoststh_default_image', $this->default_image );
|
76 |
|
77 |
if ( get_option( 'relpoststh_auto', $this->auto ) ) {
|
78 |
-
|
|
|
79 |
}
|
80 |
|
81 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
@@ -90,12 +91,12 @@ class RelatedPostsThumbnails {
|
|
90 |
add_action( 'wp_enqueue_scripts', array( $this, 'front_scripts' ) );
|
91 |
|
92 |
add_action( 'wp_head', array( $this, 'head_style' ) );
|
93 |
-
|
94 |
}
|
95 |
|
96 |
function admin_scripts( $page ) {
|
97 |
|
98 |
if ( 'toplevel_page_related-posts-thumbnails' === $page ) {
|
|
|
99 |
wp_enqueue_style( 'rpt_admin_css', plugins_url( 'assets/css/admin.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
|
100 |
wp_enqueue_style( 'jquery-ui', 'http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
|
101 |
wp_enqueue_style( 'wp-color-picker' );
|
@@ -318,6 +319,7 @@ private function review_dismissal() {
|
|
318 |
function auto_show( $content ) {
|
319 |
// Automatically displaying related posts under post body
|
320 |
return $content . $this->get_html( true );
|
|
|
321 |
}
|
322 |
|
323 |
function get_html( $show_top = false ) {
|
@@ -335,7 +337,8 @@ private function review_dismissal() {
|
|
335 |
$posts_number = get_option( 'relpoststh_number', $this->number );
|
336 |
$height = '';
|
337 |
$width = '';
|
338 |
-
|
|
|
339 |
$alt = '';
|
340 |
|
341 |
if ( $posts_number <= 0 ) { // return nothing if this parameter was set to <= 0
|
@@ -371,7 +374,7 @@ private function review_dismissal() {
|
|
371 |
}
|
372 |
$object_terms = wp_get_object_terms( $id, $taxonomy, array( 'fields' => 'ids' ) );
|
373 |
if ( empty( $object_terms ) || ! is_array( $object_terms ) ) { // no terms to get taxonomy
|
374 |
-
return $this->finish_process( $output, $debug . 'No taxonomy terms to get posts;', $time );
|
375 |
}
|
376 |
|
377 |
$query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('". implode( "', '", $object_terms ) . "')";
|
@@ -389,7 +392,7 @@ private function review_dismissal() {
|
|
389 |
$select_terms = get_option( 'relpoststh_show_categories',
|
390 |
get_option( 'relpoststh_categories' ) );
|
391 |
if ( empty( $select_terms ) || ! is_array( $select_terms ) ) { // if no categories were specified intentionally return nothing
|
392 |
-
return $this->finish_process( $output, $debug . 'No categories were selected;', $time );
|
393 |
}
|
394 |
|
395 |
$query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('". implode( "', '", $select_terms ) . "')";
|
@@ -437,7 +440,7 @@ private function review_dismissal() {
|
|
437 |
|
438 |
/* Get posts by their IDs */
|
439 |
if ( ! is_array( $random_posts ) || count( $random_posts ) < 1 ) {
|
440 |
-
return $this->finish_process( $output, $debug . 'No posts matching relationships criteria;', $time );
|
441 |
}
|
442 |
|
443 |
$posts_in = array();
|
@@ -512,6 +515,7 @@ private function review_dismissal() {
|
|
512 |
foreach ( $posts as $post ) {
|
513 |
$image = '';
|
514 |
$url = '';
|
|
|
515 |
if ( $thsource == 'custom-field' ) {
|
516 |
$debug .= 'Using custom field;';
|
517 |
$url = $basic_url = get_post_meta( $post->ID, get_option( 'relpoststh_customfield', $this->custom_field ), true );
|
@@ -531,6 +535,7 @@ private function review_dismissal() {
|
|
531 |
$debug .= 'Post has thumbnail '.$post_thumbnail_id.';';
|
532 |
$debug .= 'Postthname: '.$poststhname.';';
|
533 |
$image = wp_get_attachment_image_src( $post_thumbnail_id, $poststhname );
|
|
|
534 |
$url = $image[0];
|
535 |
$from_post_body = false;
|
536 |
} else {
|
@@ -542,10 +547,19 @@ private function review_dismissal() {
|
|
542 |
$wud = wp_upload_dir();
|
543 |
preg_match_all( '|<img.*?src=[\'"](' . $wud['baseurl'] . '.*?)[\'"].*?>|i', $post->post_content, $matches ); // searching for the first uploaded image in text
|
544 |
|
545 |
-
|
546 |
-
|
547 |
-
if ( isset( $matches ) and isset( $matches[1][0] ) ) {
|
548 |
$image = $matches[1][0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
} else {
|
550 |
$debug .= 'No image was found;';
|
551 |
}
|
@@ -586,10 +600,13 @@ private function review_dismissal() {
|
|
586 |
|
587 |
if ( ! empty( $title ) && ! empty( $excerpt ) ) {
|
588 |
$title = '<b>' . $title . '</b>';
|
589 |
-
$alt = $title;
|
590 |
$excerpt = '<br/>' . $excerpt;
|
591 |
}
|
592 |
|
|
|
|
|
|
|
|
|
593 |
$fontface = '';
|
594 |
|
595 |
$debug .= 'Using title with size ' . $text_length . '. Using excerpt with size ' . $excerpt_length . ';';
|
@@ -601,7 +618,7 @@ private function review_dismissal() {
|
|
601 |
// $output .= ' onmouseout="this.style.backgroundColor=\'' . get_option( 'relpoststh_background', $this->background ) . '\'"';
|
602 |
}
|
603 |
$output .= '>';
|
604 |
-
$output .= '<a href="' . $link . '" ><img class="relpost-post-image" alt="' . $alt . '" src="' . $url . '" width="' . $width . '" height="' . $height . '" ';
|
605 |
if ( ! $relpoststh_cleanhtml ) {
|
606 |
// $output .= 'style="padding: 0px; margin: 0px; border: 0pt none;"';
|
607 |
}
|
@@ -615,7 +632,7 @@ private function review_dismissal() {
|
|
615 |
} else {
|
616 |
$output .= '<a class="relpost-block-single" href="' . get_permalink( $post->ID ) . '">';
|
617 |
$output .= '<div style="width: ' . $width . 'px; height: ' . ( $height + $text_height ) . 'px;">';
|
618 |
-
$output .= '<div class="relpost-block-single-image" style=" background: transparent url(' . $url . ') no-repeat scroll 0% 0%; width: ' . $width . 'px; height: ' . $height . 'px; "></div>';
|
619 |
$output .= '<div class="relpost-block-single-text" style="font-family: ' . $fontface . '; font-size: ' . get_option( 'relpoststh_fontsize', $this->font_size ) . 'px; color: ' . get_option( 'relpoststh_fontcolor', $this->font_color ) . ';">' . $title . $excerpt . '</div>';
|
620 |
$output .= '</div>';
|
621 |
$output .= '</a>';
|
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.6.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 to 2018
|
13 |
|
14 |
+
This product was first developed by Maria I Shaldybina and later on maintained and developed by Adnan (WPBrigade.com)
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
75 |
update_option( 'relpoststh_default_image', $this->default_image );
|
76 |
|
77 |
if ( get_option( 'relpoststh_auto', $this->auto ) ) {
|
78 |
+
$priority = apply_filters( 'rpt_content_prioirty', 10); // Alter priority of the related post content
|
79 |
+
add_filter( 'the_content', array( $this, 'auto_show' ), $priority );
|
80 |
}
|
81 |
|
82 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
91 |
add_action( 'wp_enqueue_scripts', array( $this, 'front_scripts' ) );
|
92 |
|
93 |
add_action( 'wp_head', array( $this, 'head_style' ) );
|
|
|
94 |
}
|
95 |
|
96 |
function admin_scripts( $page ) {
|
97 |
|
98 |
if ( 'toplevel_page_related-posts-thumbnails' === $page ) {
|
99 |
+
wp_enqueue_media();
|
100 |
wp_enqueue_style( 'rpt_admin_css', plugins_url( 'assets/css/admin.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
|
101 |
wp_enqueue_style( 'jquery-ui', 'http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
|
102 |
wp_enqueue_style( 'wp-color-picker' );
|
319 |
function auto_show( $content ) {
|
320 |
// Automatically displaying related posts under post body
|
321 |
return $content . $this->get_html( true );
|
322 |
+
|
323 |
}
|
324 |
|
325 |
function get_html( $show_top = false ) {
|
337 |
$posts_number = get_option( 'relpoststh_number', $this->number );
|
338 |
$height = '';
|
339 |
$width = '';
|
340 |
+
// rpt_content_align: add content allignment class; clases are: relpost-align-left, relpost-align-right and relpost-align-center
|
341 |
+
$output = '<div class="relpost-thumb-wrapper ' . apply_filters( 'rpt_content_align', 'relpost-align-left') . ' ">';
|
342 |
$alt = '';
|
343 |
|
344 |
if ( $posts_number <= 0 ) { // return nothing if this parameter was set to <= 0
|
374 |
}
|
375 |
$object_terms = wp_get_object_terms( $id, $taxonomy, array( 'fields' => 'ids' ) );
|
376 |
if ( empty( $object_terms ) || ! is_array( $object_terms ) ) { // no terms to get taxonomy
|
377 |
+
return $this->finish_process( $output, $debug . __( 'No taxonomy terms to get posts;' ), $time );
|
378 |
}
|
379 |
|
380 |
$query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('". implode( "', '", $object_terms ) . "')";
|
392 |
$select_terms = get_option( 'relpoststh_show_categories',
|
393 |
get_option( 'relpoststh_categories' ) );
|
394 |
if ( empty( $select_terms ) || ! is_array( $select_terms ) ) { // if no categories were specified intentionally return nothing
|
395 |
+
return $this->finish_process( $output, $debug . __( 'No categories were selected;' ), $time );
|
396 |
}
|
397 |
|
398 |
$query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('". implode( "', '", $select_terms ) . "')";
|
440 |
|
441 |
/* Get posts by their IDs */
|
442 |
if ( ! is_array( $random_posts ) || count( $random_posts ) < 1 ) {
|
443 |
+
return $this->finish_process( $output, $debug . __( 'No posts matching relationships criteria;' ), $time );
|
444 |
}
|
445 |
|
446 |
$posts_in = array();
|
515 |
foreach ( $posts as $post ) {
|
516 |
$image = '';
|
517 |
$url = '';
|
518 |
+
$alt = '';
|
519 |
if ( $thsource == 'custom-field' ) {
|
520 |
$debug .= 'Using custom field;';
|
521 |
$url = $basic_url = get_post_meta( $post->ID, get_option( 'relpoststh_customfield', $this->custom_field ), true );
|
535 |
$debug .= 'Post has thumbnail '.$post_thumbnail_id.';';
|
536 |
$debug .= 'Postthname: '.$poststhname.';';
|
537 |
$image = wp_get_attachment_image_src( $post_thumbnail_id, $poststhname );
|
538 |
+
$alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
|
539 |
$url = $image[0];
|
540 |
$from_post_body = false;
|
541 |
} else {
|
547 |
$wud = wp_upload_dir();
|
548 |
preg_match_all( '|<img.*?src=[\'"](' . $wud['baseurl'] . '.*?)[\'"].*?>|i', $post->post_content, $matches ); // searching for the first uploaded image in text
|
549 |
|
550 |
+
if ( isset( $matches ) && isset( $matches[1][0] ) ) {
|
|
|
|
|
551 |
$image = $matches[1][0];
|
552 |
+
$html = $matches[0][0];
|
553 |
+
if ( !empty( $html ) ) {
|
554 |
+
preg_match( '/alt="([^"]*)"/i', $html, $array );
|
555 |
+
$explode_tag = explode( '"' , $array[0] );
|
556 |
+
$alt = $explode_tag[1];
|
557 |
+
|
558 |
+
// $dom = new DOMDocument();
|
559 |
+
// $dom->loadHTML($html);
|
560 |
+
// $nodes = $dom->getElementsByTagName('img');
|
561 |
+
// $alt = $nodes->item(0)->getAttribute('alt');
|
562 |
+
}
|
563 |
} else {
|
564 |
$debug .= 'No image was found;';
|
565 |
}
|
600 |
|
601 |
if ( ! empty( $title ) && ! empty( $excerpt ) ) {
|
602 |
$title = '<b>' . $title . '</b>';
|
|
|
603 |
$excerpt = '<br/>' . $excerpt;
|
604 |
}
|
605 |
|
606 |
+
if ( empty( $alt ) ) {
|
607 |
+
$alt = $title;
|
608 |
+
}
|
609 |
+
|
610 |
$fontface = '';
|
611 |
|
612 |
$debug .= 'Using title with size ' . $text_length . '. Using excerpt with size ' . $excerpt_length . ';';
|
618 |
// $output .= ' onmouseout="this.style.backgroundColor=\'' . get_option( 'relpoststh_background', $this->background ) . '\'"';
|
619 |
}
|
620 |
$output .= '>';
|
621 |
+
$output .= '<a href="' . $link . '" ><img class="relpost-post-image" alt="' . $alt . '" src="' . esc_url( $url ) . '" width="' . $width . '" height="' . $height . '" ';
|
622 |
if ( ! $relpoststh_cleanhtml ) {
|
623 |
// $output .= 'style="padding: 0px; margin: 0px; border: 0pt none;"';
|
624 |
}
|
632 |
} else {
|
633 |
$output .= '<a class="relpost-block-single" href="' . get_permalink( $post->ID ) . '">';
|
634 |
$output .= '<div style="width: ' . $width . 'px; height: ' . ( $height + $text_height ) . 'px;">';
|
635 |
+
$output .= '<div class="relpost-block-single-image" alt="' . $alt . '" style=" background: transparent url(' . esc_url( $url ) . ') no-repeat scroll 0% 0%; width: ' . $width . 'px; height: ' . $height . 'px; "></div>';
|
636 |
$output .= '<div class="relpost-block-single-text" style="font-family: ' . $fontface . '; font-size: ' . get_option( 'relpoststh_fontsize', $this->font_size ) . 'px; color: ' . get_option( 'relpoststh_fontcolor', $this->font_color ) . ';">' . $title . $excerpt . '</div>';
|
637 |
$output .= '</div>';
|
638 |
$output .= '</a>';
|