Related Posts for WordPress - Version 1.2.0

Version Description

: August 14, 2014 = * Related Posts heading text is now a setting. * Amount of words in excerpt is now a setting. * Displaying images of related posts is now a setting. * Frontend CSS is now editable via settings. * Added 'rp4wp_heading' filter, allows filtering of complete related posts block heading.

Download this release

Release Info

Developer barrykooij
Plugin Icon 128x128 Related Posts for WordPress
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.0 to 1.2.0

assets/css/edit-post.css CHANGED
@@ -1,37 +1 @@
1
- .rp4wp_table_manage.sortable tr {
2
- cursor: move;
3
- }
4
-
5
- .rp4wp_table_manage td {
6
- padding-bottom: 11px;
7
- }
8
-
9
- .rp4wp_table_manage.sortable td {
10
- background-position: 98% 50%;
11
- background-image: url('../images/grabber.png');
12
- background-repeat: no-repeat;
13
- }
14
-
15
- .rp4wp_table_manage tr:nth-child(odd),
16
- .sp_pt_links_overview tr:nth-child(odd) {
17
- background-color: #FCFCFC;
18
- }
19
-
20
- .rp4wp_button_holder {
21
- padding: 10px 0;
22
- float: right;
23
- }
24
-
25
- .rp4wp_button_holder span {
26
- margin-left: 10px;
27
- float: left;
28
- }
29
-
30
- .rp4wp_save_button {
31
- float: right;
32
- }
33
-
34
- .rp4wp_ajaxloader {
35
- height: 13px;
36
- margin-left: 10px;
37
- }
1
+ .rp4wp_table_manage.sortable tr{cursor:move}.rp4wp_table_manage.sortable tr td{background-position:98% 50%;background-image:url(../images/grabber.png);background-repeat:no-repeat}.rp4wp_table_manage td{padding-bottom:11px}.rp4wp_table_manage tr:nth-child(odd){background-color:#FCFCFC}.rp4wp_button_holder{padding:10px 0;float:right}.rp4wp_button_holder span{margin-left:10px;float:left}.rp4wp_save_button{float:right}.rp4wp_ajaxloader{height:13px;margin-left:10px}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/edit-post.less ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .rp4wp_table_manage {
2
+ &.sortable tr {
3
+ cursor: move;
4
+ td {
5
+ background-position: 98% 50%;
6
+ background-image: url('../images/grabber.png');
7
+ background-repeat: no-repeat;
8
+ }
9
+ }
10
+
11
+ td {
12
+ padding-bottom: 11px;
13
+ }
14
+
15
+ tr:nth-child(odd) {
16
+ background-color: #FCFCFC;
17
+ }
18
+ }
19
+
20
+ .rp4wp_button_holder {
21
+ padding: 10px 0;
22
+ float: right;
23
+
24
+ span {
25
+ margin-left: 10px;
26
+ float: left;
27
+ }
28
+ }
29
+
30
+ .rp4wp_save_button {
31
+ float: right;
32
+ }
33
+
34
+ .rp4wp_ajaxloader {
35
+ height: 13px;
36
+ margin-left: 10px;
37
+ }
assets/css/install.css CHANGED
@@ -1,43 +1 @@
1
- .install-steps li {
2
- width: 33%;
3
- padding: 10px 15px;
4
- font-weight: bold;
5
- color: #eee;
6
- background: #222222;
7
- float: left;
8
- -moz-box-sizing: border-box;
9
- -webkit-box-sizing: border-box;
10
- box-sizing: border-box;
11
- }
12
-
13
- .install-steps li.step-bar-active {
14
- background: #0074a2;
15
- }
16
-
17
- .install-steps li:first-child {
18
- margin-left: 0;
19
- }
20
-
21
- .rp4wp-install-link-box {
22
- display: inline;
23
- padding: 15px;
24
- border: 1px solid #0074a2;
25
- }
26
-
27
- .rp4wp-step .rp4wp-install-link-box label {
28
- padding-right: 20px;
29
- }
30
-
31
- .rp4wp-step .rp4wp-install-link-box input {
32
- width: 40px;
33
- text-align: center;
34
- }
35
-
36
- .rp4wp-step .rp4wp-install-link-box a.rp4wp-link-now-btn {
37
- margin-left: 20px;
38
- margin-right: 10px;
39
- }
40
-
41
- .rp4wp-step-2 #progressbar {
42
- margin-top: 30px;
43
- }
1
+ .install-steps li{width:33%;padding:10px 15px;font-weight:700;color:#eee;background:#222;float:left;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.install-steps li.step-bar-active{background:#0074a2}.install-steps li:first-child{margin-left:0}.rp4wp-step .rp4wp-install-link-box label{padding-right:20px}.rp4wp-step .rp4wp-install-link-box input{width:40px;text-align:center}.rp4wp-step .rp4wp-install-link-box a.rp4wp-link-now-btn{margin-left:20px;margin-right:10px}.rp4wp-install-link-box{display:inline;padding:15px;border:1px solid #0074a2}.rp4wp-step-2 #progressbar{margin-top:30px}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/install.less ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .install-steps {
2
+ li {
3
+ width: 33%;
4
+ padding: 10px 15px;
5
+ font-weight: bold;
6
+ color: #eee;
7
+ background: #222222;
8
+ float: left;
9
+ -moz-box-sizing: border-box;
10
+ -webkit-box-sizing: border-box;
11
+ box-sizing: border-box;
12
+
13
+ &.step-bar-active {
14
+ background: #0074a2;
15
+ }
16
+
17
+ &:first-child {
18
+ margin-left: 0;
19
+ }
20
+ }
21
+ }
22
+
23
+ .rp4wp-step {
24
+ .rp4wp-install-link-box {
25
+ label {
26
+ padding-right: 20px;
27
+ }
28
+ input {
29
+ width: 40px;
30
+ text-align: center;
31
+ }
32
+ a.rp4wp-link-now-btn {
33
+ margin-left: 20px;
34
+ margin-right: 10px;
35
+ }
36
+ }
37
+
38
+ }
39
+
40
+ .rp4wp-install-link-box {
41
+ display: inline;
42
+ padding: 15px;
43
+ border: 1px solid #0074a2;
44
+ }
45
+
46
+ .rp4wp-step-2 #progressbar {
47
+ margin-top: 30px;
48
+ }
assets/css/settings.css CHANGED
@@ -1,31 +1 @@
1
- .rp4wp-content {
2
- width: 65%;
3
- float: left;
4
- box-sizing: border-box;
5
- }
6
-
7
- .rp4wp-sidebar {
8
- width: 33%;
9
- margin-left: 2%;
10
- padding: 0 0 0 2%;
11
- border-left: 1px solid #ccc;
12
- float: left;
13
- box-sizing: border-box;
14
- }
15
-
16
- .rp4wp-box {
17
- margin-bottom: 20px;
18
- }
19
-
20
- .rp4wp-sidebar-header {
21
- line-height: 0;
22
- border-bottom: 2px solid #005592;
23
- }
24
-
25
- .rp4wp-description {
26
- display: block;
27
- margin: 5px 0;
28
- line-height: 1.4em;
29
- color: #666;
30
- font-style: italic;
31
- }
1
+ .rp4wp-content{width:65%;float:left;box-sizing:border-box}.rp4wp-content textarea{width:50%;height:150px}.rp4wp-content .rp4wp-description{display:block;margin:5px 0;line-height:1.4em;color:#666;font-style:italic}.rp4wp-sidebar{width:33%;margin-left:2%;padding:0 0 0 2%;border-left:1px solid #ccc;float:left;box-sizing:border-box}.rp4wp-sidebar .rp4wp-box{margin-bottom:20px}.rp4wp-sidebar .rp4wp-box .rp4wp-sidebar-header{line-height:0;border-bottom:2px solid #005592}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/settings.less ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .rp4wp-content {
2
+ width: 65%;
3
+ float: left;
4
+ box-sizing: border-box;
5
+
6
+ textarea {
7
+ width: 50%;
8
+ height: 150px;
9
+ }
10
+
11
+ .rp4wp-description {
12
+ display: block;
13
+ margin: 5px 0;
14
+ line-height: 1.4em;
15
+ color: #666;
16
+ font-style: italic;
17
+ }
18
+
19
+ }
20
+
21
+ .rp4wp-sidebar {
22
+ width: 33%;
23
+ margin-left: 2%;
24
+ padding: 0 0 0 2%;
25
+ border-left: 1px solid #ccc;
26
+ float: left;
27
+ box-sizing: border-box;
28
+
29
+ .rp4wp-box {
30
+ margin-bottom: 20px;
31
+
32
+ .rp4wp-sidebar-header {
33
+ line-height: 0;
34
+ border-bottom: 2px solid #005592;
35
+ }
36
+ }
37
+ }
assets/js/edit-post.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function RP4WP_Related_Manager(a){this.container=a,this.init=function(){this.bind(),this.make_sortable()},this.bind=function(){var a=this;jQuery(this.container).find(".rp4wp_table_manage .trash a").bind("click",function(){a.delete_child(this)})},this.fix_helper=function(a,b){return b.children().each(function(){jQuery(this).width(jQuery(this).width())}),b},this.make_sortable=function(){var a=this,b=jQuery(this.container).find(".sortable tbody");b.sortable({helper:a.fix_helper,update:function(){jQuery(a.container).parent().parent().find("h3").eq(0).append(jQuery("<img>").attr("src",jQuery("#rp4wp-dir-img").val()+"ajax-loader.gif").addClass("rp4wp_ajaxloader")),opts={url:ajaxurl,type:"POST",async:!0,cache:!1,dataType:"json",data:{action:"rp4wp_related_sort",rp4wp_items:b.sortable("toArray").toString(),nonce:jQuery(a.container).find("#rp4wp-ajax-nonce").val()},success:function(){jQuery(".rp4wp_ajaxloader").remove()},error:function(){jQuery(".rp4wp_ajaxloader").remove()}},jQuery.ajax(opts)}})},this.delete_child=function(a){var b=confirm("Are you sure you want to delete this related post?");if(b){var c=this,d={url:ajaxurl,type:"POST",async:!0,cache:!1,dataType:"json",data:{action:"rp4wp_delete_link",id:jQuery(a).closest("tr").attr("id"),nonce:jQuery(c.container).find("#rp4wp-ajax-nonce").val()},success:function(){jQuery(a).closest("tr").fadeTo("fast",0).slideUp(function(){jQuery(this).remove()})},error:function(){}};jQuery.ajax(d)}},this.init()}jQuery(function(a){a.each(a(".rp4wp_mb_manage"),function(a,b){new RP4WP_Related_Manager(b)})});
assets/js/install.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(a){function b(b){this.step=b,this.total_posts=0,this.ppr=null,this.req_nr=0,this.action=null,this.do_request=function(){var b=this;a.post(ajaxurl,{action:this.action,rel_amount:a("#rp4wp_related_posts_amount").val()},function(a){"more"==a?(b.req_nr++,b.do_progressbar(),b.do_request()):"done"==a?b.done():alert("Woops! Something went wrong while linking.\n\nResponse:\n\n"+a)})},this.done=function(){a("#progressbar").progressbar({value:100}),window.location=a("#rp4wp_admin_url").val()+"?page=rp4wp_install&step="+(this.step+1)},this.do_progressbar=function(){a("#progressbar").progressbar({value:this.req_nr*this.ppr/this.total_posts*100})},this.init=function(){switch(a("#progressbar").progressbar({value:!1}),this.total_posts=a("#rp4wp_total_posts").val(),this.step){case 1:this.ppr=200,this.action="rp4wp_install_save_words";break;case 2:this.ppr=5,this.action="rp4wp_install_link_posts"}this.do_request()},this.init()}var c=a(".rp4wp-step").attr("rel");1==c?b(1):2==c&&a("#rp4wp-link-now").click(function(){b(2)})});
classes/class-settings.php CHANGED
@@ -4,6 +4,11 @@ if ( !defined( 'ABSPATH' ) ) {
4
  exit;
5
  } // Exit if accessed directly
6
 
 
 
 
 
 
7
  class RP4WP_Settings {
8
 
9
  const PREFIX = 'rp4wp_';
@@ -18,12 +23,19 @@ class RP4WP_Settings {
18
  */
19
  public function __construct() {
20
 
 
 
 
 
 
 
 
21
  // The fields
22
  $this->sections = array(
23
  self::PREFIX . 'automatic_linking' => array(
24
  'id' => 'automatic_linking',
25
  'label' => __( 'Automatic post linking', 'related-posts-for-wp' ),
26
- 'description' => __( 'This is the automatic post link section.', 'related-posts-for-wp' ),
27
  'fields' => array(
28
  array(
29
  'id' => 'automatic_linking',
@@ -39,6 +51,40 @@ class RP4WP_Settings {
39
  'type' => 'text',
40
  'default' => '3',
41
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ) )
43
  );
44
 
@@ -127,6 +173,9 @@ class RP4WP_Settings {
127
  case 'text':
128
  echo '<input type="text" name="' . self::PAGE . '[' . $field['id'] . ']' . '" id="' . $field['id'] . '" value="' . $this->get_option( $field['id'] ) . '" />';
129
  break;
 
 
 
130
  }
131
 
132
  // Description
@@ -151,17 +200,25 @@ class RP4WP_Settings {
151
  */
152
  public function sanitize_option( $post_data ) {
153
 
154
- // Unset automatic_linking if not post
155
  if ( !isset( $post_data['automatic_linking'] ) ) {
156
  $post_data['automatic_linking'] = 0;
157
  }
158
 
 
 
 
 
 
159
  // automatic_linking must be an integer
160
  $post_data['automatic_linking'] = intval($post_data['automatic_linking']);
161
 
162
  // automatic_linking_post_amount must be an integer
163
  $post_data['automatic_linking_post_amount'] = intval($post_data['automatic_linking_post_amount']);
164
 
 
 
 
165
  return $post_data;
166
 
167
  }
4
  exit;
5
  } // Exit if accessed directly
6
 
7
+ /**
8
+ * Class RP4WP_Settings
9
+ *
10
+ * @todo Make class for each input type with own sanitize method.
11
+ */
12
  class RP4WP_Settings {
13
 
14
  const PREFIX = 'rp4wp_';
23
  */
24
  public function __construct() {
25
 
26
+ // CSS default
27
+ $css_default_lines = array();
28
+ $css_default_lines[] = '.rp4wp-related-posts ul {padding:0;margin:0;float:left;}';
29
+ $css_default_lines[] = '.rp4wp-related-posts li{list-style:none;padding-bottom:20px}';
30
+ $css_default_lines[] = '.rp4wp-related-posts li p {margin:0;padding:0}';
31
+ $css_default_lines[] = '.rp4wp-related-post-image{width:35%;padding-right:25px;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;float:left;}';
32
+
33
  // The fields
34
  $this->sections = array(
35
  self::PREFIX . 'automatic_linking' => array(
36
  'id' => 'automatic_linking',
37
  'label' => __( 'Automatic post linking', 'related-posts-for-wp' ),
38
+ 'description' => __( 'This section contains automatic post link related settings.', 'related-posts-for-wp' ),
39
  'fields' => array(
40
  array(
41
  'id' => 'automatic_linking',
51
  'type' => 'text',
52
  'default' => '3',
53
  )
54
+ ) ),
55
+ self::PREFIX . 'css' => array(
56
+ 'id' => 'css',
57
+ 'label' => __( 'Frontend Settings', 'related-posts-for-wp' ),
58
+ 'description' => __( 'This section contains frontend related settings.', 'related-posts-for-wp' ),
59
+ 'fields' => array(
60
+ array(
61
+ 'id' => 'heading_text',
62
+ 'label' => __( 'Heading text ', 'related-posts-for-wp' ),
63
+ 'description' => __( 'The text that is displayed above the related posts. To disable, leave field empty.', 'related-posts-for-wp' ),
64
+ 'type' => 'text',
65
+ 'default' => 'Related Posts',
66
+ ),
67
+ array(
68
+ 'id' => 'excerpt_length',
69
+ 'label' => __( 'Exceprt length', 'related-posts-for-wp' ),
70
+ 'description' => __( 'The amount of characters to be displayed below the title on website. To disable, set value to 0.', 'related-posts-for-wp' ),
71
+ 'type' => 'text',
72
+ 'default' => '25',
73
+ ),
74
+ array(
75
+ 'id' => 'display_image',
76
+ 'label' => __( 'Display Image', 'related-posts-for-wp' ),
77
+ 'description' => __( 'Checking this will enable displaying featured images of related posts.', 'related-posts-for-wp' ),
78
+ 'type' => 'checkbox',
79
+ 'default' => 0,
80
+ ),
81
+ array(
82
+ 'id' => 'css',
83
+ 'label' => __( 'CSS', 'related-posts-for-wp' ),
84
+ 'description' => __( 'Warning! This is an advanced feature! An error here will break frontend display. To disable, leave field empty.', 'related-posts-for-wp' ),
85
+ 'type' => 'textarea',
86
+ 'default' => implode(PHP_EOL, $css_default_lines),
87
+ )
88
  ) )
89
  );
90
 
173
  case 'text':
174
  echo '<input type="text" name="' . self::PAGE . '[' . $field['id'] . ']' . '" id="' . $field['id'] . '" value="' . $this->get_option( $field['id'] ) . '" />';
175
  break;
176
+ case 'textarea':
177
+ echo '<textarea name="' . self::PAGE . '[' . $field['id'] . ']' . '" id="' . $field['id'] . '">' . $this->get_option( $field['id'] ) . '</textarea>';
178
+ break;
179
  }
180
 
181
  // Description
200
  */
201
  public function sanitize_option( $post_data ) {
202
 
203
+ // Unset automatic_linking if not set in post
204
  if ( !isset( $post_data['automatic_linking'] ) ) {
205
  $post_data['automatic_linking'] = 0;
206
  }
207
 
208
+ // Unset display_image if not set in post
209
+ if ( !isset( $post_data['display_image'] ) ) {
210
+ $post_data['display_image'] = 0;
211
+ }
212
+
213
  // automatic_linking must be an integer
214
  $post_data['automatic_linking'] = intval($post_data['automatic_linking']);
215
 
216
  // automatic_linking_post_amount must be an integer
217
  $post_data['automatic_linking_post_amount'] = intval($post_data['automatic_linking_post_amount']);
218
 
219
+ // Excerpt length must be an integer
220
+ $post_data['excerpt_length'] = intval($post_data['excerpt_length']);
221
+
222
  return $post_data;
223
 
224
  }
classes/filters/class-filter-after-post.php CHANGED
@@ -8,74 +8,6 @@ class RP4WP_Filter_After_Post extends RP4WP_Filter {
8
  protected $tag = 'the_content';
9
  protected $priority = 99;
10
 
11
- /**
12
- * Generate the post list
13
- *
14
- * @param $slug
15
- * @param $title
16
- * @param $posts
17
- *
18
- * @return string
19
- */
20
- private function create_post_list( $posts, $display_excerpt, $display_image ) {
21
-
22
- $content = "<div class='rp4wp-related-posts'>\n";
23
-
24
- // Output the relation title
25
- $content .= "<h3>" . __( 'Related Posts', 'related-posts-for-wp' ) . "</h3> \n";
26
-
27
- // Open the list
28
- $content .= "<ul>\n";
29
-
30
- foreach ( $posts as $pc_post ) {
31
-
32
- // Setup the postdata
33
- setup_postdata( $pc_post );
34
-
35
- // Output the linked post
36
- $content .= "<li>";
37
-
38
- if ( '1' == $display_image ) {
39
- if ( has_post_thumbnail( $pc_post->ID ) ) {
40
-
41
- /**
42
- * Filter: 'pc_apdc_thumbnail_size' - Allows changing the thumbnail size of the thumbnail in de APDC section
43
- *
44
- * @api String $thumbnail_size The current/default thumbnail size.
45
- */
46
- $thumb_size = apply_filters( 'rp4wp_thumbnail_size', 'post-thumbnail' );
47
-
48
- $content .= "<div class='rp4wp-related-post-image'>" . PHP_EOL;
49
- $content .= "<a href='" . get_permalink( $pc_post->ID ) . "'>";
50
- $content .= get_the_post_thumbnail( $pc_post->ID, $thumb_size );
51
- $content .= "</a>";
52
- $content .= "</div>" . PHP_EOL;
53
- }
54
- }
55
-
56
- $content .= "<div class='rp4wp-related-post-content'>" . PHP_EOL;
57
- $content .= "<a href='" . get_permalink( $pc_post->ID ) . "'>" . $pc_post->post_title . "</a>";
58
-
59
- if ( '1' == $display_excerpt ) {
60
- $content .= "<p>" . get_the_excerpt() . "</p>";
61
- }
62
-
63
- $content .= "</div>" . PHP_EOL;
64
-
65
- $content .= "</li>\n";
66
-
67
- // Reset the postdata
68
- wp_reset_postdata();
69
- }
70
-
71
- // Close the wrapper div
72
- $content .= "</ul>\n";
73
- $content .= "</div>\n";
74
-
75
- return $content;
76
-
77
- }
78
-
79
  /**
80
  * the_content filter that will add linked posts to the bottom of the main post content
81
  *
@@ -104,8 +36,73 @@ class RP4WP_Filter_After_Post extends RP4WP_Filter {
104
 
105
  // Count
106
  if ( count( $related_posts ) > 0 ) {
107
- // Create Post List
108
- $content .= $this->create_post_list( $related_posts, true, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
110
 
111
  return $content;
8
  protected $tag = 'the_content';
9
  protected $priority = 99;
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  /**
12
  * the_content filter that will add linked posts to the bottom of the main post content
13
  *
36
 
37
  // Count
38
  if ( count( $related_posts ) > 0 ) {
39
+
40
+ // The rp4wp block
41
+ $content .= "<div class='rp4wp-related-posts'>\n";
42
+
43
+ // Get the heading text
44
+ $heading_text = RP4WP::get()->settings->get_option( 'heading_text' );
45
+
46
+ // Check if there is a heading text
47
+ if ( '' != $heading_text ) {
48
+
49
+ // Add heading text plus heading elements
50
+ $heading_text = '<h3>' . $heading_text . '</h3>' . PHP_EOL;
51
+ }
52
+
53
+ // Filter complete heading
54
+ $content .= apply_filters( 'rp4wp_heading', $heading_text );
55
+
56
+ // Open the list
57
+ $content .= "<ul>\n";
58
+
59
+ foreach ( $related_posts as $rp4wp_post ) {
60
+
61
+ // Setup the postdata
62
+ setup_postdata( $rp4wp_post );
63
+
64
+ // Output the linked post
65
+ $content .= "<li>";
66
+
67
+ if ( 1 == RP4WP::get()->settings->get_option( 'display_image' ) ) {
68
+ if ( has_post_thumbnail( $rp4wp_post->ID ) ) {
69
+
70
+ /**
71
+ * Filter: 'rp4wp_apdc_thumbnail_size' - Allows changing the thumbnail size of the thumbnail in de APDC section
72
+ *
73
+ * @api String $thumbnail_size The current/default thumbnail size.
74
+ */
75
+ $thumb_size = apply_filters( 'rp4wp_thumbnail_size', 'post-thumbnail' );
76
+
77
+ $content .= "<div class='rp4wp-related-post-image'>" . PHP_EOL;
78
+ $content .= "<a href='" . get_permalink( $rp4wp_post->ID ) . "'>";
79
+ $content .= get_the_post_thumbnail( $rp4wp_post->ID, $thumb_size );
80
+ $content .= "</a>";
81
+ $content .= "</div>" . PHP_EOL;
82
+ }
83
+ }
84
+
85
+ $content .= "<div class='rp4wp-related-post-content'>" . PHP_EOL;
86
+ $content .= "<a href='" . get_permalink( $rp4wp_post->ID ) . "'>" . $rp4wp_post->post_title . "</a>";
87
+
88
+ $excerpt_length = RP4WP::get()->settings->get_option( 'excerpt_length' );
89
+ if ( $excerpt_length > 0 ) {
90
+ $excerpt = substr( get_the_excerpt(), 0, $excerpt_length );
91
+ $content .= "<p>" . $excerpt . "</p>";
92
+ }
93
+
94
+ $content .= "</div>" . PHP_EOL;
95
+
96
+ $content .= "</li>\n";
97
+
98
+ // Reset the postdata
99
+ wp_reset_postdata();
100
+ }
101
+
102
+ // Close the wrapper div
103
+ $content .= "</ul>\n";
104
+ $content .= "</div>\n";
105
+
106
  }
107
 
108
  return $content;
classes/hooks/class-hook-admin-scripts.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  } // Exit if accessed directly
6
 
@@ -16,7 +16,7 @@ class RP4WP_Hook_Admin_Scripts extends RP4WP_Hook {
16
  // Load PL JS
17
  wp_enqueue_script(
18
  'rp4wp_edit_post_js',
19
- plugins_url( '/assets/js/edit-post.js', RP4WP::get_plugin_file() ),
20
  array( 'jquery', 'jquery-ui-sortable' )
21
  );
22
 
1
  <?php
2
 
3
+ if ( !defined( 'ABSPATH' ) ) {
4
  exit;
5
  } // Exit if accessed directly
6
 
16
  // Load PL JS
17
  wp_enqueue_script(
18
  'rp4wp_edit_post_js',
19
+ plugins_url( '/assets/js/edit-post' . ( ( !SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', RP4WP::get_plugin_file() ),
20
  array( 'jquery', 'jquery-ui-sortable' )
21
  );
22
 
classes/hooks/class-hook-frontend-css.php CHANGED
@@ -8,7 +8,11 @@ class RP4WP_Hook_Frontend_Css extends RP4WP_Hook {
8
  protected $tag = 'wp_head';
9
 
10
  public function run() {
11
- echo "<style type='text/css'>.rp4wp-related-posts ul {padding:0;margin:0;float:left;}.rp4wp-related-posts li{list-style:none;}.rp4wp-related-post-image{width:35%;padding-right:25px;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;float:left;}.rp4wp-related-post-content{width: 65%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;float:left;}</style>" . PHP_EOL;
 
 
 
 
12
 
13
  }
14
  }
8
  protected $tag = 'wp_head';
9
 
10
  public function run() {
11
+ $css = trim( RP4WP::get()->settings->get_option( 'css' ) );
12
+ if ( '' != $css ) {
13
+ echo "<style type='text/css'>" . $css . "</style>" . PHP_EOL;
14
+ }
15
+
16
 
17
  }
18
  }
classes/hooks/class-hook-page-install.php CHANGED
@@ -23,7 +23,7 @@ class RP4WP_Hook_Page_Install extends RP4WP_Hook {
23
  public function enqueue_install_assets() {
24
  global $wp_scripts;
25
  wp_enqueue_style( 'rp4wp-install-css', plugins_url( '/assets/css/install.css', RP4WP::get_plugin_file() ) );
26
- wp_enqueue_script( 'rp4wp-install-js', plugins_url( '/assets/js/install.js', RP4WP::get_plugin_file() ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-progressbar' ) );
27
  wp_enqueue_style( 'jquery-ui-smoothness', "http://ajax.googleapis.com/ajax/libs/jqueryui/" . $wp_scripts->query( 'jquery-ui-core' )->ver . "/themes/smoothness/jquery-ui.css", false, null );
28
  }
29
 
23
  public function enqueue_install_assets() {
24
  global $wp_scripts;
25
  wp_enqueue_style( 'rp4wp-install-css', plugins_url( '/assets/css/install.css', RP4WP::get_plugin_file() ) );
26
+ wp_enqueue_script( 'rp4wp-install-js', plugins_url( '/assets/js/install' . ( ( !SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', RP4WP::get_plugin_file() ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-progressbar' ) );
27
  wp_enqueue_style( 'jquery-ui-smoothness', "http://ajax.googleapis.com/ajax/libs/jqueryui/" . $wp_scripts->query( 'jquery-ui-core' )->ver . "/themes/smoothness/jquery-ui.css", false, null );
28
  }
29
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.barrykooij.com/
4
  Tags: related posts for wordpress, related posts for wp, simple related posts, easy related posts, related posts, related, relations, internal links, seo
5
  Requires at least: 3.6
6
  Tested up to: 3.9.2
7
- Stable tag: 1.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -28,8 +28,7 @@ After installing the plugin you will be taking to a wizard that will analyze you
28
  Everyone makes mistakes, so do we. That's why you can easily modify all automatically created related posts. Simply navigate to the post that has incorrect related posts attached to it, edit it and your done.
29
 
30
  = WPML compatible =
31
- We love love WPML, that's why we made Related Posts for WordPress fully compatible with WMPL. You can automatically and manually link related posts in their own language.
32
-
33
 
34
  **More information**
35
 
@@ -48,10 +47,16 @@ We love love WPML, that's why we made Related Posts for WordPress fully compatib
48
  == Frequently Asked Questions ==
49
 
50
  = Where's the settings screen? =
51
- Nowhere, there's no settings screen.
 
 
 
52
 
53
  = Is there any way to custom CSS ? =
54
- Not yet via the plugin, this will be added in future versions. Elements do have classes so you can style them in your own/theme CSS.
 
 
 
55
 
56
  = Is there a theme function so I can output this list anywhere in my theme I want? =
57
  Not yet, we're working on this and this will be added soon!
@@ -68,12 +73,22 @@ There is one custom table created for the post cache, this table will however no
68
 
69
  == Changelog ==
70
 
71
- = 1.1.0 - August 11, 2014 =
72
- * Added option screen.
 
 
 
 
 
 
 
73
  * Added to option to automatically link related posts on new posts, enabled by default.
74
  * Added 'rp4wp_ignored_words' filter.
75
  * Added 'rp4wp_thumbnail_size' filter.
76
  * Added missing ABSPATH checks.
77
 
78
- = 1.0.0 - August 7, 2014 =
79
- * Initial version
 
 
 
4
  Tags: related posts for wordpress, related posts for wp, simple related posts, easy related posts, related posts, related, relations, internal links, seo
5
  Requires at least: 3.6
6
  Tested up to: 3.9.2
7
+ Stable tag: 1.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
28
  Everyone makes mistakes, so do we. That's why you can easily modify all automatically created related posts. Simply navigate to the post that has incorrect related posts attached to it, edit it and your done.
29
 
30
  = WPML compatible =
31
+ Related Posts for WordPress is fully compatible with WPML. You can automatically and manually link related posts in their own language.
 
32
 
33
  **More information**
34
 
47
  == Frequently Asked Questions ==
48
 
49
  = Where's the settings screen? =
50
+ Settings > Related Posts.
51
+
52
+ = Can the displaying of excerpt be disabled? =
53
+ Yes, set the excerpt length to 0 in the Related Posts for WordPress settings screen.
54
 
55
  = Is there any way to custom CSS ? =
56
+ Yes, it's in the Related Posts for WordPress settings screen.
57
+
58
+ = Can the automatically outputted CSS be disabled? =
59
+ Yes, clear the CSS field in the Related Posts for WordPress settings screen.
60
 
61
  = Is there a theme function so I can output this list anywhere in my theme I want? =
62
  Not yet, we're working on this and this will be added soon!
73
 
74
  == Changelog ==
75
 
76
+ = 1.2.0 : August 14, 2014 =
77
+ * Related Posts heading text is now a setting.
78
+ * Amount of words in excerpt is now a setting.
79
+ * Displaying images of related posts is now a setting.
80
+ * Frontend CSS is now editable via settings.
81
+ * Added 'rp4wp_heading' filter, allows filtering of complete related posts block heading.
82
+
83
+ = 1.1.0 : August 11, 2014 =
84
+ * Added settings screen.
85
  * Added to option to automatically link related posts on new posts, enabled by default.
86
  * Added 'rp4wp_ignored_words' filter.
87
  * Added 'rp4wp_thumbnail_size' filter.
88
  * Added missing ABSPATH checks.
89
 
90
+ = 1.0.0 : August 7, 2014 =
91
+ * Initial version
92
+
93
+ == Upgrade Notice ==
94
+ This version is safe to upgrade.
related-posts-for-wp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Related Posts for WordPress
4
  Plugin URI: http://www.barrykooij.com/
5
  Description: Related Posts for WordPress, related posts that perform!
6
- Version: 1.1.0
7
  Author: Barry Kooij
8
  Author URI: http://www.barrykooij.com/
9
  License: GPL v3
@@ -26,7 +26,7 @@ class RP4WP {
26
 
27
  private static $instance = null;
28
 
29
- const VERSION = '1.1.0';
30
 
31
  /**
32
  * @var RP4WP_Settings
@@ -111,9 +111,7 @@ class RP4WP {
111
  }
112
 
113
  // Setup settings
114
- if ( is_admin() ) {
115
- $this->settings = new RP4WP_Settings();
116
- }
117
 
118
  // Filters
119
  $manager_filter = new RP4WP_Manager_Filter( plugin_dir_path( __FILE__ ) . 'classes/filters/' );
3
  Plugin Name: Related Posts for WordPress
4
  Plugin URI: http://www.barrykooij.com/
5
  Description: Related Posts for WordPress, related posts that perform!
6
+ Version: 1.2.0
7
  Author: Barry Kooij
8
  Author URI: http://www.barrykooij.com/
9
  License: GPL v3
26
 
27
  private static $instance = null;
28
 
29
+ const VERSION = '1.2.0';
30
 
31
  /**
32
  * @var RP4WP_Settings
111
  }
112
 
113
  // Setup settings
114
+ $this->settings = new RP4WP_Settings();
 
 
115
 
116
  // Filters
117
  $manager_filter = new RP4WP_Manager_Filter( plugin_dir_path( __FILE__ ) . 'classes/filters/' );