Version Description
- Made relative URLs absolute in redirects
- Fixed a potential PHP warning
- Registered the metadata fields for better XML-RPC integration
Download this release
Release Info
Developer | markjaquith |
Plugin | Page Links To |
Version | 2.9.5 |
Comparing to | |
See all releases |
Code changes from version 2.9.4 to 2.9.5
- bin/install-wp-tests.sh +79 -0
- page-links-to.php +20 -3
- readme.txt +12 -3
- tests/bootstrap.php +5 -2
- tests/test-redirection.php +14 -0
bin/install-wp-tests.sh
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
if [ $# -lt 3 ]; then
|
4 |
+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
|
5 |
+
exit 1
|
6 |
+
fi
|
7 |
+
|
8 |
+
DB_NAME=$1
|
9 |
+
DB_USER=$2
|
10 |
+
DB_PASS=$3
|
11 |
+
DB_HOST=${4-localhost}
|
12 |
+
WP_VERSION=${5-latest}
|
13 |
+
|
14 |
+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
15 |
+
WP_CORE_DIR=/tmp/wordpress/
|
16 |
+
|
17 |
+
set -ex
|
18 |
+
|
19 |
+
install_wp() {
|
20 |
+
mkdir -p $WP_CORE_DIR
|
21 |
+
|
22 |
+
if [ $WP_VERSION == 'latest' ]; then
|
23 |
+
local ARCHIVE_URL='https://github.com/WordPress/WordPress/archive/master.tar.gz'
|
24 |
+
else
|
25 |
+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
26 |
+
local ARCHIVE_URL="http://wordpress.org/${ARCHIVE_NAME}.tar.gz"
|
27 |
+
fi
|
28 |
+
|
29 |
+
wget -nv -O /tmp/wordpress.tar.gz $ARCHIVE_URL
|
30 |
+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
31 |
+
|
32 |
+
wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
|
33 |
+
}
|
34 |
+
|
35 |
+
install_test_suite() {
|
36 |
+
# portable in-place argument for both GNU sed and Mac OSX sed
|
37 |
+
if [[ $(uname -s) == 'Darwin' ]]; then
|
38 |
+
local ioption='-i .bak'
|
39 |
+
else
|
40 |
+
local ioption='-i'
|
41 |
+
fi
|
42 |
+
|
43 |
+
# set up testing suite
|
44 |
+
mkdir -p $WP_TESTS_DIR
|
45 |
+
cd $WP_TESTS_DIR
|
46 |
+
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
|
47 |
+
|
48 |
+
wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
|
49 |
+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
|
50 |
+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
|
51 |
+
sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
|
52 |
+
sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
|
53 |
+
sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
|
54 |
+
}
|
55 |
+
|
56 |
+
install_db() {
|
57 |
+
# parse DB_HOST for port or socket references
|
58 |
+
local PARTS=(${DB_HOST//\:/ })
|
59 |
+
local DB_HOSTNAME=${PARTS[0]};
|
60 |
+
local DB_SOCK_OR_PORT=${PARTS[1]};
|
61 |
+
local EXTRA=""
|
62 |
+
|
63 |
+
if ! [ -z $DB_HOSTNAME ] ; then
|
64 |
+
if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
|
65 |
+
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
66 |
+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
67 |
+
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
68 |
+
elif ! [ -z $DB_HOSTNAME ] ; then
|
69 |
+
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
70 |
+
fi
|
71 |
+
fi
|
72 |
+
|
73 |
+
# create database
|
74 |
+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
|
75 |
+
}
|
76 |
+
|
77 |
+
install_wp
|
78 |
+
install_test_suite
|
79 |
+
install_db
|
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.
|
7 |
Author: Mark Jaquith
|
8 |
Author URI: http://coveredwebservices.com/
|
9 |
Text Domain: page-links-to
|
@@ -84,6 +84,10 @@ class CWS_PageLinksTo extends WP_Stack_Plugin {
|
|
84 |
$this->hook( 'save_post' );
|
85 |
$this->hook( 'wp_nav_menu_objects' );
|
86 |
$this->hook( 'plugin_row_meta' );
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
/**
|
@@ -459,7 +463,20 @@ class CWS_PageLinksTo extends WP_Stack_Plugin {
|
|
459 |
if ( ! get_queried_object_id() )
|
460 |
return false;
|
461 |
|
462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
}
|
464 |
|
465 |
/**
|
@@ -513,7 +530,7 @@ class CWS_PageLinksTo extends WP_Stack_Plugin {
|
|
513 |
function wp_nav_menu_objects( $items ) {
|
514 |
$new_items = array();
|
515 |
foreach ( $items as $item ) {
|
516 |
-
if ( $this->get_target( $item->object_id ) )
|
517 |
$item->target = '_blank';
|
518 |
$new_items[] = $item;
|
519 |
}
|
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
|
84 |
$this->hook( 'save_post' );
|
85 |
$this->hook( 'wp_nav_menu_objects' );
|
86 |
$this->hook( 'plugin_row_meta' );
|
87 |
+
|
88 |
+
// Metadata validation grants users editing privileges for our custom fields
|
89 |
+
register_meta('post', self::LINK_META_KEY, null, '__return_true');
|
90 |
+
register_meta('post', self::TARGET_META_KEY, null, '__return_true');
|
91 |
}
|
92 |
|
93 |
/**
|
463 |
if ( ! get_queried_object_id() )
|
464 |
return false;
|
465 |
|
466 |
+
$link = $this->get_link( get_queried_object_id() );
|
467 |
+
|
468 |
+
// Convert server- and protocol-relative URLs to absolute URLs
|
469 |
+
if ( "/" === $link[0] ) {
|
470 |
+
// Protocol-relative
|
471 |
+
if ( "/" === $link[1] ) {
|
472 |
+
$link = set_url_scheme( 'http:' . $link );
|
473 |
+
} else {
|
474 |
+
// Host-relative
|
475 |
+
$link = set_url_scheme( 'http://' . $_SERVER["HTTP_HOST"] . $link );
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
+
return $link;
|
480 |
}
|
481 |
|
482 |
/**
|
530 |
function wp_nav_menu_objects( $items ) {
|
531 |
$new_items = array();
|
532 |
foreach ( $items as $item ) {
|
533 |
+
if ( isset( $item->object_id ) && $this->get_target( $item->object_id ) )
|
534 |
$item->target = '_blank';
|
535 |
$new_items[] = $item;
|
536 |
}
|
readme.txt
CHANGED
@@ -5,9 +5,9 @@
|
|
5 |
Contributors: markjaquith
|
6 |
Donate link: http://txfx.net/wordpress-plugins/donate
|
7 |
Tags: page, redirect, link, external link, repoint
|
8 |
-
Requires at least: 3.
|
9 |
-
Tested up to: 4.
|
10 |
-
Stable tag: 2.9.
|
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 |
|
@@ -57,8 +57,17 @@ If you want to link to a full URL, you *must* include the `http://` portion.
|
|
57 |
|
58 |
Yes. Linking to `/my-photos.php` is a good idea, as it'll still work if you move your site to a different domain.
|
59 |
|
|
|
|
|
|
|
|
|
60 |
== Changelog ==
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
= 2.9.4 =
|
63 |
* Add Hungarian translation.
|
64 |
|
5 |
Contributors: markjaquith
|
6 |
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 |
|
57 |
|
58 |
Yes. Linking to `/my-photos.php` is a good idea, as it'll still work if you move your site to a different domain.
|
59 |
|
60 |
+
== Contribute ==
|
61 |
+
|
62 |
+
You can contribute (or report bugs) on [Github](https://github.com/markjaquith/page-links-to/).
|
63 |
+
|
64 |
== Changelog ==
|
65 |
|
66 |
+
= 2.9.5 =
|
67 |
+
* Made relative URLs absolute in redirects
|
68 |
+
* Fixed a potential PHP warning
|
69 |
+
* Registered the metadata fields for better XML-RPC integration
|
70 |
+
|
71 |
= 2.9.4 =
|
72 |
* Add Hungarian translation.
|
73 |
|
tests/bootstrap.php
CHANGED
@@ -1,13 +1,16 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
4 |
|
5 |
function _manually_load_plugin() {
|
6 |
require dirname( __FILE__ ) . '/../page-links-to.php';
|
7 |
}
|
8 |
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
9 |
|
10 |
-
require
|
11 |
|
12 |
class CWS_PLT_TestCase extends WP_UnitTestCase {
|
13 |
function plugin() {
|
1 |
<?php
|
2 |
|
3 |
+
$_tests_dir = getenv('WP_TESTS_DIR');
|
4 |
+
if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
|
5 |
+
|
6 |
+
require_once $_tests_dir . '/includes/functions.php';
|
7 |
|
8 |
function _manually_load_plugin() {
|
9 |
require dirname( __FILE__ ) . '/../page-links-to.php';
|
10 |
}
|
11 |
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
12 |
|
13 |
+
require $_tests_dir . '/includes/bootstrap.php';
|
14 |
|
15 |
class CWS_PLT_TestCase extends WP_UnitTestCase {
|
16 |
function plugin() {
|
tests/test-redirection.php
CHANGED
@@ -7,4 +7,18 @@ class CWS_PLT_Test_Redirection extends CWS_PLT_TestCase {
|
|
7 |
query_posts( array( 'p' => $post_id ) );
|
8 |
$this->assertEquals( 'http://example.com/', $this->plugin()->get_redirect() );
|
9 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
7 |
query_posts( array( 'p' => $post_id ) );
|
8 |
$this->assertEquals( 'http://example.com/', $this->plugin()->get_redirect() );
|
9 |
}
|
10 |
+
|
11 |
+
function test_host_relative_redirect() {
|
12 |
+
$post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
|
13 |
+
$this->plugin()->set_link( $post_id, '/foo' );
|
14 |
+
query_posts( array( 'p' => $post_id ) );
|
15 |
+
$this->assertEquals( get_option( 'home' ) . '/foo', $this->plugin()->get_redirect() );
|
16 |
+
}
|
17 |
+
|
18 |
+
function test_protocol_relative_redirect() {
|
19 |
+
$post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
|
20 |
+
$this->plugin()->set_link( $post_id, '//example.com/foo' );
|
21 |
+
query_posts( array( 'p' => $post_id ) );
|
22 |
+
$this->assertEquals( (is_ssl() ? 'https:' : 'http:' ) . '//example.com/foo', $this->plugin()->get_redirect() );
|
23 |
+
}
|
24 |
}
|