Version Description
- Fixed "open in new window" functionality
Download this release
Release Info
Developer | markjaquith |
Plugin | Page Links To |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8 to 1.9
- page-links-to.php +16 -12
- readme.txt +7 -2
- trunk/page-links-to.php +0 -203
- trunk/readme.txt +0 -35
- trunk/screenshot-1.png +0 -0
page-links-to.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Page Links To
|
4 |
Plugin URI: http://txfx.net/code/wordpress/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: 1.
|
7 |
Author: Mark Jaquith
|
8 |
Author URI: http://coveredwebservices.com/
|
9 |
*/
|
@@ -90,16 +90,20 @@ function txfx_plt_meta_box() {
|
|
90 |
}
|
91 |
|
92 |
function txfx_plt_save_meta_box( $post_ID ) {
|
93 |
-
if ( wp_verify_nonce( $_REQUEST['_txfx_pl2_nonce'], 'txfx_plt' )
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
103 |
}
|
104 |
return $post_ID;
|
105 |
}
|
@@ -156,7 +160,7 @@ function txfx_page_links_to_highlight_tabs( $pages ) {
|
|
156 |
$targets = array();
|
157 |
|
158 |
foreach ( (array) $page_links_to_cache as $id => $page ) {
|
159 |
-
if ( $page_links_to_target_cache[$id] )
|
160 |
$targets[$page] = $page_links_to_target_cache[$id];
|
161 |
|
162 |
if ( str_replace( 'http://www.', 'http://', $this_url ) == str_replace( 'http://www.', 'http://', $page ) || ( is_home() && str_replace( 'http://www.', 'http://', trailingslashit( get_bloginfo( 'home' ) ) ) == str_replace( 'http://www.', 'http://', trailingslashit( $page ) ) ) ) {
|
3 |
Plugin Name: Page Links To
|
4 |
Plugin URI: http://txfx.net/code/wordpress/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: 1.9
|
7 |
Author: Mark Jaquith
|
8 |
Author URI: http://coveredwebservices.com/
|
9 |
*/
|
90 |
}
|
91 |
|
92 |
function txfx_plt_save_meta_box( $post_ID ) {
|
93 |
+
if ( wp_verify_nonce( $_REQUEST['_txfx_pl2_nonce'], 'txfx_plt' ) ) {
|
94 |
+
if ( isset( $_POST['txfx_links_to'] ) && strlen( $_POST['txfx_links_to'] ) > 7 ) {
|
95 |
+
update_post_meta( $post_ID, '_links_to', $_POST['txfx_links_to'] );
|
96 |
+
if ( isset( $_POST['txfx_links_to_new_window'] ) )
|
97 |
+
update_post_meta( $post_ID, '_links_to_target', '_blank' );
|
98 |
+
else
|
99 |
+
delete_post_meta( $post_ID, '_links_to_target' );
|
100 |
+
if ( isset( $_POST['txfx_links_to_302'] ) )
|
101 |
+
update_post_meta( $post_ID, '_links_to_type', '302' );
|
102 |
+
else
|
103 |
+
delete_post_meta( $post_ID, '_links_to_type' );
|
104 |
+
} else {
|
105 |
+
delete_post_meta( $post_ID, '_links_to' );
|
106 |
+
}
|
107 |
}
|
108 |
return $post_ID;
|
109 |
}
|
160 |
$targets = array();
|
161 |
|
162 |
foreach ( (array) $page_links_to_cache as $id => $page ) {
|
163 |
+
if ( isset( $page_links_to_target_cache[$id] ) )
|
164 |
$targets[$page] = $page_links_to_target_cache[$id];
|
165 |
|
166 |
if ( str_replace( 'http://www.', 'http://', $this_url ) == str_replace( 'http://www.', 'http://', $page ) || ( is_home() && str_replace( 'http://www.', 'http://', trailingslashit( get_bloginfo( 'home' ) ) ) == str_replace( 'http://www.', 'http://', trailingslashit( $page ) ) ) ) {
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: markjaquith
|
|
3 |
Donate link: http://txfx.net/code/wordpress/
|
4 |
Tags: page, redirect, link, external link, repoint
|
5 |
Requires at least: 2.7
|
6 |
-
Tested up to: 2.8
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Page Links To allows you to make a WordPress page or post link to a URL of your choosing, instead of its WordPress post or page.
|
@@ -32,4 +32,9 @@ This is useful for setting up navigational links to non-WordPress sections of yo
|
|
32 |
|
33 |
== Screenshots ==
|
34 |
|
35 |
-
1. The Page Links To meta box in action
|
|
|
|
|
|
|
|
|
|
3 |
Donate link: http://txfx.net/code/wordpress/
|
4 |
Tags: page, redirect, link, external link, repoint
|
5 |
Requires at least: 2.7
|
6 |
+
Tested up to: 2.8.4
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Page Links To allows you to make a WordPress page or post link to a URL of your choosing, instead of its WordPress post or page.
|
32 |
|
33 |
== Screenshots ==
|
34 |
|
35 |
+
1. The Page Links To meta box in action
|
36 |
+
|
37 |
+
== Changelog ==
|
38 |
+
|
39 |
+
= 1.9 =
|
40 |
+
* Fixed "open in new window" functionality
|
trunk/page-links-to.php
DELETED
@@ -1,203 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Page Links To
|
4 |
-
Plugin URI: http://txfx.net/code/wordpress/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: 1.8
|
7 |
-
Author: Mark Jaquith
|
8 |
-
Author URI: http://coveredwebservices.com/
|
9 |
-
*/
|
10 |
-
|
11 |
-
/* Copyright 2005-2008 Mark Jaquith (email: mark.gpl@txfx.net)
|
12 |
-
|
13 |
-
This program is free software; you can redistribute it and/or modify
|
14 |
-
it under the terms of the GNU General Public License as published by
|
15 |
-
the Free Software Foundation; either version 2 of the License, or
|
16 |
-
(at your option) any later version.
|
17 |
-
|
18 |
-
This program is distributed in the hope that it will be useful,
|
19 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
-
GNU General Public License for more details.
|
22 |
-
|
23 |
-
You should have received a copy of the GNU General Public License
|
24 |
-
along with this program; if not, write to the Free Software
|
25 |
-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26 |
-
*/
|
27 |
-
|
28 |
-
function txfx_get_page_links_to_meta () {
|
29 |
-
global $wpdb, $page_links_to_cache;
|
30 |
-
|
31 |
-
if ( !isset( $page_links_to_cache ) ) {
|
32 |
-
$links_to = $wpdb->get_results(
|
33 |
-
"SELECT post_id, meta_value " .
|
34 |
-
"FROM $wpdb->postmeta, $wpdb->posts " .
|
35 |
-
"WHERE post_id = ID AND meta_key = '_links_to' AND (post_status = 'static' OR post_status = 'publish')");
|
36 |
-
} else {
|
37 |
-
return $page_links_to_cache;
|
38 |
-
}
|
39 |
-
|
40 |
-
if ( !$links_to ) {
|
41 |
-
$page_links_to_cache = false;
|
42 |
-
return false;
|
43 |
-
}
|
44 |
-
|
45 |
-
foreach ( (array) $links_to as $link )
|
46 |
-
$page_links_to_cache[$link->post_id] = $link->meta_value;
|
47 |
-
|
48 |
-
return $page_links_to_cache;
|
49 |
-
}
|
50 |
-
|
51 |
-
function txfx_get_page_links_to_targets () {
|
52 |
-
global $wpdb, $page_links_to_target_cache;
|
53 |
-
|
54 |
-
if ( !isset( $page_links_to_target_cache ) ) {
|
55 |
-
$links_to = $wpdb->get_results(
|
56 |
-
"SELECT post_id, meta_value " .
|
57 |
-
"FROM $wpdb->postmeta, $wpdb->posts " .
|
58 |
-
"WHERE post_id = ID AND meta_key = '_links_to_target' AND (post_status = 'static' OR post_status = 'publish')");
|
59 |
-
} else {
|
60 |
-
return $page_links_to_target_cache;
|
61 |
-
}
|
62 |
-
|
63 |
-
if ( !$links_to ) {
|
64 |
-
$page_links_to_target_cache = false;
|
65 |
-
return false;
|
66 |
-
}
|
67 |
-
|
68 |
-
foreach ( (array) $links_to as $link ) {
|
69 |
-
$page_links_to_target_cache[$link->post_id] = $link->meta_value;
|
70 |
-
}
|
71 |
-
|
72 |
-
return $page_links_to_target_cache;
|
73 |
-
}
|
74 |
-
|
75 |
-
function txfx_plt_add_meta_box( $page, $context ) {
|
76 |
-
if ( ( 'page' === $page || 'post' === $page ) && 'advanced' === $context )
|
77 |
-
add_meta_box('page-links-to', 'Page Links To', 'txfx_plt_meta_box', $page, 'advanced', 'low');
|
78 |
-
}
|
79 |
-
|
80 |
-
function txfx_plt_meta_box() {
|
81 |
-
global $post;
|
82 |
-
echo '<p>';
|
83 |
-
wp_nonce_field( 'txfx_plt', '_txfx_pl2_nonce', false, true );
|
84 |
-
echo '</p>';
|
85 |
-
?>
|
86 |
-
<p>Point to this URL: <input name="txfx_links_to" type="text" style="width:75%" id="txfx_links_to" value="<?php echo attribute_escape( get_post_meta( $post->ID, '_links_to', true) ); ?>" /></p>
|
87 |
-
<p><label for="txfx_links_to_new_window"><input type="checkbox" name="txfx_links_to_new_window" id="txfx_links_to_new_window" value="_blank"<?php if ( "_blank" == get_post_meta( $post->ID, '_links_to_target', true ) ) { echo ' checked="checked"'; } ?>> Open this link in a new window</label></p>
|
88 |
-
<p><label for="txfx_links_to_302"><input type="checkbox" name="txfx_links_to_302" id="txfx_links_to_302" value="302"<?php if ( '302' == get_post_meta( $post->ID, '_links_to_type', true ) ) { echo ' checked="checked"'; } ?>> Use a temporary <code>302</code> redirect (default is a permanent <code>301</code> redirect)</label></p>
|
89 |
-
<?php
|
90 |
-
}
|
91 |
-
|
92 |
-
function txfx_plt_save_meta_box( $post_ID ) {
|
93 |
-
if ( wp_verify_nonce( $_REQUEST['_txfx_pl2_nonce'], 'txfx_plt' ) ) {
|
94 |
-
if ( isset( $_POST['txfx_links_to'] ) && strlen( $_POST['txfx_links_to'] ) > 7 ) {
|
95 |
-
update_post_meta( $post_ID, '_links_to', $_POST['txfx_links_to'] );
|
96 |
-
if ( isset( $_POST['txfx_links_to_new_window'] ) )
|
97 |
-
update_post_meta( $post_ID, '_links_to_target', '_blank' );
|
98 |
-
else
|
99 |
-
delete_post_meta( $post_ID, '_links_to_target' );
|
100 |
-
if ( isset( $_POST['txfx_links_to_302'] ) )
|
101 |
-
update_post_meta( $post_ID, '_links_to_type', '302' );
|
102 |
-
else
|
103 |
-
delete_post_meta( $post_ID, '_links_to_type' );
|
104 |
-
} else {
|
105 |
-
delete_post_meta( $post_ID, '_links_to' );
|
106 |
-
}
|
107 |
-
}
|
108 |
-
return $post_ID;
|
109 |
-
}
|
110 |
-
|
111 |
-
|
112 |
-
function txfx_filter_links_to_pages ($link, $post) {
|
113 |
-
$page_links_to_cache = txfx_get_page_links_to_meta();
|
114 |
-
|
115 |
-
// Really strange, but page_link gives us an ID and post_link gives us a post object
|
116 |
-
$id = ($post->ID) ? $post->ID : $post;
|
117 |
-
|
118 |
-
if ( $page_links_to_cache[$id] )
|
119 |
-
$link = $page_links_to_cache[$id];
|
120 |
-
|
121 |
-
return $link;
|
122 |
-
}
|
123 |
-
|
124 |
-
function txfx_redirect_links_to_pages() {
|
125 |
-
if ( !is_single() && !is_page() )
|
126 |
-
return;
|
127 |
-
|
128 |
-
global $wp_query;
|
129 |
-
|
130 |
-
$link = get_post_meta( $wp_query->post->ID, '_links_to', true );
|
131 |
-
|
132 |
-
if ( !$link )
|
133 |
-
return;
|
134 |
-
|
135 |
-
$redirect_type = get_post_meta( $wp_query->post->ID, '_links_to_type', true );
|
136 |
-
|
137 |
-
if ( $redirect_type && $redirect_type != '302' ) {
|
138 |
-
// Only supporting 301 and 302 for now.
|
139 |
-
// The others aren't widely supported or needed anyway
|
140 |
-
header( "HTTP/1.0 301 Moved Permanently" );
|
141 |
-
header( "Status: 301 Moved Permanently" );
|
142 |
-
header( "Location: $link" );
|
143 |
-
exit;
|
144 |
-
}
|
145 |
-
|
146 |
-
// If we got this far, it's a 302 redirect
|
147 |
-
header( "Status: 302 Moved Temporarily" );
|
148 |
-
wp_redirect( $link );
|
149 |
-
exit;
|
150 |
-
}
|
151 |
-
|
152 |
-
function txfx_page_links_to_highlight_tabs( $pages ) {
|
153 |
-
$page_links_to_cache = txfx_get_page_links_to_meta();
|
154 |
-
$page_links_to_target_cache = txfx_get_page_links_to_targets();
|
155 |
-
|
156 |
-
if ( !$page_links_to_cache && !$page_links_to_target_cache )
|
157 |
-
return $pages;
|
158 |
-
|
159 |
-
$this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
160 |
-
$targets = array();
|
161 |
-
|
162 |
-
foreach ( (array) $page_links_to_cache as $id => $page ) {
|
163 |
-
if ( $page_links_to_target_cache[$id] )
|
164 |
-
$targets[$page] = $page_links_to_target_cache[$id];
|
165 |
-
|
166 |
-
if ( str_replace( 'http://www.', 'http://', $this_url ) == str_replace( 'http://www.', 'http://', $page ) || ( is_home() && str_replace( 'http://www.', 'http://', trailingslashit( get_bloginfo( 'home' ) ) ) == str_replace( 'http://www.', 'http://', trailingslashit( $page ) ) ) ) {
|
167 |
-
$highlight = true;
|
168 |
-
$current_page = $page;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
if ( count( $targets ) ) {
|
173 |
-
foreach ( $targets as $p => $t ) {
|
174 |
-
$pages = str_replace( '<a href="' . $p . '" ', '<a href="' . $p . '" target="' . $t . '" ', $pages );
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
if ( $highlight ) {
|
179 |
-
$pages = str_replace( ' class="page_item current_page_item"', ' class="page_item"', $pages );
|
180 |
-
$pages = str_replace( '<li class="page_item"><a href="' . $current_page . '"', '<li class="page_item current_page_item"><a href="' . $current_page . '"', $pages );
|
181 |
-
}
|
182 |
-
|
183 |
-
return $pages;
|
184 |
-
}
|
185 |
-
|
186 |
-
function txfx_plt_init() {
|
187 |
-
if ( get_option( 'txfx_plt_schema_version' ) < 3 ) {
|
188 |
-
global $wpdb;
|
189 |
-
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to' WHERE meta_key = 'links_to'" );
|
190 |
-
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to_target' WHERE meta_key = 'links_to_target'" );
|
191 |
-
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to_type' WHERE meta_key = 'links_to_type'" );
|
192 |
-
wp_cache_flush();
|
193 |
-
update_option( 'txfx_plt_schema_version', 3 );
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
add_filter( 'wp_list_pages', 'txfx_page_links_to_highlight_tabs' );
|
198 |
-
add_action( 'template_redirect', 'txfx_redirect_links_to_pages' );
|
199 |
-
add_filter( 'page_link', 'txfx_filter_links_to_pages', 20, 2 );
|
200 |
-
add_filter( 'post_link', 'txfx_filter_links_to_pages', 20, 2 );
|
201 |
-
add_action( 'do_meta_boxes', 'txfx_plt_add_meta_box', 10, 2 );
|
202 |
-
add_action( 'save_post', 'txfx_plt_save_meta_box' );
|
203 |
-
add_action( 'init', 'txfx_plt_init' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/readme.txt
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
=== Plugin Name ===
|
2 |
-
Contributors: markjaquith
|
3 |
-
Donate link: http://txfx.net/code/wordpress/
|
4 |
-
Tags: page, redirect, link, external link, repoint
|
5 |
-
Requires at least: 2.7
|
6 |
-
Tested up to: 2.8
|
7 |
-
Stable tag: trunk
|
8 |
-
|
9 |
-
Page Links To allows you to make a WordPress page or post link to a URL of your choosing, instead of its WordPress post or page.
|
10 |
-
|
11 |
-
== Description ==
|
12 |
-
|
13 |
-
Page Links To is a plugin that allows you to make a WordPress page or post link to a URL of your choosing, instead of its WordPress page or post URL. It also will redirect people who go to the old (or "normal") URL to the new one, using a redirect style of your choosing (`301 Moved Permanently` is standard, but you can enable `302 Moved Temporarily` redirects if you wish.)
|
14 |
-
|
15 |
-
This is useful for setting up navigational links to non-WordPress sections of your site or to off-site resources.
|
16 |
-
|
17 |
-
== Installation ==
|
18 |
-
|
19 |
-
1. Upload the `page-links-to` folder to your `/wp-content/plugins/` directory
|
20 |
-
|
21 |
-
2. Activate the "Page Links To" plugin in your WordPress administration interface
|
22 |
-
|
23 |
-
3. Create (or edit) a page or a post to have a title of your choosing (leave the content blank)
|
24 |
-
|
25 |
-
4. Down below, in the advanced section, find the Page Links To widget and add a URL of your choosing
|
26 |
-
|
27 |
-
5. Optionally check the boxes to enable link opening in a new browser window, or `302 Moved Temporarily` redirects
|
28 |
-
|
29 |
-
6. Save the post or page
|
30 |
-
|
31 |
-
7. Done! Now that post or page will point to the URL that you chose
|
32 |
-
|
33 |
-
== Screenshots ==
|
34 |
-
|
35 |
-
1. The Page Links To meta box in action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/screenshot-1.png
DELETED
Binary file
|