Yet Another Related Posts Plugin (YARPP) - Version 5.27.8

Version Description

(01-December-2021) = * New: [yarpp] shortcode supports all the same parameters as yarpp_related(). See the updated documentation. * Bugfix: Apply the additional CSS class(es) defined in YARPP Advanced Block settings

Download this release

Release Info

Developer jeffparker
Plugin Icon 128x128 Yet Another Related Posts Plugin (YARPP)
Version 5.27.8
Comparing to
See all releases

Code changes from version 5.27.7 to 5.27.8

classes/YARPP_Block.php CHANGED
@@ -64,7 +64,7 @@ if ( ! class_exists( 'YARPP_Block', false ) && function_exists( 'register_block_
64
  $reference_post = get_post( (int) $block_attributes['reference_id']);
65
  $post_id = $reference_post->ID;
66
  }
67
- // Checks if the block is been used on the admin interface
68
  if ( isset( $block_attributes['yarpp_is_admin'] ) ) {
69
  $yarpp_is_admin = $block_attributes['yarpp_is_admin'];
70
  }
@@ -80,6 +80,9 @@ if ( ! class_exists( 'YARPP_Block', false ) && function_exists( 'register_block_
80
  if ( isset( $block_attributes['domain'] ) ) {
81
  $yarpp_args['domain'] = $block_attributes['domain'];
82
  }
 
 
 
83
 
84
  $output = '';
85
 
64
  $reference_post = get_post( (int) $block_attributes['reference_id']);
65
  $post_id = $reference_post->ID;
66
  }
67
+ // Checks if the block is being used in the admin interface
68
  if ( isset( $block_attributes['yarpp_is_admin'] ) ) {
69
  $yarpp_is_admin = $block_attributes['yarpp_is_admin'];
70
  }
80
  if ( isset( $block_attributes['domain'] ) ) {
81
  $yarpp_args['domain'] = $block_attributes['domain'];
82
  }
83
+ if ( isset( $block_attributes['className'] ) ) {
84
+ $yarpp_args['extra_css_class'] = $block_attributes['className'];
85
+ }
86
 
87
  $output = '';
88
 
classes/YARPP_Core.php CHANGED
@@ -1119,7 +1119,7 @@ class YARPP {
1119
  $include_post_type = yarpp_get_option( 'include_post_type' );
1120
  $include_post_type = wp_parse_list( $include_post_type );
1121
  if ( isset( $args['post_type'] ) ) {
1122
- $post_types = (array) $args['post_type'];
1123
  } elseif ( ! $this->get_option( 'cross_relate' ) ) {
1124
  $current_post_type = get_post_type( $reference_ID );
1125
  $post_types = array( $current_post_type );
@@ -1431,6 +1431,15 @@ class YARPP {
1431
  if ( $this->do_not_query_for_related() ) {
1432
  return false;
1433
  }
 
 
 
 
 
 
 
 
 
1434
  wp_register_style( 'yarppRelatedCss', plugins_url( '/style/related.css', YARPP_MAIN_FILE ), array(), YARPP_VERSION );
1435
  /**
1436
  * Filter to allow dequeing of related.css.
@@ -1527,6 +1536,29 @@ class YARPP {
1527
  }
1528
  return $output;
1529
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1530
  /**
1531
  * Returns the YARPP template html data.
1532
  *
@@ -1545,6 +1577,7 @@ class YARPP {
1545
  'domain',
1546
  'template',
1547
  'promote_yarpp',
 
1548
  );
1549
 
1550
  extract( $this->parse_args( $args, $options ) );
@@ -1585,6 +1618,11 @@ class YARPP {
1585
  $output .= ' yarpp-template-list';
1586
  }
1587
 
 
 
 
 
 
1588
  $output .= "'>\n";
1589
 
1590
  // avoid any monkeying around where someone could trya custom template like a template name like
@@ -1797,6 +1835,17 @@ class YARPP {
1797
  return $output;
1798
  }
1799
 
 
 
 
 
 
 
 
 
 
 
 
1800
  public function parse_args( $args, $options ) {
1801
  $options_with_rss_variants = array(
1802
  'limit',
1119
  $include_post_type = yarpp_get_option( 'include_post_type' );
1120
  $include_post_type = wp_parse_list( $include_post_type );
1121
  if ( isset( $args['post_type'] ) ) {
1122
+ $post_types = wp_parse_list( $args['post_type'] );
1123
  } elseif ( ! $this->get_option( 'cross_relate' ) ) {
1124
  $current_post_type = get_post_type( $reference_ID );
1125
  $post_types = array( $current_post_type );
1431
  if ( $this->do_not_query_for_related() ) {
1432
  return false;
1433
  }
1434
+ $this->parse_json_arg($args, 'weight');
1435
+ $this->parse_json_arg($args, 'require_tax');
1436
+ // Custom templates require .php extension.
1437
+ if ( isset( $args['template'] ) && $args['template'] ) {
1438
+ // Normalize parameter.
1439
+ if ( ( strpos( $args['template'], 'yarpp-template-' ) === 0 ) && ( strpos( $args['template'], '.php' ) === false ) ) {
1440
+ $args['template'] .= '.php';
1441
+ }
1442
+ }
1443
  wp_register_style( 'yarppRelatedCss', plugins_url( '/style/related.css', YARPP_MAIN_FILE ), array(), YARPP_VERSION );
1444
  /**
1445
  * Filter to allow dequeing of related.css.
1536
  }
1537
  return $output;
1538
  }
1539
+
1540
+ /**
1541
+ * Handles in case JSON was provided for this argument.
1542
+ *
1543
+ * If the argument specified is a string, it is expected to be a string of JSON, otherwise an error is logged.
1544
+ *
1545
+ * Nothing is returned, modifies the $args passed in.
1546
+ *
1547
+ * @param array $args
1548
+ * @param string $key
1549
+ *
1550
+ * @return null but modifies the $args array provided
1551
+ */
1552
+ protected function parse_json_arg( &$args, $key ) {
1553
+ if ( isset( $args[$key] ) && ! empty( $args[$key] ) && is_string($args[$key]) ) {
1554
+ $decoded_json = json_decode( $args[$key], true );
1555
+ if ( json_last_error() === JSON_ERROR_NONE ) {
1556
+ $args[$key] = $decoded_json;
1557
+ } else {
1558
+ error_log(sprintf('Error parsing JSON in YARPP argument "%s". JSON was "%s" and JSON error was "%s"', $key, $args[$key], function_exists('json_last_error_msg') ? json_last_error_msg() : json_last_error()));
1559
+ }
1560
+ }
1561
+ }
1562
  /**
1563
  * Returns the YARPP template html data.
1564
  *
1577
  'domain',
1578
  'template',
1579
  'promote_yarpp',
1580
+ 'extra_css_class',
1581
  );
1582
 
1583
  extract( $this->parse_args( $args, $options ) );
1618
  $output .= ' yarpp-template-list';
1619
  }
1620
 
1621
+ // Add any extra CSS classes specified (blocks)
1622
+ if ( isset( $extra_css_class ) && $extra_css_class ) {
1623
+ $output .= " $extra_css_class";
1624
+ }
1625
+
1626
  $output .= "'>\n";
1627
 
1628
  // avoid any monkeying around where someone could trya custom template like a template name like
1835
  return $output;
1836
  }
1837
 
1838
+ /**
1839
+ * Create an array whose keys come from $options, and whose values are either their values in $args or the option's
1840
+ * default value.
1841
+ * Any keys from $args that aren't in $options are ignored and not included in the returned result.
1842
+ *
1843
+ * @param array $args inputted arguments
1844
+ * @param array $options names of arguments to consider
1845
+ *
1846
+ * @return array with all the keys from the list of $options, with their values
1847
+ * from $args or the options' default values.
1848
+ */
1849
  public function parse_args( $args, $options ) {
1850
  $options_with_rss_variants = array(
1851
  'limit',
classes/YARPP_Shortcode.php CHANGED
@@ -15,53 +15,51 @@ class YARPP_Shortcode {
15
  }
16
 
17
  /**
18
- * @param $atts
19
  *
20
  * @return string
21
  */
22
  public function render( $atts ) {
23
- $atts = shortcode_atts(
 
 
 
 
 
 
 
24
  array(
25
  'reference_id' => null,
26
  'template' => null,
27
  'limit' => null,
28
  'recent' => null,
29
  ),
30
- $atts
31
  );
32
- /** @global $yarpp YARPP */
33
- global $yarpp;
34
- $post = get_post( (int) $atts['reference_id'] );
35
- $yarpp_args = array(
36
- 'domain' => 'shortcode',
37
- );
38
-
39
- // Custom templates require .php extension.
40
- if ( isset( $atts['template'] ) && $atts['template'] ) {
41
- // Normalize parameter.
42
- $yarpp_args['template'] = trim( $atts['template'] );
43
- if ( ( strpos( $yarpp_args['template'], 'yarpp-template-' ) === 0 ) && ( strpos( $yarpp_args['template'], '.php' ) === false ) ) {
44
- $yarpp_args['template'] .= '.php';
45
  }
46
- }
47
- // Can ignore validation of the "recent" attribute here as it is validated in the SQL function of the YARPP_Cache class.
48
- if ( isset( $atts['recent'] ) && $atts['recent'] ) {
49
- $yarpp_args['recent'] = trim( $atts['recent'] );
50
- }
51
- if ( isset( $atts['limit'] ) && $atts['limit'] ) {
52
- // Normalize parameter.
53
- $atts['limit'] = trim( $atts['limit'] );
54
-
55
- // Use only if numeric value is passed.
56
- if ( is_numeric( $atts['limit'] ) ) {
57
- $yarpp_args['limit'] = (int) $atts['limit'];
58
- }
59
- }
60
 
 
 
 
 
 
 
 
 
61
  if ( $post instanceof WP_Post ) {
62
  return $yarpp->display_related(
63
  $post->ID,
64
- $yarpp_args,
65
  false
66
  );
67
  } else {
15
  }
16
 
17
  /**
18
+ * @param array $atts see https://wordpress.org/plugins/yet-another-related-posts-plugin/#installation for acceptable arguments
19
  *
20
  * @return string
21
  */
22
  public function render( $atts ) {
23
+ /** @global $yarpp YARPP */
24
+ global $yarpp;
25
+ // don't use shortcode_atts() as it's DRYer to all the validation in YARPP::display_related()
26
+ // but do use the same filter as shortcode_atts, with all the same parameters as before the backward-compatibility
27
+ $atts = apply_filters(
28
+ 'shortcode_atts_yarpp',
29
+ (array) $atts,
30
+ $atts,
31
  array(
32
  'reference_id' => null,
33
  'template' => null,
34
  'limit' => null,
35
  'recent' => null,
36
  ),
37
+ 'yarpp'
38
  );
39
+ $atts = array_map(function( $item ) {
40
+ $trimmed_value = trim($item);
41
+ // check for the strings "true" and "false" to mean boolean true and false
42
+ if ( is_string($trimmed_value) ) {
43
+ $lower_trimmed_value = strtolower($trimmed_value);
44
+ if ( $lower_trimmed_value === 'true' ) {
45
+ $trimmed_value = true;
46
+ } elseif ( $lower_trimmed_value === 'false' ) {
47
+ $trimmed_value = false;
48
+ }
 
 
 
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ return $trimmed_value;
52
+ },
53
+ $atts
54
+ );
55
+ // Hardcoded the domain name because it should not be editable by the user.
56
+ $atts['domain'] = 'shortcode';
57
+ $post = get_post( isset($atts['reference_id']) ? (int) $atts['reference_id'] : null );
58
+ unset($atts['reference_id']);
59
  if ( $post instanceof WP_Post ) {
60
  return $yarpp->display_related(
61
  $post->ID,
62
+ $atts,
63
  false
64
  );
65
  } else {
js/block.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,a,n,l){var i=a.createElement,o=a.useEffect;const{registerBlockType:r,createBlock:p}=e,s=t["__"];var d=wp.serverSideRender;const C=l["InspectorControls"];l=i("svg",{width:"24px",height:"24px",viewBox:"0 0 145 191"},i("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd"},i("g",{id:"mark",transform:"translate(1.000000, 0.000000)",fill:"#000000",fillRule:"nonzero"},[i("g",{id:"coffee",transform:"translate(71.500000, 120.703704) scale(-1, 1) rotate(-180.000000) translate(-71.500000, -120.703704) translate(0.000000, 51.703704)"},[i("path",{d:"M42.8605706,136.08228 C32.8383705,134.783388 25.4669697,132.899997 20.7463681,130.432103 L17.3693225,127.801849 L17.6961333,113.286738 C17.9140072,99.3561292 17.9140072,98.6742113 15.626331,96.8232912 C9.85267229,92.1472827 0,79.2639855 0,68.5481325 C0,63.190206 1.55910743,60.0622836 4.82721619,54.4121066 C7.00595535,50.8076833 13.5249703,45.5370334 14.7232769,44.5628649 C17.0109529,43.0041953 18.4586919,44.1303138 17.6961333,33.1222102 C16.8246376,19.386435 16.0620789,17.4285621 24.0144768,12.8499703 C34.7992358,6.61529219 42.7516337,3.59536997 52.7738339,1.7444499 C76.6310277,-2.44447446 113.342783,1.25736568 126.30628,9.14813017 C133.931868,13.9215556 136.546355,16.844061 136.546355,20.9355684 C140.468085,87.8934137 142.537888,121.85942 142.755761,122.833589 C143.191509,125.074177 142.755761,125.658677 139.160842,127.314764 C134.040804,129.652769 127.831398,130.821771 106.588691,133.354609 C97.6558607,134.426194 87.0889758,135.692613 83.1672452,136.277114 C74.5612255,137.446116 52.55596,137.348699 42.8605706,136.08228 Z M84.5302734,132.078704 C90.2338167,131.384856 99.0983213,130.250086 109.038086,129.19345 C123.269589,127.025504 135.419901,125.626331 136.052413,123.330859 C136.26325,122.693228 123.934295,120.974239 120.350064,119.826503 C114.130371,117.786084 102.282696,120.185881 90.3749197,122.413563 C78.5049292,124.634175 65.4563408,123.330859 57.2545987,123.330859 C57.2545987,123.330859 52.4754466,122.523193 42.9171425,120.907861 C34.8760316,119.548931 36.2210561,119.122494 30.0013622,121.800545 C26.4171319,123.458385 23.2545757,125.243752 23.1491572,126.00891 C23.1491572,126.646541 23.4436238,128.461522 26.4171319,129.962221 C30.7587891,132.153411 43.5141602,132.441008 54.7143555,132.987395 C63.4858398,132.987395 78.8267301,132.772551 84.5302734,132.078704 Z M39.8706761,116.766844 C44.1268856,115.725876 53.6774041,114.21174 61.1517228,113.360038 C78.7994201,111.372734 134.960621,119.511215 135.168241,119.227315 C135.375861,119.038049 134.441571,54.1194625 131.327272,29.7040177 C129.873932,18.9157978 129.354882,17.9694627 122.088183,13.4270544 C110.461465,6.04564084 74.5432107,2.73346808 53.365974,6.9919759 C42.9849757,9.07391307 36.7563767,11.7236513 27.4134781,17.6855623 L22.2811694,21.5880854 L23.5725088,121.309253 L39.8706761,116.766844 Z M17.5997043,65.8013821 C17.5997043,50.8200023 18.1706592,50.7529753 17.5997043,50.7529753 C14.2258377,50.7529753 10.6869946,53.2086296 7.93345172,57.6428564 C5.8104668,61.0616507 5.50346166,65.6301628 5.50346166,67.2280714 C5.50346166,78.0260213 10.8676018,86.5101525 17.5997043,86.5101525 C17.5997043,86.5101525 17.5997043,79.607229 17.5997043,65.8013821 Z",id:"mug",stroke:"#000000"}),i("g",{id:"Face",transform:"translate(50.942850, 60.400797)"},[i("path",{d:"M62.160778,33.5475835 C58.4082262,26.6041533 60.1139316,19.0295022 64.8899066,19.0295022 C67.6190353,19.0295022 70.6893049,21.554386 71.7127282,24.7104906 C74.1007157,31.0226999 65.2310478,39.2285718 62.160778,33.5475835 Z",id:"Shape"}),i("path",{d:"M2.10303837,34.0061906 C-1.64951349,27.0627603 0.0561919019,19.4881092 4.832167,19.4881092 C7.56129563,19.4881092 10.6315653,22.0129929 11.6549885,25.1690976 C14.0429761,31.4813068 5.17330808,39.6871789 2.10303837,34.0061906 Z",id:"Shape"}),i("path",{d:"M31.2744481,13.4867788 C22.3526728,9.75718844 22.3526728,6.85639597 31.6992946,2.91960618 C42.1080324,-1.22438307 54.6410025,-0.809984147 59.1018902,3.74840403 C62.2882385,7.47799435 62.2882385,7.89239328 58.8894669,10.7931858 C53.1540399,15.7659729 39.3465305,17.0091696 31.2744481,13.4867788 Z M34.976751,7.90748093 C31.9007499,10.1104937 36.6921961,10.3294258 44.7947408,9.91788078 C56.0107659,9.20199741 56.1391309,4.42943021 44.7105432,4.91244623 C39.9559268,5.04429429 35.7457513,7.35672775 34.976751,7.90748093 Z",id:"Shape"})])]),i("g",{id:"Steam",transform:"translate(59.000000, 0.000000)"},[i("path",{d:"M4.16072763,0 C3.8378459,2.63060705 3.63689662,5.30305159 3.55986302,7.99095841 C3.50399,11.7470679 4.34571573,15.3721626 5.88012483,17.9837251 C6.89080993,19.79566 7.8953323,21.6238698 8.89369196,23.4683544 C9.94816663,25.3544895 10.6511261,27.7615875 10.9088994,30.3688969 C11.2199644,33.5056623 10.7257443,36.7238795 9.55926508,39.1573237 C8.32730672,41.7867086 6.67010618,43.6939485 4.8078126,44.6256781 L4.16072763,45 C4.54897862,43.79566 4.91874145,42.6889692 5.26077208,41.5660036 C5.72297563,40.0524412 6.18517917,38.5388789 6.61040644,36.9764919 C7.10981843,35.2326056 7.05009434,33.1543735 6.45325723,31.5081374 C6.2293797,30.9214149 5.97231446,30.3761351 5.68599934,29.880651 C4.66915153,28.0415914 3.62457152,26.2676311 2.63545592,24.4122966 C1.45178454,22.2681987 0.62382925,19.5948547 0.241241542,16.681736 C-0.438989396,11.7709757 0.340504342,6.58788172 2.31191343,2.91320073 C2.76487291,2.01808319 3.30102903,1.28571429 3.80020887,0.455696202 L4.06828692,5.05924416e-15 L4.16072763,0 Z",id:"Shape"}),i("path",{d:"M42,22.2784335 C41.5087566,23.247748 41.0367776,24.1755205 40.5551664,25.1586823 C40.1845249,25.9527384 39.8622545,26.7913079 39.591944,27.6650528 C39.2956943,28.8926755 39.2292571,30.2107229 39.3992994,31.4869214 C39.5437829,33.4255504 39.7267951,35.3641795 39.8038529,37.3028085 C39.8563132,38.9567993 39.5167155,40.587414 38.8406305,41.9278235 C38.0105027,43.6950754 36.6602155,44.8138092 35.1803853,44.9603932 C33.720005,45.1484608 32.2558855,44.6634774 31,43.5756581 L31.1348511,43.4094899 C32.0980736,42.4955649 33.1287215,41.5954871 34.1015762,40.6400199 C34.7603771,40.0681104 35.0780935,38.9403296 34.8817863,37.8705499 C34.5399208,35.5070657 34.3752325,33.0977166 34.390543,30.683775 C34.5530247,26.3626272 36.7924318,22.7913004 39.765324,22.1122653 C40.4194081,21.9625782 41.0858457,21.9625782 41.7399299,22.1122653 L41.8844134,22.1122653 L42,22.2784335 Z",id:"Shape"})])])));const{TextControl:u,SelectControl:c,PanelBody:y}=n;r("yarpp/yarpp-block",{title:s("Related Posts [YARPP]","yet-another-related-posts-plugin"),description:s("Display related posts by YARPP","yet-another-related-posts-plugin"),category:"yarpp",icon:l,keywords:[s("yarpp","yet-another-related-posts-plugin"),s("yet another","yet-another-related-posts-plugin"),s("related posts","yet-another-related-posts-plugin"),s("contextual","yet-another-related-posts-plugin"),s("popular","yet-another-related-posts-plugin"),s("similar","yet-another-related-posts-plugin"),s("thumbnail","yet-another-related-posts-plugin"),s("you may also","yet-another-related-posts-plugin"),s("posts","yet-another-related-posts-plugin")],supports:{html:!1},transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:({idBase:e,instance:t})=>!!t?.raw&&"yarpp_widget"===e,transform:({instance:e})=>{var t=e.raw.template,e="heading"in e.raw?e.raw.heading:"thumbnails"===t?e.raw.thumbnails_heading:e.raw.title;return p("yarpp/yarpp-block",{name:"yarpp_widget",template:t,heading:e,domain:"widget"})}}]},attributes:{reference_id:{type:"string",default:""},heading:{type:"string",default:s("You may also like","yet-another-related-posts-plugin")},limit:{type:"number",default:6},template:{type:"string",default:yarpp_localized.selected_theme_style},yarpp_preview:{type:"string"},domain:{type:"string",default:"block"},yarpp_is_admin:{type:"boolean",default:yarpp_localized.yarpp_is_admin}},example:{attributes:{yarpp_preview:"yarpp_preview"}},edit:function(e){var t=e.attributes;const a=e.setAttributes;var n,l=Object.keys(yarpp_localized.template).map(function(e){return{value:e,label:yarpp_localized.template[e]}});return e.isSelected,o(()=>{a({domain:yarpp_localized.default_domain})},[]),[i("div",{className:e.className},i(d,{block:"yarpp/yarpp-block",attributes:t})),i(C,{},i(y,{title:"YARPP Posts Settings",initialOpen:!0},i(u,{label:s("Reference ID (Optional)","yet-another-related-posts-plugin"),value:t.reference_id,help:s("The ID of the post to use for finding related posts. Defaults to current post.","yet-another-related-posts-plugin"),onChange:function(e){a({reference_id:e})}}),i(u,{label:s("Maximum number of posts","yet-another-related-posts-plugin"),value:t.limit,onChange:function(e){a({limit:parseInt(e)})},type:"number",min:1,step:1}),i(c,{value:t.template,label:s("Theme","yet-another-related-posts-plugin"),onChange:function(e){a({template:e})},options:l}),(n=t.template,("widget"===yarpp_localized.default_domain?["","builtin","list","thumbnail","thumbnails"]:["thumbnail","thumbnails"]).includes(n)&&i(u,{label:s("Heading","yet-another-related-posts-plugin"),value:t.heading,onChange:function(e){a({heading:e})}}))))]},save(){return null}})}(window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,(window.wp.editor,window.wp.blockEditor),window.wp.serverSideRender),function(a){a(document).on("widget-added",function(){function e(e){"object"==typeof e&&"type"in e&&e.stopImmediatePropagation();var t=a(this).closest("form").find(".widget-id").val();/__i__$/.test(t)||(e="builtin"===(e=a("#widget-"+t+"-template_file").val())||"thumbnails"===e,a("#widget-"+t+"-heading").closest("p").toggle(e))}a(".yarpp-widget-select-control","#wpbody").each(e),a(".yarpp-widget-select-control select","#wpbody").on("change",e)})}(jQuery);
1
+ !function(e,t,a,n,l){var i=a.createElement,o=a.useEffect;const{registerBlockType:r,createBlock:p}=e,s=t["__"];var d=wp.serverSideRender;const C=l["InspectorControls"];l=i("svg",{width:"24px",height:"24px",viewBox:"0 0 145 191"},i("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd"},i("g",{id:"mark",transform:"translate(1.000000, 0.000000)",fill:"#000000",fillRule:"nonzero"},[i("g",{id:"coffee",transform:"translate(71.500000, 120.703704) scale(-1, 1) rotate(-180.000000) translate(-71.500000, -120.703704) translate(0.000000, 51.703704)"},[i("path",{d:"M42.8605706,136.08228 C32.8383705,134.783388 25.4669697,132.899997 20.7463681,130.432103 L17.3693225,127.801849 L17.6961333,113.286738 C17.9140072,99.3561292 17.9140072,98.6742113 15.626331,96.8232912 C9.85267229,92.1472827 0,79.2639855 0,68.5481325 C0,63.190206 1.55910743,60.0622836 4.82721619,54.4121066 C7.00595535,50.8076833 13.5249703,45.5370334 14.7232769,44.5628649 C17.0109529,43.0041953 18.4586919,44.1303138 17.6961333,33.1222102 C16.8246376,19.386435 16.0620789,17.4285621 24.0144768,12.8499703 C34.7992358,6.61529219 42.7516337,3.59536997 52.7738339,1.7444499 C76.6310277,-2.44447446 113.342783,1.25736568 126.30628,9.14813017 C133.931868,13.9215556 136.546355,16.844061 136.546355,20.9355684 C140.468085,87.8934137 142.537888,121.85942 142.755761,122.833589 C143.191509,125.074177 142.755761,125.658677 139.160842,127.314764 C134.040804,129.652769 127.831398,130.821771 106.588691,133.354609 C97.6558607,134.426194 87.0889758,135.692613 83.1672452,136.277114 C74.5612255,137.446116 52.55596,137.348699 42.8605706,136.08228 Z M84.5302734,132.078704 C90.2338167,131.384856 99.0983213,130.250086 109.038086,129.19345 C123.269589,127.025504 135.419901,125.626331 136.052413,123.330859 C136.26325,122.693228 123.934295,120.974239 120.350064,119.826503 C114.130371,117.786084 102.282696,120.185881 90.3749197,122.413563 C78.5049292,124.634175 65.4563408,123.330859 57.2545987,123.330859 C57.2545987,123.330859 52.4754466,122.523193 42.9171425,120.907861 C34.8760316,119.548931 36.2210561,119.122494 30.0013622,121.800545 C26.4171319,123.458385 23.2545757,125.243752 23.1491572,126.00891 C23.1491572,126.646541 23.4436238,128.461522 26.4171319,129.962221 C30.7587891,132.153411 43.5141602,132.441008 54.7143555,132.987395 C63.4858398,132.987395 78.8267301,132.772551 84.5302734,132.078704 Z M39.8706761,116.766844 C44.1268856,115.725876 53.6774041,114.21174 61.1517228,113.360038 C78.7994201,111.372734 134.960621,119.511215 135.168241,119.227315 C135.375861,119.038049 134.441571,54.1194625 131.327272,29.7040177 C129.873932,18.9157978 129.354882,17.9694627 122.088183,13.4270544 C110.461465,6.04564084 74.5432107,2.73346808 53.365974,6.9919759 C42.9849757,9.07391307 36.7563767,11.7236513 27.4134781,17.6855623 L22.2811694,21.5880854 L23.5725088,121.309253 L39.8706761,116.766844 Z M17.5997043,65.8013821 C17.5997043,50.8200023 18.1706592,50.7529753 17.5997043,50.7529753 C14.2258377,50.7529753 10.6869946,53.2086296 7.93345172,57.6428564 C5.8104668,61.0616507 5.50346166,65.6301628 5.50346166,67.2280714 C5.50346166,78.0260213 10.8676018,86.5101525 17.5997043,86.5101525 C17.5997043,86.5101525 17.5997043,79.607229 17.5997043,65.8013821 Z",id:"mug",stroke:"#000000"}),i("g",{id:"Face",transform:"translate(50.942850, 60.400797)"},[i("path",{d:"M62.160778,33.5475835 C58.4082262,26.6041533 60.1139316,19.0295022 64.8899066,19.0295022 C67.6190353,19.0295022 70.6893049,21.554386 71.7127282,24.7104906 C74.1007157,31.0226999 65.2310478,39.2285718 62.160778,33.5475835 Z",id:"Shape"}),i("path",{d:"M2.10303837,34.0061906 C-1.64951349,27.0627603 0.0561919019,19.4881092 4.832167,19.4881092 C7.56129563,19.4881092 10.6315653,22.0129929 11.6549885,25.1690976 C14.0429761,31.4813068 5.17330808,39.6871789 2.10303837,34.0061906 Z",id:"Shape"}),i("path",{d:"M31.2744481,13.4867788 C22.3526728,9.75718844 22.3526728,6.85639597 31.6992946,2.91960618 C42.1080324,-1.22438307 54.6410025,-0.809984147 59.1018902,3.74840403 C62.2882385,7.47799435 62.2882385,7.89239328 58.8894669,10.7931858 C53.1540399,15.7659729 39.3465305,17.0091696 31.2744481,13.4867788 Z M34.976751,7.90748093 C31.9007499,10.1104937 36.6921961,10.3294258 44.7947408,9.91788078 C56.0107659,9.20199741 56.1391309,4.42943021 44.7105432,4.91244623 C39.9559268,5.04429429 35.7457513,7.35672775 34.976751,7.90748093 Z",id:"Shape"})])]),i("g",{id:"Steam",transform:"translate(59.000000, 0.000000)"},[i("path",{d:"M4.16072763,0 C3.8378459,2.63060705 3.63689662,5.30305159 3.55986302,7.99095841 C3.50399,11.7470679 4.34571573,15.3721626 5.88012483,17.9837251 C6.89080993,19.79566 7.8953323,21.6238698 8.89369196,23.4683544 C9.94816663,25.3544895 10.6511261,27.7615875 10.9088994,30.3688969 C11.2199644,33.5056623 10.7257443,36.7238795 9.55926508,39.1573237 C8.32730672,41.7867086 6.67010618,43.6939485 4.8078126,44.6256781 L4.16072763,45 C4.54897862,43.79566 4.91874145,42.6889692 5.26077208,41.5660036 C5.72297563,40.0524412 6.18517917,38.5388789 6.61040644,36.9764919 C7.10981843,35.2326056 7.05009434,33.1543735 6.45325723,31.5081374 C6.2293797,30.9214149 5.97231446,30.3761351 5.68599934,29.880651 C4.66915153,28.0415914 3.62457152,26.2676311 2.63545592,24.4122966 C1.45178454,22.2681987 0.62382925,19.5948547 0.241241542,16.681736 C-0.438989396,11.7709757 0.340504342,6.58788172 2.31191343,2.91320073 C2.76487291,2.01808319 3.30102903,1.28571429 3.80020887,0.455696202 L4.06828692,5.05924416e-15 L4.16072763,0 Z",id:"Shape"}),i("path",{d:"M42,22.2784335 C41.5087566,23.247748 41.0367776,24.1755205 40.5551664,25.1586823 C40.1845249,25.9527384 39.8622545,26.7913079 39.591944,27.6650528 C39.2956943,28.8926755 39.2292571,30.2107229 39.3992994,31.4869214 C39.5437829,33.4255504 39.7267951,35.3641795 39.8038529,37.3028085 C39.8563132,38.9567993 39.5167155,40.587414 38.8406305,41.9278235 C38.0105027,43.6950754 36.6602155,44.8138092 35.1803853,44.9603932 C33.720005,45.1484608 32.2558855,44.6634774 31,43.5756581 L31.1348511,43.4094899 C32.0980736,42.4955649 33.1287215,41.5954871 34.1015762,40.6400199 C34.7603771,40.0681104 35.0780935,38.9403296 34.8817863,37.8705499 C34.5399208,35.5070657 34.3752325,33.0977166 34.390543,30.683775 C34.5530247,26.3626272 36.7924318,22.7913004 39.765324,22.1122653 C40.4194081,21.9625782 41.0858457,21.9625782 41.7399299,22.1122653 L41.8844134,22.1122653 L42,22.2784335 Z",id:"Shape"})])])));const{TextControl:u,SelectControl:c,PanelBody:y}=n;r("yarpp/yarpp-block",{title:s("Related Posts [YARPP]","yet-another-related-posts-plugin"),description:s("Display related posts by YARPP","yet-another-related-posts-plugin"),category:"yarpp",icon:l,keywords:[s("yarpp","yet-another-related-posts-plugin"),s("yet another","yet-another-related-posts-plugin"),s("related posts","yet-another-related-posts-plugin"),s("contextual","yet-another-related-posts-plugin"),s("popular","yet-another-related-posts-plugin"),s("similar","yet-another-related-posts-plugin"),s("thumbnail","yet-another-related-posts-plugin"),s("you may also","yet-another-related-posts-plugin"),s("posts","yet-another-related-posts-plugin")],supports:{html:!1},transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:({idBase:e,instance:t})=>!!t?.raw&&"yarpp_widget"===e,transform:({instance:e})=>{var t=e.raw.template,e="heading"in e.raw?e.raw.heading:"thumbnails"===t?e.raw.thumbnails_heading:e.raw.title;return p("yarpp/yarpp-block",{name:"yarpp_widget",template:t,heading:e,domain:"widget"})}}]},attributes:{reference_id:{type:"string",default:""},heading:{type:"string",default:s("You may also like","yet-another-related-posts-plugin")},limit:{type:"number",default:6},template:{type:"string",default:yarpp_localized.selected_theme_style},yarpp_preview:{type:"string"},domain:{type:"string",default:"block"},yarpp_is_admin:{type:"boolean",default:yarpp_localized.yarpp_is_admin}},example:{attributes:{yarpp_preview:"yarpp_preview"}},edit:function(e){var t=e.attributes;const a=e.setAttributes;var n=Object.keys(yarpp_localized.template).map(function(e){return{value:e,label:yarpp_localized.template[e]}});return e.isSelected,o(()=>{a({domain:yarpp_localized.default_domain})},[]),[i("div",{className:e.className},i(d,{block:"yarpp/yarpp-block",attributes:t})),i(C,{},i(y,{title:"YARPP Posts Settings",initialOpen:!0},i(u,{label:s("Reference ID (Optional)","yet-another-related-posts-plugin"),value:t.reference_id,help:s("The ID of the post to use for finding related posts. Defaults to current post.","yet-another-related-posts-plugin"),onChange:function(e){a({reference_id:e})}}),i(u,{label:s("Maximum number of posts","yet-another-related-posts-plugin"),value:t.limit,onChange:function(e){a({limit:parseInt(e)})},type:"number",min:1,step:1}),i(c,{value:t.template,label:s("Theme","yet-another-related-posts-plugin"),onChange:function(e){a({template:e})},options:n}),(n=t.template,("widget"===yarpp_localized.default_domain?["","builtin","list","thumbnail","thumbnails"]:["thumbnail","thumbnails"]).includes(n)&&i(u,{label:s("Heading","yet-another-related-posts-plugin"),value:t.heading,onChange:function(e){a({heading:e})}}))))]},save(){return null}})}(window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,(window.wp.editor,window.wp.blockEditor),window.wp.serverSideRender),function(a){a(document).on("widget-added",function(){function e(e){"object"==typeof e&&"type"in e&&e.stopImmediatePropagation();var t=a(this).closest("form").find(".widget-id").val();/__i__$/.test(t)||(e="builtin"===(e=a("#widget-"+t+"-template_file").val())||"thumbnails"===e,a("#widget-"+t+"-heading").closest("p").toggle(e))}a(".yarpp-widget-select-control","#wpbody").each(e),a(".yarpp-widget-select-control select","#wpbody").on("change",e)})}(jQuery);
readme.txt CHANGED
@@ -5,8 +5,8 @@ Donate link: https://yarpp.com
5
  Requires at least: 3.7
6
  Requires PHP: 5.3
7
  License: GPLv2 or later
8
- Tested up to: 5.8
9
- Stable tag: 5.27.7
10
 
11
  The best WordPress plugin for displaying related posts. Simple and flexible, with a powerful proven algorithm and inbuilt caching.
12
 
@@ -124,6 +124,8 @@ To add to post content, use the shortcode:
124
 
125
  `[yarpp]` to show content related to the current post. You may use more than one YARPP shortcode in a given post or template.
126
 
 
 
127
  If you know the reference Post ID that you want to show content related to, use:
128
 
129
  `[yarpp reference_id=123]` to show content related to post 123
@@ -142,6 +144,26 @@ To only show recent posts, use the "recent" attribute (provide it with a number,
142
 
143
  `[yarpp recent="6 month"]`
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  To add YARPP shortcode to your theme files (eg. single.php), use:
146
 
147
  `<?php echo do_shortcode('[yarpp]'); ?>`
@@ -215,6 +237,7 @@ yarpp_related(
215
  'order' => 'score DESC', // column on "wp_posts" to order by, then a space, and whether to order in ascending ("ASC") or descending ("DESC") order
216
  'promote_yarpp' => true, // boolean indicating whether to add 'Powered by YARPP' below related posts
217
  'generate_missing_thumbnails' => true, // automatically generate missing thumbnail sizes on the fly
 
218
  ),
219
  $reference_ID, // second argument: (optional) the post ID. If not included, will use the current post.
220
  true // third argument: (optional) true to echo the HTML block; false to return it
@@ -539,6 +562,11 @@ Beginning with version 4.0.7, YARPP includes clean uninstall functionality. If y
539
 
540
 
541
  == Changelog ==
 
 
 
 
 
542
  = 5.27.7 (29-October-2021) =
543
  * Enhancement: CSS improvements for better cross-theme compatibility
544
  * Documentation: [Available YARPP filters](https://support.shareaholic.com/hc/en-us/articles/4408775687060)
@@ -1444,5 +1472,5 @@ After a break of many years, the plugin is 100% supported now that the baton has
1444
  * Initial upload
1445
 
1446
  == Upgrade Notice ==
1447
- = 5.27.7 =
1448
  We update this plugin regularly so we can make it better for you. Update to the latest version for all of the available features and improvements. Thank you for using YARPP!
5
  Requires at least: 3.7
6
  Requires PHP: 5.3
7
  License: GPLv2 or later
8
+ Tested up to: 6.0
9
+ Stable tag: 5.27.8
10
 
11
  The best WordPress plugin for displaying related posts. Simple and flexible, with a powerful proven algorithm and inbuilt caching.
12
 
124
 
125
  `[yarpp]` to show content related to the current post. You may use more than one YARPP shortcode in a given post or template.
126
 
127
+ All the parameters accepted by `yarpp_related()` (see below) can also be used in the shortcode. Here are some examples...
128
+
129
  If you know the reference Post ID that you want to show content related to, use:
130
 
131
  `[yarpp reference_id=123]` to show content related to post 123
144
 
145
  `[yarpp recent="6 month"]`
146
 
147
+ To show another post type, use the "post_type" parameter.
148
+
149
+ `
150
+ [yarpp post_type="page"]
151
+ `
152
+
153
+ If you need to provide multiple values (eg posts and pages, or a list of categorires of posts to exlude), separate them with a comma but no space.
154
+ `
155
+ [yarpp post_type="post,page"] - include both posts and pages in results
156
+ [yarpp exclude="1,2,3"] - exclude posts with categories with IDs 1,2 and 3
157
+ `
158
+
159
+ To adjust the weights and taxonomy requirements, provide the value as JSON (using the same structure as for `yarpp_related()` below). Eg
160
+
161
+ `
162
+ [yarpp weight='{"body":1}'] - only consider body content
163
+ [yarpp weight='{"body":2,"title":2,"tax":{"category":0, "post_tag":0}}'] - give extra weight to bodies and titles, but none to categories
164
+ [yarpp require_tax='{"category": 2, "post_tag": 0}'] - require at least one category in common
165
+ `
166
+
167
  To add YARPP shortcode to your theme files (eg. single.php), use:
168
 
169
  `<?php echo do_shortcode('[yarpp]'); ?>`
237
  'order' => 'score DESC', // column on "wp_posts" to order by, then a space, and whether to order in ascending ("ASC") or descending ("DESC") order
238
  'promote_yarpp' => true, // boolean indicating whether to add 'Powered by YARPP' below related posts
239
  'generate_missing_thumbnails' => true, // automatically generate missing thumbnail sizes on the fly
240
+ 'extra_css_class' => 'class_1 class_2', // add CSS classes to YARPP's parent div
241
  ),
242
  $reference_ID, // second argument: (optional) the post ID. If not included, will use the current post.
243
  true // third argument: (optional) true to echo the HTML block; false to return it
562
 
563
 
564
  == Changelog ==
565
+
566
+ = 5.27.8 (01-December-2021) =
567
+ * New: `[yarpp]` shortcode supports all the same parameters as `yarpp_related()`. [See the updated documentation.](https://wordpress.org/plugins/yet-another-related-posts-plugin/#installation)
568
+ * Bugfix: Apply the additional CSS class(es) defined in YARPP Advanced Block settings
569
+
570
  = 5.27.7 (29-October-2021) =
571
  * Enhancement: CSS improvements for better cross-theme compatibility
572
  * Documentation: [Available YARPP filters](https://support.shareaholic.com/hc/en-us/articles/4408775687060)
1472
  * Initial upload
1473
 
1474
  == Upgrade Notice ==
1475
+ = 5.27.8 =
1476
  We update this plugin regularly so we can make it better for you. Update to the latest version for all of the available features and improvements. Thank you for using YARPP!
style/styles_thumbnails.css CHANGED
@@ -1 +1 @@
1
- .yarpp-thumbnail-default,.yarpp-thumbnail-title,.yarpp-thumbnails-horizontal .yarpp-thumbnail{display:inline-block}.yarpp-thumbnails-horizontal .yarpp-thumbnail{border:1px solid rgba(127,127,127,.1);vertical-align:top}.yarpp-thumbnails-horizontal .yarpp-thumbnail-default,.yarpp-thumbnails-horizontal .yarpp-thumbnail>img{display:block}.yarpp-thumbnails-horizontal .yarpp-thumbnail-title{font-size:1em;line-height:1.4em;max-height:2.8em;overflow:hidden;text-decoration:inherit}.yarpp-thumbnail-default{overflow:hidden}
1
+ .yarpp-thumbnail-default,.yarpp-thumbnail-title,.yarpp-thumbnails-horizontal .yarpp-thumbnail{display:inline-block}.yarpp-thumbnails-horizontal .yarpp-thumbnail{border:1px solid hsla(0,0%,50%,.1);vertical-align:top}.yarpp-thumbnails-horizontal .yarpp-thumbnail-default,.yarpp-thumbnails-horizontal .yarpp-thumbnail>img{display:block}.yarpp-thumbnails-horizontal .yarpp-thumbnail-title{font-size:1em;line-height:1.4em;max-height:2.8em;overflow:hidden;text-decoration:inherit}.yarpp-thumbnail-default{overflow:hidden}
yarpp.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Yet Another Related Posts Plugin (YARPP)
4
  Description: Adds related posts to your site and in RSS feeds, based on a powerful, customizable algorithm.
5
- Version: 5.27.7
6
  Author: YARPP
7
  Author URI: https://yarpp.com/
8
  Plugin URI: https://yarpp.com/
@@ -25,7 +25,7 @@ if ( ! defined( 'WP_CONTENT_DIR' ) ) {
25
  define( 'WP_CONTENT_DIR', substr( $tr, 0, strrpos( $tr, '/' ) ) );
26
  }
27
 
28
- define( 'YARPP_VERSION', '5.27.7' );
29
 
30
  define( 'YARPP_DIR', dirname( __FILE__ ) );
31
  /**
2
  /*
3
  Plugin Name: Yet Another Related Posts Plugin (YARPP)
4
  Description: Adds related posts to your site and in RSS feeds, based on a powerful, customizable algorithm.
5
+ Version: 5.27.8
6
  Author: YARPP
7
  Author URI: https://yarpp.com/
8
  Plugin URI: https://yarpp.com/
25
  define( 'WP_CONTENT_DIR', substr( $tr, 0, strrpos( $tr, '/' ) ) );
26
  }
27
 
28
+ define( 'YARPP_VERSION', '5.27.8' );
29
 
30
  define( 'YARPP_DIR', dirname( __FILE__ ) );
31
  /**