Version Description
- Fix SQL injection bug opened up by SQL search functionality.
Download this release
Release Info
| Developer | tlovett1 |
| Plugin | |
| Version | 1.9.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.9 to 1.9.1
- inc/classes/class-srm-post-type.php +127 -139
- inc/classes/class-srm-redirect.php +6 -1
- inc/classes/class-srm-wp-cli.php +15 -4
- inc/functions.php +32 -14
- lang/safe-redirect-manager.pot +56 -52
- readme.txt +3 -0
- safe-redirect-manager.php +8 -6
inc/classes/class-srm-post-type.php
CHANGED
|
@@ -1,13 +1,28 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Setup SRM post type
|
|
|
|
|
|
|
| 4 |
*/
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
class SRM_Post_Type {
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
public $status_code_labels = array(); // Defined later to allow i18n
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Sets up redirect manager
|
|
@@ -25,6 +40,7 @@ class SRM_Post_Type {
|
|
| 25 |
);
|
| 26 |
|
| 27 |
add_action( 'init', array( $this, 'action_register_post_types' ) );
|
|
|
|
| 28 |
add_action( 'save_post', array( $this, 'action_save_post' ) );
|
| 29 |
add_filter( 'manage_redirect_rule_posts_columns', array( $this, 'filter_redirect_columns' ) );
|
| 30 |
add_filter( 'manage_edit-redirect_rule_sortable_columns', array( $this, 'filter_redirect_sortable_columns' ) );
|
|
@@ -39,23 +55,36 @@ class SRM_Post_Type {
|
|
| 39 |
add_action( 'admin_print_styles-post-new.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
| 40 |
add_filter( 'post_type_link', array( $this, 'filter_post_type_link' ), 10, 2 );
|
| 41 |
add_filter( 'default_hidden_columns', array( $this, 'filter_hidden_columns' ), 10, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
// Search filters
|
| 44 |
-
add_filter( 'posts_join', array( $this, 'filter_search_join' ) );
|
| 45 |
-
add_filter( 'posts_where', array( $this, 'filter_search_where' ) );
|
| 46 |
-
add_filter( 'posts_distinct', array( $this, 'filter_search_distinct' ) );
|
| 47 |
add_filter( 'post_row_actions', array( $this, 'filter_disable_quick_edit' ), 10, 2 );
|
| 48 |
}
|
| 49 |
|
| 50 |
/**
|
| 51 |
* Hide order column by default
|
| 52 |
*
|
| 53 |
-
* @param array $hidden
|
| 54 |
* @since 1.9
|
| 55 |
* @return array
|
| 56 |
*/
|
| 57 |
public function filter_hidden_columns( $hidden ) {
|
| 58 |
-
|
| 59 |
if ( empty( $_GET['post_type'] ) || 'redirect_rule' !== $_GET['post_type'] ) {
|
| 60 |
return $hidden;
|
| 61 |
}
|
|
@@ -68,8 +97,8 @@ class SRM_Post_Type {
|
|
| 68 |
/**
|
| 69 |
* Remove quick edit
|
| 70 |
*
|
| 71 |
-
* @param array $actions
|
| 72 |
-
* @param WP_Post $post
|
| 73 |
* @since 1.8
|
| 74 |
* @return array
|
| 75 |
*/
|
|
@@ -83,110 +112,59 @@ class SRM_Post_Type {
|
|
| 83 |
}
|
| 84 |
|
| 85 |
/**
|
| 86 |
-
*
|
| 87 |
*
|
| 88 |
-
* @
|
| 89 |
-
* @param string $join
|
| 90 |
-
* @uses get_query_var
|
| 91 |
-
* @return string
|
| 92 |
*/
|
| 93 |
-
public function
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
| 98 |
}
|
| 99 |
-
|
| 100 |
-
global $wpdb;
|
| 101 |
-
|
| 102 |
-
$s = get_query_var( 's' );
|
| 103 |
-
if ( ! empty( $s ) ) {
|
| 104 |
-
$join .= " LEFT JOIN $wpdb->postmeta AS m ON ($wpdb->posts.ID = m.post_id) ";
|
| 105 |
-
}
|
| 106 |
-
return $join;
|
| 107 |
}
|
| 108 |
|
| 109 |
/**
|
| 110 |
-
*
|
| 111 |
*
|
| 112 |
-
* @
|
| 113 |
-
* @param
|
| 114 |
-
* @uses get_query_var
|
| 115 |
-
* @return string
|
| 116 |
-
*/
|
| 117 |
-
public function filter_search_distinct( $distinct ) {
|
| 118 |
-
global $wp_query;
|
| 119 |
-
|
| 120 |
-
if ( empty( $wp_query ) || 'redirect_rule' !== get_query_var( 'post_type' ) ) {
|
| 121 |
-
return $distinct;
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
return 'DISTINCT';
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
/**
|
| 128 |
-
* Join posts table with postmeta table on search
|
| 129 |
-
*
|
| 130 |
-
* @since 1.2
|
| 131 |
-
* @param string $where
|
| 132 |
-
* @uses is_search, get_query_var
|
| 133 |
-
* @return string
|
| 134 |
-
*/
|
| 135 |
-
public function filter_search_where( $where ) {
|
| 136 |
-
global $wp_query;
|
| 137 |
-
|
| 138 |
-
if ( empty( $wp_query ) || 'redirect_rule' !== get_query_var( 'post_type' ) || ! is_search() || empty( $where ) ) {
|
| 139 |
-
return $where;
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
-
$terms = $this->get_search_terms();
|
| 143 |
-
|
| 144 |
-
if ( empty( $terms ) ) {
|
| 145 |
-
return $where;
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
$exact = get_query_var( 'exact' );
|
| 149 |
-
$n = ( ! empty( $exact ) ) ? '' : '%';
|
| 150 |
-
|
| 151 |
-
$search = '';
|
| 152 |
-
$seperator = '';
|
| 153 |
-
$search .= '(';
|
| 154 |
-
|
| 155 |
-
// we check the meta values against each term in the search
|
| 156 |
-
foreach ( $terms as $term ) {
|
| 157 |
-
$search .= $seperator;
|
| 158 |
-
// Used esc_sql instead of wpdb->prepare since wpdb->prepare wraps things in quotes
|
| 159 |
-
$search .= sprintf( "( ( m.meta_value LIKE '%s%s%s' AND m.meta_key = '%s') OR ( m.meta_value LIKE '%s%s%s' AND m.meta_key = '%s') )", $n, esc_sql( $term ), $n, esc_sql( '_redirect_rule_from' ), $n, esc_sql( $term ), $n, esc_sql( '_redirect_rule_to' ) );
|
| 160 |
-
|
| 161 |
-
$seperator = ' OR ';
|
| 162 |
-
}
|
| 163 |
-
|
| 164 |
-
$search .= ')';
|
| 165 |
-
|
| 166 |
-
$where = preg_replace( '/\(\(\(.*?\)\)\)/is', '((' . $search . '))', $where );
|
| 167 |
-
|
| 168 |
-
return $where;
|
| 169 |
-
}
|
| 170 |
-
|
| 171 |
-
/**
|
| 172 |
-
* Get an array of search terms
|
| 173 |
-
*
|
| 174 |
-
* @since 1.2
|
| 175 |
-
* @uses get_query_var
|
| 176 |
* @return array
|
| 177 |
*/
|
| 178 |
-
|
| 179 |
-
$
|
| 180 |
|
| 181 |
-
if (
|
| 182 |
-
|
| 183 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
}
|
| 185 |
-
return $search_terms;
|
| 186 |
-
}
|
| 187 |
|
| 188 |
-
|
| 189 |
-
return trim( $a, "\\\"'\\n\\r " );
|
| 190 |
}
|
| 191 |
|
| 192 |
/**
|
|
@@ -207,13 +185,14 @@ class SRM_Post_Type {
|
|
| 207 |
width: 60%;
|
| 208 |
}
|
| 209 |
</style>
|
| 210 |
-
|
| 211 |
}
|
| 212 |
}
|
| 213 |
|
| 214 |
/**
|
| 215 |
* Limit the bulk actions available in the Manage Redirects view
|
| 216 |
*
|
|
|
|
| 217 |
* @since 1.0
|
| 218 |
* @return array
|
| 219 |
*/
|
|
@@ -257,7 +236,7 @@ class SRM_Post_Type {
|
|
| 257 |
<div class="updated">
|
| 258 |
<p><?php esc_html_e( 'Safe Redirect Manager Warning: Possible redirect loops and/or chains have been created.', 'safe-redirect-manager' ); ?></p>
|
| 259 |
</div>
|
| 260 |
-
|
| 261 |
}
|
| 262 |
}
|
| 263 |
if ( srm_max_redirects_reached() ) {
|
|
@@ -271,7 +250,7 @@ class SRM_Post_Type {
|
|
| 271 |
<div class="error">
|
| 272 |
<p><?php esc_html_e( 'Safe Redirect Manager Error: You have reached the maximum allowable number of redirects', 'safe-redirect-manager' ); ?></p>
|
| 273 |
</div>
|
| 274 |
-
|
| 275 |
}
|
| 276 |
}
|
| 277 |
}
|
|
@@ -280,8 +259,8 @@ class SRM_Post_Type {
|
|
| 280 |
* Filters title out for redirect from in post manager
|
| 281 |
*
|
| 282 |
* @since 1.0
|
| 283 |
-
* @param string $title
|
| 284 |
-
* @param int $post_id
|
| 285 |
* @uses is_admin, get_post_meta
|
| 286 |
* @return string
|
| 287 |
*/
|
|
@@ -295,7 +274,7 @@ class SRM_Post_Type {
|
|
| 295 |
return $title;
|
| 296 |
}
|
| 297 |
|
| 298 |
-
if ( $redirect->post_type
|
| 299 |
return $title;
|
| 300 |
}
|
| 301 |
|
|
@@ -311,7 +290,7 @@ class SRM_Post_Type {
|
|
| 311 |
* Customizes updated messages for redirects
|
| 312 |
*
|
| 313 |
* @since 1.0
|
| 314 |
-
* @param array $messages
|
| 315 |
* @uses esc_url, get_permalink, add_query_var, wp_post_revision_title
|
| 316 |
* @return array
|
| 317 |
*/
|
|
@@ -332,7 +311,8 @@ class SRM_Post_Type {
|
|
| 332 |
9 => sprintf(
|
| 333 |
esc_html__( 'Redirect rule scheduled for: %1$s.', 'safe-redirect-manager' ),
|
| 334 |
// translators: Publish box date format, see http://php.net/date
|
| 335 |
-
date_i18n( esc_html__( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ),
|
|
|
|
| 336 |
),
|
| 337 |
10 => sprintf( esc_html__( 'Redirect rule draft updated.', 'safe-redirect-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
|
| 338 |
);
|
|
@@ -344,9 +324,9 @@ class SRM_Post_Type {
|
|
| 344 |
* Clear redirect cache if appropriate post type is transitioned
|
| 345 |
*
|
| 346 |
* @since 1.0
|
| 347 |
-
* @param string
|
| 348 |
-
* @param string
|
| 349 |
-
* @param
|
| 350 |
* @return void
|
| 351 |
*/
|
| 352 |
public function action_transition_post_status( $new_status, $old_status, $post ) {
|
|
@@ -364,8 +344,8 @@ class SRM_Post_Type {
|
|
| 364 |
* Displays custom columns on redirect manager screen
|
| 365 |
*
|
| 366 |
* @since 1.0
|
| 367 |
-
* @param string $column
|
| 368 |
-
* @param int $post_id
|
| 369 |
* @uses get_post_meta, esc_html, admin_url
|
| 370 |
* @return void
|
| 371 |
*/
|
|
@@ -374,9 +354,9 @@ class SRM_Post_Type {
|
|
| 374 |
echo esc_html( get_post_meta( $post_id, '_redirect_rule_to', true ) );
|
| 375 |
} elseif ( 'srm_redirect_rule_status_code' === $column ) {
|
| 376 |
echo absint( get_post_meta( $post_id, '_redirect_rule_status_code', true ) );
|
| 377 |
-
} elseif ( 'menu_order'
|
| 378 |
global $post;
|
| 379 |
-
echo $post->menu_order;
|
| 380 |
}
|
| 381 |
}
|
| 382 |
|
|
@@ -384,7 +364,7 @@ class SRM_Post_Type {
|
|
| 384 |
* Add new columns to manage redirect screen
|
| 385 |
*
|
| 386 |
* @since 1.0
|
| 387 |
-
* @param array $columns
|
| 388 |
* @return array
|
| 389 |
*/
|
| 390 |
public function filter_redirect_columns( $columns ) {
|
|
@@ -405,9 +385,9 @@ class SRM_Post_Type {
|
|
| 405 |
/**
|
| 406 |
* Allow menu_order column to be sortable.
|
| 407 |
*
|
| 408 |
-
* @param $columns
|
| 409 |
-
* @since
|
| 410 |
-
* @return
|
| 411 |
*/
|
| 412 |
public function filter_redirect_sortable_columns( $columns ) {
|
| 413 |
$columns['menu_order'] = 'menu_order';
|
|
@@ -418,7 +398,7 @@ class SRM_Post_Type {
|
|
| 418 |
* Saves meta info for redirect rules
|
| 419 |
*
|
| 420 |
* @since 1.0
|
| 421 |
-
* @param int $post_id
|
| 422 |
* @uses current_user_can, get_post_type, wp_verify_nonce, update_post_meta, delete_post_meta
|
| 423 |
* @return void
|
| 424 |
*/
|
|
@@ -471,6 +451,29 @@ class SRM_Post_Type {
|
|
| 471 |
}
|
| 472 |
}
|
| 473 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 474 |
/**
|
| 475 |
* Registers post types for plugin
|
| 476 |
*
|
|
@@ -495,21 +498,7 @@ class SRM_Post_Type {
|
|
| 495 |
'menu_name' => esc_html__( 'Safe Redirect Manager', 'safe-redirect-manager' ),
|
| 496 |
);
|
| 497 |
|
| 498 |
-
$redirect_capability =
|
| 499 |
-
|
| 500 |
-
$roles = array( 'administrator' );
|
| 501 |
-
|
| 502 |
-
foreach ( $roles as $role ) {
|
| 503 |
-
$role = get_role( $role );
|
| 504 |
-
|
| 505 |
-
if ( empty( $role ) || $role->has_cap( $redirect_capability ) ) {
|
| 506 |
-
continue;
|
| 507 |
-
}
|
| 508 |
-
|
| 509 |
-
$role->add_cap( $redirect_capability );
|
| 510 |
-
}
|
| 511 |
-
|
| 512 |
-
$redirect_capability = apply_filters( 'srm_restrict_to_capability', $redirect_capability );
|
| 513 |
|
| 514 |
$capabilities = array(
|
| 515 |
'edit_post' => $redirect_capability,
|
|
@@ -556,7 +545,7 @@ class SRM_Post_Type {
|
|
| 556 |
* Echoes HTML for redirect rule meta box
|
| 557 |
*
|
| 558 |
* @since 1.0
|
| 559 |
-
* @param
|
| 560 |
* @uses wp_nonce_field, get_post_meta, esc_attr, selected
|
| 561 |
* @return void
|
| 562 |
*/
|
|
@@ -602,7 +591,7 @@ class SRM_Post_Type {
|
|
| 602 |
<textarea name="srm_redirect_rule_notes" id="srm_redirect_rule_notes" class="widefat"><?php echo esc_attr( $redirect_notes ); ?></textarea>
|
| 603 |
<em><?php esc_html_e( 'Optionally leave notes on this redirect e.g. why was it created.', 'safe-redirect-manager' ); ?></em>
|
| 604 |
</p>
|
| 605 |
-
|
| 606 |
}
|
| 607 |
|
| 608 |
/**
|
|
@@ -657,4 +646,3 @@ class SRM_Post_Type {
|
|
| 657 |
return $instance;
|
| 658 |
}
|
| 659 |
}
|
| 660 |
-
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Setup SRM post type
|
| 4 |
+
*
|
| 5 |
+
* @package safe-redirect-manager
|
| 6 |
*/
|
| 7 |
|
| 8 |
+
/**
|
| 9 |
+
* Post type class
|
| 10 |
+
*/
|
| 11 |
class SRM_Post_Type {
|
| 12 |
|
| 13 |
+
/**
|
| 14 |
+
* Status code lables for reuse
|
| 15 |
+
*
|
| 16 |
+
* @var array
|
| 17 |
+
*/
|
| 18 |
public $status_code_labels = array(); // Defined later to allow i18n
|
| 19 |
|
| 20 |
+
/**
|
| 21 |
+
* We have to store the redirect search so we can grab it later
|
| 22 |
+
*
|
| 23 |
+
* @var string
|
| 24 |
+
*/
|
| 25 |
+
private $redirect_search_term;
|
| 26 |
|
| 27 |
/**
|
| 28 |
* Sets up redirect manager
|
| 40 |
);
|
| 41 |
|
| 42 |
add_action( 'init', array( $this, 'action_register_post_types' ) );
|
| 43 |
+
add_action( 'admin_init', array( $this, 'init_search_filters' ) );
|
| 44 |
add_action( 'save_post', array( $this, 'action_save_post' ) );
|
| 45 |
add_filter( 'manage_redirect_rule_posts_columns', array( $this, 'filter_redirect_columns' ) );
|
| 46 |
add_filter( 'manage_edit-redirect_rule_sortable_columns', array( $this, 'filter_redirect_sortable_columns' ) );
|
| 55 |
add_action( 'admin_print_styles-post-new.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
| 56 |
add_filter( 'post_type_link', array( $this, 'filter_post_type_link' ), 10, 2 );
|
| 57 |
add_filter( 'default_hidden_columns', array( $this, 'filter_hidden_columns' ), 10, 1 );
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Setup search filters
|
| 62 |
+
*/
|
| 63 |
+
public function init_search_filters() {
|
| 64 |
+
$redirect_capability = $this->get_redirect_capability();
|
| 65 |
+
|
| 66 |
+
if ( ! is_admin() ) {
|
| 67 |
+
return;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
if ( ! current_user_can( $redirect_capability ) ) {
|
| 71 |
+
return;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
add_action( 'pre_get_posts', array( $this, 'disable_core_search' ) );
|
| 75 |
+
add_filter( 'posts_clauses', array( $this, 'filter_search_clauses' ), 10, 2 );
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
add_filter( 'post_row_actions', array( $this, 'filter_disable_quick_edit' ), 10, 2 );
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 81 |
* Hide order column by default
|
| 82 |
*
|
| 83 |
+
* @param array $hidden Array of hidden post types
|
| 84 |
* @since 1.9
|
| 85 |
* @return array
|
| 86 |
*/
|
| 87 |
public function filter_hidden_columns( $hidden ) {
|
|
|
|
| 88 |
if ( empty( $_GET['post_type'] ) || 'redirect_rule' !== $_GET['post_type'] ) {
|
| 89 |
return $hidden;
|
| 90 |
}
|
| 97 |
/**
|
| 98 |
* Remove quick edit
|
| 99 |
*
|
| 100 |
+
* @param array $actions Array of actions
|
| 101 |
+
* @param WP_Post $post Post object
|
| 102 |
* @since 1.8
|
| 103 |
* @return array
|
| 104 |
*/
|
| 112 |
}
|
| 113 |
|
| 114 |
/**
|
| 115 |
+
* We don't need core's fancy search functionality since we provide our own.
|
| 116 |
*
|
| 117 |
+
* @param \WP_Query $query WP Query object
|
|
|
|
|
|
|
|
|
|
| 118 |
*/
|
| 119 |
+
public function disable_core_search( $query ) {
|
| 120 |
+
if ( $query->is_search() && 'redirect_rule' === $query->get( 'post_type' ) ) {
|
| 121 |
+
// Store a reference to the search term for later use.
|
| 122 |
+
$this->redirect_search_term = $query->get( 's' );
|
| 123 |
+
// Don't let core build it's search clauses since we override them.
|
| 124 |
+
$query->set( 's', '' );
|
| 125 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 127 |
|
| 128 |
/**
|
| 129 |
+
* Build custom JOIN + WHERE clauses to do a more direct search through meta.
|
| 130 |
*
|
| 131 |
+
* @param array $clauses Array of SQL clauses
|
| 132 |
+
* @param WP_Query $query WP_Query object
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
* @return array
|
| 134 |
*/
|
| 135 |
+
public function filter_search_clauses( $clauses, $query ) {
|
| 136 |
+
global $wpdb;
|
| 137 |
|
| 138 |
+
if ( $this->redirect_search_term ) {
|
| 139 |
+
$search_term = $this->redirect_search_term;
|
| 140 |
+
$search_term_like = '%' . $wpdb->esc_like( $search_term ) . '%';
|
| 141 |
+
|
| 142 |
+
$query->set( 's', $this->redirect_search_term );
|
| 143 |
+
unset( $this->redirect_search_term );
|
| 144 |
+
|
| 145 |
+
$clauses['distinct'] = 'DISTINCT';
|
| 146 |
+
|
| 147 |
+
$clauses['join'] .= " LEFT JOIN $wpdb->postmeta AS pm ON ($wpdb->posts.ID = pm.post_id) ";
|
| 148 |
+
|
| 149 |
+
$clauses['where'] = $wpdb->prepare(
|
| 150 |
+
"AND (
|
| 151 |
+
(
|
| 152 |
+
pm.meta_value LIKE %s
|
| 153 |
+
AND pm.meta_key = '_redirect_rule_from'
|
| 154 |
+
) OR (
|
| 155 |
+
pm.meta_value LIKE %s
|
| 156 |
+
AND pm.meta_key = '_redirect_rule_to'
|
| 157 |
+
)
|
| 158 |
+
)
|
| 159 |
+
AND $wpdb->posts.post_type = 'redirect_rule'
|
| 160 |
+
AND $wpdb->posts.post_status IN ( 'publish', 'future', 'draft', 'pending' )
|
| 161 |
+
",
|
| 162 |
+
$search_term_like,
|
| 163 |
+
$search_term_like
|
| 164 |
+
);
|
| 165 |
}
|
|
|
|
|
|
|
| 166 |
|
| 167 |
+
return $clauses;
|
|
|
|
| 168 |
}
|
| 169 |
|
| 170 |
/**
|
| 185 |
width: 60%;
|
| 186 |
}
|
| 187 |
</style>
|
| 188 |
+
<?php
|
| 189 |
}
|
| 190 |
}
|
| 191 |
|
| 192 |
/**
|
| 193 |
* Limit the bulk actions available in the Manage Redirects view
|
| 194 |
*
|
| 195 |
+
* @param array $actions Array of actions
|
| 196 |
* @since 1.0
|
| 197 |
* @return array
|
| 198 |
*/
|
| 236 |
<div class="updated">
|
| 237 |
<p><?php esc_html_e( 'Safe Redirect Manager Warning: Possible redirect loops and/or chains have been created.', 'safe-redirect-manager' ); ?></p>
|
| 238 |
</div>
|
| 239 |
+
<?php
|
| 240 |
}
|
| 241 |
}
|
| 242 |
if ( srm_max_redirects_reached() ) {
|
| 250 |
<div class="error">
|
| 251 |
<p><?php esc_html_e( 'Safe Redirect Manager Error: You have reached the maximum allowable number of redirects', 'safe-redirect-manager' ); ?></p>
|
| 252 |
</div>
|
| 253 |
+
<?php
|
| 254 |
}
|
| 255 |
}
|
| 256 |
}
|
| 259 |
* Filters title out for redirect from in post manager
|
| 260 |
*
|
| 261 |
* @since 1.0
|
| 262 |
+
* @param string $title Admin title
|
| 263 |
+
* @param int $post_id Post ID
|
| 264 |
* @uses is_admin, get_post_meta
|
| 265 |
* @return string
|
| 266 |
*/
|
| 274 |
return $title;
|
| 275 |
}
|
| 276 |
|
| 277 |
+
if ( 'redirect_rule' !== $redirect->post_type ) {
|
| 278 |
return $title;
|
| 279 |
}
|
| 280 |
|
| 290 |
* Customizes updated messages for redirects
|
| 291 |
*
|
| 292 |
* @since 1.0
|
| 293 |
+
* @param array $messages Array of messages
|
| 294 |
* @uses esc_url, get_permalink, add_query_var, wp_post_revision_title
|
| 295 |
* @return array
|
| 296 |
*/
|
| 311 |
9 => sprintf(
|
| 312 |
esc_html__( 'Redirect rule scheduled for: %1$s.', 'safe-redirect-manager' ),
|
| 313 |
// translators: Publish box date format, see http://php.net/date
|
| 314 |
+
date_i18n( esc_html__( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ),
|
| 315 |
+
esc_url( get_permalink( $post_ID ) )
|
| 316 |
),
|
| 317 |
10 => sprintf( esc_html__( 'Redirect rule draft updated.', 'safe-redirect-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
|
| 318 |
);
|
| 324 |
* Clear redirect cache if appropriate post type is transitioned
|
| 325 |
*
|
| 326 |
* @since 1.0
|
| 327 |
+
* @param string $new_status New post status
|
| 328 |
+
* @param string $old_status Old post status
|
| 329 |
+
* @param WP_Post $post Post object
|
| 330 |
* @return void
|
| 331 |
*/
|
| 332 |
public function action_transition_post_status( $new_status, $old_status, $post ) {
|
| 344 |
* Displays custom columns on redirect manager screen
|
| 345 |
*
|
| 346 |
* @since 1.0
|
| 347 |
+
* @param string $column Column name
|
| 348 |
+
* @param int $post_id Post Id
|
| 349 |
* @uses get_post_meta, esc_html, admin_url
|
| 350 |
* @return void
|
| 351 |
*/
|
| 354 |
echo esc_html( get_post_meta( $post_id, '_redirect_rule_to', true ) );
|
| 355 |
} elseif ( 'srm_redirect_rule_status_code' === $column ) {
|
| 356 |
echo absint( get_post_meta( $post_id, '_redirect_rule_status_code', true ) );
|
| 357 |
+
} elseif ( 'menu_order' === $column ) {
|
| 358 |
global $post;
|
| 359 |
+
echo esc_html( $post->menu_order );
|
| 360 |
}
|
| 361 |
}
|
| 362 |
|
| 364 |
* Add new columns to manage redirect screen
|
| 365 |
*
|
| 366 |
* @since 1.0
|
| 367 |
+
* @param array $columns Array columns
|
| 368 |
* @return array
|
| 369 |
*/
|
| 370 |
public function filter_redirect_columns( $columns ) {
|
| 385 |
/**
|
| 386 |
* Allow menu_order column to be sortable.
|
| 387 |
*
|
| 388 |
+
* @param array $columns Array of columns
|
| 389 |
+
* @since 1.9
|
| 390 |
+
* @return array
|
| 391 |
*/
|
| 392 |
public function filter_redirect_sortable_columns( $columns ) {
|
| 393 |
$columns['menu_order'] = 'menu_order';
|
| 398 |
* Saves meta info for redirect rules
|
| 399 |
*
|
| 400 |
* @since 1.0
|
| 401 |
+
* @param int $post_id Post ID
|
| 402 |
* @uses current_user_can, get_post_type, wp_verify_nonce, update_post_meta, delete_post_meta
|
| 403 |
* @return void
|
| 404 |
*/
|
| 451 |
}
|
| 452 |
}
|
| 453 |
|
| 454 |
+
/**
|
| 455 |
+
* Get required capability for managing redirects
|
| 456 |
+
*
|
| 457 |
+
* @return string
|
| 458 |
+
*/
|
| 459 |
+
protected function get_redirect_capability() {
|
| 460 |
+
$redirect_capability = 'srm_manage_redirects';
|
| 461 |
+
|
| 462 |
+
$roles = array( 'administrator' );
|
| 463 |
+
|
| 464 |
+
foreach ( $roles as $role ) {
|
| 465 |
+
$role = get_role( $role );
|
| 466 |
+
|
| 467 |
+
if ( empty( $role ) || $role->has_cap( $redirect_capability ) ) {
|
| 468 |
+
continue;
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
$role->add_cap( $redirect_capability );
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
return apply_filters( 'srm_restrict_to_capability', $redirect_capability );
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
/**
|
| 478 |
* Registers post types for plugin
|
| 479 |
*
|
| 498 |
'menu_name' => esc_html__( 'Safe Redirect Manager', 'safe-redirect-manager' ),
|
| 499 |
);
|
| 500 |
|
| 501 |
+
$redirect_capability = $this->get_redirect_capability();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
|
| 503 |
$capabilities = array(
|
| 504 |
'edit_post' => $redirect_capability,
|
| 545 |
* Echoes HTML for redirect rule meta box
|
| 546 |
*
|
| 547 |
* @since 1.0
|
| 548 |
+
* @param WP_Post $post Post object
|
| 549 |
* @uses wp_nonce_field, get_post_meta, esc_attr, selected
|
| 550 |
* @return void
|
| 551 |
*/
|
| 591 |
<textarea name="srm_redirect_rule_notes" id="srm_redirect_rule_notes" class="widefat"><?php echo esc_attr( $redirect_notes ); ?></textarea>
|
| 592 |
<em><?php esc_html_e( 'Optionally leave notes on this redirect e.g. why was it created.', 'safe-redirect-manager' ); ?></em>
|
| 593 |
</p>
|
| 594 |
+
<?php
|
| 595 |
}
|
| 596 |
|
| 597 |
/**
|
| 646 |
return $instance;
|
| 647 |
}
|
| 648 |
}
|
|
|
inc/classes/class-srm-redirect.php
CHANGED
|
@@ -1,8 +1,13 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Handle redirection
|
|
|
|
|
|
|
| 4 |
*/
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
class SRM_Redirect {
|
| 7 |
/**
|
| 8 |
* Store whitelisted host
|
|
@@ -32,7 +37,7 @@ class SRM_Redirect {
|
|
| 32 |
* Apply whitelisted host to allowed_redirect_hosts filter
|
| 33 |
*
|
| 34 |
* @since 1.8
|
| 35 |
-
* @param array $hosts
|
| 36 |
* @return array
|
| 37 |
*/
|
| 38 |
public function filter_allowed_redirect_hosts( $hosts ) {
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Handle redirection
|
| 4 |
+
*
|
| 5 |
+
* @package safe-redirect-manager
|
| 6 |
*/
|
| 7 |
|
| 8 |
+
/**
|
| 9 |
+
* Redirect functionality class
|
| 10 |
+
*/
|
| 11 |
class SRM_Redirect {
|
| 12 |
/**
|
| 13 |
* Store whitelisted host
|
| 37 |
* Apply whitelisted host to allowed_redirect_hosts filter
|
| 38 |
*
|
| 39 |
* @since 1.8
|
| 40 |
+
* @param array $hosts Array of hosts
|
| 41 |
* @return array
|
| 42 |
*/
|
| 43 |
public function filter_allowed_redirect_hosts( $hosts ) {
|
inc/classes/class-srm-wp-cli.php
CHANGED
|
@@ -1,8 +1,13 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* Setup SRM WP CLI commands
|
|
|
|
|
|
|
| 4 |
*/
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
class SRM_WP_CLI extends WP_CLI_Command {
|
| 7 |
|
| 8 |
|
|
@@ -11,7 +16,7 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
| 11 |
*
|
| 12 |
* @subcommand list
|
| 13 |
*/
|
| 14 |
-
public function
|
| 15 |
$fields = array(
|
| 16 |
'ID',
|
| 17 |
'redirect_from',
|
|
@@ -47,6 +52,7 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
| 47 |
/**
|
| 48 |
* Create a redirect
|
| 49 |
*
|
|
|
|
| 50 |
* @subcommand create
|
| 51 |
* @synopsis <from> <to> [<status-code>] [<enable-regex>] [<post-status>]
|
| 52 |
*/
|
|
@@ -87,6 +93,7 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
| 87 |
/**
|
| 88 |
* Delete a redirect
|
| 89 |
*
|
|
|
|
| 90 |
* @subcommand delete
|
| 91 |
* @synopsis <id>
|
| 92 |
*/
|
|
@@ -119,6 +126,8 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
| 119 |
/**
|
| 120 |
* Import .htaccess file redirects
|
| 121 |
*
|
|
|
|
|
|
|
| 122 |
* @subcommand import-htaccess
|
| 123 |
* @synopsis <file>
|
| 124 |
*/
|
|
@@ -229,7 +238,8 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
| 229 |
*/
|
| 230 |
public function import( $args, $assoc_args ) {
|
| 231 |
$mapping = wp_parse_args(
|
| 232 |
-
$assoc_args,
|
|
|
|
| 233 |
'source' => 'source',
|
| 234 |
'target' => 'target',
|
| 235 |
'regex' => 'regex',
|
|
@@ -237,7 +247,8 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
| 237 |
)
|
| 238 |
);
|
| 239 |
|
| 240 |
-
$created =
|
|
|
|
| 241 |
|
| 242 |
foreach ( $args as $file ) {
|
| 243 |
$processed = srm_import_file( $file, $mapping );
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Setup SRM WP CLI commands.
|
| 4 |
+
*
|
| 5 |
+
* @package safe-redirect-manager
|
| 6 |
*/
|
| 7 |
|
| 8 |
+
/**
|
| 9 |
+
* WP CLI command class
|
| 10 |
+
*/
|
| 11 |
class SRM_WP_CLI extends WP_CLI_Command {
|
| 12 |
|
| 13 |
|
| 16 |
*
|
| 17 |
* @subcommand list
|
| 18 |
*/
|
| 19 |
+
public function list() {
|
| 20 |
$fields = array(
|
| 21 |
'ID',
|
| 22 |
'redirect_from',
|
| 52 |
/**
|
| 53 |
* Create a redirect
|
| 54 |
*
|
| 55 |
+
* @param array $args Array of arguments
|
| 56 |
* @subcommand create
|
| 57 |
* @synopsis <from> <to> [<status-code>] [<enable-regex>] [<post-status>]
|
| 58 |
*/
|
| 93 |
/**
|
| 94 |
* Delete a redirect
|
| 95 |
*
|
| 96 |
+
* @param array $args Array of arguments
|
| 97 |
* @subcommand delete
|
| 98 |
* @synopsis <id>
|
| 99 |
*/
|
| 126 |
/**
|
| 127 |
* Import .htaccess file redirects
|
| 128 |
*
|
| 129 |
+
* @param array $args Array of arguments
|
| 130 |
+
* @param array $assoc_args Array of associate arguments
|
| 131 |
* @subcommand import-htaccess
|
| 132 |
* @synopsis <file>
|
| 133 |
*/
|
| 238 |
*/
|
| 239 |
public function import( $args, $assoc_args ) {
|
| 240 |
$mapping = wp_parse_args(
|
| 241 |
+
$assoc_args,
|
| 242 |
+
array(
|
| 243 |
'source' => 'source',
|
| 244 |
'target' => 'target',
|
| 245 |
'regex' => 'regex',
|
| 247 |
)
|
| 248 |
);
|
| 249 |
|
| 250 |
+
$created = 0;
|
| 251 |
+
$skipped = 0;
|
| 252 |
|
| 253 |
foreach ( $args as $file ) {
|
| 254 |
$processed = srm_import_file( $file, $mapping );
|
inc/functions.php
CHANGED
|
@@ -1,4 +1,9 @@
|
|
| 1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Get redirects from the database
|
|
@@ -10,7 +15,9 @@
|
|
| 10 |
*/
|
| 11 |
function srm_get_redirects( $args = array(), $hard = false ) {
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
$redirects = array();
|
| 16 |
|
|
@@ -114,8 +121,13 @@ function srm_flush_cache() {
|
|
| 114 |
function srm_check_for_possible_redirect_loops() {
|
| 115 |
$redirects = srm_get_redirects();
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
foreach ( $redirects as $redirect ) {
|
| 121 |
$redirect_from = $redirect['redirect_from'];
|
|
@@ -124,7 +136,12 @@ function srm_check_for_possible_redirect_loops() {
|
|
| 124 |
foreach ( $redirects as $compare_redirect ) {
|
| 125 |
$redirect_to = $compare_redirect['redirect_to'];
|
| 126 |
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
$redirect_host = ( is_array( $redirect_url ) && ! empty( $redirect_url['host'] ) ) ? $redirect_url['host'] : '';
|
| 129 |
|
| 130 |
// check if we are redirecting locally
|
|
@@ -151,12 +168,12 @@ function srm_check_for_possible_redirect_loops() {
|
|
| 151 |
/**
|
| 152 |
* Creates a redirect post, this function will be useful for import/exports scripts
|
| 153 |
*
|
| 154 |
-
* @param string $redirect_from
|
| 155 |
-
* @param string $redirect_to
|
| 156 |
-
* @param int $status_code
|
| 157 |
-
* @param bool $enable_regex
|
| 158 |
-
* @param string $post_status
|
| 159 |
-
* @param int $menu_order
|
| 160 |
* @since 1.8
|
| 161 |
* @uses wp_insert_post, update_post_meta
|
| 162 |
* @return int|WP_Error
|
|
@@ -220,7 +237,7 @@ function srm_create_redirect( $redirect_from, $redirect_to, $status_code = 302,
|
|
| 220 |
* esc_url_raw( 'test' ) == 'http://test', whereas sanitize_redirect_path( 'test' ) == '/test'
|
| 221 |
*
|
| 222 |
* @since 1.8
|
| 223 |
-
* @param string $path
|
| 224 |
* @return string
|
| 225 |
*/
|
| 226 |
function srm_sanitize_redirect_to( $path ) {
|
|
@@ -243,8 +260,8 @@ function srm_sanitize_redirect_to( $path ) {
|
|
| 243 |
* Sanitize redirect from path
|
| 244 |
*
|
| 245 |
* @since 1.8
|
| 246 |
-
* @param string $path
|
| 247 |
-
* @param boolean $allow_regex
|
| 248 |
* @return string
|
| 249 |
*/
|
| 250 |
function srm_sanitize_redirect_from( $path, $allow_regex = false ) {
|
|
@@ -306,7 +323,8 @@ function srm_import_file( $file, $args ) {
|
|
| 306 |
}
|
| 307 |
|
| 308 |
// process all rows of the file
|
| 309 |
-
$created =
|
|
|
|
| 310 |
$headers = fgetcsv( $handle );
|
| 311 |
|
| 312 |
while ( ( $row = fgetcsv( $handle ) ) ) {
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* General plugin functions
|
| 4 |
+
*
|
| 5 |
+
* @package safe-redirect-manager
|
| 6 |
+
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Get redirects from the database
|
| 15 |
*/
|
| 16 |
function srm_get_redirects( $args = array(), $hard = false ) {
|
| 17 |
|
| 18 |
+
$redirects = get_transient( '_srm_redirects' );
|
| 19 |
+
|
| 20 |
+
if ( $hard || false === $redirects ) {
|
| 21 |
|
| 22 |
$redirects = array();
|
| 23 |
|
| 121 |
function srm_check_for_possible_redirect_loops() {
|
| 122 |
$redirects = srm_get_redirects();
|
| 123 |
|
| 124 |
+
if ( function_exists( 'wp_parse_url' ) ) {
|
| 125 |
+
$current_url = wp_parse_url( home_url() );
|
| 126 |
+
} else {
|
| 127 |
+
$current_url = parse_url( home_url() );
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
$this_host = ( is_array( $current_url ) && ! empty( $current_url['host'] ) ) ? $current_url['host'] : '';
|
| 131 |
|
| 132 |
foreach ( $redirects as $redirect ) {
|
| 133 |
$redirect_from = $redirect['redirect_from'];
|
| 136 |
foreach ( $redirects as $compare_redirect ) {
|
| 137 |
$redirect_to = $compare_redirect['redirect_to'];
|
| 138 |
|
| 139 |
+
if ( function_exists( 'wp_parse_url' ) ) {
|
| 140 |
+
$redirect_url = wp_parse_url( $redirect_to );
|
| 141 |
+
} else {
|
| 142 |
+
$redirect_url = parse_url( $redirect_to );
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
$redirect_host = ( is_array( $redirect_url ) && ! empty( $redirect_url['host'] ) ) ? $redirect_url['host'] : '';
|
| 146 |
|
| 147 |
// check if we are redirecting locally
|
| 168 |
/**
|
| 169 |
* Creates a redirect post, this function will be useful for import/exports scripts
|
| 170 |
*
|
| 171 |
+
* @param string $redirect_from Redirect from location
|
| 172 |
+
* @param string $redirect_to Redirect to location
|
| 173 |
+
* @param int $status_code Redirect status code
|
| 174 |
+
* @param bool $enable_regex Whether to enable regex or not
|
| 175 |
+
* @param string $post_status Post status
|
| 176 |
+
* @param int $menu_order Menu order
|
| 177 |
* @since 1.8
|
| 178 |
* @uses wp_insert_post, update_post_meta
|
| 179 |
* @return int|WP_Error
|
| 237 |
* esc_url_raw( 'test' ) == 'http://test', whereas sanitize_redirect_path( 'test' ) == '/test'
|
| 238 |
*
|
| 239 |
* @since 1.8
|
| 240 |
+
* @param string $path Path to sanitize
|
| 241 |
* @return string
|
| 242 |
*/
|
| 243 |
function srm_sanitize_redirect_to( $path ) {
|
| 260 |
* Sanitize redirect from path
|
| 261 |
*
|
| 262 |
* @since 1.8
|
| 263 |
+
* @param string $path Path to sanitize
|
| 264 |
+
* @param boolean $allow_regex Whether to allow regex
|
| 265 |
* @return string
|
| 266 |
*/
|
| 267 |
function srm_sanitize_redirect_from( $path, $allow_regex = false ) {
|
| 323 |
}
|
| 324 |
|
| 325 |
// process all rows of the file
|
| 326 |
+
$created = 0;
|
| 327 |
+
$skipped = 0;
|
| 328 |
$headers = fgetcsv( $handle );
|
| 329 |
|
| 330 |
while ( ( $row = fgetcsv( $handle ) ) ) {
|
lang/safe-redirect-manager.pot
CHANGED
|
@@ -2,114 +2,114 @@
|
|
| 2 |
# This file is distributed under the GPLv2 or later.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
-
"Project-Id-Version: Safe Redirect Manager 1.9\n"
|
| 6 |
"Report-Msgid-Bugs-To: "
|
| 7 |
"https://wordpress.org/support/plugin/safe-redirect-manager\n"
|
| 8 |
-
"POT-Creation-Date: 2018-
|
| 9 |
"MIME-Version: 1.0\n"
|
| 10 |
"Content-Type: text/plain; charset=utf-8\n"
|
| 11 |
"Content-Transfer-Encoding: 8bit\n"
|
| 12 |
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
|
| 13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
| 14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
| 15 |
-
"X-Generator: node-wp-i18n 1.
|
| 16 |
|
| 17 |
-
#: inc/classes/class-srm-post-type.php:
|
| 18 |
msgid "Moved Permanently"
|
| 19 |
msgstr ""
|
| 20 |
|
| 21 |
-
#: inc/classes/class-srm-post-type.php:
|
| 22 |
msgid "Found"
|
| 23 |
msgstr ""
|
| 24 |
|
| 25 |
-
#: inc/classes/class-srm-post-type.php:
|
| 26 |
msgid "See Other"
|
| 27 |
msgstr ""
|
| 28 |
|
| 29 |
-
#: inc/classes/class-srm-post-type.php:
|
| 30 |
msgid "Temporary Redirect"
|
| 31 |
msgstr ""
|
| 32 |
|
| 33 |
-
#: inc/classes/class-srm-post-type.php:
|
| 34 |
msgid "Forbidden"
|
| 35 |
msgstr ""
|
| 36 |
|
| 37 |
-
#: inc/classes/class-srm-post-type.php:
|
| 38 |
msgid "Not Found"
|
| 39 |
msgstr ""
|
| 40 |
|
| 41 |
-
#: inc/classes/class-srm-post-type.php:
|
| 42 |
msgid ""
|
| 43 |
"Safe Redirect Manager Warning: Possible redirect loops and/or chains have "
|
| 44 |
"been created."
|
| 45 |
msgstr ""
|
| 46 |
|
| 47 |
-
#: inc/classes/class-srm-post-type.php:
|
| 48 |
msgid ""
|
| 49 |
"Safe Redirect Manager Error: You have reached the maximum allowable number "
|
| 50 |
"of redirects"
|
| 51 |
msgstr ""
|
| 52 |
|
| 53 |
-
#: inc/classes/class-srm-post-type.php:
|
| 54 |
-
#: inc/classes/class-srm-post-type.php:
|
| 55 |
msgid "Redirect rule updated."
|
| 56 |
msgstr ""
|
| 57 |
|
| 58 |
-
#: inc/classes/class-srm-post-type.php:
|
| 59 |
msgid "Custom field updated."
|
| 60 |
msgstr ""
|
| 61 |
|
| 62 |
-
#: inc/classes/class-srm-post-type.php:
|
| 63 |
msgid "Custom field deleted."
|
| 64 |
msgstr ""
|
| 65 |
|
| 66 |
-
#: inc/classes/class-srm-post-type.php:
|
| 67 |
#. translators: %s: date and time of the revision
|
| 68 |
msgid "Redirect rule restored to revision from %s"
|
| 69 |
msgstr ""
|
| 70 |
|
| 71 |
-
#: inc/classes/class-srm-post-type.php:
|
| 72 |
msgid "Redirect rule published."
|
| 73 |
msgstr ""
|
| 74 |
|
| 75 |
-
#: inc/classes/class-srm-post-type.php:
|
| 76 |
msgid "Redirect rule saved."
|
| 77 |
msgstr ""
|
| 78 |
|
| 79 |
-
#: inc/classes/class-srm-post-type.php:
|
| 80 |
msgid "Redirect rule submitted."
|
| 81 |
msgstr ""
|
| 82 |
|
| 83 |
-
#: inc/classes/class-srm-post-type.php:
|
| 84 |
msgid "Redirect rule scheduled for: %1$s."
|
| 85 |
msgstr ""
|
| 86 |
|
| 87 |
-
#: inc/classes/class-srm-post-type.php:
|
| 88 |
#. translators: Publish box date format, see http:php.net/date
|
| 89 |
msgid "M j, Y @ G:i"
|
| 90 |
msgstr ""
|
| 91 |
|
| 92 |
-
#: inc/classes/class-srm-post-type.php:
|
| 93 |
msgid "Redirect rule draft updated."
|
| 94 |
msgstr ""
|
| 95 |
|
| 96 |
-
#: inc/classes/class-srm-post-type.php:
|
| 97 |
msgid "Redirect To"
|
| 98 |
msgstr ""
|
| 99 |
|
| 100 |
-
#: inc/classes/class-srm-post-type.php:
|
| 101 |
msgid "HTTP Status Code"
|
| 102 |
msgstr ""
|
| 103 |
|
| 104 |
-
#: inc/classes/class-srm-post-type.php:
|
| 105 |
msgid "Order"
|
| 106 |
msgstr ""
|
| 107 |
|
| 108 |
-
#: inc/classes/class-srm-post-type.php:
|
| 109 |
msgid "Redirect From"
|
| 110 |
msgstr ""
|
| 111 |
|
| 112 |
-
#: inc/classes/class-srm-post-type.php:
|
| 113 |
msgid "Date"
|
| 114 |
msgstr ""
|
| 115 |
|
|
@@ -117,43 +117,43 @@ msgstr ""
|
|
| 117 |
msgid "Safe Redirect Manager"
|
| 118 |
msgstr ""
|
| 119 |
|
| 120 |
-
#: inc/classes/class-srm-post-type.php:
|
| 121 |
msgid "Edit Redirect Rule"
|
| 122 |
msgstr ""
|
| 123 |
|
| 124 |
-
#: inc/classes/class-srm-post-type.php:
|
| 125 |
msgid "New Redirect Rule"
|
| 126 |
msgstr ""
|
| 127 |
|
| 128 |
-
#: inc/classes/class-srm-post-type.php:
|
| 129 |
msgid "View Redirect Rule"
|
| 130 |
msgstr ""
|
| 131 |
|
| 132 |
-
#: inc/classes/class-srm-post-type.php:
|
| 133 |
msgid "Search Redirects"
|
| 134 |
msgstr ""
|
| 135 |
|
| 136 |
-
#: inc/classes/class-srm-post-type.php:
|
| 137 |
msgid "No redirect rules found."
|
| 138 |
msgstr ""
|
| 139 |
|
| 140 |
-
#: inc/classes/class-srm-post-type.php:
|
| 141 |
msgid "No redirect rules found in trash."
|
| 142 |
msgstr ""
|
| 143 |
|
| 144 |
-
#: inc/classes/class-srm-post-type.php:
|
| 145 |
msgid "Redirect Settings"
|
| 146 |
msgstr ""
|
| 147 |
|
| 148 |
-
#: inc/classes/class-srm-post-type.php:
|
| 149 |
msgid "* Redirect From:"
|
| 150 |
msgstr ""
|
| 151 |
|
| 152 |
-
#: inc/classes/class-srm-post-type.php:
|
| 153 |
msgid "Enable Regular Expressions (advanced)"
|
| 154 |
msgstr ""
|
| 155 |
|
| 156 |
-
#: inc/classes/class-srm-post-type.php:
|
| 157 |
msgid ""
|
| 158 |
"This path should be relative to the root of this WordPress installation (or "
|
| 159 |
"the sub-site, if you are running a multi-site). Appending a (*) wildcard "
|
|
@@ -162,51 +162,51 @@ msgid ""
|
|
| 162 |
"symbol is interpretted."
|
| 163 |
msgstr ""
|
| 164 |
|
| 165 |
-
#: inc/classes/class-srm-post-type.php:
|
| 166 |
msgid "* Redirect To:"
|
| 167 |
msgstr ""
|
| 168 |
|
| 169 |
-
#: inc/classes/class-srm-post-type.php:
|
| 170 |
msgid ""
|
| 171 |
"This can be a URL or a path relative to the root of your website (not your "
|
| 172 |
"WordPress installation). Ending with a (*) wildcard character will append "
|
| 173 |
"the request match to the redirect."
|
| 174 |
msgstr ""
|
| 175 |
|
| 176 |
-
#: inc/classes/class-srm-post-type.php:
|
| 177 |
msgid "* HTTP Status Code:"
|
| 178 |
msgstr ""
|
| 179 |
|
| 180 |
-
#: inc/classes/class-srm-post-type.php:
|
| 181 |
msgid "If you don't know what this is, leave it as is."
|
| 182 |
msgstr ""
|
| 183 |
|
| 184 |
-
#: inc/classes/class-srm-post-type.php:
|
| 185 |
msgid "Notes:"
|
| 186 |
msgstr ""
|
| 187 |
|
| 188 |
-
#: inc/classes/class-srm-post-type.php:
|
| 189 |
msgid "Optionally leave notes on this redirect e.g. why was it created."
|
| 190 |
msgstr ""
|
| 191 |
|
| 192 |
-
#: inc/functions.php:
|
| 193 |
msgid "Redirect from and/or redirect to arguments are invalid."
|
| 194 |
msgstr ""
|
| 195 |
|
| 196 |
-
#: inc/functions.php:
|
| 197 |
msgid "Invalid status code."
|
| 198 |
msgstr ""
|
| 199 |
|
| 200 |
-
#: inc/functions.php:
|
| 201 |
msgid "Redirect already exists for %s"
|
| 202 |
msgstr ""
|
| 203 |
|
| 204 |
-
#: inc/functions.php:
|
| 205 |
msgid "An error occurred creating the redirect."
|
| 206 |
msgstr ""
|
| 207 |
|
| 208 |
-
#.
|
| 209 |
-
msgid "https://
|
| 210 |
msgstr ""
|
| 211 |
|
| 212 |
#. Description of the plugin/theme
|
|
@@ -217,17 +217,21 @@ msgstr ""
|
|
| 217 |
msgid "10up"
|
| 218 |
msgstr ""
|
| 219 |
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
msgctxt "post type general name"
|
| 222 |
msgid "Safe Redirect Manager"
|
| 223 |
msgstr ""
|
| 224 |
|
| 225 |
-
#: inc/classes/class-srm-post-type.php:
|
| 226 |
msgctxt "post type singular name"
|
| 227 |
msgid "Redirect"
|
| 228 |
msgstr ""
|
| 229 |
|
| 230 |
-
#: inc/classes/class-srm-post-type.php:
|
| 231 |
msgctxt "redirect rule"
|
| 232 |
msgid "Create Redirect Rule"
|
| 233 |
msgstr ""
|
| 2 |
# This file is distributed under the GPLv2 or later.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
+
"Project-Id-Version: Safe Redirect Manager 1.9.1\n"
|
| 6 |
"Report-Msgid-Bugs-To: "
|
| 7 |
"https://wordpress.org/support/plugin/safe-redirect-manager\n"
|
| 8 |
+
"POT-Creation-Date: 2018-11-22 02:09:56+00:00\n"
|
| 9 |
"MIME-Version: 1.0\n"
|
| 10 |
"Content-Type: text/plain; charset=utf-8\n"
|
| 11 |
"Content-Transfer-Encoding: 8bit\n"
|
| 12 |
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
|
| 13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
| 14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
| 15 |
+
"X-Generator: node-wp-i18n 1.2.1\n"
|
| 16 |
|
| 17 |
+
#: inc/classes/class-srm-post-type.php:34
|
| 18 |
msgid "Moved Permanently"
|
| 19 |
msgstr ""
|
| 20 |
|
| 21 |
+
#: inc/classes/class-srm-post-type.php:35
|
| 22 |
msgid "Found"
|
| 23 |
msgstr ""
|
| 24 |
|
| 25 |
+
#: inc/classes/class-srm-post-type.php:36
|
| 26 |
msgid "See Other"
|
| 27 |
msgstr ""
|
| 28 |
|
| 29 |
+
#: inc/classes/class-srm-post-type.php:37
|
| 30 |
msgid "Temporary Redirect"
|
| 31 |
msgstr ""
|
| 32 |
|
| 33 |
+
#: inc/classes/class-srm-post-type.php:38
|
| 34 |
msgid "Forbidden"
|
| 35 |
msgstr ""
|
| 36 |
|
| 37 |
+
#: inc/classes/class-srm-post-type.php:39
|
| 38 |
msgid "Not Found"
|
| 39 |
msgstr ""
|
| 40 |
|
| 41 |
+
#: inc/classes/class-srm-post-type.php:237
|
| 42 |
msgid ""
|
| 43 |
"Safe Redirect Manager Warning: Possible redirect loops and/or chains have "
|
| 44 |
"been created."
|
| 45 |
msgstr ""
|
| 46 |
|
| 47 |
+
#: inc/classes/class-srm-post-type.php:251
|
| 48 |
msgid ""
|
| 49 |
"Safe Redirect Manager Error: You have reached the maximum allowable number "
|
| 50 |
"of redirects"
|
| 51 |
msgstr ""
|
| 52 |
|
| 53 |
+
#: inc/classes/class-srm-post-type.php:302
|
| 54 |
+
#: inc/classes/class-srm-post-type.php:305
|
| 55 |
msgid "Redirect rule updated."
|
| 56 |
msgstr ""
|
| 57 |
|
| 58 |
+
#: inc/classes/class-srm-post-type.php:303
|
| 59 |
msgid "Custom field updated."
|
| 60 |
msgstr ""
|
| 61 |
|
| 62 |
+
#: inc/classes/class-srm-post-type.php:304
|
| 63 |
msgid "Custom field deleted."
|
| 64 |
msgstr ""
|
| 65 |
|
| 66 |
+
#: inc/classes/class-srm-post-type.php:307
|
| 67 |
#. translators: %s: date and time of the revision
|
| 68 |
msgid "Redirect rule restored to revision from %s"
|
| 69 |
msgstr ""
|
| 70 |
|
| 71 |
+
#: inc/classes/class-srm-post-type.php:308
|
| 72 |
msgid "Redirect rule published."
|
| 73 |
msgstr ""
|
| 74 |
|
| 75 |
+
#: inc/classes/class-srm-post-type.php:309
|
| 76 |
msgid "Redirect rule saved."
|
| 77 |
msgstr ""
|
| 78 |
|
| 79 |
+
#: inc/classes/class-srm-post-type.php:310
|
| 80 |
msgid "Redirect rule submitted."
|
| 81 |
msgstr ""
|
| 82 |
|
| 83 |
+
#: inc/classes/class-srm-post-type.php:312
|
| 84 |
msgid "Redirect rule scheduled for: %1$s."
|
| 85 |
msgstr ""
|
| 86 |
|
| 87 |
+
#: inc/classes/class-srm-post-type.php:314
|
| 88 |
#. translators: Publish box date format, see http:php.net/date
|
| 89 |
msgid "M j, Y @ G:i"
|
| 90 |
msgstr ""
|
| 91 |
|
| 92 |
+
#: inc/classes/class-srm-post-type.php:317
|
| 93 |
msgid "Redirect rule draft updated."
|
| 94 |
msgstr ""
|
| 95 |
|
| 96 |
+
#: inc/classes/class-srm-post-type.php:371
|
| 97 |
msgid "Redirect To"
|
| 98 |
msgstr ""
|
| 99 |
|
| 100 |
+
#: inc/classes/class-srm-post-type.php:372
|
| 101 |
msgid "HTTP Status Code"
|
| 102 |
msgstr ""
|
| 103 |
|
| 104 |
+
#: inc/classes/class-srm-post-type.php:373
|
| 105 |
msgid "Order"
|
| 106 |
msgstr ""
|
| 107 |
|
| 108 |
+
#: inc/classes/class-srm-post-type.php:376
|
| 109 |
msgid "Redirect From"
|
| 110 |
msgstr ""
|
| 111 |
|
| 112 |
+
#: inc/classes/class-srm-post-type.php:380
|
| 113 |
msgid "Date"
|
| 114 |
msgstr ""
|
| 115 |
|
| 117 |
msgid "Safe Redirect Manager"
|
| 118 |
msgstr ""
|
| 119 |
|
| 120 |
+
#: inc/classes/class-srm-post-type.php:490
|
| 121 |
msgid "Edit Redirect Rule"
|
| 122 |
msgstr ""
|
| 123 |
|
| 124 |
+
#: inc/classes/class-srm-post-type.php:491
|
| 125 |
msgid "New Redirect Rule"
|
| 126 |
msgstr ""
|
| 127 |
|
| 128 |
+
#: inc/classes/class-srm-post-type.php:493
|
| 129 |
msgid "View Redirect Rule"
|
| 130 |
msgstr ""
|
| 131 |
|
| 132 |
+
#: inc/classes/class-srm-post-type.php:494
|
| 133 |
msgid "Search Redirects"
|
| 134 |
msgstr ""
|
| 135 |
|
| 136 |
+
#: inc/classes/class-srm-post-type.php:495
|
| 137 |
msgid "No redirect rules found."
|
| 138 |
msgstr ""
|
| 139 |
|
| 140 |
+
#: inc/classes/class-srm-post-type.php:496
|
| 141 |
msgid "No redirect rules found in trash."
|
| 142 |
msgstr ""
|
| 143 |
|
| 144 |
+
#: inc/classes/class-srm-post-type.php:541
|
| 145 |
msgid "Redirect Settings"
|
| 146 |
msgstr ""
|
| 147 |
|
| 148 |
+
#: inc/classes/class-srm-post-type.php:566
|
| 149 |
msgid "* Redirect From:"
|
| 150 |
msgstr ""
|
| 151 |
|
| 152 |
+
#: inc/classes/class-srm-post-type.php:569
|
| 153 |
msgid "Enable Regular Expressions (advanced)"
|
| 154 |
msgstr ""
|
| 155 |
|
| 156 |
+
#: inc/classes/class-srm-post-type.php:571
|
| 157 |
msgid ""
|
| 158 |
"This path should be relative to the root of this WordPress installation (or "
|
| 159 |
"the sub-site, if you are running a multi-site). Appending a (*) wildcard "
|
| 162 |
"symbol is interpretted."
|
| 163 |
msgstr ""
|
| 164 |
|
| 165 |
+
#: inc/classes/class-srm-post-type.php:574
|
| 166 |
msgid "* Redirect To:"
|
| 167 |
msgstr ""
|
| 168 |
|
| 169 |
+
#: inc/classes/class-srm-post-type.php:577
|
| 170 |
msgid ""
|
| 171 |
"This can be a URL or a path relative to the root of your website (not your "
|
| 172 |
"WordPress installation). Ending with a (*) wildcard character will append "
|
| 173 |
"the request match to the redirect."
|
| 174 |
msgstr ""
|
| 175 |
|
| 176 |
+
#: inc/classes/class-srm-post-type.php:580
|
| 177 |
msgid "* HTTP Status Code:"
|
| 178 |
msgstr ""
|
| 179 |
|
| 180 |
+
#: inc/classes/class-srm-post-type.php:586
|
| 181 |
msgid "If you don't know what this is, leave it as is."
|
| 182 |
msgstr ""
|
| 183 |
|
| 184 |
+
#: inc/classes/class-srm-post-type.php:590
|
| 185 |
msgid "Notes:"
|
| 186 |
msgstr ""
|
| 187 |
|
| 188 |
+
#: inc/classes/class-srm-post-type.php:592
|
| 189 |
msgid "Optionally leave notes on this redirect e.g. why was it created."
|
| 190 |
msgstr ""
|
| 191 |
|
| 192 |
+
#: inc/functions.php:193
|
| 193 |
msgid "Redirect from and/or redirect to arguments are invalid."
|
| 194 |
msgstr ""
|
| 195 |
|
| 196 |
+
#: inc/functions.php:197
|
| 197 |
msgid "Invalid status code."
|
| 198 |
msgstr ""
|
| 199 |
|
| 200 |
+
#: inc/functions.php:202
|
| 201 |
msgid "Redirect already exists for %s"
|
| 202 |
msgstr ""
|
| 203 |
|
| 204 |
+
#: inc/functions.php:216
|
| 205 |
msgid "An error occurred creating the redirect."
|
| 206 |
msgstr ""
|
| 207 |
|
| 208 |
+
#. Plugin URI of the plugin/theme
|
| 209 |
+
msgid "https://wordpress.org/plugins/safe-redirect-manager"
|
| 210 |
msgstr ""
|
| 211 |
|
| 212 |
#. Description of the plugin/theme
|
| 217 |
msgid "10up"
|
| 218 |
msgstr ""
|
| 219 |
|
| 220 |
+
#. Author URI of the plugin/theme
|
| 221 |
+
msgid "https://10up.com"
|
| 222 |
+
msgstr ""
|
| 223 |
+
|
| 224 |
+
#: inc/classes/class-srm-post-type.php:486
|
| 225 |
msgctxt "post type general name"
|
| 226 |
msgid "Safe Redirect Manager"
|
| 227 |
msgstr ""
|
| 228 |
|
| 229 |
+
#: inc/classes/class-srm-post-type.php:487
|
| 230 |
msgctxt "post type singular name"
|
| 231 |
msgid "Redirect"
|
| 232 |
msgstr ""
|
| 233 |
|
| 234 |
+
#: inc/classes/class-srm-post-type.php:488
|
| 235 |
msgctxt "redirect rule"
|
| 236 |
msgid "Create Redirect Rule"
|
| 237 |
msgstr ""
|
readme.txt
CHANGED
|
@@ -19,6 +19,9 @@ Extract the zip file and just drop the contents in the wp-content/plugins/ direc
|
|
| 19 |
|
| 20 |
== Changelog ==
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
= 1.9 =
|
| 23 |
* Add redirect notes feature.
|
| 24 |
* Fix PHP 7.2 errors
|
| 19 |
|
| 20 |
== Changelog ==
|
| 21 |
|
| 22 |
+
= 1.9.1 =
|
| 23 |
+
* Fix SQL injection bug opened up by SQL search functionality.
|
| 24 |
+
|
| 25 |
= 1.9 =
|
| 26 |
* Add redirect notes feature.
|
| 27 |
* Fix PHP 7.2 errors
|
safe-redirect-manager.php
CHANGED
|
@@ -1,15 +1,17 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: Safe Redirect Manager
|
| 4 |
-
* Plugin URI: https://
|
| 5 |
* Description: Easily and safely manage HTTP redirects.
|
| 6 |
* Author: 10up
|
| 7 |
-
* Version: 1.9
|
| 8 |
* Text Domain: safe-redirect-manager
|
| 9 |
* Domain Path: /lang/
|
| 10 |
* Author URI: https://10up.com
|
| 11 |
* License: GPLv2 or later
|
| 12 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
|
|
|
| 13 |
*/
|
| 14 |
|
| 15 |
/**
|
|
@@ -22,13 +24,13 @@ function srm_load_textdomain() {
|
|
| 22 |
}
|
| 23 |
add_action( 'plugins_loaded', 'srm_load_textdomain' );
|
| 24 |
|
| 25 |
-
require_once
|
| 26 |
-
require_once
|
| 27 |
-
require_once
|
| 28 |
|
| 29 |
|
| 30 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
| 31 |
-
require_once
|
| 32 |
WP_CLI::add_command( 'safe-redirect-manager', 'SRM_WP_CLI' );
|
| 33 |
}
|
| 34 |
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: Safe Redirect Manager
|
| 4 |
+
* Plugin URI: https://wordpress.org/plugins/safe-redirect-manager
|
| 5 |
* Description: Easily and safely manage HTTP redirects.
|
| 6 |
* Author: 10up
|
| 7 |
+
* Version: 1.9.1
|
| 8 |
* Text Domain: safe-redirect-manager
|
| 9 |
* Domain Path: /lang/
|
| 10 |
* Author URI: https://10up.com
|
| 11 |
* License: GPLv2 or later
|
| 12 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 13 |
+
*
|
| 14 |
+
* @package safe-redirect-manager
|
| 15 |
*/
|
| 16 |
|
| 17 |
/**
|
| 24 |
}
|
| 25 |
add_action( 'plugins_loaded', 'srm_load_textdomain' );
|
| 26 |
|
| 27 |
+
require_once dirname( __FILE__ ) . '/inc/functions.php';
|
| 28 |
+
require_once dirname( __FILE__ ) . '/inc/classes/class-srm-post-type.php';
|
| 29 |
+
require_once dirname( __FILE__ ) . '/inc/classes/class-srm-redirect.php';
|
| 30 |
|
| 31 |
|
| 32 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
| 33 |
+
require_once dirname( __FILE__ ) . '/inc/classes/class-srm-wp-cli.php';
|
| 34 |
WP_CLI::add_command( 'safe-redirect-manager', 'SRM_WP_CLI' );
|
| 35 |
}
|
| 36 |
|
