Page Links To - Version 2.9.6

Version Description

  • Fixed an issue with redirects that have @ in the URL
  • Fixed issues with setting and displaying custom URLs for attachments
Download this release

Release Info

Developer markjaquith
Plugin Icon wp plugin Page Links To
Version 2.9.6
Comparing to
See all releases

Code changes from version 2.9.5 to 2.9.6

page-links-to.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Page Links To
4
  Plugin URI: http://txfx.net/wordpress-plugins/page-links-to/
5
  Description: Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources.
6
- Version: 2.9.5
7
  Author: Mark Jaquith
8
  Author URI: http://coveredwebservices.com/
9
  Text Domain: page-links-to
@@ -65,9 +65,10 @@ class CWS_PageLinksTo extends WP_Stack_Plugin {
65
  */
66
  function register_hooks() {
67
  // Hook in to URL generation
68
- $this->hook( 'page_link', 'link', 20 );
69
- $this->hook( 'post_link', 'link', 20 );
70
- $this->hook( 'post_type_link', 'link', 20 );
 
71
 
72
  // Non-standard priority hooks
73
  $this->hook( 'do_meta_boxes', 20 );
@@ -82,6 +83,7 @@ class CWS_PageLinksTo extends WP_Stack_Plugin {
82
  $this->hook( 'wp_list_pages' );
83
  $this->hook( 'template_redirect' );
84
  $this->hook( 'save_post' );
 
85
  $this->hook( 'wp_nav_menu_objects' );
86
  $this->hook( 'plugin_row_meta' );
87
 
@@ -275,6 +277,16 @@ class CWS_PageLinksTo extends WP_Stack_Plugin {
275
  <?php
276
  }
277
 
 
 
 
 
 
 
 
 
 
 
278
  /**
279
  * Saves data on post save
280
  *
@@ -476,6 +488,10 @@ class CWS_PageLinksTo extends WP_Stack_Plugin {
476
  }
477
  }
478
 
 
 
 
 
479
  return $link;
480
  }
481
 
3
  Plugin Name: Page Links To
4
  Plugin URI: http://txfx.net/wordpress-plugins/page-links-to/
5
  Description: Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources.
6
+ Version: 2.9.6
7
  Author: Mark Jaquith
8
  Author URI: http://coveredwebservices.com/
9
  Text Domain: page-links-to
65
  */
66
  function register_hooks() {
67
  // Hook in to URL generation
68
+ $this->hook( 'page_link', 'link', 20 );
69
+ $this->hook( 'post_link', 'link', 20 );
70
+ $this->hook( 'post_type_link', 'link', 20 );
71
+ $this->hook( 'attachment_link', 'link', 20 );
72
 
73
  // Non-standard priority hooks
74
  $this->hook( 'do_meta_boxes', 20 );
83
  $this->hook( 'wp_list_pages' );
84
  $this->hook( 'template_redirect' );
85
  $this->hook( 'save_post' );
86
+ $this->hook( 'edit_attachment' );
87
  $this->hook( 'wp_nav_menu_objects' );
88
  $this->hook( 'plugin_row_meta' );
89
 
277
  <?php
278
  }
279
 
280
+ /**
281
+ * Saves data on attachment save
282
+ *
283
+ * @param int $post_id
284
+ * @return int the attachment post ID that was passed in
285
+ */
286
+ function edit_attachment( $post_id ) {
287
+ return $this->save_post( $post_id );
288
+ }
289
+
290
  /**
291
  * Saves data on post save
292
  *
488
  }
489
  }
490
 
491
+ if ( 'mailto' !== parse_url( $link, PHP_URL_SCHEME ) ) {
492
+ $link = str_replace( '@', '%40', $link );
493
+ }
494
+
495
  return $link;
496
  }
497
 
readme.txt CHANGED
@@ -7,7 +7,7 @@ Donate link: http://txfx.net/wordpress-plugins/donate
7
  Tags: page, redirect, link, external link, repoint
8
  Requires at least: 3.9.2
9
  Tested up to: 4.2
10
- Stable tag: 2.9.5
11
 
12
  Lets you make a WordPress page (or other content type) link to an external URL of your choosing, instead of its WordPress URL.
13
 
@@ -63,6 +63,10 @@ You can contribute (or report bugs) on [Github](https://github.com/markjaquith/p
63
 
64
  == Changelog ==
65
 
 
 
 
 
66
  = 2.9.5 =
67
  * Made relative URLs absolute in redirects
68
  * Fixed a potential PHP warning
7
  Tags: page, redirect, link, external link, repoint
8
  Requires at least: 3.9.2
9
  Tested up to: 4.2
10
+ Stable tag: 2.9.6
11
 
12
  Lets you make a WordPress page (or other content type) link to an external URL of your choosing, instead of its WordPress URL.
13
 
63
 
64
  == Changelog ==
65
 
66
+ = 2.9.6 =
67
+ * Fixed an issue with redirects that have `@` in the URL
68
+ * Fixed issues with setting and displaying custom URLs for attachments
69
+
70
  = 2.9.5 =
71
  * Made relative URLs absolute in redirects
72
  * Fixed a potential PHP warning
tests/test-redirection.php CHANGED
@@ -21,4 +21,11 @@ class CWS_PLT_Test_Redirection extends CWS_PLT_TestCase {
21
  query_posts( array( 'p' => $post_id ) );
22
  $this->assertEquals( (is_ssl() ? 'https:' : 'http:' ) . '//example.com/foo', $this->plugin()->get_redirect() );
23
  }
 
 
 
 
 
 
 
24
  }
21
  query_posts( array( 'p' => $post_id ) );
22
  $this->assertEquals( (is_ssl() ? 'https:' : 'http:' ) . '//example.com/foo', $this->plugin()->get_redirect() );
23
  }
24
+
25
+ function test_redirection_with_asperand() {
26
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
27
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/@test' ) );
28
+ query_posts( array( 'p' => $post_id ) );
29
+ $this->assertEquals( 'http://example.com/%40test', $this->plugin()->get_redirect() );
30
+ }
31
  }
tests/test-saving.php CHANGED
@@ -60,6 +60,21 @@ class CWS_PLT_Test_Saving extends CWS_PLT_TestCase {
60
  $this->assertFalse( $this->plugin()->get_target( $post_id ) );
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  function test_updating_post() {
64
  $user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
65
  wp_set_current_user( $user_id );
60
  $this->assertFalse( $this->plugin()->get_target( $post_id ) );
61
  }
62
 
63
+ function test_updating_attachment() {
64
+ $user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
65
+ wp_set_current_user( $user_id );
66
+ $post_id = $this->factory->post->create( array( 'post_type' => 'attachment', 'post_author' => $user_id ) );
67
+
68
+ $this->set_post( '_cws_plt_nonce', wp_create_nonce( 'cws_plt_' . $post_id ) );
69
+
70
+ // example.org in same window
71
+ $this->set_post( 'cws_links_to_choice', 'custom' );
72
+ $this->set_post( 'cws_links_to', 'http://example.org/' );
73
+ $this->unset_post( 'cws_links_to_new_tab' );
74
+ $this->plugin()->edit_attachment( $post_id );
75
+ $this->assertEquals( 'http://example.org/', $this->plugin()->get_link( $post_id ) );
76
+ }
77
+
78
  function test_updating_post() {
79
  $user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
80
  wp_set_current_user( $user_id );