Related Posts Thumbnails Plugin for WordPress - Version 1.9.1

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.1
Comparing to
See all releases

Code changes from version 1.9.0 to 1.9.1

assets/css/front.css CHANGED
@@ -44,6 +44,14 @@
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;
44
  background-color: #eeeeef;
45
  }
46
 
47
+ @media screen and (min-width: 290px) and (max-width: 520px) {
48
+ .relpost-block-container {
49
+ display: flex;
50
+ flex-wrap: wrap;
51
+ justify-content: center;
52
+ }
53
+ }
54
+
55
  .related-posts-nav>li>a>.related-post-list-item-inner-container {
56
  border: 0pt none;
57
  margin: 0pt;
inc/rpt-settings.php CHANGED
@@ -272,9 +272,13 @@ if ( $this->wp_version >= 3 ) {
272
  <div class="wrap relpoststh">
273
 
274
  <div class="rpt-top-bar">
275
- <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>
 
 
276
  <div class="rpt-top-bar-content">
277
- <h3><?php _e( 'Related Post Thumbnails - Settings', 'related-posts-thumbnails' ); ?>:</h3>
 
 
278
  <p><?php _e( '<strong>Related Post Thumbnails</strong> by <strong><a href=" ' . esc_url( "https://wpbrigade.com/" ) . ' ">WPBrigade</a></strong>.', 'related-posts-thumbnails' ); ?></p>
279
  </div>
280
  </div>
@@ -287,711 +291,713 @@ if ( $this->wp_version >= 3 ) {
287
  <?php wp_nonce_field( 'related-posts-thumbnails' ); ?>
288
 
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">
330
- <th scope="row">
331
- <?php _e( 'Automatically append to the post content', 'related-posts-thumbnails' ); ?>:
332
- </th>
333
- <td>
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
- />
341
- <label for="relpoststh_auto">
342
- <p class="description rpth-discription" >
343
- <?php _e( 'Or use the following snippet in The Loop <b>&lt;?php get_related_posts_thumbnails(); ?&gt;</b>', 'related-posts-thumbnails' ); ?>
344
- </p>
345
- </label>
346
- <br />
347
- </td>
348
- </tr>
349
- <tr valign="top">
350
- <th scope="row">
351
- <?php _e( 'Developer mode', 'related-posts-thumbnails' ); ?>:
352
- </th>
353
- <td>
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>
478
- <th scope="row">
479
- <?php _e( 'Sort by', 'related-posts-thumbnails' ); ?>:
480
- </th>
481
- <td>
482
- <select class="rpt_post_sort" name="rpt_post_sort">
483
- <option value="rand"
484
- <?php
485
- if( get_option('rpt_post_sort') == 'rand' ) {
486
- echo 'selected';
487
- }
488
- ?> >
489
- <?php _e( 'Random', 'related-posts-thumbnails' ); ?>
490
- </option>
491
- <option value="latest"
492
- <?php
493
- if( get_option('rpt_post_sort') == 'latest' ) {
494
- echo 'selected';
495
- }
496
- ?> >
497
- <?php _e( 'Latest posts', 'related-posts-thumbnails' ); ?>
498
- </option>
499
- </select>
500
- </td>
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"> -->
522
- <tr>
523
- <th scope="row">
524
- <?php _e( 'Default image', 'related-posts-thumbnails' ); ?>:
525
- </th>
526
- <td>
527
- <?php
528
- // $imgid =(isset( $instance[ 'imgid' ] )) ? $instance[ 'imgid' ] : "";
529
- // $img = wp_get_attachment_image_src($imgid, 'thumbnail');
530
- // var_dump($img);
531
- ?>
532
- <!-- <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=""> -->
533
- <img
534
- src="<?php echo get_option( 'relpoststh_default_image', $this->default_image ); ?>"
535
- id="relpoststh_default_image_prev" class="regular-text process_custom_images" height="200" width="30">
536
- <div class="relposts-button-section">
537
- <button class="relpoststh_set_def_image button">
538
- <?php _e( 'Set Image', 'related-posts-thumbnails' ); ?>
539
- </button>
540
- <button
541
- value="<?php echo esc_url( plugins_url( '../img/default.png', __FILE__ ) ); ?>"
542
- class="relpoststh_set_plug_image button">
543
- <?php _e( 'Default Image', 'related-posts-thumbnails' ); ?>
544
- </button>
545
- <input type="hidden" name="relpoststh_default_image" id="relpoststh_default_image"
546
- value="<?php echo get_option( 'relpoststh_default_image', $this->default_image ); ?>" size="50"/>
547
- </div>
548
- </td>
549
- </tr>
550
- <!-- </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' ); ?>
557
- </h2>
558
-
559
- <table class="form-table">
560
- <tr>
561
- <th>
562
- <?php _e( 'Select thumbnails source', 'related-posts-thumbnails' ); ?>
563
- </th>
564
- <td>
565
- <select class="select-style" name="relpoststh_thsource" id="relpoststh_thsource">
566
- <?php foreach ( $thsources as $name => $title ): ?>
567
- <option value="<?php echo $name; ?>"
568
- <?php
569
- if ( $relpoststh_thsource == $name ) {
570
- echo 'selected';
571
- }
572
- ?> >
573
- <?php echo $title; ?>
574
- </option>
575
- <?php endforeach; ?>
576
- </select>
577
- </td>
578
- </tr>
579
- </table>
580
-
581
- <div id="relpoststh-post-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>
272
  <div class="wrap relpoststh">
273
 
274
  <div class="rpt-top-bar">
275
+ <a href="<?php echo esc_url( 'https://wpbrigade.com/' ); ?>">
276
+ <img src="<?php echo plugins_url( 'assets/images/rpt-logo.png', dirname( __FILE__ ) ); ?>" alt="<?php echo esc_attr( 'Related Post Thumbnails' ); ?>">
277
+ </a>
278
  <div class="rpt-top-bar-content">
279
+ <h3>
280
+ <?php _e( 'Related Post Thumbnails - Settings', 'related-posts-thumbnails' ); ?>:
281
+ </h3>
282
  <p><?php _e( '<strong>Related Post Thumbnails</strong> by <strong><a href=" ' . esc_url( "https://wpbrigade.com/" ) . ' ">WPBrigade</a></strong>.', 'related-posts-thumbnails' ); ?></p>
283
  </div>
284
  </div>
291
  <?php wp_nonce_field( 'related-posts-thumbnails' ); ?>
292
 
293
  <div class="wpbr-wrap"><div class="wpbr-tabsWrapper">
294
+ <div class="wpbr-button-container top">
295
+ <div class="setting-notification">
296
+ <?php _e( 'Settings have changed, you should save them!', 'related-posts-thumbnails' ); ?>
297
+ </div>
298
+ <input type="submit" name="Submit" class="wpb-rpt-settings-submit button button-primary button-big"
299
+ value="<?php esc_html_e( 'Save Settings', 'related-posts-thumbnails' ); ?>" id="wpb_rpt_save_setting_top">
300
+ </div>
301
+
302
+ <div id="relpoststh-settings" class="">
303
+ <ul class="nav-tab-wrapper">
304
+ <li>
305
+ <a href="#content_general_options" class="nav-tab" id="content_general_options-tab">
306
+ <?php _e( 'General Display Options', 'related-posts-thumbnails' ); ?>
307
+ </a>
308
+ </li>
309
+ <li>
310
+ <a href="#content_thumbnail_options" class="nav-tab" id="content_thumbnail_options-tab">
311
+ <?php _e( 'Thumbnails', 'related-posts-thumbnails' ); ?>
312
+ </a>
313
+ </li>
314
+ <li>
315
+ <a href="#content_style_options" class="nav-tab" id="content_style_options-tab">
316
+ <?php _e( 'Style Options', 'related-posts-thumbnails' ); ?>
317
+ </a>
318
+ </li>
319
+ <li>
320
+ <a href="#content_relation_options" class="nav-tab" id="content_relation_options-tab">
321
+ <?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>
322
+ </a>
323
+ </li>
324
+ </ul>
325
+
326
+ <div class="metabox-holder rpth-setting-options">
327
+ <div class="postbox" style="padding: 20px" id="content_general_options">
328
+ <h2>
329
+ <?php _e( 'General Display Options', 'related-posts-thumbnails' ); ?>
330
+ </h2>
331
+
332
+ <table class="form-table">
333
+ <tr valign="top">
334
+ <th scope="row">
335
+ <?php _e( 'Automatically append to the post content', 'related-posts-thumbnails' ); ?>:
336
+ </th>
337
+ <td>
338
+ <input type="checkbox" name="relpoststh_auto" id="relpoststh_auto" value="1"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  <?php
340
+ if ( $relpoststh_auto ) {
341
  echo 'checked="checked"';
342
+ }
343
+ ?>
344
  />
345
+ <label for="relpoststh_auto">
346
+ <p class="description rpth-discription" >
347
+ <?php _e( 'Or use the following snippet in The Loop <b>&lt;?php get_related_posts_thumbnails(); ?&gt;</b>', 'related-posts-thumbnails' ); ?>
348
+ </p>
349
+ </label>
350
+ <br />
351
+ </td>
352
+ </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  <tr valign="top">
354
  <th scope="row">
355
+ <?php _e( 'Developer mode', 'related-posts-thumbnails' ); ?>:
356
  </th>
357
  <td>
358
+ <input type="checkbox" name="relpoststh_devmode" id="relpoststh_devmode" value="1"
359
+ <?php
360
+ if ( $relpoststh_devmode ) {
361
+ echo 'checked="checked"';
362
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  ?>
364
  />
365
+ <label for="relpoststh_devmode">
366
+ <p class="description rpth-discription">
367
+ <?php _e( 'This will add debugging information in HTML source', 'related-posts-thumbnails' ); ?>
368
+ </p>
369
+ </label>
 
 
 
 
 
 
 
 
 
370
  <br />
371
+ </td>
372
+ </tr>
373
+ <tr valign="top">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  <th scope="row">
375
+ <?php _e( 'Display related posts', 'related-posts-thumbnails' ); ?>:
376
  </th>
377
  <td>
378
+ <input type="checkbox" name="relpoststh_single_only" id="relpoststh_single_only" value="1"
379
+ <?php
380
+ if ( $relpoststh_single_only ) {
381
+ echo 'checked="checked"';
382
+ } ?>
383
+ />
384
+ <label for="relpoststh_single_only">
385
+ <?php _e( 'On single posts only', 'related-posts-thumbnails' ); ?>
386
+ </label>
387
+ <br />
388
  </td>
389
  </tr>
 
 
 
 
 
 
390
  <tr valign="top">
391
  <th scope="row">
392
+ <?php _e( 'Post types', 'related-posts-thumbnails' ); ?>:
393
  </th>
 
394
  <td>
395
+ <?php
396
+ if ( is_array( $post_types ) && count( $post_types ) ):
397
+ foreach ( $post_types as $post_type ): ?>
398
+ <input type="checkbox" name="relpoststh_post_types[]"
399
+ id="pt_<?php esc_html_e( $post_type, 'related-posts-thumbnails'); ?>"
400
+ value="<?php echo $post_type; ?>"
401
+ <?php
402
+ if ( in_array( $post_type, $relpoststh_post_types ) ) {
403
+ echo 'checked="checked"';
404
+ }
405
+ ?>
406
+ />
407
+ <label for="pt_<?php esc_html_e( $post_type, 'related-posts-thumbnails') ?>">
408
+ <?php esc_html_e( $post_type, 'related-posts-thumbnails') ?>
409
+ </label>
410
+ <?php
411
+ endforeach;
412
+ endif;
413
+ ?>
414
+ </td>
415
  </tr>
 
416
  <tr valign="top">
417
  <th scope="row">
418
+ <?php _e( 'Display related posts on categories', 'related-posts-thumbnails' ); ?>:
419
  </th>
 
420
  <td>
421
+ <?php $this->display_categories_list( $relpoststh_categoriesall, $categories, $relpoststh_categories, 'relpoststh_categoriesall', 'relpoststh_categories' );
422
+ ?>
423
+ </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  </tr>
 
425
  <tr valign="top">
426
  <th scope="row">
427
+ <?php _e( 'Categories will appear in related posts', 'related-posts-thumbnails' ); ?>:
428
+ </th>
 
429
  <td>
430
+ <?php $this->display_categories_list( $relpoststh_show_categoriesall, $categories, $relpoststh_show_categories, 'relpoststh_show_categoriesall', 'relpoststh_show_categories' );
431
+ ?>
432
+ </td>
 
 
 
433
  </tr>
434
+ <tr valign="top">
435
+ <th scope="row">
436
+ <?php _e( 'Mobile view', 'related-posts-thumbnails' ); ?>:
437
+ </th>
438
+ <td>
439
+ <input type="checkbox" name="relpoststh_mobile_view" id="relpoststh_mobile_view" value="1"
440
+ <?php
441
+ if ( $relpoststh_mobile_view ) {
442
+ echo 'checked="checked"';
443
+ }
444
+ ?>
445
+ />
446
+ <label for="relpoststh_mobile_view">
447
+ <?php _e( 'Hide on mobile devices', 'related-posts-thumbnails' ); ?>
448
+ </label>
449
+ <br />
450
+ </td>
451
+ </tr>
452
+ <!-- <tr valign="top">
453
+ <th scope="row">
454
+ <?php // _e( 'Show date under posts', 'related-posts-thumbnails' ); ?>:
455
+ </th>
456
+ <td>
457
+ <input type="checkbox" name="relpoststh_show_date" id="relpoststh_show_date" value="1"
 
 
 
 
 
 
 
 
458
  <?php
459
+ // if ( $relpoststh_show_date == '1' ) {
460
+ // echo 'checked="checked"';
461
+ // }
462
+ ?>
463
+ />
464
+ </td>
465
+ </tr> -->
466
+ <tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  <th scope="row">
468
+ <?php _e( 'Include posts after', 'related-posts-thumbnails' ); ?>:
469
  </th>
470
  <td>
471
+ <input type="text" class="rpt_post_include" name="rpt_post_include" value="<?php echo get_option( 'relpoststh_startdate' ); ?>" >
472
+ <button type="button" class="button rpt_clear_date">Clear</button>
473
+ <label for="relpoststh_excerptlength">
474
+ <p class="description">
475
+ <?php _e( 'Leave empty for all posts dates', 'related-posts-thumbnails' ); ?>
476
+ </p>
477
+ </label>
478
+ <br />
479
  </td>
480
  </tr>
481
+ <tr>
 
482
  <th scope="row">
483
+ <?php _e( 'Sort by', 'related-posts-thumbnails' ); ?>:
484
  </th>
485
  <td>
486
+ <select class="rpt_post_sort" name="rpt_post_sort">
487
+ <option value="rand"
488
+ <?php
489
+ if( get_option('rpt_post_sort') == 'rand' ) {
490
+ echo 'selected';
491
+ }
492
+ ?> >
493
+ <?php _e( 'Random', 'related-posts-thumbnails' ); ?>
494
+ </option>
495
+ <option value="latest"
496
+ <?php
497
+ if( get_option('rpt_post_sort') == 'latest' ) {
498
+ echo 'selected';
499
+ }
500
+ ?> >
501
+ <?php _e( 'Latest posts', 'related-posts-thumbnails' ); ?>
502
+ </option>
503
+ </select>
504
  </td>
505
  </tr>
506
+ <tr>
507
  <th scope="row">
508
+ <?php _e( 'Top text', 'related-posts-thumbnails' ); ?>:
509
  </th>
510
  <td>
511
+ <input type="text" name="relpoststh_top_text" value="<?php echo stripslashes( htmlspecialchars( get_option( 'relpoststh_top_text', $this->top_text ) ) ); ?>" size="50"/>
 
 
 
 
 
 
 
 
 
512
  </td>
513
  </tr>
514
+ <tr>
515
  <th scope="row">
516
+ <?php _e( 'Number of posts to display', 'related-posts-thumbnails' ); ?>:
517
  </th>
518
  <td>
519
+ <input type="number" min="1" name="relpoststh_number" value="<?php echo get_option( 'relpoststh_number', $this->number ); ?>" size="2"/>
520
+ <span class='rpt-no-validate-error' style="display:none;">
521
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
522
+ </span>
 
 
 
 
 
 
523
  </td>
524
  </tr>
525
+ <!-- <table class="form-table"> -->
526
+ <tr>
527
  <th scope="row">
528
+ <?php _e( 'Default image', 'related-posts-thumbnails' ); ?>:
529
  </th>
530
  <td>
531
+ <?php
532
+ // $imgid =(isset( $instance[ 'imgid' ] )) ? $instance[ 'imgid' ] : "";
533
+ // $img = wp_get_attachment_image_src($imgid, 'thumbnail');
534
+ // var_dump($img);
535
+ ?>
536
+ <!-- <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=""> -->
537
+ <img
538
+ src="<?php echo get_option( 'relpoststh_default_image', $this->default_image ); ?>"
539
+ id="relpoststh_default_image_prev" class="regular-text process_custom_images" height="200" width="30">
540
+ <div class="relposts-button-section">
541
+ <button class="relpoststh_set_def_image button">
542
+ <?php _e( 'Set Image', 'related-posts-thumbnails' ); ?>
543
+ </button>
544
+ <button
545
+ value="<?php echo esc_url( plugins_url( '../img/default.png', __FILE__ ) ); ?>"
546
+ class="relpoststh_set_plug_image button">
547
+ <?php _e( 'Default Image', 'related-posts-thumbnails' ); ?>
548
+ </button>
549
+ <input type="hidden" name="relpoststh_default_image" id="relpoststh_default_image"
550
+ value="<?php echo get_option( 'relpoststh_default_image', $this->default_image ); ?>" size="50"/>
551
+ </div>
552
  </td>
553
+ </tr>
554
+ <!-- </table> -->
555
+ </table>
556
+ </div>
 
 
 
 
 
557
 
558
+ <div class="postbox" style="padding: 20px; display:none;" id="content_thumbnail_options">
559
+ <h2>
560
+ <?php _e( 'Thumbnails', 'related-posts-thumbnails' ); ?>
561
+ </h2>
562
 
563
+ <table class="form-table">
564
+ <tr>
565
+ <th>
566
+ <?php _e( 'Select thumbnails source', 'related-posts-thumbnails' ); ?>
567
  </th>
 
568
  <td>
569
+ <select class="select-style" name="relpoststh_thsource" id="relpoststh_thsource">
570
+ <?php foreach ( $thsources as $name => $title ): ?>
571
+ <option value="<?php echo $name; ?>"
572
+ <?php
573
+ if ( $relpoststh_thsource == $name ) {
574
+ echo 'selected';
575
+ }
576
+ ?> >
577
+ <?php echo $title; ?>
578
+ </option>
579
+ <?php endforeach; ?>
580
+ </select>
581
+ </td>
582
+ </tr>
583
+ </table>
584
+
585
+ <div id="relpoststh-post-thumbnails">
586
+ <table class="form-table">
587
+ <tr valign="top">
588
+ <th scope="row">
589
+ <?php _e( 'Related posts thumbnail size', 'related-posts-thumbnails' ); ?>:
590
+ </th>
591
+ <td>
592
+ <select name="relpoststh_poststhname">
593
+ <?php foreach ( $available_sizes as $size_name => $size ): ?>
594
+ <option <?php if ( $size_name == get_option( 'relpoststh_poststhname', $this->poststhname ) ) {
595
+ echo 'selected';
596
+ } ?> >
597
+ <?php echo $size_name; ?>
598
+ </option>
599
+ <?php endforeach; ?>
600
+ </select>
601
+ <?php if ( !current_theme_supports( 'post-thumbnails' ) ): ?> (<?php
602
+ e( 'Your theme has to support post-thumbnails to have more choices', 'related-posts-thumbnails' ); ?>)
603
+ <?php endif; ?>
604
+ </td>
605
+ </tr>
606
+ <?php if ( current_theme_supports( 'post-thumbnails' ) ): ?>
607
+ <tr>
608
+ <th scope="row">
609
+ <?php _e( 'Show posts with featured image', 'related-posts-thumbnails' ); ?>:
610
+ </th>
611
+ <td>
612
+ <input type="checkbox" name="onlywiththumbs" id="onlywiththumbs" value="1" <?php if ( $onlywiththumbs ) { echo 'checked="checked"'; } ?> />
613
+ <label for="onlywiththumbs">
614
+ <p class="description rpth-discription">
615
+ <?php _e( 'Only those posts will be shown that has featured image', 'related-posts-thumbnails' ); ?>
616
+ </p>
617
  </label>
618
  <br />
619
+ </td>
620
+ </tr>
621
+ <?php endif; ?>
622
+ </table>
623
+ </div>
624
+
625
+ <div id="relpoststh-custom-field">
626
+ <table class="form-table">
627
+ <tr valign="top">
628
+ <th scope="row">
629
+ <?php _e( 'Custom field name', 'related-posts-thumbnails' ); ?>:
630
+ </th>
631
+
632
+ <td>
633
+ <input type="text" name="relpoststh_customfield" value="<?php echo get_option( 'relpoststh_customfield', $this->custom_field ); ?>" size="50"/>
634
+ </td>
635
+ </tr>
636
+
637
+ <tr valign="top">
638
+ <th scope="row">
639
+ <?php _e( 'Size', 'related-posts-thumbnails' ); ?>:
640
+ </th>
641
+
642
+ <td>
643
+ <label for="relpoststh_customwidth" id="relpoststh_customwidth">
644
+ <?php _e( 'Width', 'related-posts-thumbnails' ); ?>:
645
+ </label>
646
+
647
+ <input type="number" min="1" name="relpoststh_customwidth" value="<?php echo get_option( 'relpoststh_customwidth', $this->custom_width ); ?>" size="3"/>
648
+
649
+ <p class="description rpth-discription">
650
+ <?php _e( ' px', 'related-posts-thumbnails' ); ?>
651
+ </p>
652
+ <br>
653
+
654
+ <label for="relpoststh_customheight">
655
+ <?php _e( 'Height', 'related-posts-thumbnails' ); ?>:
656
+ </label>
657
+
658
+ <input type="number" min="1" name="relpoststh_customheight" value="<?php echo get_option( 'relpoststh_customheight', $this->custom_height );?>" size="3"/>
659
+
660
+ <p class="description rpth-discription">
661
+ <?php _e( ' px', 'related-posts-thumbnails' ); ?>
662
+ </p>
663
+
664
+ <br>
665
+
666
+ <span class='rpt-no-validate-error' style="display:none;">
667
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
668
+ </span>
669
+ </td>
670
+ </tr>
671
+
672
+ <tr valign="top">
673
+ <th scope="row">
674
+ <?php _e( 'Theme resize url', 'related-posts-thumbnails' ); ?>:
675
+ </th>
676
+
677
+ <td>
678
+ <input type="text" name="relpoststh_theme_resize_url" value="<?php echo get_option( 'relpoststh_theme_resize_url', '' ); ?>" size="50"/>
679
+
680
+ <p class='description rpth-discription'>
681
+ <?php _e( 'If your theme resizes images, enter URL to its resizing PHP file', 'related-posts-thumbnails' ); ?>
682
+ </p>
683
+ </td>
684
+ </tr>
685
+ </table>
686
+ </div>
687
+ </div>
688
+
689
+
690
+ <!-- DISPLAY SETTINGS -->
691
+ <div class="postbox" style="padding: 20px; display:none;" id="content_style_options">
692
+ <h2>
693
+ <?php _e( 'Style Options', 'related-posts-thumbnails' ); ?>
694
+ </h2>
695
+
696
+ <table class="form-table">
697
+
698
+ <!-- calling layouts from pro -->
699
+ <?php // do_action('rptp_style_layouts'); ?>
700
+
701
+ <tr>
702
+ <th scope="row"><?php
703
+ _e( 'Output style', 'related-posts-thumbnails' ); ?>:
704
+ </th>
705
+
706
+ <td>
707
+ <select name="relpoststh_output_style" id="relpoststh_output_style">
708
+ <?php foreach ( $output_styles as $name => $title ): ?>
709
+ <option value="<?php echo $name; ?>"
710
+ <?php if ( $relpoststh_output_style == $name ) { echo 'selected'; } ?> >
711
+ <?php echo $title; ?>
712
+ </option>
713
+ <?php
714
+ endforeach; ?>
715
+ </select>
716
+ <span id="relpoststh_cleanhtml" style="display:
717
  <?php
718
+ if ( $relpoststh_output_style == 'list' ) {
719
+ echo 'inline';
720
+ } else {
721
+ echo 'none';
722
+ } ?> ;">
723
+
724
+ <?php _e( 'Turn off plugin styles', 'related-posts-thumbnails' ); ?>
725
+ <input type="checkbox" name="relpoststh_cleanhtml" <?php if ( $relpoststh_cleanhtml ) { echo 'checked="checked"'; } ?> />
726
+ </span>
727
+ </td>
728
+ </tr>
729
+
730
+ <tr valign="top">
731
+
732
+ <th scope="row"><?php
733
+ _e( 'Background color', 'related-posts-thumbnails' ); ?>:
734
+ </th>
735
+
736
+ <td>
737
+ <input type="text" name="relpoststh_background" value="<?php echo get_option( 'relpoststh_background', $this->background ); ?>" data-default-color="<?php echo $this->background; ?>"/>
738
+ </td>
739
+ </tr>
740
+
741
+ <tr valign="top">
742
+ <th scope="row">
743
+ <?php _e( 'Background color on mouse over', 'related-posts-thumbnails' ); ?>:
744
+ </th>
745
+
746
+ <td>
747
+ <input type="text" name="relpoststh_hoverbackground" value="<?php echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground ); ?>" data-default-color="<?php echo $this->hoverbackground; ?>" />
748
+ </td>
749
+ </tr>
750
+
751
+ <tr valign="top">
752
+ <th scope="row">
753
+ <?php _e( 'Border color', 'related-posts-thumbnails' ); ?>:
754
+ </th>
755
+
756
+ <td>
757
+ <input type="text" name="relpoststh_bordercolor" value="<?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>" data-default-color="<?php echo $this->border_color; ?>"/>
758
+ </td>
759
+ </tr>
760
+
761
+ <tr valign="top">
762
+ <th scope="row">
763
+ <?php _e( 'Font color', 'related-posts-thumbnails' ); ?>:
764
+ </th>
765
+ <td>
766
+ <input type="text" name="relpoststh_fontcolor" value="<?php echo get_option( 'relpoststh_fontcolor', $this->font_color ); ?>" data-default-color="<?php echo $this->font_color; ?>"/>
767
+ </td>
768
+ </tr>
769
+
770
+ <tr valign="top">
771
+ <th scope="row">
772
+ <?php _e( 'Font family', 'related-posts-thumbnails' ); ?>:
773
+ </th>
774
+ <td>
775
+ <input type="text" name="relpoststh_fontfamily" value="<?php echo stripslashes( htmlspecialchars( get_option( 'relpoststh_fontfamily', $this->font_family ) ) ); ?>" size="50"/>
776
+ </td>
777
+ </tr>
778
+
779
+ <tr valign="top">
780
+ <th scope="row">
781
+ <?php _e( 'Font size', 'related-posts-thumbnails' ); ?>:
782
+ </th>
783
+ <td>
784
+ <input type="number" min="1" name="relpoststh_fontsize" value="<?php echo get_option( 'relpoststh_fontsize', $this->font_size ); ?>" size="7"/>
785
+ <label for="relpoststh_fontsize">
786
+ <p class="description rpth-discription"><?php _e( 'px', 'related-posts-thumbnails' ); ?></p>
787
+ </label>
788
 
789
+ <span class='rpt-no-validate-error' style="display:none;">
790
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
791
+ </span>
792
+ </td>
793
+ </tr>
794
+ <tr valign="top">
795
+ <th scope="row">
796
+ <?php _e( 'Text maximum length', 'related-posts-thumbnails' ); ?>:
797
+ </th>
798
+ <td>
799
+ <input type="number" min="0" name="relpoststh_textlength" value="<?php echo get_option( 'relpoststh_textlength', $this->text_length ); ?>" size="7"/>
800
+ <label for="relpoststh_textlength">
801
+ <p class="description rpth-discription">
802
+ <?php _e( 'Set 0 for no title', 'related-posts-thumbnails' ); ?>
803
+ </p>
804
+ </label>
805
+ <span class='rpt-no-validate-error' style="display:none;">
806
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
807
+ </span>
808
+ <br />
809
+ </td>
810
+ </tr>
811
+ <tr valign="top">
812
+ <th scope="row">
813
+ <?php _e( 'Excerpt maximum length', 'related-posts-thumbnails' ); ?>:
814
+ </th>
815
+ <td>
816
+ <input type="number" min="0" name="relpoststh_excerptlength" value="<?php echo get_option( 'relpoststh_excerptlength', $this->excerpt_length ); ?>" size="7"/>
817
+ <label for="relpoststh_excerptlength">
818
+ <p class="description rpth-discription" >
819
+ <?php _e( 'Set 0 for no excerpt', 'related-posts-thumbnails' ); ?>
820
+ </p>
821
+ </label>
822
+ <span class='rpt-no-validate-error' style="display:none;">
823
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
824
+ </span>
825
+ <br />
826
+ </td>
827
+ </tr>
828
+ <tr valign="top">
829
+ <th scope="row">
830
+ <?php _e( 'Text block height', 'related-posts-thumbnails' ); ?>:
831
+ </th>
832
+ <td>
833
+ <input type="number" min="0" name="relpoststh_textblockheight" value="<?php echo get_option( 'relpoststh_textblockheight', $this->text_block_height ); ?>" size="7"/>
834
+ <p class="description rpth-discription">px</p>
835
+ <span class='rpt-no-validate-error' style="display:none;">
836
+ <?php _e( 'Only Digits are allowed', 'related-posts-thumbnails' ); ?>
837
+ </span>
838
+ </td>
839
+ </tr>
840
+ </table>
841
+ </div>
842
+
843
+ <div class="postbox" style="padding: 20px; display:none;" id="content_relation_options">
844
+ <h2>
845
+ <?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>
846
+ </h2>
847
+ <table class="form-table">
848
+
849
+ <tr valign="top">
850
+
851
+ <th scope="row">
852
+ <?php _e( 'Base relation on:', 'related-posts-thumbnails' ); ?>
853
+ </th>
854
+
855
+ <td>
856
+ <?php
857
+ if ( is_array( $relation_options ) && count( $relation_options ) ):
858
+ foreach ( $relation_options as $ro_key => $ro_name ): ?>
859
+ <input type="radio" name="relpoststh_relation" id="relpoststh_relation_<?php echo esc_html_e( $ro_key, 'related-posts-thumbnails' ); ?>" value="<?php echo $ro_key; ?>"
860
+ <?php if ( $relpoststh_relation == $ro_key ) { echo 'checked="checked"'; } ?>
861
+ />
862
+ <label for="relpoststh_relation_<?php _e( $ro_key, 'related-posts-thumbnails' ); ?>">
863
+ <?php _e( $ro_key, 'related-posts-thumbnails' ); ?>
864
+ </label>
865
+ <br />
866
+ <?php
867
+ endforeach;
868
+
869
+ endif;
870
+ ?>
871
+ <div id="custom_taxonomies" style="display:
872
  <?php
873
+ if ( $relpoststh_relation == 'custom' ) {
874
+ echo 'inline';
875
+ } else {
876
+ echo 'none';
877
+ } ?> ;">
 
 
 
878
  <?php
879
+ if ( is_array( $custom_taxonomies ) && count( $custom_taxonomies ) ):
880
+ foreach ( $custom_taxonomies as $custom_taxonomy ): ?>
881
+ <input type="checkbox" name="relpoststh_custom_taxonomies[]" id="ct_<?php echo $custom_taxonomy; ?>" value="<?php echo $custom_taxonomy; ?>"
882
+ <?php
883
+ if ( in_array( $custom_taxonomy, $relpoststh_custom_taxonomies ) ) {
884
+ echo 'checked="checked"';
885
+ }
886
+ ?>
887
+ />
888
+ <label for="ct_<?php _e( $custom_taxonomy, 'related-posts-thumbnails' ); ?>">
889
+ <?php _e( $custom_taxonomy, 'related-posts-thumbnails' ); ?>
890
+ </label>
891
+ <?php
892
+ endforeach;
893
+
894
+ endif;
895
+ ?>
896
+ </div>
897
+ </td>
898
+ </tr>
899
+ </table>
900
+ </div>
901
+ <!-- <input name="Submit" value="<?php _e( 'Save Changes', 'related-posts-thumbnails' ); ?>" type="submit" class="button-primary"> -->
902
+ </div>
903
  </div>
 
904
 
905
+ <div class="wpbr-button-container bottom">
906
+
907
+ <div class="wpbr-social-links alignleft">
908
+ <a href="https://profiles.wordpress.org/hiddenpearls/" class="wordpress" target="_blank">
909
+ <span class="dashicons dashicons-wordpress"> </span>
910
+ </a>
911
+ </div>
912
+ <input type="submit" name="Submit" class="wpb-rpt-settings-submit button button-primary button-big" value="<?php
913
+ esc_html_e( 'Save Settings', 'related-posts-thumbnails' );
914
+ ?>" id="wpb_rpt_save_setting_bottom">
915
+ </div>
916
+ </div>
 
917
 
918
+ <div class="metabox-holder wpbr-sidebar">
919
+ <div class="sidebar postbox">
920
+ <h2>
921
+ <?php esc_html_e( 'Spread the Word', 'related-posts-thumbnails' ); ?>
922
+ </h2>
923
+ <ul>
924
+ <li>
925
+ <?php
926
+ echo sprintf( '<a href="%1$s%2$s%3$s" data-count="%4$s" class="%5$s" target="%6$s" title="%7$s"> %8$s <span class ="%9$s"></span> </a>', "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", 'none', 'button twitter' , '_blank', __( 'Post to Twitter Now', 'related-posts-thumbnails'), __( 'Share on Twitter', 'related-posts-thumbnails' ), 'dashicons dashicons-twitter' );
927
+ ?>
928
+ </li>
929
 
930
+ <li>
931
+ <?php
932
+ echo sprintf( '<a href="%1$s" class="%3$s" target="%4$s" title="%5$s"> %6$s <span class ="%7$s"></span> </a>', "https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails", 'none', 'button facebook' , '_blank', __( 'Share with your facebook friends about this awesome plugin.', 'related-posts-thumbnails'), __( 'Share on Facebook', 'related-posts-thumbnails' ), 'dashicons dashicons-facebook' );
933
+ ?>
934
+ </li>
 
 
935
 
936
+ <li>
937
+ <?php
938
+ echo sprintf( '<a href="%1$s" class="%3$s" target="%4$s" title="%5$s"> %6$s <span class ="%7$s"></span> </a>', "https://wordpress.org/support/view/plugin-reviews/related-posts-thumbnails?filter=5", 'none', 'button wordpress' , '_blank', __( 'Rate on Wordpress.org.', 'related-posts-thumbnails'), __( 'Rate on Wordpress.org', 'related-posts-thumbnails' ), 'dashicons dashicons-wordpress' );
939
+ ?>
940
+
941
+ </li>
942
+ </ul>
943
+ </div>
944
+
945
+ <div class="sidebar postbox">
946
+
947
+ <h2>
948
+ <?php esc_html_e( 'Subscribe Newsletter', 'related-posts-thumbnails' ); ?>
949
+ </h2>
950
+ <ul>
951
+ <li>
952
+ <label for="Email"><?php esc_html_e( 'Email', 'related-posts-thumbnails' ); ?></label>
953
+ <input type="email" name="subscriber_mail" value="<?php echo get_option( 'admin_email' ); ?>" id="rpt_subscribe_mail">
954
+ <p class='rpt_subscribe_warning'></p>
955
+ </li>
956
+ <li>
957
+ <label for="Name"><?php esc_html_e( 'Name', 'related-posts-thumbnails' ); ?></label>
958
+ <input type="text" name="subscriber_name" id="rpt_subscribe_name" value="<?php echo wp_get_current_user()->display_name; ?>" id="rpt_subscribe_mail">
959
+ </li>
960
+ <li>
961
+ <input type="submit" value="<?php esc_html_e( 'Subscribe Now', 'related-posts-thumbnails' ); ?>" class="button button-primary button-big" id='rpt_subscribe_btn' />
962
+ <img src="<?php echo admin_url( 'images/spinner.gif' ); ?>" class='rpt_subscribe_loader' style="display:none" />
963
+ </li>
964
+ <li>
965
+ <p class='rpt_return_message'></p>
966
+ </li>
967
+ </ul>
968
+ </div>
969
+
970
+ <div class="sidebar postbox">
971
+ <h2>
972
+ <?php esc_html_e( 'Recommended Plugins', 'related-posts-thumbnails' ); ?>
973
+ </h2>
974
+ <!-- <p>Following are the plugins highly recommend by Team WPBrigade.</p> -->
975
+ <ul class="plugins_lists">
976
+ <li>
977
+ <?php
978
+ echo sprintf( '<a href="%1$s" data-count="%2$s" target="%4$s" title="%5$s"> %6$s <span></span> </a>', "https://wpbrigade.com/wordpress/plugins/loginpress-pro/?utm_source=related-posts-lite&utm_medium=sidebar&utm_campaign=pro-upgrade", 'none', 'button wordpress' , '_blank', __( 'Share with your facebook friends about this awesome plugin.', 'related-posts-thumbnails'), __( 'Google Analytics by Analytify' ), 'dashicons dashicons-wordpress' );
979
+ ?>
980
+ <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( 'LoginPress - Login Customizer', 'related-posts-thumbnails' ); ?>"><?php esc_html_e( 'LoginPress - Login Customizer', 'related-posts-thumbnails' ); ?> </a>
981
+ </li>
982
 
983
+ <li>
984
+ <?php
985
+ echo sprintf( '<a href="%1$s" target="%4$s" title="%5$s"> %6$s <span></span> </a>', "https://analytify.io/ref/73/?utm_source=related-posts-lite&utm_medium=sidebar&utm_campaign=pro-upgrade", 'none', 'button wordpress' , '_blank', __( 'Google Analytics by Analytify.', 'related-posts-thumbnails'), __( 'Google Analytics by Analytify' ), 'dashicons dashicons-wordpress' );
986
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
987
 
988
+ </li>
 
 
 
 
 
 
 
 
989
 
990
+ <li>
991
+ <?php
992
+ echo sprintf( '<a href="%1$s" target="%4$s" title="%5$s"> %6$s <span></span> </a>', "https://wpbrigade.com/recommend/maintenance-mode", 'none', 'button wordpress' , '_blank', __( 'Under Construction & Maintenance mode', 'related-posts-thumbnails', 'related-posts-thumbnails'), __( 'Under Construction & Maintenance mode', 'related-posts-thumbnails' ), 'dashicons dashicons-wordpress' );
993
+ ?>
 
 
994
 
995
+ </li>
996
+ </ul>
997
+ </div>
 
 
 
 
998
  </div>
999
  </div>
1000
 
 
1001
  </form>
1002
  <p style="margin-top: 40px;">
1003
  <small>
inc/rpt-widget.php CHANGED
@@ -22,13 +22,15 @@ class RelatedPostsThumbnailsWidget extends WP_Widget {
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,19 +42,28 @@ class RelatedPostsThumbnailsWidget extends WP_Widget {
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'] );
53
  return $instance;
54
  }
55
 
 
 
 
 
 
 
 
56
  function form( $instance ) {
57
  $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
58
  ?>
@@ -65,6 +76,8 @@ class RelatedPostsThumbnailsWidget extends WP_Widget {
65
  /**
66
  * Register Widget.
67
  *
 
 
68
  */
69
  function register_wpb_rpt_widget() {
70
  register_widget( 'RelatedPostsThumbnailsWidget' );
22
  );
23
  parent::__construct( false, 'Related Posts Thumbnails', $args );
24
  }
25
+
26
+ /**
27
+ * Show Widget
28
+ *
29
+ * @param $args
30
+ * @param $instance
31
+ *
32
+ * @return void
33
+ */
34
  function widget( $args, $instance ) {
35
  if ( is_single() && ! is_page() ) { // display on post page only
36
  extract( $args );
42
  echo $after_widget;
43
  }
44
  }
45
+
46
+ /**
47
+ * Widget Instance update
48
+ *
49
+ * @param $new_instance
50
+ * @param $old_instance
51
+ *
52
+ * @return $instance
53
+ */
54
  function update( $new_instance, $old_instance ) {
55
  $instance = $old_instance;
56
  $instance['title'] = strip_tags( $new_instance['title'] );
57
  return $instance;
58
  }
59
 
60
+ /**
61
+ * Widget Form
62
+ *
63
+ * @param $instance
64
+ *
65
+ * @return void
66
+ */
67
  function form( $instance ) {
68
  $title = !empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
69
  ?>
76
  /**
77
  * Register Widget.
78
  *
79
+ * @version 1.9.0
80
+ *
81
  */
82
  function register_wpb_rpt_widget() {
83
  register_widget( 'RelatedPostsThumbnailsWidget' );
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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
 
@@ -70,11 +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
- = 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.
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.1
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
70
  1. Plugin settings page
71
 
72
  == Upgrade Notice ==
73
+
74
+ = 1.9.1 =
75
  * Please upgrade immediately - Introducing filters for developers to extend Related Posts
76
 
77
  == Changelog ==
78
 
79
+ = 1.9.1 - 2021-04-08 =
80
+ * Bugfix: Mobile view layout.
81
+ * New Feature : Introducing Lazy Loading filter. Use `rpt-lazy-loading` filter to enable the lazy loading for thumbnails. By default it's false.
82
+ * Compatibility : Compatible with PHP 8.0
83
+
84
  = 1.9.0 - 2021-03-22 =
85
  * New Feature : Filter to add custom sizes of thumbnails to choose from.
86
  * New Feature : added 'rpt_exclude_post' filter to exclude posts from showing as Related Posts.
related-posts-thumbnails.php CHANGED
@@ -3,7 +3,7 @@
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
  */
@@ -24,39 +24,40 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
  GNU General Public License for more details.
25
  */
26
  class RelatedPostsThumbnails {
27
- /* Default values. PHP 4 compatible */
28
- public $single_only = '1';
29
- public $auto = '1';
30
- public $top_text = '<h3>Related posts:</h3>';
31
- public $number = 3;
32
- public $relation = 'categories';
33
- public $poststhname = 'thumbnail';
34
- public $background = '#ffffff';
35
- public $hoverbackground = '#eeeeee';
36
- public $border_color = '#dddddd';
37
- public $font_color = '#333333';
38
- public $font_family = 'Arial';
39
- public $font_size = '12';
40
- public $text_length = '100';
41
- public $excerpt_length = '0';
42
- public $custom_field = '';
43
- public $custom_height = '100';
44
- public $custom_width = '100';
45
- public $text_block_height = '75';
46
- public $thsource = 'post-thumbnails';
47
- public $categories_all = '1';
48
- public $devmode = '0';
49
- public $output_style = 'div';
50
- public $post_types = array( 'post' );
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
 
@@ -64,7 +65,7 @@ class RelatedPostsThumbnails {
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
@@ -96,17 +97,15 @@ class RelatedPostsThumbnails {
96
  add_shortcode( 'related-posts-thumbnails', array( $this, 'related_posts_shortcode' ) );
97
 
98
  }
99
-
100
  /**
101
- * Prevent related posts on editor screen (builders).
102
- *
103
- * @return bool $return
104
- */
105
  function prevent_on_editors() {
106
  $return = false;
107
- $prevent_on_edit = apply_filters( 'rpt_prevent_on_edit', array(
108
- 'divi' => false,
109
- ) );
110
 
111
  foreach ( $prevent_on_edit as $key => $value ) {
112
  switch ( $key ) {
@@ -122,18 +121,20 @@ class RelatedPostsThumbnails {
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'];
@@ -147,6 +148,7 @@ class RelatedPostsThumbnails {
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
  }
@@ -154,626 +156,647 @@ class RelatedPostsThumbnails {
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
- */
211
- function add_deactive_modal() {
212
- global $pagenow;
213
-
214
- if ( 'plugins.php' !== $pagenow ) {
215
- return;
216
- }
217
-
218
- include RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . 'inc/rpt-deactivate-form.php';
219
- }
220
-
221
-
222
- /**
223
- * Send the deactivate user response to api.
224
- *
225
- * @since 1.6.2
226
- */
227
- function rpt_deactivate() {
228
- $email = get_option( 'admin_email' );
229
- $_reason = sanitize_text_field( wp_unslash( $_POST[ 'reason' ] ) );
230
- $reason_detail = sanitize_text_field( wp_unslash( $_POST[ 'reason_detail' ] ) );
231
- $reason = '';
232
-
233
- if ( $_reason == '1' ) {
234
- $reason = 'I only needed the plugin for a short period';
235
- } elseif ( $_reason == '2' ) {
236
- $reason = 'I found a better plugin';
237
- } elseif ( $_reason == '3' ) {
238
- $reason = 'The plugin broke my site';
239
- } elseif ( $_reason == '4' ) {
240
- $reason = 'The plugin suddenly stopped working';
241
- } elseif ( $_reason == '5' ) {
242
- $reason = 'I no longer need the plugin';
243
- } elseif ( $_reason == '6' ) {
244
- $reason = 'It\'s a temporary deactivation. I\'m just debugging an issue.';
245
- } elseif ( $_reason == '7' ) {
246
- $reason = 'Other';
247
- }
248
- $fields = array(
249
- 'email' => $email,
250
- 'website' => get_site_url(),
251
- 'action' => 'Deactivate',
252
- 'reason' => $reason,
253
- 'reason_detail' => $reason_detail,
254
- 'blog_language' => get_bloginfo( 'language' ),
255
- 'wordpress_version' => get_bloginfo( 'version' ),
256
- 'php_version' => PHP_VERSION,
257
- 'plugin_version' => RELATED_POSTS_THUMBNAILS_VERSION,
258
- 'plugin_name' => 'Related Post Thumbnails'
259
- );
260
-
261
- $response = wp_remote_post( RELATED_POSTS_THUMBNAILS_FEEDBACK_SERVER, array(
262
- 'method' => 'POST',
263
- 'timeout' => 5,
264
- 'httpversion' => '1.0',
265
- 'blocking' => false,
266
- 'headers' => array(),
267
- 'body' => $fields
268
- ) );
269
-
270
- wp_die();
271
- }
272
-
273
- /**
274
- * Check either to show notice or not.
275
- *
276
- * @since 1.8.2
277
- */
278
- public function review_notice() {
279
- $this->review_dismissal();
280
- $this->review_prending();
281
-
282
- $review_dismissal = get_option( 'rpt_review_dismiss' );
283
- if ( 'yes' == $review_dismissal ) {
284
- return;
285
- }
286
-
287
- $activation_time = get_option( 'rpt_active_time' );
288
- if ( !$activation_time ) {
289
- $activation_time = time();
290
- add_option( 'rpt_active_time', $activation_time );
291
- }
292
-
293
- // 1296000 = 15 Days in seconds.
294
- if ( time() - $activation_time > 1296000 ) {
295
- add_action( 'admin_notices', array(
296
- $this,
297
- 'review_notice_message'
298
- ) );
299
- }
300
- }
301
-
302
- /**
303
- * Show review Message After 15 days.
304
- *
305
- * @since 1.8.2
306
- */
307
- public function review_notice_message() {
308
- $scheme = ( parse_url( $_SERVER[ 'REQUEST_URI' ], PHP_URL_QUERY ) ) ? '&' : '?';
309
- $url = $_SERVER[ 'REQUEST_URI' ] . $scheme . 'rpt_review_dismiss=yes';
310
- $dismiss_url = wp_nonce_url( $url, 'rpt-review-nonce' );
311
-
312
- $_later_link = $_SERVER[ 'REQUEST_URI' ] . $scheme . 'ssb_review_later=yes';
313
- $later_url = wp_nonce_url( $_later_link, 'rpt-review-nonce' ); ?>
314
-
315
- <style media="screen">
316
- .rpt-review-notice { padding: 15px 0; background-color: #fff; border-radius: 3px; margin: 20px 20px 0 0; border-left: 4px solid transparent; } .rpt-review-notice:after { content: ''; display: table; clear: both; }
317
- .rpt-review-thumbnail { float: left; line-height: 80px; text-align: center; width: 117px; }
318
- .rpt-review-thumbnail img { width: 118px; vertical-align: middle; }
319
- .rpt-review-text { overflow: hidden; }
320
- .rpt-review-text h3 { font-size: 24px; margin: 0 0 5px; font-weight: 400; line-height: 1.3; }
321
- .rpt-review-text p { font-size: 13px; margin: 0 0 5px; }
322
- .rpt-review-ul { margin: 0; padding: 0; }
323
- .rpt-review-ul li { display: inline-block; margin-right: 15px; }
324
- .rpt-review-ul li a { display: inline-block; color: #10738B; text-decoration: none; padding-left: 26px; position: relative; }
325
- .rpt-review-ul li a span { position: absolute; left: 0; top: -2px; }
326
- </style>
327
- <div class="rpt-review-notice">
328
- <div class="rpt-review-thumbnail">
329
- <img src="<?php
330
- echo plugins_url( 'assets/images/rpt-logo.png', __FILE__ );
331
- ?>" alt="">
332
- </div>
333
- <div class="rpt-review-text">
334
- <h3><?php
335
- _e( 'Leave A Review?', 'related-posts-thumbnails' );
336
- ?></h3>
337
- <p><?php
338
- _e( 'We hope you\'ve enjoyed using Related Post Thumbnails! Would you consider leaving us a review on WordPress.org?', 'related-posts-thumbnails' );
339
- ?></p>
340
- <ul class="rpt-review-ul">
341
- <li>
342
- <a href="https://wordpress.org/support/plugin/related-posts-thumbnails/reviews/?filter=5" target="_blank"><span class="dashicons dashicons-external"></span>
343
- <?php _e( 'Sure! I\'d love to!', 'related-posts-thumbnails' ); ?>
344
- </a>
345
- </li>
346
- <li>
347
- <a href="<?php echo $dismiss_url; ?>">
348
- <span class="dashicons dashicons-smiley"></span>
349
- <?php _e( 'I\'ve already left a review', 'related-posts-thumbnails' ); ?>
350
- </a>
351
- </li>
352
- <li>
353
- <a href="<?php echo $later_url; ?>">
354
- <span class="dashicons dashicons-calendar-alt"></span>
355
- <?php _e( 'Maybe Later', 'related-posts-thumbnails' ); ?>
356
- </a>
357
- </li>
358
- <li>
359
- <a href="<?php echo $dismiss_url; ?>">
360
- <span class="dashicons dashicons-dismiss"></span>
361
- <?php _e( 'Never show again', 'related-posts-thumbnails' ); ?>
362
- </a>
363
- </li>
364
- </ul>
365
- </div>
366
- </div>
367
-
368
- <?php
369
- }
370
-
371
- /**
372
- * Set time to current so review notice will popup after 15 days
373
- *
374
- * @since 1.8.2
375
- */
376
- function review_prending() {
377
- // delete_site_option( 'rpt_review_dismiss' );
378
- if ( !is_admin() || !current_user_can( 'manage_options' ) || !isset( $_GET[ '_wpnonce' ] ) || !wp_verify_nonce( sanitize_key( wp_unslash( $_GET[ '_wpnonce' ] ) ), 'rpt-review-nonce' ) || !isset( $_GET[ 'ssb_review_later' ] ) ) {
379
-
380
- return;
381
- }
382
-
383
- // Reset Time to current time.
384
- update_option( 'rpt_active_time', time() );
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' );
394
- if ( !is_admin() || !current_user_can( 'manage_options' ) || !isset( $_GET[ '_wpnonce' ] ) || !wp_verify_nonce( sanitize_key( wp_unslash( $_GET[ '_wpnonce' ] ) ), 'rpt-review-nonce' ) || !isset( $_GET[ 'rpt_review_dismiss' ] ) ) {
395
-
396
- return;
397
- }
398
-
399
- add_option( 'rpt_review_dismiss', 'yes' );
400
- }
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() {
408
- if ( get_option( 'relpoststh_default_image' ) !== $this->default_image ) {
409
-
410
- $chunks = explode( '/', get_option( 'relpoststh_default_image' ) );
411
- if ( in_array( 'related-posts-thumbnails', $chunks ) ) {
412
- return true;
413
- }
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 );
456
-
457
- $amp_endpoint = ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) ? true : false;
458
-
459
- // Stop execution if RPT is disabled in AMP view
460
- if ( ( $amp_endpoint ) && ( 'disable' === apply_filters( 'rpth_amp', true ) ) ) {
461
- $debug .= 'AMP view disabled';
462
-
463
- return $this->finish_process( '', $debug, $time );
464
- }
465
-
466
- $posts_number_opt = get_option( 'relpoststh_number', $this->number );
467
- $posts_number = !empty( $posts_number ) ? $posts_number : $posts_number_opt;
468
- $height = '';
469
- $width = '';
470
- // $date = '';
471
- $order_by = 'DESC';
472
-
473
- $sort_by_opt = get_option( 'rpt_post_sort') == 'latest' ? 'post_date '.$order_by.'': 'rand()';
474
- $sort_by = !empty( $sort_by ) ? $sort_by : $sort_by_opt;
475
-
476
- // rpt_content_align: add content allignment class; clases are: relpost-align-left, relpost-align-right and relpost-align-center
477
- $output = '<!-- relpost-thumb-wrapper -->';
478
- $output .= '<div class="relpost-thumb-wrapper">';
479
- $output .= '<!-- filter-class -->';
480
- $output .='<div class="relpost-thumb-container'. apply_filters( 'rpt_content_align', '' ) . '">';
481
- $alt = '';
482
-
483
- if ( $posts_number <= 0 ) { // return nothing if this parameter was set to <= 0
484
- $output = '';
485
- return $this->finish_process( $output, $debug . 'Posts number is 0;', $time );
486
- }
487
-
488
- $id = get_the_ID();
489
- $relation = get_option( 'relpoststh_relation', $this->relation );
490
- $poststhname = get_option( 'relpoststh_poststhname', $this->poststhname );
491
- $text_length = get_option( 'relpoststh_textlength', $this->text_length );
492
- $excerpt_length = get_option( 'relpoststh_excerptlength', $this->excerpt_length );
493
- $thsource = get_option( 'relpoststh_thsource', $this->thsource );
494
- $categories_show_all = get_option( 'relpoststh_show_categoriesall', get_option( 'relpoststh_categoriesall', $this->categories_all ) );
495
- $onlywiththumbs = ( current_theme_supports( 'post-thumbnails' ) && $thsource == 'post-thumbnails' ) ? get_option( 'relpoststh_onlywiththumbs', false ) : false;
496
- $post_type = get_post_type();
497
-
498
- global $wpdb;
499
-
500
- /* Get taxonomy terms */
501
- $debug .= "Relation: $relation; All categories: $categories_show_all;";
502
- $use_filter = ( $categories_show_all != '1' || $relation != 'no' );
503
-
504
- if ( $use_filter ) {
505
- $query_objects = "SELECT distinct object_id FROM $wpdb->term_relationships WHERE 1=1 ";
506
-
507
- if ( $relation != 'no' ) {
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
- }
525
- $object_terms = wp_get_object_terms( $id, $taxonomy, array(
526
- 'fields' => 'ids'
527
- ) );
528
- if ( empty( $object_terms ) || !is_array( $object_terms ) ) { // no terms to get taxonomy
529
- $output = '';
530
- return $this->finish_process( $output, $debug . __( 'No taxonomy terms to get posts;' ), $time );
531
- }
532
-
533
- $query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('" . implode( "', '", $object_terms ) . "')";
534
- $object_taxonomy = $wpdb->get_results( $query );
535
- $object_taxonomy_a = array();
536
- if ( count( $object_taxonomy ) > 0 ) {
537
- foreach ( $object_taxonomy as $item ) {
538
- $object_taxonomy_a[] = $item->term_taxonomy_id;
539
- }
540
- }
541
- $query_objects .= " AND term_taxonomy_id IN ('" . implode( "', '", $object_taxonomy_a ) . "') ";
542
- }
543
-
544
- if ( $categories_show_all != '1' ) {
545
- /* Get filter terms */
546
- $select_terms = get_option( 'relpoststh_show_categories', get_option( 'relpoststh_categories' ) );
547
- if ( empty( $select_terms ) || !is_array( $select_terms ) ) { // if no categories were specified intentionally return nothing
548
- $output = '';
549
- return $this->finish_process( $output, $debug . __( 'No categories were selected;' ), $time );
550
- }
551
-
552
- $query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('" . implode( "', '", $select_terms ) . "')";
553
- $taxonomy = $wpdb->get_results( $query );
554
- $filter_taxonomy_a = array();
555
- if ( count( $taxonomy ) > 0 ) {
556
- foreach ( $taxonomy as $item ) {
557
- $filter_taxonomy_a[] = $item->term_taxonomy_id;
558
- }
559
- }
560
- if ( $relation != 'no' ) {
561
- $query_objects .= " AND object_id IN (SELECT distinct object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ('" . implode( "', '", $filter_taxonomy_a ) . "') )";
562
- } else {
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 ) {
570
- foreach ( $relationships as $item ) {
571
- $related_objects[] = $item->object_id;
572
- }
573
- }
574
- }
575
-
576
- // $selected_post_type = '';
577
- // foreach( get_option ( 'relpoststh_post_types' ) as $checked_post_type ) {
578
- // $selected_post_type .= "'".$checked_post_type."',";
579
- // }
580
- // $checked_post_type = rtrim( $selected_post_type, ',' );
581
-
582
- // $query = "SELECT distinct ID FROM $wpdb->posts ";
583
- $query = "SELECT ID FROM $wpdb->posts ";
584
- $where = " WHERE post_type = '" . $post_type . "' AND post_status = 'publish' AND ID<>" . $id; // not the current post
585
- // $where = " WHERE post_type IN (" . $checked_post_type . ") AND post_status = 'publish' AND ID<>" . $id; // not the current post
586
- $startdate = get_option( 'relpoststh_startdate' );
587
- if ( !empty( $startdate ) && preg_match( '/^\d\d\d\d-\d\d-\d\d$/', $startdate ) ) { // If startdate was set
588
- $debug .= "Startdate: $startdate;";
589
- $where .= " AND post_date >= '" . $startdate . "'";
590
- }
591
- if ( $use_filter ) {
592
- $where .= " AND ID IN ('" . implode( "', '", $related_objects ) . "')";
593
- }
594
- $join = '';
595
- if ( $onlywiththumbs ) {
596
- $debug .= 'Only with thumbnails;';
597
- $join = " INNER JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)";
598
- $where .= " AND $wpdb->postmeta.meta_key = '_thumbnail_id'";
599
- }
600
-
601
- $order_query = ' ORDER BY ' . $sort_by;
602
- $limit_order = $order_query . ' LIMIT ' . $posts_number;
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
- }
610
-
611
- $posts_in = array();
612
-
613
- foreach ( $random_posts as $random_post ) {
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;';
645
- $output = '';
646
- return $this->finish_process( $output, $debug, $time );
647
- } else {
648
- $debug .= 'Found ' . count( $posts ) . ' posts;';
649
- }
650
-
651
- /* Calculating sizes */
652
- if ( $thsource == 'custom-field' ) {
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" );
661
- $height = get_option( "{$poststhname}_size_h" );
662
- } elseif ( current_theme_supports( 'post-thumbnails' ) ) { // get sizes for theme supported thumbnails
663
- global $_wp_additional_image_sizes;
664
- if ( isset( $_wp_additional_image_sizes[ $poststhname ] ) ) {
665
- $debug .= 'Additional sizes;';
666
- $width = $_wp_additional_image_sizes[ $poststhname ][ 'width' ];
667
- $height = $_wp_additional_image_sizes[ $poststhname ][ 'height' ];
668
- } else {
669
- $debug .= 'No additional sizes;';
670
- }
671
- }
672
- }
673
- // displaying square if one size is not cropping
674
- if ( $height == 9999 ) {
675
- $height = $width;
676
- }
677
- if ( $width == 9999 ) {
678
- $width = $height;
679
- }
680
- // theme is not supporting but settings were not changed
681
- if ( empty( $width ) ) {
682
- $debug .= 'Using default width;';
683
- $width = get_option( 'thumbnail_size_w' );
684
- }
685
- if ( empty( $height ) ) {
686
- $debug .= 'Using default height;';
687
- $height = get_option( 'thumbnail_size_h' );
688
- }
689
-
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 );
703
- $relpoststh_cleanhtml = get_option( 'relpoststh_cleanhtml', 0 );
704
- $text_height = get_option( 'relpoststh_textblockheight', $this->text_block_height );
705
-
706
-
707
- if ( $relpoststh_output_style == 'list' ) {
708
- $output .= '<!-- related_posts_thumbnails -->';
709
- $output .= '<ul id="related_posts_thumbnails"';
710
- if ( ! $relpoststh_cleanhtml ) {
711
- $output .= ' style="list-style-type:none; list-style-position: inside; padding: 0; margin:0"';
712
- }
713
- $output .= '>';
714
- } else {
715
-
716
- $output .= '<div style="clear: both"></div>';
717
-
718
- // $output .= '<!-- related-posts-nav -->';
719
- // $output .= '<ul class="related-posts-nav">'; //open blocks ul
720
-
721
- $output .= '<div style="clear: both"></div>';
722
-
723
- $output .= '<!-- relpost-block-container -->';
724
- $output .= '<div class="relpost-block-container">'; // open relpost-block-container div
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
 
@@ -793,319 +816,338 @@ class RelatedPostsThumbnails {
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 ) {
831
- $url = get_bloginfo( 'url' ) . $url;
832
- $debug .= 'Relative url: ' . $url . ';';
833
- }
834
-
835
- // parsed URL is empty or no image found
836
- if ( empty( $url ) ) {
837
- $debug .= 'Image URL: ' . $url . ';';
838
- $debug .= 'Image is empty or no file. Using default image;';
839
- $url = get_option( 'relpoststh_default_image', $this->default_image );
840
- }
841
-
842
- $title = $this->process_text_cut( $post->post_title, $text_length );
843
- $post_excerpt = ( empty( $post->post_excerpt ) ) ? $post->post_content : $post->post_excerpt;
844
- $excerpt = $this->process_text_cut( $post_excerpt, $excerpt_length );
845
-
846
- if ( !empty( $title ) && !empty( $excerpt ) ) {
847
- $title = '<b>' . $title . '</b>';
848
- $excerpt = '<br/>' . $excerpt;
849
- }
850
-
851
- if ( empty( $alt ) ) {
852
- $alt = str_replace('"', '', $title);
853
- }
854
-
855
- $fontface = str_replace( '"', "'", stripslashes( get_option( 'relpoststh_fontfamily', $this->font_family ) ) );
856
- $debug .= 'Using title with size ' . $text_length . '. Using excerpt with size ' . $excerpt_length . ';';
857
- $after_content = apply_filters( 'rpth_after_content', '', $post );
858
-
859
- if ( ( $amp_endpoint ) && ( true === apply_filters( 'rpth_amp', true ) ) ) {
860
- $debug .= 'AMP view enabled';
861
- $output .= '<li style="' . apply_filters( 'rpth_amp_list_style', 'margin: 5px 20px;' ) . '">';
862
- $output .= '<a href="' . get_permalink( $post->ID ) . '" class="relpost_content" font-family: ' . $fontface . '>';
863
- $output .= '<span class="rpth_amp_list_content">' . $title . $excerpt . '</span>' . $after_content . '</a></li>';
864
- } else {
865
- if ( $relpoststh_output_style == 'list' ) {
866
- $link = get_permalink( $post->ID );
867
- $output .= '<li ';
868
-
869
- // if ( !$relpoststh_cleanhtml ) {
870
- // $output .= ' onmouseout="this.style.backgroundColor=\'' . get_option( 'relpoststh_background', $this->background ) . '\'"';
871
- // }
872
-
873
- $output .= '>';
874
- $output .= '<a href="' . $link . '" ><img class="relpost-post-image" alt="' . $alt . '" src="' . esc_url( $url ) . '" width="' . $width . '" height="' . $height . '" ';
875
-
876
- // if ( !$relpoststh_cleanhtml ) {
877
- // $output .= 'style="padding: 0px; margin: 0px; border: 0pt none;"';
878
- // }
879
-
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
-
895
- $output .= '<a class="relpost-block-single" href="' . get_permalink( $post->ID ) . '">';
896
- $output .= '<div style="width: ' . $width . 'px; height: ' . ( $height + $text_height ) . 'px;">';
897
- $output .= '<div class="relpost-block-single-image" alt="' . $alt . '" style="'. $rpt_single_background . '"></div>';
898
- $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>';
899
- $output .= $after_content;
900
- // $output .= $date;
901
- $output .= '</div>';
902
- $output .= '</a>';
903
- }
904
- }
905
-
906
- } // end foreach
907
- if ( $relpoststh_output_style == 'list' ) {
908
- $output .= '</ul>';
909
- $output .= '<!-- close related_posts_thumbnails -->';
910
- } else {
911
- $output .= '</div>';
912
- $output .= '<!-- close relpost-block-container -->';
913
- // $output .= '</ul>';
914
- // $output .= '<!-- close related-posts-nav -->';
915
- }
916
-
917
- $output .= '<div style="clear: both"></div>';
918
-
919
- $output .= '</div>';
920
- $output .= '<!-- close filter class -->';
921
-
922
- $output .= '</div>';
923
- $output .= '<!-- close relpost-thumb-wrapper -->';
924
-
925
- return $this->finish_process( $output, $debug, $time );
926
- }
927
-
928
- // function is_url_404( $url ) {
929
- // $response = wp_remote_request( $url,
930
- // array(
931
- // 'method' => 'GET'
932
- // )
933
- // );
934
-
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 ) {
950
- $time = microtime( true ) - $time;
951
- $debug .= "Plugin execution time: $time sec;";
952
- $output .= '<!-- ' . $debug . ' -->';
953
- }
954
- return $output;
955
- }
956
-
957
- function process_text_cut( $text, $length ) {
958
- if ( $length == 0 ) {
959
- return '';
960
- } else {
961
- $text = strip_tags( strip_shortcodes( $text ) );
962
- if ( function_exists( 'mb_strlen' ) ) {
963
- return ( ( mb_strlen( $text ) > $length ) ? mb_substr( $text, 0, $length ) . '...' : $text );
964
- } else {
965
- return ( ( strlen( $text ) > $length ) ? substr( $text, 0, $length ) . '...' : $text );
966
- }
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
990
- $post_categories = wp_get_object_terms( $id, array(
991
- 'category'
992
- ), array(
993
- 'fields' => 'ids'
994
- ) );
995
- $relpoststh_categories = get_option( 'relpoststh_categories' );
996
- if ( !is_array( $relpoststh_categories ) || !is_array( $post_categories ) ) { // no categories were selcted or post doesn't belong to any
997
- return false;
998
- }
999
- $common_categories = array_intersect( $relpoststh_categories, $post_categories );
1000
- if ( empty( $common_categories ) ) { // post doesn't belong to specified categories
1001
- return false;
1002
- }
1003
- }
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
-
1094
- <?php
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() {
1105
- define( 'RELATED_POSTS_THUMBNAILS_URI', plugin_dir_url( __FILE__ ) );
1106
 
1107
- global $related_posts_thumbnails;
1108
- $related_posts_thumbnails = new RelatedPostsThumbnails();
1109
  }
1110
 
1111
  // Include Widget File.
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.1
7
  * Author: WPBrigade
8
  * Author URI: https://WPBrigade.com/?utm_source=related-posts-lite&utm_medium=author-link&utm_campaign=pro-upgrade-rp
9
  */
24
  GNU General Public License for more details.
25
  */
26
  class RelatedPostsThumbnails {
27
+ /* Default values. PHP 4 compatible */
28
+ public $single_only = '1';
29
+ public $auto = '1';
30
+ public $top_text = '<h3>Related posts:</h3>';
31
+ public $number = 3;
32
+ public $relation = 'categories';
33
+ public $poststhname = 'thumbnail';
34
+ public $background = '#ffffff';
35
+ public $hoverbackground = '#eeeeee';
36
+ public $border_color = '#dddddd';
37
+ public $font_color = '#333333';
38
+ public $font_family = 'Arial';
39
+ public $font_size = '12';
40
+ public $text_length = '100';
41
+ public $excerpt_length = '0';
42
+ public $custom_field = '';
43
+ public $custom_height = '100';
44
+ public $custom_width = '100';
45
+ public $text_block_height = '75';
46
+ public $thsource = 'post-thumbnails';
47
+ public $categories_all = '1';
48
+ public $devmode = '0';
49
+ public $output_style = 'div';
50
+ public $post_types = array( 'post' );
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
+
59
  $this->constant();
60
+ // Load text domain for translation
61
  load_plugin_textdomain( 'related-posts-thumbnails', false, basename( dirname( __FILE__ ) ) . '/locale' );
62
  $this->default_image = esc_url( plugins_url( 'img/default.png', __FILE__ ) );
63
 
65
 
66
  // Compatibility for old default image path.
67
  if ( $this->is_old_default_img() )
68
+ update_option( 'relpoststh_default_image', $this->default_image );
69
 
70
  if ( get_option( 'relpoststh_auto', $this->auto ) ) {
71
  $priority = apply_filters( 'rpt_content_prioirty', 10 ); // Alter priority of the related post content
97
  add_shortcode( 'related-posts-thumbnails', array( $this, 'related_posts_shortcode' ) );
98
 
99
  }
100
+
101
  /**
102
+ * Prevent related posts on editor screen (builders).
103
+ *
104
+ * @return bool $return
105
+ */
106
  function prevent_on_editors() {
107
  $return = false;
108
+ $prevent_on_edit = apply_filters( 'rpt_prevent_on_edit', array( 'divi' => false, ) );
 
 
109
 
110
  foreach ( $prevent_on_edit as $key => $value ) {
111
  switch ( $key ) {
121
  }
122
 
123
  /**
124
+ * callback for shortcode related_posts_shortcode
125
+ *
126
+ * @param array $atts attributes of shortcode
127
+
128
+ * @version 1.9.0
129
+ */
130
  function related_posts_shortcode( $atts ) {
131
+
132
  $atts = shortcode_atts( array(
133
  'posts_number' => '3',
134
  'posts_sort' => 'random',
135
  'main_title' => '',
136
+ 'exclude_post' => '' ),
137
+ $atts, 'related-posts-thumbnails'
138
  );
139
 
140
  $number = $atts['posts_number'];
148
  //sanitization through regex expression to know if a string is consisting of numeric values.
149
  $regex = '/^\d+(?:,\d+)*$/';
150
  $excluded_posts_array = preg_match( $regex, $atts['exclude_post'] ) ? $atts['exclude_post'] : array();
151
+
152
  if ( !is_numeric( $number ) ) {
153
  $number = 3;
154
  }
156
  $main_title = str_replace( '_', ' ', $atts['main_title'] );
157
 
158
  return $this->get_thumbnails( true, $number, $sort, $main_title, $excluded_posts_array );
159
+
160
+ }
161
 
162
  /**
163
+ * Function to enqueue admin styles and scripts.
164
+ *
165
+ * @param $page
166
+ * @return void
167
+ * @since 1.7.0
168
+ * @version 1.9.0
169
+ *
170
+ */
171
  function admin_scripts( $page ) {
172
  if ( 'toplevel_page_related-posts-thumbnails' === $page ) {
173
  wp_enqueue_media();
174
  wp_enqueue_style( 'rpt_admin_css', plugins_url( 'assets/css/admin.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
175
  wp_enqueue_style( 'jquery-ui', 'https://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
176
  wp_enqueue_style( 'wp-color-picker' );
177
+ wp_enqueue_script( 'rpt_admin_js', plugins_url( 'assets/js/admin.js', __FILE__ ),
178
+ array(
179
+ 'jquery',
180
+ 'wp-color-picker',
181
+ 'jquery-ui-datepicker'
182
+ ), RELATED_POSTS_THUMBNAILS_VERSION
183
+ );
184
  }
185
  }
186
 
187
  /**
188
+ * Function to enqueue front styles and scripts.
189
+ *
190
+ * @param $page
191
+ * @return void
192
+ * @since 1.7.0
193
+ * @version 1.9.0
194
+ *
195
+ */
196
  function front_scripts() {
197
  wp_enqueue_style( 'rpt_front_style', plugins_url( 'assets/css/front.css', __FILE__ ), false, RELATED_POSTS_THUMBNAILS_VERSION );
198
  }
199
+
200
  /**
201
+ * Function to define plugin Constants
202
+ *
203
+ * @return void
204
+ */
205
  function constant() {
206
  define( 'RELATED_POSTS_THUMBNAILS_VERSION', '1.9.0' );
207
  define( 'RELATED_POSTS_THUMBNAILS_FEEDBACK_SERVER', 'https://wpbrigade.com/' );
208
  define( 'RELATED_POSTS_THUMBNAILS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
209
  }
210
 
211
+ /**
212
+ * Show the popup modal on plugin deactivate
213
+ *
214
+ * @since 1.6.2
215
+ */
216
+ function add_deactive_modal() {
217
+ global $pagenow;
218
+
219
+ if ( 'plugins.php' !== $pagenow ) {
220
+ return;
221
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
+ include RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . 'inc/rpt-deactivate-form.php';
224
  }
225
+
226
+
227
  /**
228
+ * Send the deactivate user response to api.
229
+ *
230
+ * @since 1.6.2
231
+ */
232
+ function rpt_deactivate() {
233
+ $email = get_option( 'admin_email' );
234
+ $_reason = sanitize_text_field( wp_unslash( $_POST[ 'reason' ] ) );
235
+ $reason_detail = sanitize_text_field( wp_unslash( $_POST[ 'reason_detail' ] ) );
236
+ $reason = '';
237
+
238
+ if ( $_reason == '1' ) {
239
+ $reason = 'I only needed the plugin for a short period';
240
+ } elseif ( $_reason == '2' ) {
241
+ $reason = 'I found a better plugin';
242
+ } elseif ( $_reason == '3' ) {
243
+ $reason = 'The plugin broke my site';
244
+ } elseif ( $_reason == '4' ) {
245
+ $reason = 'The plugin suddenly stopped working';
246
+ } elseif ( $_reason == '5' ) {
247
+ $reason = 'I no longer need the plugin';
248
+ } elseif ( $_reason == '6' ) {
249
+ $reason = 'It\'s a temporary deactivation. I\'m just debugging an issue.';
250
+ } elseif ( $_reason == '7' ) {
251
+ $reason = 'Other';
252
+ }
253
+ $fields = array(
254
+ 'email' => $email,
255
+ 'website' => get_site_url(),
256
+ 'action' => 'Deactivate',
257
+ 'reason' => $reason,
258
+ 'reason_detail' => $reason_detail,
259
+ 'blog_language' => get_bloginfo( 'language' ),
260
+ 'wordpress_version' => get_bloginfo( 'version' ),
261
+ 'php_version' => PHP_VERSION,
262
+ 'plugin_version' => RELATED_POSTS_THUMBNAILS_VERSION,
263
+ 'plugin_name' => 'Related Post Thumbnails'
264
+ );
265
+
266
+ $response = wp_remote_post( RELATED_POSTS_THUMBNAILS_FEEDBACK_SERVER, array(
267
+ 'method' => 'POST',
268
+ 'timeout' => 5,
269
+ 'httpversion' => '1.0',
270
+ 'blocking' => false,
271
+ 'headers' => array(),
272
+ 'body' => $fields
273
+ ) );
274
 
275
+ wp_die();
276
  }
277
+
278
+ /**
279
+ * Check either to show notice or not.
280
+ *
281
+ * @since 1.8.2
282
+ */
283
+ public function review_notice() {
284
+ $this->review_dismissal();
285
+ $this->review_prending();
286
+
287
+ $review_dismissal = get_option( 'rpt_review_dismiss' );
288
+
289
+ if ( 'yes' == $review_dismissal ) {
290
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
+ $activation_time = get_option( 'rpt_active_time' );
294
+
295
+ if ( !$activation_time ) {
296
+ $activation_time = time();
297
+ add_option( 'rpt_active_time', $activation_time );
298
+ }
299
+
300
+ // 1296000 = 15 Days in seconds.
301
+ if ( time() - $activation_time > 1296000 ) {
302
+ add_action( 'admin_notices', array( $this, 'review_notice_message' ) );
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Show review Message After 15 days.
308
+ *
309
+ * @since 1.8.2
310
+ */
311
+ public function review_notice_message() {
312
+ $scheme = ( parse_url( $_SERVER[ 'REQUEST_URI' ], PHP_URL_QUERY ) ) ? '&' : '?';
313
+ $url = $_SERVER[ 'REQUEST_URI' ] . $scheme . 'rpt_review_dismiss=yes';
314
+ $dismiss_url = wp_nonce_url( $url, 'rpt-review-nonce' );
315
+
316
+ $_later_link = $_SERVER[ 'REQUEST_URI' ] . $scheme . 'ssb_review_later=yes';
317
+ $later_url = wp_nonce_url( $_later_link, 'rpt-review-nonce' ); ?>
318
+
319
+ <style media="screen">
320
+ .rpt-review-notice { padding: 15px 0; background-color: #fff; border-radius: 3px; margin: 20px 20px 0 0; border-left: 4px solid transparent; } .rpt-review-notice:after { content: ''; display: table; clear: both; }
321
+ .rpt-review-thumbnail { float: left; line-height: 80px; text-align: center; width: 117px; }
322
+ .rpt-review-thumbnail img { width: 118px; vertical-align: middle; }
323
+ .rpt-review-text { overflow: hidden; }
324
+ .rpt-review-text h3 { font-size: 24px; margin: 0 0 5px; font-weight: 400; line-height: 1.3; }
325
+ .rpt-review-text p { font-size: 13px; margin: 0 0 5px; }
326
+ .rpt-review-ul { margin: 0; padding: 0; }
327
+ .rpt-review-ul li { display: inline-block; margin-right: 15px; }
328
+ .rpt-review-ul li a { display: inline-block; color: #10738B; text-decoration: none; padding-left: 26px; position: relative; }
329
+ .rpt-review-ul li a span { position: absolute; left: 0; top: -2px; }
330
+ </style>
331
+
332
+ <div class="rpt-review-notice">
333
+ <div class="rpt-review-thumbnail">
334
+ <img src="<?php echo plugins_url( 'assets/images/rpt-logo.png', __FILE__ ); ?>" alt="">
335
+ </div>
336
+ <div class="rpt-review-text">
337
+
338
+ <h3>
339
+ <?php _e( 'Leave A Review?', 'related-posts-thumbnails' ); ?>
340
+ </h3>
341
+
342
+ <p>
343
+ <?php _e( 'We hope you\'ve enjoyed using Related Post Thumbnails! Would you consider leaving us a review on WordPress.org?', 'related-posts-thumbnails' ); ?>
344
+ </p>
345
+
346
+ <ul class="rpt-review-ul">
347
+ <li>
348
+ <a href="https://wordpress.org/support/plugin/related-posts-thumbnails/reviews/?filter=5" target="_blank"><span class="dashicons dashicons-external"></span>
349
+ <?php _e( 'Sure! I\'d love to!', 'related-posts-thumbnails' ); ?>
350
+ </a>
351
+ </li>
352
+
353
+ <li>
354
+ <a href="<?php echo $dismiss_url; ?>">
355
+ <span class="dashicons dashicons-smiley"></span>
356
+ <?php _e( 'I\'ve already left a review', 'related-posts-thumbnails' ); ?>
357
+ </a>
358
+ </li>
359
+
360
+ <li>
361
+ <a href="<?php echo $later_url; ?>">
362
+ <span class="dashicons dashicons-calendar-alt"></span>
363
+ <?php _e( 'Maybe Later', 'related-posts-thumbnails' ); ?>
364
+ </a>
365
+ </li>
366
+
367
+ <li>
368
+ <a href="<?php echo $dismiss_url; ?>">
369
+ <span class="dashicons dashicons-dismiss"></span>
370
+ <?php _e( 'Never show again', 'related-posts-thumbnails' ); ?>
371
+ </a>
372
+ </li>
373
+ </ul>
374
+ </div>
375
+ </div>
376
+
377
+ <?php
378
+ }
379
+
380
+ /**
381
+ * Set time to current so review notice will popup after 15 days
382
+ *
383
+ * @since 1.8.2
384
+ */
385
+ function review_prending() {
386
+ // delete_site_option( 'rpt_review_dismiss' );
387
+ if ( !is_admin() || !current_user_can( 'manage_options' ) || !isset( $_GET[ '_wpnonce' ] ) || !wp_verify_nonce( sanitize_key( wp_unslash( $_GET[ '_wpnonce' ] ) ), 'rpt-review-nonce' ) || !isset( $_GET[ 'ssb_review_later' ] ) ) {
388
+
389
+ return;
390
+ }
391
+
392
+ // Reset Time to current time.
393
+ update_option( 'rpt_active_time', time() );
394
+ }
395
+
396
+ /**
397
+ * Check and Dismiss review message.
398
+ *
399
+ * @since 1.8.2
400
+ */
401
+ private function review_dismissal() {
402
+ //delete_option( 'rpt_review_dismiss' );
403
+ if ( !is_admin() || !current_user_can( 'manage_options' ) || !isset( $_GET[ '_wpnonce' ] ) || !wp_verify_nonce( sanitize_key( wp_unslash( $_GET[ '_wpnonce' ] ) ), 'rpt-review-nonce' ) || !isset( $_GET[ 'rpt_review_dismiss' ] ) ) {
404
+
405
+ return;
406
+ }
407
+
408
+ add_option( 'rpt_review_dismiss', 'yes' );
409
+ }
410
+
411
+ /**
412
+ * [is_old_default_img Check the compatibility for old default image path.]
413
+ *
414
+ * @return boolean Return true if path is old.
415
+ */
416
+ function is_old_default_img() {
417
+ if ( get_option( 'relpoststh_default_image' ) !== $this->default_image ) {
418
+
419
+ $chunks = explode( '/', get_option( 'relpoststh_default_image' ) );
420
+ if ( in_array( 'related-posts-thumbnails', $chunks ) ) {
421
+ return true;
422
+ }
423
+ }
424
+ }
425
+
426
+ /**
427
+ * Automatically displaying related posts under post body
428
+ *
429
+ * @param $content
430
+ *
431
+ * @return void
432
+ */
433
+ function auto_show( $content ) {
434
+ return $content . $this->get_html( true );
435
+ }
436
+
437
+ /**
438
+ * Getting related posts HTML
439
+ *
440
+ * @param boolean $show_top
441
+ *
442
+ */
443
+ function get_html( $show_top = false ) {
444
+ if ( $this->is_relpoststh_show() ) {
445
+ return $this->get_thumbnails( $show_top );
446
+ }
447
+
448
+ return '';
449
+ }
450
+
451
+ /**
452
+ * function responsible for Thumbnail creation
453
+ *
454
+ * @param boolean $show_top Position of the thumbnails
455
+ * @param string $posts_number Number of posts to display
456
+ * @param string $sort_by sort the thumbnails by
457
+ * @param string $main_title thumbnail title
458
+ * @param string $exclude post_ids to exclude from related posts thumbnails
459
+ *
460
+ * @return void
461
+ */
462
+ function get_thumbnails( $show_top = false, $posts_number = '', $sort_by = '', $main_title = '', $exclude ='' ) {
463
+ $output = '';
464
+ $debug = 'Developer mode initialisation; Version: 1.2.9;';
465
+ $time = microtime( true );
466
+
467
+ $amp_endpoint = ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) ? true : false;
468
+
469
+ // Stop execution if RPT is disabled in AMP view
470
+ if ( ( $amp_endpoint ) && ( 'disable' === apply_filters( 'rpth_amp', true ) ) ) {
471
+
472
+ $debug .= 'AMP view disabled';
473
+ return $this->finish_process( '', $debug, $time );
474
+ }
475
+
476
+ $posts_number_opt = get_option( 'relpoststh_number', $this->number );
477
+ $posts_number = !empty( $posts_number ) ? $posts_number : $posts_number_opt;
478
+ $height = '';
479
+ $width = '';
480
+ // $date = '';
481
+ $order_by = 'DESC';
482
+
483
+ $sort_by_opt = get_option( 'rpt_post_sort') == 'latest' ? 'post_date '.$order_by.'': 'rand()';
484
+ $sort_by = !empty( $sort_by ) ? $sort_by : $sort_by_opt;
485
+
486
+ // rpt_content_align: add content allignment class; clases are: relpost-align-left, relpost-align-right and relpost-align-center
487
+ $output = '<!-- relpost-thumb-wrapper -->';
488
+ $output .= '<div class="relpost-thumb-wrapper">';
489
+ $output .= '<!-- filter-class -->';
490
+ $output .='<div class="relpost-thumb-container'. apply_filters( 'rpt_content_align', '' ) . '">';
491
+ $alt = '';
492
+
493
+ if ( $posts_number <= 0 ) { // return nothing if this parameter was set to <= 0
494
+ $output = '';
495
+ return $this->finish_process( $output, $debug . 'Posts number is 0;', $time );
496
+ }
497
+
498
+ $id = get_the_ID();
499
+ $relation = get_option( 'relpoststh_relation', $this->relation );
500
+ $poststhname = get_option( 'relpoststh_poststhname', $this->poststhname );
501
+ $text_length = get_option( 'relpoststh_textlength', $this->text_length );
502
+ $excerpt_length = get_option( 'relpoststh_excerptlength', $this->excerpt_length );
503
+ $thsource = get_option( 'relpoststh_thsource', $this->thsource );
504
+ $categories_show_all = get_option( 'relpoststh_show_categoriesall', get_option( 'relpoststh_categoriesall', $this->categories_all ) );
505
+ $onlywiththumbs = ( current_theme_supports( 'post-thumbnails' ) && $thsource == 'post-thumbnails' ) ? get_option( 'relpoststh_onlywiththumbs', false ) : false;
506
+ $post_type = get_post_type();
507
+
508
+ global $wpdb;
509
+
510
+ /* Get taxonomy terms */
511
+ $debug .= "Relation: $relation; All categories: $categories_show_all;";
512
+ $use_filter = ( $categories_show_all != '1' || $relation != 'no' );
513
+
514
+ if ( $use_filter ) {
515
+ $query_objects = "SELECT distinct object_id FROM $wpdb->term_relationships WHERE 1=1 ";
516
+
517
+ if ( $relation != 'no' ) {
518
+ /* Get object terms */
519
+ if ( $relation == 'categories' ) {
520
+ $taxonomy = array(
521
+ 'category'
522
+ );
523
+ } elseif ( $relation == 'tags' ) {
524
+ $taxonomy = array(
525
+ 'post_tag'
526
+ );
527
+ } elseif ( $relation == 'custom' ) {
528
+ $taxonomy = get_option( 'relpoststh_custom_taxonomies', $this->custom_taxonomies );
529
+ } else {
530
+ $taxonomy = array(
531
+ 'category',
532
+ 'post_tag'
533
+ );
534
+ }
535
+ $object_terms = wp_get_object_terms( $id, $taxonomy, array(
536
+ 'fields' => 'ids'
537
+ ) );
538
+
539
+ if ( empty( $object_terms ) || !is_array( $object_terms ) ) { // no terms to get taxonomy
540
+ $output = '';
541
+ return $this->finish_process( $output, $debug . __( 'No taxonomy terms to get posts;' ), $time );
542
+ }
543
+
544
+ $query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('" . implode( "', '", $object_terms ) . "')";
545
+ $object_taxonomy = $wpdb->get_results( $query );
546
+ $object_taxonomy_a = array();
547
+
548
+ if ( count( $object_taxonomy ) > 0 ) {
549
+ foreach ( $object_taxonomy as $item ) {
550
+ $object_taxonomy_a[] = $item->term_taxonomy_id;
551
+ }
552
+ }
553
+
554
+ $query_objects .= " AND term_taxonomy_id IN ('" . implode( "', '", $object_taxonomy_a ) . "') ";
555
+ }
556
+
557
+ if ( $categories_show_all != '1' ) {
558
+ /* Get filter terms */
559
+ $select_terms = get_option( 'relpoststh_show_categories', get_option( 'relpoststh_categories' ) );
560
+ if ( empty( $select_terms ) || !is_array( $select_terms ) ) { // if no categories were specified intentionally return nothing
561
+ $output = '';
562
+ return $this->finish_process( $output, $debug . __( 'No categories were selected;' ), $time );
563
+ }
564
+
565
+ $query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id in ('" . implode( "', '", $select_terms ) . "')";
566
+ $taxonomy = $wpdb->get_results( $query );
567
+ $filter_taxonomy_a = array();
568
+ if ( count( $taxonomy ) > 0 ) {
569
+ foreach ( $taxonomy as $item ) {
570
+ $filter_taxonomy_a[] = $item->term_taxonomy_id;
571
+ }
572
  }
573
+ if ( $relation != 'no' ) {
574
+ $query_objects .= " AND object_id IN (SELECT distinct object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ('" . implode( "', '", $filter_taxonomy_a ) . "') )";
575
+ } else {
576
+ $query_objects .= " AND term_taxonomy_id IN ('" . implode( "', '", $filter_taxonomy_a ) . "')";
577
+ }
578
+ }
579
 
580
+ $relationships = $wpdb->get_results( $query_objects );
581
+ $related_objects = array();
582
+ if ( count( $relationships ) > 0 ) {
583
+ foreach ( $relationships as $item ) {
584
+ $related_objects[] = $item->object_id;
585
  }
586
  }
587
+ }
588
+
589
+ // $selected_post_type = '';
590
+ // foreach( get_option ( 'relpoststh_post_types' ) as $checked_post_type ) {
591
+ // $selected_post_type .= "'".$checked_post_type."',";
592
+ // }
593
+ // $checked_post_type = rtrim( $selected_post_type, ',' );
594
+
595
+ // $query = "SELECT distinct ID FROM $wpdb->posts ";
596
+ $query = "SELECT ID FROM $wpdb->posts ";
597
+ $where = " WHERE post_type = '" . $post_type . "' AND post_status = 'publish' AND ID<>" . $id; // not the current post
598
+ // $where = " WHERE post_type IN (" . $checked_post_type . ") AND post_status = 'publish' AND ID<>" . $id; // not the current post
599
+ $startdate = get_option( 'relpoststh_startdate' );
600
+
601
+ if ( !empty( $startdate ) && preg_match( '/^\d\d\d\d-\d\d-\d\d$/', $startdate ) ) { // If startdate was set
602
+ $debug .= "Startdate: $startdate;";
603
+ $where .= " AND post_date >= '" . $startdate . "'";
604
+ }
605
+
606
+ if ( $use_filter ) {
607
+ $where .= " AND ID IN ('" . implode( "', '", $related_objects ) . "')";
608
+ }
609
+
610
+ $join = '';
611
+
612
+ if ( $onlywiththumbs ) {
613
+ $debug .= 'Only with thumbnails;';
614
+ $join = " INNER JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)";
615
+ $where .= " AND $wpdb->postmeta.meta_key = '_thumbnail_id'";
616
+ }
617
+
618
+ $order_query = ' ORDER BY ' . $sort_by;
619
+ $limit_order = $order_query . ' LIMIT ' . $posts_number;
620
+ $random_posts = $wpdb->get_results( $query . $join . $where . $limit_order );
621
+
622
+ /* Get posts by their IDs */
623
+ if ( !is_array( $random_posts ) || count( $random_posts ) < 1 ) {
624
+ $output = '';
625
+ return $this->finish_process( $output, $debug . __( 'No posts matching relationships criteria;' ), $time );
626
+ }
627
+
628
+ $posts_in = array();
629
+
630
+ foreach ( $random_posts as $random_post ) {
631
+ $posts_in[] = $random_post->ID;
632
+ }
633
+
634
+ if( $exclude == ! "" ) {
635
+
636
+ $exclude_post_ids = explode( ",", $exclude );
637
+ $posts_in = array_diff( $posts_in, $exclude_post_ids );
638
+
639
+ }
640
+ /**
641
+ *
642
+ * Filter rpt_exclude_post to exclude post from RPT thumbnails
643
+ *
644
+ * @since 1.9.0
645
+ *
646
+ */
647
+ $exclude_by_filter = apply_filters( 'rpt_exclude_post', '' );
648
+
649
+ if( $exclude_by_filter !== '' ) {
650
+ $regex = '/^\d+(?:,\d+)*$/';
651
+ $exclude_by_filter = preg_match( $regex, $exclude_by_filter ) ? $exclude_by_filter : array();
652
+ $exclude_by_filter_ids = explode( ",", $exclude_by_filter );
653
+ $posts_in = array_diff( $posts_in, $exclude_by_filter_ids );
654
+
655
+ }
656
+
657
+ $query = "SELECT ID, post_content, post_excerpt, post_title FROM $wpdb->posts WHERE ID IN ('" . implode( "', '", $posts_in ) . "') $order_query ";
658
+ $posts = $wpdb->get_results( $query );
659
+
660
+ if ( !( is_array( $posts ) && count( $posts ) > 0 ) ) { // no posts
661
+ $debug .= 'No posts found;';
662
+ $output = '';
663
+ return $this->finish_process( $output, $debug, $time );
664
+ } else {
665
+ $debug .= 'Found ' . count( $posts ) . ' posts;';
666
+ }
667
+
668
+ /* Calculating sizes */
669
+ if ( $thsource == 'custom-field' ) {
670
+ $debug .= 'Custom sizes;';
671
+ $width = get_option( 'relpoststh_customwidth', $this->custom_width );
672
+ $height = get_option( 'relpoststh_customheight', $this->custom_height );
673
+ } else {
674
+ // post-thumbnails source
675
+ if ( $poststhname == 'thumbnail' || $poststhname == 'medium' || $poststhname == 'large' ) { // get thumbnail size for basic sizes
676
+ $debug .= 'Basic sizes;';
677
+ $width = get_option( "{$poststhname}_size_w" );
678
+ $height = get_option( "{$poststhname}_size_h" );
679
+ } elseif ( current_theme_supports( 'post-thumbnails' ) ) { // get sizes for theme supported thumbnails
680
+ global $_wp_additional_image_sizes;
681
+ if ( isset( $_wp_additional_image_sizes[ $poststhname ] ) ) {
682
+ $debug .= 'Additional sizes;';
683
+ $width = $_wp_additional_image_sizes[ $poststhname ][ 'width' ];
684
+ $height = $_wp_additional_image_sizes[ $poststhname ][ 'height' ];
685
  } else {
686
+ $debug .= 'No additional sizes;';
687
  }
688
  }
689
+ }
690
+
691
+ // displaying square if one size is not cropping
692
+ if ( $height == 9999 ) {
693
+ $height = $width;
694
+ }
695
+
696
+ if ( $width == 9999 ) {
697
+ $width = $height;
698
+ }
699
+ // theme is not supporting but settings were not changed
700
+ if ( empty( $width ) ) {
701
+ $debug .= 'Using default width;';
702
+ $width = get_option( 'thumbnail_size_w' );
703
+ }
704
+ if ( empty( $height ) ) {
705
+ $debug .= 'Using default height;';
706
+ $height = get_option( 'thumbnail_size_h' );
707
+ }
708
+
709
+ $debug .= 'Got sizes ' . $width . 'x' . $height . ';';
710
+
711
+ // rendering related posts HTML
712
+ if ( $show_top ) {
713
+ if ( ! empty( $main_title ) ) {
714
+ $output .= '<p class="relpoststh-block-title">' . $main_title . '</p>';
715
+ } else {
716
+ $top_text = stripslashes( get_option( 'relpoststh_top_text', $this->top_text ) );
717
+ $output .= stripslashes ( apply_filters( 'rpt_top_text', $top_text ) );
718
+ }
719
+ }
720
+
721
+ $relpoststh_output_style = get_option( 'relpoststh_output_style', $this->output_style );
722
+ $relpoststh_cleanhtml = get_option( 'relpoststh_cleanhtml', 0 );
723
+ $text_height = get_option( 'relpoststh_textblockheight', $this->text_block_height );
724
+
725
+
726
+ if ( $relpoststh_output_style == 'list' ) {
727
+ $output .= '<!-- related_posts_thumbnails -->';
728
+ $output .= '<ul id="related_posts_thumbnails"';
729
+ if ( ! $relpoststh_cleanhtml ) {
730
+ $output .= ' style="list-style-type:none; list-style-position: inside; padding: 0; margin:0"';
731
+ }
732
+ $output .= '>';
733
+ } else {
734
+
735
+ $output .= '<div style="clear: both"></div>';
736
+
737
+ // $output .= '<!-- related-posts-nav -->';
738
+ // $output .= '<ul class="related-posts-nav">'; //open blocks ul
739
+
740
+ $output .= '<div style="clear: both"></div>';
741
+
742
+ $output .= '<!-- relpost-block-container -->';
743
+ $output .= '<div class="relpost-block-container">'; // open relpost-block-container div
744
+ }
745
+
746
+ foreach ( $posts as $post ) {
747
+ $image = '';
748
+ $url = '';
749
+ $alt = '';
750
+
751
+ if ( $thsource == 'custom-field' ) {
752
+ $custom_field = get_option( 'relpoststh_customfield', $this->custom_field );
753
+ $custom_field_meta = get_post_meta( $post->ID, $custom_field, true );
754
+
755
+ if ( empty( $custom_field ) ) {
756
+ $debug .= 'No custom field specifield, using default thumbnail image;';
757
+ $url = $this->default_image;
758
+ } elseif ( empty( $custom_field_meta ) && apply_filters( 'rpt_remove_empty_cfield', false ) ) {
759
+ $debug .= 'Custom field meta is empty, using rpt_remove_empty_cfield filter;';
760
+ continue;
761
+ } elseif ( empty( $custom_field_meta ) ) {
762
+ $debug .= 'Custom field meta is empty, using default thumbnail image;';
763
+ $url = $this->default_image;
764
+ } else {
765
+ $debug .= 'Using custom field;';
766
+ $url = $custom_field_meta;
767
+ $theme_resize_url = get_option( 'relpoststh_theme_resize_url', '' );
768
+
769
+ if ( strpos( $url, '/wp-content' ) !== false ) {
770
+ $url = substr( $url, strpos( $url, '/wp-content' ) );
771
+ }
772
 
773
+ if ( !empty( $theme_resize_url ) ) {
774
+ $url = $theme_resize_url . '?src=' . $url . '&w=' . $width . '&h=' . $height . '&zc=1&q=90';
775
+ }
776
+ }
777
+ } else {
778
+ $from_post_body = true;
779
+
780
+ // using built in WordPress Thumbnails Feature
781
+ if ( current_theme_supports( 'post-thumbnails' ) ) {
782
+
783
+ $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
784
+ $debug .= 'Post-thumbnails enabled in theme;';
785
+
786
+ if ( !( empty( $post_thumbnail_id ) || $post_thumbnail_id === false ) ) { // post has thumbnail
787
+ $debug .= 'Post has thumbnail ' . $post_thumbnail_id . ';';
788
+ $debug .= 'Postthname: ' . $poststhname . ';';
789
+ $image = wp_get_attachment_image_src( $post_thumbnail_id, $poststhname );
790
+ $alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
791
+ $url = $image[ 0 ];
792
+ $from_post_body = false;
793
+ } else {
794
+ $debug .= 'Post has no thumbnail;';
795
+ }
796
+ }
797
+
798
+ // Theme does not support post-thumbnails, or post does not have assigned thumbnail
799
+ if ( $from_post_body ) {
800
  $debug .= 'Getting image from post body;';
801
  $wud = wp_upload_dir();
802
 
816
  }
817
  }
818
 
819
+ } else {
820
+ $debug .= 'No image was found;';
821
+ }
822
 
823
+ if ( strlen( trim( $image ) ) > 0 ) {
 
824
 
825
+ $image_sizes = @getimagesize( $image );
826
+
827
+ if ( $image_sizes === false ) {
828
+ $debug .= 'Unable to determine parsed image size';
829
+ }
830
 
831
+ if ( ( $image_sizes !== false && isset( $image_sizes[ 0 ] ) ) && $image_sizes[ 0 ] == $width ) {
832
  // if this image is the same size
833
+ $debug .= 'Image used is the required size;';
834
+ $url = $image;
835
+ } elseif ( apply_filters( 'rpt_prevent_img_size_check', false ) && $image_sizes[ 0 ] < $width ) {
836
+ // if this image is samll than required size
837
+ $debug .= 'Image used is smaller than the required size, rpt_prevent_img_size_check filter is active;';
838
+ $url = $image;
839
+ } else {
840
+ // search for resized thumbnail according to Wordpress thumbnails naming function
841
+ $debug .= 'Changing image according to Wordpress standards;';
842
+ $url = preg_replace( '/(-[0-9]+x[0-9]+)?(\.[^\.]*)$/', '-' . $width . 'x' . $height . '$2', $image );
843
+ }
844
+
845
+ } else {
846
+ $debug .= 'Found wrong formatted image: ' . $image . ';';
847
  }
848
 
 
 
849
  }
850
+ }
851
 
852
+ if ( strpos( $url, '/' ) === 0 ) {
853
+ $url = get_bloginfo( 'url' ) . $url;
854
+ $debug .= 'Relative url: ' . $url . ';';
855
  }
856
+
857
+ // parsed URL is empty or no image found
858
+ if ( empty( $url ) ) {
859
+ $debug .= 'Image URL: ' . $url . ';';
860
+ $debug .= 'Image is empty or no file. Using default image;';
861
+ $url = get_option( 'relpoststh_default_image', $this->default_image );
862
+ }
863
+
864
+ $title = $this->process_text_cut( $post->post_title, $text_length );
865
+ $post_excerpt = ( empty( $post->post_excerpt ) ) ? $post->post_content : $post->post_excerpt;
866
+ $excerpt = $this->process_text_cut( $post_excerpt, $excerpt_length );
867
+
868
+ if ( !empty( $title ) && !empty( $excerpt ) ) {
869
+ $title = '<b>' . $title . '</b>';
870
+ $excerpt = '<br/>' . $excerpt;
871
+ }
872
+
873
+ if ( empty( $alt ) ) {
874
+ $alt = str_replace('"', '', $title);
875
+ }
876
+
877
+ $fontface = str_replace( '"', "'", stripslashes( get_option( 'relpoststh_fontfamily', $this->font_family ) ) );
878
+ $debug .= 'Using title with size ' . $text_length . '. Using excerpt with size ' . $excerpt_length . ';';
879
+ $after_content = apply_filters( 'rpth_after_content', '', $post );
880
+
881
+ if ( ( $amp_endpoint ) && ( true === apply_filters( 'rpth_amp', true ) ) ) {
882
+ $debug .= 'AMP view enabled';
883
+ $output .= '<li style="' . apply_filters( 'rpth_amp_list_style', 'margin: 5px 20px;' ) . '">';
884
+ $output .= '<a href="' . get_permalink( $post->ID ) . '" class="relpost_content" font-family: ' . $fontface . '>';
885
+ $output .= '<span class="rpth_amp_list_content">' . $title . $excerpt . '</span>' . $after_content . '</a></li>';
886
+ } else {
887
+ if ( $relpoststh_output_style == 'list' ) {
888
+ $link = get_permalink( $post->ID );
889
+ $output .= '<li ';
890
+
891
+ // if ( !$relpoststh_cleanhtml ) {
892
+ // $output .= ' onmouseout="this.style.backgroundColor=\'' . get_option( 'relpoststh_background', $this->background ) . '\'"';
893
+ // }
894
+
895
+ $output .= '>';
896
+ $output .= '<a href="' . $link . '" ><img class="relpost-post-image" alt="' . $alt . '" src="' . esc_url( $url ) . '" width="' . $width . '" height="' . $height . '" ';
897
+
898
+ // if ( !$relpoststh_cleanhtml ) {
899
+ // $output .= 'style="padding: 0px; margin: 0px; border: 0pt none;"';
900
+ // }
901
+
902
+ $output .= '/></a>';
903
+
904
+ if ( $text_height != '0' ) {
905
+ $output .= '<a href="' . $link . '" class="relpost_content"';
906
+
907
+ if ( !$relpoststh_cleanhtml ) {
908
+ $output .= ' style="width: ' . $width . 'px;height: ' . $text_height . 'px; font-family: ' . $fontface . '; "';
909
+ }
910
+
911
+ // $output .= '><span class="rpth_list_content">' . $title . $excerpt . '</span>' . $date . '</a></li>';
912
+ $output .= '><span class="rpth_list_content">' . $title . $excerpt . '</span>' . $after_content . '</a></li>';
913
+ }
914
+ } else {
915
+ //if lazy-load is not activated
916
+ $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;' );
917
+
918
+ //if lazy-load is activated
919
+ $rpt_lazy_single_background = apply_filters( 'rpt-lazy-loading', false );
920
+
921
+ $output .= '<a class="relpost-block-single" href="' . get_permalink( $post->ID ) . '">';
922
+ $output .= '<div class="relpost-custom-block-single" style="width: ' . $width . 'px; height: ' . ( $height + $text_height ) . 'px;">';
923
+
924
+ if( $rpt_lazy_single_background ) {
925
+ $output .= '<img loading="lazy" class="relpost-block-single-image" alt="' . $alt . '" src="'. $url . '"></img>';
926
+ } else {
927
+ $output .= '<div class="relpost-block-single-image" alt="' . $alt . '" style="'. $rpt_single_background . '"></div>';
928
  }
929
+ $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>';
930
+ $output .= $after_content;
931
+ // $output .= $date;
932
+ $output .= '</div>';
933
+ $output .= '</a>';
934
+ }
935
+ }
936
 
937
+ } // end foreach
938
+
939
+ if ( $relpoststh_output_style == 'list' ) {
940
+ $output .= '</ul>';
941
+ $output .= '<!-- close related_posts_thumbnails -->';
942
+ } else {
943
+ $output .= '</div>';
944
+ $output .= '<!-- close relpost-block-container -->';
945
+ // $output .= '</ul>';
946
+ // $output .= '<!-- close related-posts-nav -->';
947
+ }
948
+
949
+ $output .= '<div style="clear: both"></div>';
950
+
951
+ $output .= '</div>';
952
+ $output .= '<!-- close filter class -->';
953
+
954
+ $output .= '</div>';
955
+ $output .= '<!-- close relpost-thumb-wrapper -->';
956
+
957
+ return $this->finish_process( $output, $debug, $time );
958
+ }
959
+
960
+ // function is_url_404( $url ) {
961
+ // $response = wp_remote_request( $url,
962
+ // array(
963
+ // 'method' => 'GET'
964
+ // )
965
+ // );
966
+
967
+ // return $response['response']['code'];
968
+ // }
969
+
970
+ /**
971
+ * This will add debugging information in HTML source
972
+ *
973
+ * @param $output
974
+ * @param $debug
975
+ * @param int $time time took to create the thumbnails
976
+ *
977
+ * @return $output debugged information
978
+ */
979
+ function finish_process( $output, $debug, $time ) {
980
+
981
+ $devmode = get_option( 'relpoststh_devmode', $this->devmode );
982
+
983
+ if ( $devmode ) {
984
+ $time = microtime( true ) - $time;
985
+ $debug .= "Plugin execution time: $time sec;";
986
+ $output .= '<!-- ' . $debug . ' -->';
987
+ }
988
+
989
+ return $output;
990
+ }
991
+
992
+ function process_text_cut( $text, $length ) {
993
+
994
+ if ( $length == 0 ) {
995
+ return '';
996
+ } else {
997
+ $text = strip_tags( strip_shortcodes( $text ) );
998
+
999
+ if ( function_exists( 'mb_strlen' ) ) {
1000
+ return ( ( mb_strlen( $text ) > $length ) ? mb_substr( $text, 0, $length ) . '...' : $text );
1001
+ } else {
1002
+ return ( ( strlen( $text ) > $length ) ? substr( $text, 0, $length ) . '...' : $text );
1003
+ }
1004
+ }
1005
+ }
1006
+
1007
+ /**
1008
+ * Function to check th options to show the thumbnails according to the post types, categories etc.
1009
+ *
1010
+ * @return boolean
1011
+ */
1012
+ function is_relpoststh_show() {
1013
+ // Checking display options
1014
+ if ( !is_single() && get_option( 'relpoststh_single_only', $this->single_only ) ) { // single only
1015
+ return false;
1016
+ }
1017
+ // Check post type
1018
+ $post_types = get_option( 'relpoststh_post_types', $this->post_types );
1019
+ $post_type = get_post_type();
1020
+
1021
+ if ( !in_array( $post_type, $post_types ) ) {
1022
+ return false;
1023
+ }
1024
+ // Check categories
1025
+ $id = get_the_ID();
1026
+ $categories_all = get_option( 'relpoststh_categoriesall', $this->categories_all );
1027
+
1028
+ if ( $categories_all != '1' ) { // only specific categories were selected
1029
+
1030
+ $post_categories = wp_get_object_terms( $id, array( 'category' ), array( 'fields' => 'ids' ) );
1031
+ $relpoststh_categories = get_option( 'relpoststh_categories' );
1032
+
1033
+ if ( !is_array( $relpoststh_categories ) || !is_array( $post_categories ) ) { // no categories were selcted or post doesn't belong to any
1034
+ return false;
1035
+ }
1036
+
1037
+ $common_categories = array_intersect( $relpoststh_categories, $post_categories );
1038
+
1039
+ if ( empty( $common_categories ) ) { // post doesn't belong to specified categories
1040
+ return false;
1041
+ }
1042
+ }
1043
+
1044
+ return true;
1045
+ }
1046
+
1047
+ /**
1048
+ * Admin Menu page
1049
+ *
1050
+ * @return void
1051
+ */
1052
+ function admin_menu() {
1053
+ $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' );
1054
+ }
1055
+
1056
+ /**
1057
+ * Related post thumbnail settings page load
1058
+ *
1059
+ * @return void
1060
+ */
1061
+ function admin_interface() {
1062
+ include_once RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . '/inc/rpt-settings.php';
1063
+ }
1064
+
1065
+ /**
1066
+ * Category List in Settings
1067
+ *
1068
+ * @param $categoriesall
1069
+ * @param $categories
1070
+ * @param $selected_categories
1071
+ * @param $all_name
1072
+ * @param $specific_name
1073
+ */
1074
+ function display_categories_list( $categoriesall, $categories, $selected_categories, $all_name, $specific_name ) { ?>
1075
+ <input id="<?php echo $all_name; ?>" class="select_all" type="checkbox" name="<?php echo $all_name; ?>" value="1" <?php
 
 
 
 
 
 
 
1076
  if ( $categoriesall == '1' ) {
1077
  echo 'checked="checked"';
1078
  } ?>
1079
+ />
1080
+ <label for="<?php echo $all_name; ?>">
1081
+ <?php _e( 'All', 'related-posts-thumbnails' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1082
  </label>
1083
+ <div class="select_specific" <?php
1084
+ if ( $categoriesall == '1' ): ?>
1085
+ style="display:none"
1086
+ <?php endif; ?> >
1087
+ <?php foreach ( $categories as $category ): ?>
1088
+ <input type="checkbox" name="<?php echo $specific_name; ?>[]" id="<?php echo $specific_name; ?>_<?php echo $category->category_nicename;
1089
+ ?>" value="<?php echo $category->cat_ID; ?>"
1090
+ <?php
1091
+ if ( in_array( $category->cat_ID, (array) $selected_categories ) ) {
1092
+ echo 'checked="checked"';
1093
+ }
1094
+ ?>/>
1095
+ <label for="<?php echo $specific_name; ?>_<?php echo $category->category_nicename; ?>">
1096
+ <?php echo $category->cat_name; ?>
1097
+ </label>
1098
+ <br />
1099
+ <?php
1100
+ endforeach;
1101
+ ?>
1102
+ </div>
1103
+
1104
  <?php
1105
+ }
1106
+ /**
1107
+ * Related posts Thumbnails styling.
1108
+ *
1109
+ * @return void
1110
+ */
1111
+ function head_style() { ?>
1112
+ <style>
1113
+ #related_posts_thumbnails li{
1114
+ border-right: 1px solid <?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>;
1115
+ background-color: <?php echo get_option( 'relpoststh_background', $this->background ); ?>
1116
+ }
1117
+ #related_posts_thumbnails li:hover{
1118
+ background-color: <?php echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground ); ?>;
1119
+ }
1120
+ .relpost_content{
1121
+ font-size: <?php echo get_option( 'relpoststh_fontsize', $this->font_size ) . 'px'; ?>;
1122
+ color: <?php echo get_option( 'relpoststh_fontcolor', $this->font_color ); ?>;
1123
+ }
1124
+ .relpost-block-single{
1125
+ background-color: <?php echo get_option( 'relpoststh_background', $this->background ); ?>;
1126
+ border-right: 1px solid <?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>;
1127
+ border-left: 1px solid <?php echo get_option( 'relpoststh_bordercolor', $this->border_color ); ?>;
1128
+ margin-right: -1px;
1129
+ }
1130
+ .relpost-block-single:hover{
1131
+ background-color: <?php echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground ); ?>;
1132
+ }
1133
+ </style>
1134
 
1135
+ <?php
1136
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1137
  }
1138
 
1139
+ //End Class
1140
+ /**
1141
+ *
1142
+ * Create the Object of Related Posts thumbnails.
1143
+ */
1144
  add_action( 'init', 'related_posts_thumbnails' );
1145
 
1146
  function related_posts_thumbnails() {
1147
+ define( 'RELATED_POSTS_THUMBNAILS_URI', plugin_dir_url( __FILE__ ) );
1148
 
1149
+ global $related_posts_thumbnails;
1150
+ $related_posts_thumbnails = new RelatedPostsThumbnails();
1151
  }
1152
 
1153
  // Include Widget File.