Version Description
- August 11, 2014 =
- Added option screen.
- Added to option to automatically link related posts on new posts, enabled by default.
- Added 'rp4wp_ignored_words' filter.
- Added 'rp4wp_thumbnail_size' filter.
- Added missing ABSPATH checks.
Download this release
Release Info
| Developer | barrykooij |
| Plugin | |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.1.0
- assets/css/install.css +0 -4
- assets/css/settings.css +31 -0
- classes/class-cap-manager.php +5 -2
- classes/class-class-manager.php +3 -1
- classes/class-constants.php +6 -4
- classes/class-installer.php +4 -0
- classes/class-manager-hook.php +6 -3
- classes/class-post-link-manager.php +0 -57
- classes/class-related-post-manager.php +6 -2
- classes/class-related-word-manager.php +1 -1
- classes/class-settings.php +197 -0
- classes/filters/class-filter-after-post.php +1 -1
- classes/filters/class-filter.php +1 -1
- classes/hooks/class-hook-ajax-install-link-posts.php +1 -1
- classes/hooks/class-hook-page-install.php +7 -1
- classes/hooks/class-hook-post-type.php +4 -0
- classes/hooks/class-hook-related-auto-link.php +56 -0
- classes/hooks/class-hook-related-save-words.php +5 -0
- classes/hooks/class-hook-settings-page.php +103 -0
- classes/hooks/class-hook.php +3 -1
- readme.txt +8 -1
- related-posts-for-wp.php +36 -4
assets/css/install.css
CHANGED
|
@@ -1,7 +1,3 @@
|
|
| 1 |
-
.install-steps {
|
| 2 |
-
|
| 3 |
-
}
|
| 4 |
-
|
| 5 |
.install-steps li {
|
| 6 |
width: 33%;
|
| 7 |
padding: 10px 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
.install-steps li {
|
| 2 |
width: 33%;
|
| 3 |
padding: 10px 15px;
|
assets/css/settings.css
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
classes/class-cap-manager.php
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
if ( !
|
|
|
|
|
|
|
| 4 |
|
| 5 |
class RP4WP_Cap_Manager {
|
| 6 |
|
|
@@ -14,7 +16,8 @@ class RP4WP_Cap_Manager {
|
|
| 14 |
public static function get_capability( $post_id ) {
|
| 15 |
$post_type = ( isset( $post_id ) ) ? get_post_type( $post_id ) : 'post';
|
| 16 |
$post_type_obj = get_post_type_object( $post_type );
|
| 17 |
-
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
|
| 7 |
class RP4WP_Cap_Manager {
|
| 8 |
|
| 16 |
public static function get_capability( $post_id ) {
|
| 17 |
$post_type = ( isset( $post_id ) ) ? get_post_type( $post_id ) : 'post';
|
| 18 |
$post_type_obj = get_post_type_object( $post_type );
|
| 19 |
+
|
| 20 |
+
return ( ( null != $post_type_obj ) ? $post_type_obj->cap->edit_posts : 'edit_posts' );
|
| 21 |
}
|
| 22 |
|
| 23 |
}
|
classes/class-class-manager.php
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
if ( !
|
|
|
|
|
|
|
| 4 |
|
| 5 |
class RP4WP_Class_Manager {
|
| 6 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
|
| 7 |
class RP4WP_Class_Manager {
|
| 8 |
|
classes/class-constants.php
CHANGED
|
@@ -6,14 +6,16 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
| 6 |
|
| 7 |
abstract class RP4WP_Constants {
|
| 8 |
|
| 9 |
-
//
|
| 10 |
const LINK_PT = 'rp4wp_link';
|
| 11 |
|
| 12 |
-
//
|
| 13 |
const PM_PARENT = 'rp4wp_parent';
|
| 14 |
const PM_CHILD = 'rp4wp_child';
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
// Options
|
| 19 |
const OPTION_DO_INSTALL = 'rp4wp_do_install';
|
| 6 |
|
| 7 |
abstract class RP4WP_Constants {
|
| 8 |
|
| 9 |
+
// Link title
|
| 10 |
const LINK_PT = 'rp4wp_link';
|
| 11 |
|
| 12 |
+
// Linked meta
|
| 13 |
const PM_PARENT = 'rp4wp_parent';
|
| 14 |
const PM_CHILD = 'rp4wp_child';
|
| 15 |
+
|
| 16 |
+
// Post meta
|
| 17 |
+
const PM_CACHED = 'rp4wp_cached'; // Posts that words are saved of
|
| 18 |
+
const PM_POST_AUTO_LINKED = 'rp4wp_auto_linked'; // Posts that have automatically linked posts
|
| 19 |
|
| 20 |
// Options
|
| 21 |
const OPTION_DO_INSTALL = 'rp4wp_do_install';
|
classes/class-installer.php
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class RP4WP_Installer {
|
| 4 |
|
| 5 |
/**
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
+
|
| 7 |
class RP4WP_Installer {
|
| 8 |
|
| 9 |
/**
|
classes/class-manager-hook.php
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
if ( !
|
|
|
|
|
|
|
| 4 |
|
| 5 |
class RP4WP_Manager_Hook {
|
| 6 |
|
| 7 |
private $hook_dir;
|
| 8 |
private static $hooks;
|
| 9 |
|
| 10 |
-
public function __construct( $hook_dir
|
| 11 |
$this->hook_dir = $hook_dir;
|
| 12 |
}
|
| 13 |
|
|
@@ -23,7 +25,7 @@ class RP4WP_Manager_Hook {
|
|
| 23 |
foreach ( new DirectoryIterator( $this->hook_dir ) as $file ) {
|
| 24 |
$file_name = $file->getFileName();
|
| 25 |
|
| 26 |
-
if (
|
| 27 |
|
| 28 |
$class = RP4WP_Class_Manager::format_class_name( $file->getFileName() );
|
| 29 |
if ( 'RP4WP_Hook' != $class ) {
|
|
@@ -47,6 +49,7 @@ class RP4WP_Manager_Hook {
|
|
| 47 |
if ( isset( self::$hooks[$class_name] ) ) {
|
| 48 |
return self::$hooks[$class_name];
|
| 49 |
}
|
|
|
|
| 50 |
return null;
|
| 51 |
}
|
| 52 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
|
| 7 |
class RP4WP_Manager_Hook {
|
| 8 |
|
| 9 |
private $hook_dir;
|
| 10 |
private static $hooks;
|
| 11 |
|
| 12 |
+
public function __construct( $hook_dir ) {
|
| 13 |
$this->hook_dir = $hook_dir;
|
| 14 |
}
|
| 15 |
|
| 25 |
foreach ( new DirectoryIterator( $this->hook_dir ) as $file ) {
|
| 26 |
$file_name = $file->getFileName();
|
| 27 |
|
| 28 |
+
if ( !$file->isDir() && ( strpos( $file->getFileName(), '.' ) !== 0 ) ) {
|
| 29 |
|
| 30 |
$class = RP4WP_Class_Manager::format_class_name( $file->getFileName() );
|
| 31 |
if ( 'RP4WP_Hook' != $class ) {
|
| 49 |
if ( isset( self::$hooks[$class_name] ) ) {
|
| 50 |
return self::$hooks[$class_name];
|
| 51 |
}
|
| 52 |
+
|
| 53 |
return null;
|
| 54 |
}
|
| 55 |
|
classes/class-post-link-manager.php
CHANGED
|
@@ -273,61 +273,4 @@ class RP4WP_Post_Link_Manager {
|
|
| 273 |
endwhile;
|
| 274 |
}
|
| 275 |
|
| 276 |
-
/**
|
| 277 |
-
* Generate the children list
|
| 278 |
-
*
|
| 279 |
-
* @param $parent
|
| 280 |
-
* @param $link
|
| 281 |
-
* @param $excerpt
|
| 282 |
-
* @param string $header_tag
|
| 283 |
-
*
|
| 284 |
-
* @return string
|
| 285 |
-
*/
|
| 286 |
-
public function generate_children_list( $parent, $link, $excerpt, $header_tag = 'b' ) {
|
| 287 |
-
|
| 288 |
-
// Make the header tag filterable
|
| 289 |
-
$header_tag = apply_filters( 'pc_children_list_header_tag', $header_tag );
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
// Get the children
|
| 293 |
-
$children = $this->get_children( $parent );
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
$return = "";
|
| 297 |
-
|
| 298 |
-
if ( count( $children ) > 0 ) {
|
| 299 |
-
$return .= "<div class='rp4wp-related-posts'>\n";
|
| 300 |
-
|
| 301 |
-
$return .= "<ul>\n";
|
| 302 |
-
foreach ( $children as $child ) {
|
| 303 |
-
|
| 304 |
-
$return .= "<li class='rp4wp-post-{$child->ID}'>";
|
| 305 |
-
$return .= "<{$header_tag}>";
|
| 306 |
-
if ( $link == 'true' ) {
|
| 307 |
-
$return .= "<a href='" . get_permalink( $child->ID ) . "'>";
|
| 308 |
-
}
|
| 309 |
-
$return .= $child->post_title;
|
| 310 |
-
if ( $link == 'true' ) {
|
| 311 |
-
$return .= "</a>";
|
| 312 |
-
}
|
| 313 |
-
$return .= "</{$header_tag}>";
|
| 314 |
-
|
| 315 |
-
// Excerpt
|
| 316 |
-
if ( $excerpt == 'true' ) {
|
| 317 |
-
$the_excerpt = !empty( $child->post_excerpt ) ? $child->post_excerpt : $child->post_content;
|
| 318 |
-
if ( $the_excerpt != '' ) {
|
| 319 |
-
$return .= "<p>{$the_excerpt}</p>";
|
| 320 |
-
}
|
| 321 |
-
}
|
| 322 |
-
|
| 323 |
-
$return .= "</li>\n";
|
| 324 |
-
}
|
| 325 |
-
$return .= "</ul>\n";
|
| 326 |
-
|
| 327 |
-
$return .= "</div>\n";
|
| 328 |
-
}
|
| 329 |
-
|
| 330 |
-
return $return;
|
| 331 |
-
}
|
| 332 |
-
|
| 333 |
}
|
| 273 |
endwhile;
|
| 274 |
}
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
}
|
classes/class-related-post-manager.php
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class RP4WP_Related_Post_Manager {
|
| 4 |
|
| 5 |
/**
|
|
@@ -67,7 +71,7 @@ class RP4WP_Related_Post_Manager {
|
|
| 67 |
'post_status' => 'publish',
|
| 68 |
'meta_query' => array(
|
| 69 |
array(
|
| 70 |
-
'key' => RP4WP_Constants::
|
| 71 |
'compare' => 'NOT EXISTS',
|
| 72 |
'value' => ''
|
| 73 |
),
|
|
@@ -95,7 +99,7 @@ class RP4WP_Related_Post_Manager {
|
|
| 95 |
}
|
| 96 |
}
|
| 97 |
|
| 98 |
-
update_post_meta( $post_id, RP4WP_Constants::
|
| 99 |
|
| 100 |
return true;
|
| 101 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
+
|
| 7 |
class RP4WP_Related_Post_Manager {
|
| 8 |
|
| 9 |
/**
|
| 71 |
'post_status' => 'publish',
|
| 72 |
'meta_query' => array(
|
| 73 |
array(
|
| 74 |
+
'key' => RP4WP_Constants::PM_POST_AUTO_LINKED,
|
| 75 |
'compare' => 'NOT EXISTS',
|
| 76 |
'value' => ''
|
| 77 |
),
|
| 99 |
}
|
| 100 |
}
|
| 101 |
|
| 102 |
+
update_post_meta( $post_id, RP4WP_Constants::PM_POST_AUTO_LINKED, 1 );
|
| 103 |
|
| 104 |
return true;
|
| 105 |
}
|
classes/class-related-word-manager.php
CHANGED
|
@@ -92,7 +92,7 @@ class RP4WP_Related_Word_Manager {
|
|
| 92 |
}
|
| 93 |
|
| 94 |
// Words to ignore
|
| 95 |
-
return apply_filters( '
|
| 96 |
}
|
| 97 |
|
| 98 |
/**
|
| 92 |
}
|
| 93 |
|
| 94 |
// Words to ignore
|
| 95 |
+
return apply_filters( 'rp4wp_ignored_words', $ignored_words );
|
| 96 |
}
|
| 97 |
|
| 98 |
/**
|
classes/class-settings.php
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
+
|
| 7 |
+
class RP4WP_Settings {
|
| 8 |
+
|
| 9 |
+
const PREFIX = 'rp4wp_';
|
| 10 |
+
|
| 11 |
+
const PAGE = 'rp4wp';
|
| 12 |
+
|
| 13 |
+
private $sections;
|
| 14 |
+
private $defaults;
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Constructor
|
| 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',
|
| 30 |
+
'label' => __( 'Enable', 'related-posts-for-wp' ),
|
| 31 |
+
'description' => __( 'Checking this will enable automatically linking posts to new posts', 'related-posts-for-wp' ),
|
| 32 |
+
'type' => 'checkbox',
|
| 33 |
+
'default' => 1,
|
| 34 |
+
),
|
| 35 |
+
array(
|
| 36 |
+
'id' => 'automatic_linking_post_amount',
|
| 37 |
+
'label' => __( 'Amount of Posts', 'related-posts-for-wp' ),
|
| 38 |
+
'description' => __( 'The amount of automatically linked post', 'related-posts-for-wp' ),
|
| 39 |
+
'type' => 'text',
|
| 40 |
+
'default' => '3',
|
| 41 |
+
)
|
| 42 |
+
) )
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
// Set defaults
|
| 46 |
+
foreach ( $this->sections as $section ) {
|
| 47 |
+
foreach ( $section['fields'] as $field ) {
|
| 48 |
+
$this->defaults[$field['id']] = $field['default'];
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
// Setup settings
|
| 53 |
+
add_action( 'admin_init', array( $this, 'setup' ) );
|
| 54 |
+
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Setup the settings
|
| 59 |
+
*
|
| 60 |
+
* @since 1.1.0
|
| 61 |
+
* @access public
|
| 62 |
+
*/
|
| 63 |
+
public function setup() {
|
| 64 |
+
if ( count( $this->sections ) > 0 ) {
|
| 65 |
+
foreach ( $this->sections as $section ) {
|
| 66 |
+
|
| 67 |
+
// Add the section
|
| 68 |
+
add_settings_section(
|
| 69 |
+
self::PREFIX . $section['id'],
|
| 70 |
+
$section['label'],
|
| 71 |
+
array( $this, 'section_intro' ),
|
| 72 |
+
self::PAGE
|
| 73 |
+
);
|
| 74 |
+
|
| 75 |
+
// Check & Loop
|
| 76 |
+
if ( count( $section['fields'] ) > 0 ) {
|
| 77 |
+
foreach ( $section['fields'] as $field ) {
|
| 78 |
+
|
| 79 |
+
// Add section
|
| 80 |
+
add_settings_field(
|
| 81 |
+
self::PREFIX . $field['id'],
|
| 82 |
+
$field['label'],
|
| 83 |
+
array( $this, 'do_field' ),
|
| 84 |
+
self::PAGE,
|
| 85 |
+
self::PREFIX . $section['id'],
|
| 86 |
+
$field
|
| 87 |
+
);
|
| 88 |
+
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
// Register section setting
|
| 96 |
+
register_setting( self::PAGE, self::PAGE, array( $this, 'sanitize_option' ) );
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Method that is called when adding a section
|
| 102 |
+
*
|
| 103 |
+
* @param $section
|
| 104 |
+
*
|
| 105 |
+
* @since 1.1.0
|
| 106 |
+
* @access public
|
| 107 |
+
*/
|
| 108 |
+
public function section_intro( $section ) {
|
| 109 |
+
echo '<p>' . $this->sections[$section['id']]['description'] . '</p>' . PHP_EOL;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* Method that outputs the correct field
|
| 114 |
+
*
|
| 115 |
+
* @param $field
|
| 116 |
+
*
|
| 117 |
+
* @since 1.1.0
|
| 118 |
+
* @access public
|
| 119 |
+
*/
|
| 120 |
+
public function do_field( $field ) {
|
| 121 |
+
|
| 122 |
+
// For now we just do a simple switch here, make this more OOP in future version
|
| 123 |
+
switch ( $field['type'] ) {
|
| 124 |
+
case 'checkbox':
|
| 125 |
+
echo '<input type="checkbox" name="' . self::PAGE . '[' . $field['id'] . ']' . '" id="' . $field['id'] . '" value="1" ' . checked( 1, $this->get_option( $field['id'] ), false ) . ' />';
|
| 126 |
+
break;
|
| 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
|
| 133 |
+
if ( isset( $field['description'] ) && '' != $field['description'] ) {
|
| 134 |
+
echo '<label class="rp4wp-description" for="' . $field['id'] . '">' . $field['description'] . '</label>';
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
// End of line
|
| 138 |
+
echo PHP_EOL;
|
| 139 |
+
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Sanitize the option value
|
| 144 |
+
*
|
| 145 |
+
* @param array $post_data
|
| 146 |
+
*
|
| 147 |
+
* @since 1.1.0
|
| 148 |
+
* @access public
|
| 149 |
+
*
|
| 150 |
+
* @return array
|
| 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 |
+
}
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Get the plugin options
|
| 171 |
+
*
|
| 172 |
+
* @since 1.1.0
|
| 173 |
+
* @access public
|
| 174 |
+
*
|
| 175 |
+
* @return mixed|void
|
| 176 |
+
*/
|
| 177 |
+
public function get_options() {
|
| 178 |
+
return apply_filters( 'rp4wp_options', wp_parse_args( get_option( self::PAGE, array() ), $this->defaults ) );
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Return a single option
|
| 183 |
+
*
|
| 184 |
+
* @param $option
|
| 185 |
+
*
|
| 186 |
+
* @since 1.0.0
|
| 187 |
+
* @access public
|
| 188 |
+
*
|
| 189 |
+
* @return mixed|bool
|
| 190 |
+
*/
|
| 191 |
+
public function get_option( $option ) {
|
| 192 |
+
$options = $this->get_options();
|
| 193 |
+
|
| 194 |
+
return isset( $options[$option] ) ? $options[$option] : false;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
}
|
classes/filters/class-filter-after-post.php
CHANGED
|
@@ -43,7 +43,7 @@ class RP4WP_Filter_After_Post extends RP4WP_Filter {
|
|
| 43 |
*
|
| 44 |
* @api String $thumbnail_size The current/default thumbnail size.
|
| 45 |
*/
|
| 46 |
-
$thumb_size = apply_filters( '
|
| 47 |
|
| 48 |
$content .= "<div class='rp4wp-related-post-image'>" . PHP_EOL;
|
| 49 |
$content .= "<a href='" . get_permalink( $pc_post->ID ) . "'>";
|
| 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 ) . "'>";
|
classes/filters/class-filter.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
if ( !
|
| 4 |
exit;
|
| 5 |
} // Exit if accessed directly
|
| 6 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
exit;
|
| 5 |
} // Exit if accessed directly
|
| 6 |
|
classes/hooks/class-hook-ajax-install-link-posts.php
CHANGED
|
@@ -15,7 +15,7 @@ class RP4WP_Hook_Ajax_Install_Link_Posts extends RP4WP_Hook {
|
|
| 15 |
// Related Post Manager object
|
| 16 |
$related_post_manager = new RP4WP_Related_Post_Manager();
|
| 17 |
|
| 18 |
-
// Link
|
| 19 |
if ( true === $related_post_manager->link_related_posts( $rel_amount, 5 ) ) {
|
| 20 |
|
| 21 |
// Check if we're done
|
| 15 |
// Related Post Manager object
|
| 16 |
$related_post_manager = new RP4WP_Related_Post_Manager();
|
| 17 |
|
| 18 |
+
// Link 5 posts
|
| 19 |
if ( true === $related_post_manager->link_related_posts( $rel_amount, 5 ) ) {
|
| 20 |
|
| 21 |
// Check if we're done
|
classes/hooks/class-hook-page-install.php
CHANGED
|
@@ -14,6 +14,12 @@ class RP4WP_Hook_Page_Install extends RP4WP_Hook {
|
|
| 14 |
add_action( 'load-' . $menu_hook, array( $this, 'enqueue_install_assets' ) );
|
| 15 |
}
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
public function enqueue_install_assets() {
|
| 18 |
global $wp_scripts;
|
| 19 |
wp_enqueue_style( 'rp4wp-install-css', plugins_url( '/assets/css/install.css', RP4WP::get_plugin_file() ) );
|
|
@@ -74,7 +80,7 @@ class RP4WP_Hook_Page_Install extends RP4WP_Hook {
|
|
| 74 |
<p style="font-weight: bold;">Do NOT close this window if you click the "Link now" button, wait for this process to finish and this wizard to take you to the next step.</p>
|
| 75 |
<br class="clear" />
|
| 76 |
<p class="rp4wp-install-link-box">
|
| 77 |
-
<label for="rp4wp_related_posts_amount">Amount of related posts per post:</label><input class="form-input-tip" type="text" id="rp4wp_related_posts_amount" value="
|
| 78 |
<a href="javascript:;" class="button button-primary button-large rp4wp-link-now-btn" id="rp4wp-link-now">Link now</a>
|
| 79 |
<a href="<?php echo admin_url(); ?>?page=rp4wp_install&step=3" class="button">Skip linking</a>
|
| 80 |
</p>
|
| 14 |
add_action( 'load-' . $menu_hook, array( $this, 'enqueue_install_assets' ) );
|
| 15 |
}
|
| 16 |
|
| 17 |
+
/**
|
| 18 |
+
* Enqueue install assets
|
| 19 |
+
*
|
| 20 |
+
* @since 1.0.0
|
| 21 |
+
* @access public
|
| 22 |
+
*/
|
| 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() ) );
|
| 80 |
<p style="font-weight: bold;">Do NOT close this window if you click the "Link now" button, wait for this process to finish and this wizard to take you to the next step.</p>
|
| 81 |
<br class="clear" />
|
| 82 |
<p class="rp4wp-install-link-box">
|
| 83 |
+
<label for="rp4wp_related_posts_amount">Amount of related posts per post:</label><input class="form-input-tip" type="text" id="rp4wp_related_posts_amount" value="3" />
|
| 84 |
<a href="javascript:;" class="button button-primary button-large rp4wp-link-now-btn" id="rp4wp-link-now">Link now</a>
|
| 85 |
<a href="<?php echo admin_url(); ?>?page=rp4wp_install&step=3" class="button">Skip linking</a>
|
| 86 |
</p>
|
classes/hooks/class-hook-post-type.php
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class RP4WP_Hook_Post_Type extends RP4WP_Hook {
|
| 4 |
protected $tag = 'init';
|
| 5 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
+
|
| 7 |
class RP4WP_Hook_Post_Type extends RP4WP_Hook {
|
| 8 |
protected $tag = 'init';
|
| 9 |
|
classes/hooks/class-hook-related-auto-link.php
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
+
|
| 7 |
+
class RP4WP_Hook_Related_Auto_Link extends RP4WP_Hook {
|
| 8 |
+
protected $tag = 'save_post';
|
| 9 |
+
protected $args = 2;
|
| 10 |
+
protected $priority = 11;
|
| 11 |
+
|
| 12 |
+
public function run( $post_id, $post ) {
|
| 13 |
+
|
| 14 |
+
// verify this is not an auto save routine.
|
| 15 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
| 16 |
+
return;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// Only count on post type 'post'
|
| 20 |
+
if ( 'post' != $post->post_type ) {
|
| 21 |
+
return;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
// Check permission
|
| 25 |
+
if ( !current_user_can( 'edit_post', $post_id ) ) {
|
| 26 |
+
return;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
// Post status must be publish
|
| 30 |
+
if ( 'publish' != $post->post_status ) {
|
| 31 |
+
return;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
// Is automatic linking enabled?
|
| 35 |
+
if( 1 != RP4WP::get()->settings->get_option( 'automatic_linking' ) ) {
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// Check if the current post is already auto linked
|
| 40 |
+
if ( 1 != get_post_meta( $post_id, RP4WP_Constants::PM_POST_AUTO_LINKED, true ) ) {
|
| 41 |
+
|
| 42 |
+
// Get automatic linking post amount
|
| 43 |
+
$automatic_linking_post_amount = RP4WP::get()->settings->get_option( 'automatic_linking_post_amount' );
|
| 44 |
+
|
| 45 |
+
// Related Posts Manager
|
| 46 |
+
$related_post_manager = new RP4WP_Related_Post_Manager();
|
| 47 |
+
|
| 48 |
+
// Link related posts
|
| 49 |
+
$related_post_manager->link_related_post( $post_id, $automatic_linking_post_amount );
|
| 50 |
+
|
| 51 |
+
// Set the auto linked meta
|
| 52 |
+
update_post_meta( $post_id, RP4WP_Constants::PM_POST_AUTO_LINKED, 1 );
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
}
|
| 56 |
+
}
|
classes/hooks/class-hook-related-save-words.php
CHANGED
|
@@ -25,6 +25,11 @@ class RP4WP_Hook_Related_Save_Words extends RP4WP_Hook {
|
|
| 25 |
return;
|
| 26 |
}
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
// Save Words
|
| 29 |
$related_word_manager = new RP4WP_Related_Word_Manager();
|
| 30 |
$related_word_manager->save_words_of_post( $post_id );
|
| 25 |
return;
|
| 26 |
}
|
| 27 |
|
| 28 |
+
// Post status must be publish
|
| 29 |
+
if ( 'publish' != $post->post_status ) {
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
// Save Words
|
| 34 |
$related_word_manager = new RP4WP_Related_Word_Manager();
|
| 35 |
$related_word_manager->save_words_of_post( $post_id );
|
classes/hooks/class-hook-settings-page.php
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
+
|
| 7 |
+
class RP4WP_Hook_Settings_Page extends RP4WP_Hook {
|
| 8 |
+
protected $tag = 'admin_menu';
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Hook callback, add the sub menu page
|
| 12 |
+
*
|
| 13 |
+
* @since 1.1.0
|
| 14 |
+
* @access public
|
| 15 |
+
*/
|
| 16 |
+
public function run() {
|
| 17 |
+
$menu_hook = add_submenu_page( 'options-general.php', __( 'Related Posts', 'related-posts-for-wp' ), __( 'Related Posts', 'related-posts-for-wp' ), 'manage_options', 'rp4wp', array(
|
| 18 |
+
$this,
|
| 19 |
+
'screen'
|
| 20 |
+
) );
|
| 21 |
+
|
| 22 |
+
add_action( 'load-' . $menu_hook, array( $this, 'enqueue_assets' ) );
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Enqueue settings page assets
|
| 27 |
+
*
|
| 28 |
+
* @since 1.0.0
|
| 29 |
+
* @access public
|
| 30 |
+
*/
|
| 31 |
+
public function enqueue_assets() {
|
| 32 |
+
wp_enqueue_style( 'rp4wp-settings-css', plugins_url( '/assets/css/settings.css', RP4WP::get_plugin_file() ) );
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* The sidebar
|
| 37 |
+
*
|
| 38 |
+
* @since 1.0.0
|
| 39 |
+
* @access private
|
| 40 |
+
*/
|
| 41 |
+
private function sidebar() {
|
| 42 |
+
?>
|
| 43 |
+
<div class="rp4wp-sidebar">
|
| 44 |
+
|
| 45 |
+
<div class="rp4wp-box">
|
| 46 |
+
<div class="rp4wp-sidebar-header">
|
| 47 |
+
<h3>Related Posts for WordPress</h3>
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
+
<p><?php _e( 'Plugin version', 'related-posts-for-wp' ); ?>: <?php echo RP4WP::VERSION; ?></p>
|
| 51 |
+
</div>
|
| 52 |
+
|
| 53 |
+
<div class="rp4wp-box">
|
| 54 |
+
<h3 class="rp4wp-title"><?php _e( 'More information', 'related-posts-for-wp' ); ?></h3>
|
| 55 |
+
|
| 56 |
+
<p><?php printf( __( "<a href='%s'>FAQ</a>", 'related-posts-for-wp' ), 'http://wordpress.org/plugins/related-posts-for-wp/faq/' ); ?></p>
|
| 57 |
+
|
| 58 |
+
<p><?php printf( __( "<a href='%s'>Change log</a>", 'related-posts-for-wp' ), 'http://wordpress.org/support/plugin/related-posts-for-wp' ); ?></p>
|
| 59 |
+
|
| 60 |
+
<p><?php printf( __( "<a href='%s'>Give us a review</a>", 'related-posts-for-wp' ), 'http://wordpress.org/support/view/plugin-reviews/related-posts-for-wp' ); ?></p>
|
| 61 |
+
|
| 62 |
+
<p><?php printf( __( "<a href='%s'>Release blog post</a>", 'related-posts-for-wp' ), 'http://www.barrykooij.com/related-posts-wordpress/?utm_source=plugin&utm_medium=link&utm_campaign=sidebar' ); ?></p>
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
<div class="rp4wp-box">
|
| 66 |
+
<h3 class="rp4wp-title"><?php _e( 'About the developer', 'related-posts-for-wp' ); ?></h3>
|
| 67 |
+
|
| 68 |
+
<p><?php _e( "Barry is a WordPress developer that works on WooCommerce by WooThemes and is the author of various WordPress plugins that include Post Connector, Related Posts for WordPress and What The File.", 'related-posts-for-wp' ); ?></p>
|
| 69 |
+
|
| 70 |
+
<p><?php _e( "Barry likes contributing to opensource projects and visiting WordCamps and WordPress meetups. He’s the organizer of the WordPress meetup in Tilburg.", 'related-posts-for-wp' ); ?></p>
|
| 71 |
+
|
| 72 |
+
<p><?php printf( __( "You can follow Barry on Twitter <a href='%s'>here</a>.", 'related-posts-for-wp' ), 'https://twitter.com/cageNL' ); ?></p>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
</div>
|
| 76 |
+
<?php
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Settings screen output
|
| 81 |
+
*
|
| 82 |
+
* @since 1.1.0
|
| 83 |
+
* @access public
|
| 84 |
+
*/
|
| 85 |
+
public function screen() {
|
| 86 |
+
?>
|
| 87 |
+
<div class="wrap">
|
| 88 |
+
<h2>Related Posts for WordPress</h2>
|
| 89 |
+
|
| 90 |
+
<div class="rp4wp-content">
|
| 91 |
+
<form method="post" action="options.php">
|
| 92 |
+
<?php settings_fields( 'rp4wp' ); //pass slug name of page, also referred
|
| 93 |
+
//to in Settings API as option group name
|
| 94 |
+
do_settings_sections( 'rp4wp' ); //pass slug name of page
|
| 95 |
+
submit_button();
|
| 96 |
+
?>
|
| 97 |
+
</form>
|
| 98 |
+
</div>
|
| 99 |
+
<?php $this->sidebar(); ?>
|
| 100 |
+
</div>
|
| 101 |
+
<?php
|
| 102 |
+
}
|
| 103 |
+
}
|
classes/hooks/class-hook.php
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
if ( !
|
|
|
|
|
|
|
| 4 |
|
| 5 |
abstract class RP4WP_Hook {
|
| 6 |
protected $tag = null;
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
| 4 |
+
exit;
|
| 5 |
+
} // Exit if accessed directly
|
| 6 |
|
| 7 |
abstract class RP4WP_Hook {
|
| 8 |
protected $tag = null;
|
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.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -68,5 +68,12 @@ There is one custom table created for the post cache, this table will however no
|
|
| 68 |
|
| 69 |
== Changelog ==
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
= 1.0.0 - August 7, 2014 =
|
| 72 |
* 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.1.0
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 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
|
related-posts-for-wp.php
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
/*
|
| 4 |
Plugin Name: Related Posts for WordPress
|
| 5 |
Plugin URI: http://www.barrykooij.com/
|
| 6 |
Description: Related Posts for WordPress, related posts that perform!
|
| 7 |
-
Version: 1.
|
| 8 |
Author: Barry Kooij
|
| 9 |
Author URI: http://www.barrykooij.com/
|
| 10 |
License: GPL v3
|
|
@@ -25,6 +24,30 @@
|
|
| 25 |
|
| 26 |
class RP4WP {
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
/**
|
| 29 |
* Get the plugin file
|
| 30 |
*
|
|
@@ -64,7 +87,7 @@ class RP4WP {
|
|
| 64 |
/**
|
| 65 |
* The constructor
|
| 66 |
*/
|
| 67 |
-
|
| 68 |
$this->init();
|
| 69 |
}
|
| 70 |
|
|
@@ -87,6 +110,11 @@ class RP4WP {
|
|
| 87 |
exit;
|
| 88 |
}
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
// Filters
|
| 91 |
$manager_filter = new RP4WP_Manager_Filter( plugin_dir_path( __FILE__ ) . 'classes/filters/' );
|
| 92 |
$manager_filter->load_filters();
|
|
@@ -98,8 +126,12 @@ class RP4WP {
|
|
| 98 |
|
| 99 |
}
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
function __rp4wp_main() {
|
| 102 |
-
|
| 103 |
}
|
| 104 |
|
| 105 |
// Create object - Plugin init
|
| 1 |
<?php
|
|
|
|
| 2 |
/*
|
| 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
|
| 24 |
|
| 25 |
class RP4WP {
|
| 26 |
|
| 27 |
+
private static $instance = null;
|
| 28 |
+
|
| 29 |
+
const VERSION = '1.1.0';
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @var RP4WP_Settings
|
| 33 |
+
*/
|
| 34 |
+
public $settings = null;
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Singleton get method
|
| 38 |
+
*
|
| 39 |
+
* @since 1.0.0
|
| 40 |
+
* @access public
|
| 41 |
+
*
|
| 42 |
+
* @return RP4WP
|
| 43 |
+
*/
|
| 44 |
+
public static function get() {
|
| 45 |
+
if(null == self::$instance) {
|
| 46 |
+
self::$instance = new self();
|
| 47 |
+
}
|
| 48 |
+
return self::$instance;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
/**
|
| 52 |
* Get the plugin file
|
| 53 |
*
|
| 87 |
/**
|
| 88 |
* The constructor
|
| 89 |
*/
|
| 90 |
+
private function __construct() {
|
| 91 |
$this->init();
|
| 92 |
}
|
| 93 |
|
| 110 |
exit;
|
| 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/' );
|
| 120 |
$manager_filter->load_filters();
|
| 126 |
|
| 127 |
}
|
| 128 |
|
| 129 |
+
function RP4WP() {
|
| 130 |
+
return RP4WP::get();
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
function __rp4wp_main() {
|
| 134 |
+
RP4WP();
|
| 135 |
}
|
| 136 |
|
| 137 |
// Create object - Plugin init
|
