Version Description
Download this release
Release Info
| Developer | markjaquith |
| Plugin | |
| Version | 1.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.6 to 1.7
- page-links-to.php +38 -19
- readme.txt +18 -10
- 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 |
*/
|
|
@@ -32,7 +32,7 @@ function txfx_get_page_links_to_meta () {
|
|
| 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 = '
|
| 36 |
} else {
|
| 37 |
return $page_links_to_cache;
|
| 38 |
}
|
|
@@ -42,9 +42,8 @@ function txfx_get_page_links_to_meta () {
|
|
| 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 |
|
| 49 |
return $page_links_to_cache;
|
| 50 |
}
|
|
@@ -56,7 +55,7 @@ function txfx_get_page_links_to_targets () {
|
|
| 56 |
$links_to = $wpdb->get_results(
|
| 57 |
"SELECT post_id, meta_value " .
|
| 58 |
"FROM $wpdb->postmeta, $wpdb->posts " .
|
| 59 |
-
"WHERE post_id = ID AND meta_key = '
|
| 60 |
} else {
|
| 61 |
return $page_links_to_target_cache;
|
| 62 |
}
|
|
@@ -80,19 +79,28 @@ function txfx_plt_add_meta_box( $page, $context ) {
|
|
| 80 |
|
| 81 |
function txfx_plt_meta_box() {
|
| 82 |
global $post;
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
}
|
| 92 |
|
| 93 |
function txfx_plt_save_meta_box( $post_ID ) {
|
| 94 |
-
if ( wp_verify_nonce( $_REQUEST['_txfx_pl2_nonce'], 'txfx_plt' ) && isset( $_POST['txfx_links_to'] ) && strlen( $_POST['txfx_links_to'] ) > 7 )
|
| 95 |
-
update_post_meta( $post_ID, '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
return $post_ID;
|
| 97 |
}
|
| 98 |
|
|
@@ -115,12 +123,12 @@ function txfx_redirect_links_to_pages() {
|
|
| 115 |
|
| 116 |
global $wp_query;
|
| 117 |
|
| 118 |
-
$link = get_post_meta( $wp_query->post->ID, '
|
| 119 |
|
| 120 |
if ( !$link )
|
| 121 |
return;
|
| 122 |
|
| 123 |
-
$redirect_type = get_post_meta( $wp_query->post->ID, '
|
| 124 |
|
| 125 |
if ( $redirect_type && $redirect_type != '302' ) {
|
| 126 |
// Only supporting 301 and 302 for now.
|
|
@@ -171,10 +179,21 @@ function txfx_page_links_to_highlight_tabs( $pages ) {
|
|
| 171 |
return $pages;
|
| 172 |
}
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
add_filter( 'wp_list_pages', 'txfx_page_links_to_highlight_tabs' );
|
| 175 |
add_action( 'template_redirect', 'txfx_redirect_links_to_pages' );
|
| 176 |
add_filter( 'page_link', 'txfx_filter_links_to_pages', 20, 2 );
|
| 177 |
add_filter( 'post_link', 'txfx_filter_links_to_pages', 20, 2 );
|
| 178 |
add_action( 'do_meta_boxes', 'txfx_plt_add_meta_box', 10, 2 );
|
| 179 |
-
add_action( '
|
| 180 |
-
|
| 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
|
| 7 |
Author: Mark Jaquith
|
| 8 |
Author URI: http://coveredwebservices.com/
|
| 9 |
*/
|
| 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 |
}
|
| 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 |
}
|
| 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 |
}
|
| 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' ) && isset( $_POST['txfx_links_to'] ) && strlen( $_POST['txfx_links_to'] ) > 7 ) {
|
| 94 |
+
update_post_meta( $post_ID, '_links_to', $_POST['txfx_links_to'] );
|
| 95 |
+
if ( isset( $_POST['txfx_links_to_new_window'] ) )
|
| 96 |
+
update_post_meta( $post_ID, '_links_to_target', '_blank' );
|
| 97 |
+
else
|
| 98 |
+
delete_post_meta( $post_ID, '_links_to_target' );
|
| 99 |
+
if ( isset( $_POST['txfx_links_to_302'] ) )
|
| 100 |
+
update_post_meta( $post_ID, '_links_to_type', '302' );
|
| 101 |
+
else
|
| 102 |
+
delete_post_meta( $post_ID, '_links_to_type' );
|
| 103 |
+
}
|
| 104 |
return $post_ID;
|
| 105 |
}
|
| 106 |
|
| 123 |
|
| 124 |
global $wp_query;
|
| 125 |
|
| 126 |
+
$link = get_post_meta( $wp_query->post->ID, '_links_to', true );
|
| 127 |
|
| 128 |
if ( !$link )
|
| 129 |
return;
|
| 130 |
|
| 131 |
+
$redirect_type = get_post_meta( $wp_query->post->ID, '_links_to_type', true );
|
| 132 |
|
| 133 |
if ( $redirect_type && $redirect_type != '302' ) {
|
| 134 |
// Only supporting 301 and 302 for now.
|
| 179 |
return $pages;
|
| 180 |
}
|
| 181 |
|
| 182 |
+
function txfx_plt_init() {
|
| 183 |
+
if ( get_option( 'txfx_plt_schema_version' ) < 3 ) {
|
| 184 |
+
global $wpdb;
|
| 185 |
+
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to' WHERE meta_key = 'links_to'" );
|
| 186 |
+
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to_target' WHERE meta_key = 'links_to_target'" );
|
| 187 |
+
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to_type' WHERE meta_key = 'links_to_type'" );
|
| 188 |
+
wp_cache_flush();
|
| 189 |
+
update_option( 'txfx_plt_schema_version', 3 );
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
add_filter( 'wp_list_pages', 'txfx_page_links_to_highlight_tabs' );
|
| 194 |
add_action( 'template_redirect', 'txfx_redirect_links_to_pages' );
|
| 195 |
add_filter( 'page_link', 'txfx_filter_links_to_pages', 20, 2 );
|
| 196 |
add_filter( 'post_link', 'txfx_filter_links_to_pages', 20, 2 );
|
| 197 |
add_action( 'do_meta_boxes', 'txfx_plt_add_meta_box', 10, 2 );
|
| 198 |
+
add_action( 'save_post', 'txfx_plt_save_meta_box' );
|
| 199 |
+
add_action( 'init', 'txfx_plt_init' );
|
readme.txt
CHANGED
|
@@ -1,27 +1,35 @@
|
|
| 1 |
=== Plugin Name ===
|
| 2 |
Contributors: markjaquith
|
| 3 |
Donate link: http://txfx.net/code/wordpress/
|
| 4 |
-
Tags:
|
| 5 |
-
Requires at least: 2.
|
| 6 |
-
Tested up to: 2.
|
| 7 |
Stable tag: trunk
|
| 8 |
|
| 9 |
-
Page Links To allows you to make
|
| 10 |
|
| 11 |
== Description ==
|
| 12 |
|
| 13 |
-
Page Links To is a plugin that allows you to make
|
|
|
|
|
|
|
| 14 |
|
| 15 |
== Installation ==
|
| 16 |
|
| 17 |
-
1. Upload `page-links-to
|
| 18 |
|
| 19 |
2. Activate the "Page Links To" plugin in your WordPress administration interface
|
| 20 |
|
| 21 |
-
3. Create (or edit) a page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 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 their WordPress post or page.
|
| 10 |
|
| 11 |
== Description ==
|
| 12 |
|
| 13 |
+
Page Links To is a plugin that allows you to make a WordPress pages or posts link to a URL of your choosing, instead of their 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
|
screenshot-1.png
ADDED
|
Binary file
|
