Version Description
- Move Block Editor UI into its own panel.
- Compatibility with Elementor.
- Allow posts to load in the customizer (used by some front-end editing plugins).
- Allow the "open in new tab" functionality to be completely disabled with a filter.
- Make "open in new tab" more reliable.
Download this release
Release Info
Developer | markjaquith |
Plugin | Page Links To |
Version | 3.3.0 |
Comparing to | |
See all releases |
Code changes from version 3.2.2 to 3.3.0
- classes/plugin.php +36 -7
- dist/block-editor.asset.php +1 -1
- dist/block-editor.js +1 -1
- dist/new-tab.asset.php +1 -1
- dist/new-tab.js +1 -1
- page-links-to.php +1 -1
- readme.txt +8 -1
classes/plugin.php
CHANGED
@@ -31,7 +31,7 @@ class CWS_PageLinksTo {
|
|
31 |
const DISMISSED_NOTICES = 'page_links_dismissed_options';
|
32 |
const MESSAGE_ID = 4;
|
33 |
const NEWSLETTER_URL = 'https://pages.convertkit.com/8eb23c1339/1ce4614706';
|
34 |
-
const CSS_JS_VERSION = '3.
|
35 |
|
36 |
/**
|
37 |
* Whether to replace WP links with their specified URLs.
|
@@ -313,7 +313,9 @@ class CWS_PageLinksTo {
|
|
313 |
* @return void
|
314 |
*/
|
315 |
public function wp_enqueue_scripts() {
|
316 |
-
|
|
|
|
|
317 |
}
|
318 |
|
319 |
/**
|
@@ -337,7 +339,12 @@ class CWS_PageLinksTo {
|
|
337 |
public function enqueue_block_editor_assets() {
|
338 |
// Gutenberg.
|
339 |
if ( self::is_block_editor() && self::is_supported_post_type() ) {
|
340 |
-
wp_enqueue_script( 'plt-
|
|
|
|
|
|
|
|
|
|
|
341 |
}
|
342 |
}
|
343 |
|
@@ -521,7 +528,9 @@ class CWS_PageLinksTo {
|
|
521 |
<p><label><input type="radio" id="cws-links-to-choose-custom" name="cws_links_to_choice" value="custom" <?php checked( $linked ); ?> /> <?php _e( 'A custom URL', 'page-links-to' ); ?></label></p>
|
522 |
<div id="cws-links-to-custom-section" class="<?php echo ! $linked ? 'hide-if-js' : ''; ?>">
|
523 |
<p><input placeholder="http://" name="cws_links_to" type="text" id="cws-links-to" value="<?php echo esc_attr( $url ); ?>" /></p>
|
524 |
-
|
|
|
|
|
525 |
<?php do_action( 'page_links_to_meta_box_bottom' ); ?>
|
526 |
</div>
|
527 |
|
@@ -539,6 +548,14 @@ class CWS_PageLinksTo {
|
|
539 |
return $this->save_post( $post_id );
|
540 |
}
|
541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
/**
|
543 |
* Saves data on post save.
|
544 |
*
|
@@ -550,7 +567,7 @@ class CWS_PageLinksTo {
|
|
550 |
if ( ( ! isset( $_POST['cws_links_to_choice'] ) || 'custom' == $_POST['cws_links_to_choice'] ) && isset( $_POST['cws_links_to'] ) && strlen( $_POST['cws_links_to'] ) > 0 && $_POST['cws_links_to'] !== 'http://' ) {
|
551 |
$url = self::clean_url( stripslashes( $_POST['cws_links_to'] ) );
|
552 |
self::set_link( $post_id, $url );
|
553 |
-
if ( isset( $_POST['cws_links_to_new_tab'] ) ) {
|
554 |
self::set_link_new_tab( $post_id );
|
555 |
} else {
|
556 |
self::set_link_same_tab( $post_id );
|
@@ -644,7 +661,7 @@ class CWS_PageLinksTo {
|
|
644 |
if ( $meta_link ) {
|
645 |
$link = apply_filters( 'page_links_to_link', $meta_link, $post, $link );
|
646 |
$link = esc_url( $link );
|
647 |
-
if ( ! is_admin() && ! (defined( 'REST_REQUEST' ) && REST_REQUEST ) && self::get_target( $post->ID ) ) {
|
648 |
$link .= '#new_tab';
|
649 |
}
|
650 |
}
|
@@ -667,6 +684,18 @@ class CWS_PageLinksTo {
|
|
667 |
return $url;
|
668 |
}
|
669 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
670 |
/**
|
671 |
* Performs a redirect.
|
672 |
*
|
@@ -675,7 +704,7 @@ class CWS_PageLinksTo {
|
|
675 |
function template_redirect() {
|
676 |
$link = self::get_redirect();
|
677 |
|
678 |
-
if ( $link ) {
|
679 |
do_action( 'page_links_to_redirect_url', get_queried_object_id(), $link );
|
680 |
wp_redirect( $link, 301 );
|
681 |
exit;
|
31 |
const DISMISSED_NOTICES = 'page_links_dismissed_options';
|
32 |
const MESSAGE_ID = 4;
|
33 |
const NEWSLETTER_URL = 'https://pages.convertkit.com/8eb23c1339/1ce4614706';
|
34 |
+
const CSS_JS_VERSION = '3.3.0';
|
35 |
|
36 |
/**
|
37 |
* Whether to replace WP links with their specified URLs.
|
313 |
* @return void
|
314 |
*/
|
315 |
public function wp_enqueue_scripts() {
|
316 |
+
if ( self::supports( 'new_tab' ) ) {
|
317 |
+
wp_enqueue_script( 'page-links-to', $this->get_url() . 'dist/new-tab.js', array(), self::CSS_JS_VERSION, true );
|
318 |
+
}
|
319 |
}
|
320 |
|
321 |
/**
|
339 |
public function enqueue_block_editor_assets() {
|
340 |
// Gutenberg.
|
341 |
if ( self::is_block_editor() && self::is_supported_post_type() ) {
|
342 |
+
wp_enqueue_script( 'plt-block-editor', $this->get_url() . 'dist/block-editor.js', array( 'wp-edit-post', 'wp-element', 'wp-plugins' ), self::CSS_JS_VERSION, true );
|
343 |
+
wp_localize_script( 'plt-block-editor', 'pltOptions', [
|
344 |
+
'supports' => [
|
345 |
+
'newTab' => self::supports( 'new_tab' ),
|
346 |
+
],
|
347 |
+
]);
|
348 |
}
|
349 |
}
|
350 |
|
528 |
<p><label><input type="radio" id="cws-links-to-choose-custom" name="cws_links_to_choice" value="custom" <?php checked( $linked ); ?> /> <?php _e( 'A custom URL', 'page-links-to' ); ?></label></p>
|
529 |
<div id="cws-links-to-custom-section" class="<?php echo ! $linked ? 'hide-if-js' : ''; ?>">
|
530 |
<p><input placeholder="http://" name="cws_links_to" type="text" id="cws-links-to" value="<?php echo esc_attr( $url ); ?>" /></p>
|
531 |
+
<?php if ( $this->supports('new_tab') ) { ?>
|
532 |
+
<p><label for="cws-links-to-new-tab"><input type="checkbox" name="cws_links_to_new_tab" id="cws-links-to-new-tab" value="_blank" <?php checked( (bool) self::get_target( $post->ID ) ); ?>> <?php _e( 'Open this link in a new tab', 'page-links-to' ); ?></label></p>
|
533 |
+
<?php } ?>
|
534 |
<?php do_action( 'page_links_to_meta_box_bottom' ); ?>
|
535 |
</div>
|
536 |
|
548 |
return $this->save_post( $post_id );
|
549 |
}
|
550 |
|
551 |
+
public static function supports( $feature = '' ) {
|
552 |
+
switch( $feature ) {
|
553 |
+
case 'new_tab':
|
554 |
+
default:
|
555 |
+
return apply_filters( 'page_links_to_supports_' . $feature, true );
|
556 |
+
}
|
557 |
+
}
|
558 |
+
|
559 |
/**
|
560 |
* Saves data on post save.
|
561 |
*
|
567 |
if ( ( ! isset( $_POST['cws_links_to_choice'] ) || 'custom' == $_POST['cws_links_to_choice'] ) && isset( $_POST['cws_links_to'] ) && strlen( $_POST['cws_links_to'] ) > 0 && $_POST['cws_links_to'] !== 'http://' ) {
|
568 |
$url = self::clean_url( stripslashes( $_POST['cws_links_to'] ) );
|
569 |
self::set_link( $post_id, $url );
|
570 |
+
if ( isset( $_POST['cws_links_to_new_tab'] ) && self::supports( 'new_tab' ) ) {
|
571 |
self::set_link_new_tab( $post_id );
|
572 |
} else {
|
573 |
self::set_link_same_tab( $post_id );
|
661 |
if ( $meta_link ) {
|
662 |
$link = apply_filters( 'page_links_to_link', $meta_link, $post, $link );
|
663 |
$link = esc_url( $link );
|
664 |
+
if ( self::supports( 'new_tab' ) && ! is_admin() && ! (defined( 'REST_REQUEST' ) && REST_REQUEST ) && self::get_target( $post->ID ) ) {
|
665 |
$link .= '#new_tab';
|
666 |
}
|
667 |
}
|
684 |
return $url;
|
685 |
}
|
686 |
|
687 |
+
/**
|
688 |
+
* Whether the request has a flag that should halt the redirect.
|
689 |
+
*
|
690 |
+
* @return bool
|
691 |
+
*/
|
692 |
+
function has_non_redirect_flag() {
|
693 |
+
return (
|
694 |
+
isset( $_GET['customize_theme'] ) ||
|
695 |
+
isset( $_GET['elementor-preview'] )
|
696 |
+
);
|
697 |
+
}
|
698 |
+
|
699 |
/**
|
700 |
* Performs a redirect.
|
701 |
*
|
704 |
function template_redirect() {
|
705 |
$link = self::get_redirect();
|
706 |
|
707 |
+
if ( $link && !self::has_non_redirect_flag() ) {
|
708 |
do_action( 'page_links_to_redirect_url', get_queried_object_id(), $link );
|
709 |
wp_redirect( $link, 301 );
|
710 |
exit;
|
dist/block-editor.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins', 'wp-polyfill'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins', 'wp-polyfill'), 'version' => '38c7841f3ee595833041ebb0e30ac5d1');
|
dist/block-editor.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){var t={};function n(
|
1 |
+
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=10)}([function(e,t){!function(){e.exports=this.wp.components}()},function(e,t){!function(){e.exports=this.wp.compose}()},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.wp.editPost}()},function(e,t){!function(){e.exports=this.wp.plugins}()},,,,,function(e,t,n){"use strict";n.r(t);var o=n(0),r=n(1),i=n(2),a=n(3),l=n(4),u=n(5);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var d=function(e){function t(e){var n,o,r,i,a,l;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),o=this,n=!(r=p(t).call(this,e))||"object"!==c(r)&&"function"!=typeof r?f(o):r,i=f(n),l={prevUrl:"",prevNewTab:!1},(a="state")in i?Object.defineProperty(i,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):i[a]=l,n.toggleStatus=n.toggleStatus.bind(f(n)),n.state.enabled=n.hasUrl(),n}var n,i,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(t,e),n=t,(i=[{key:"getUrl",value:function(){return this.props.url||""}},{key:"getDisplayUrl",value:function(){var e=this.state.prevUrl;return this.getUrl()||e}},{key:"hasUrl",value:function(){return this.getUrl().length>0}},{key:"opensInNewTab",value:function(){return this.props.newTab}},{key:"enabled",value:function(){return this.state.enabled}},{key:"toggleStatus",value:function(e){var t=this,n=this.state,o=n.prevUrl,r=n.prevNewTab,i=this.props,a=i.onUpdateLink,l=i.onUpdateNewTab;this.setState((function(n){var o={enabled:e};return n.enabled&&(o.prevUrl=t.getUrl()),o})),e?(a(o),l(r)):(a(null),l(!1),this.setState({prevUrl:this.getUrl(),prevNewTab:this.opensInNewTab()}))}},{key:"updateLink",value:function(e){var t=this.props,n=t.meta;(0,t.onUpdateLink)(n,e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.onUpdateLink,i=t.onUpdateNewTab,a=Object(r.withState)({option:this.enabled()?"custom":"wordpress"})((function(t){var n=t.option,r=t.setState;return React.createElement(o.RadioControl,{label:"Point this content to:",selected:n,options:[{label:"Its normal WordPress URL",value:"wordpress"},{label:"A custom URL",value:"custom"}],onChange:function(t){r({option:t}),e.toggleStatus("custom"===t)}})}));return React.createElement(l.PluginDocumentSettingPanel,{title:"Page Links To",name:"PageLinksTo",icon:this.enabled()?"admin-links":"disabled",className:"plt-panel"},React.createElement(o.PanelRow,null,React.createElement(a,null)),this.enabled()&&React.createElement(React.Fragment,null,React.createElement(o.PanelRow,null,React.createElement(o.TextControl,{label:"Links to","data-testid":"plt-url",value:this.getDisplayUrl(),onChange:n,placeholder:"https://"})),window.pltOptions.supports.newTab&&React.createElement(o.PanelRow,null,React.createElement(o.CheckboxControl,{label:"Open in new tab","data-testid":"plt-newtab",checked:this.opensInNewTab(),onChange:i}))))}}])&&s(n.prototype,i),a&&s(n,a),t}(a.Component),h=Object(r.compose)([Object(i.withSelect)((function(e){var t=function(t){return(e("core/editor").getEditedPostAttribute("meta")||[])[t]};return{url:t("_links_to"),newTab:"_blank"===t("_links_to_target")}})),Object(i.withDispatch)((function(e){return{onUpdateLink:function(t){e("core/editor").editPost({meta:{_links_to:t}})},onUpdateNewTab:function(t){e("core/editor").editPost({meta:{_links_to_target:t?"_blank":""}})}}})),r.withInstanceId])(d);Object(u.registerPlugin)("page-links-to",{render:h})}]);
|
dist/new-tab.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'aa558cd385761d6ec13ab44d6774c409');
|
dist/new-tab.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=
|
1 |
+
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=11)}({11:function(e,t,r){"use strict";r.r(t);var n=function(e){var t=/#new_tab$/;"A"===e.tagName&&t.test(e.getAttribute("href"))&&(e.setAttribute("target","_blank"),e.setAttribute("href",e.getAttribute("href").replace(t,"")))},o=function(e){return n(e.target.closest("a"))},u=function(){for(var e=document.getElementsByTagName("A"),t=0;t<e.length;t++)n(e[t])};document.addEventListener("click",o),document.addEventListener("DOMContentLoaded",u)}});
|
page-links-to.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Plugin Name: Page Links To
|
8 |
* Plugin URI: http://txfx.net/wordpress-plugins/page-links-to/
|
9 |
* 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.
|
10 |
-
* Version: 3.
|
11 |
* Author: Mark Jaquith
|
12 |
* Author URI: https://coveredweb.com/
|
13 |
* Text Domain: page-links-to
|
7 |
* Plugin Name: Page Links To
|
8 |
* Plugin URI: http://txfx.net/wordpress-plugins/page-links-to/
|
9 |
* 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.
|
10 |
+
* Version: 3.3.0
|
11 |
* Author: Mark Jaquith
|
12 |
* Author URI: https://coveredweb.com/
|
13 |
* Text Domain: page-links-to
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: https://txfx.net/wordpress-plugins/donate
|
|
5 |
Tags: page, redirect, link, external link, repoint
|
6 |
Requires at least: 4.8
|
7 |
Tested up to: 5.4
|
8 |
-
Stable tag: 3.
|
9 |
|
10 |
Lets you make a WordPress page (or port or other content type) link to a URL of your choosing (on your site, or on another site), instead of its normal WordPress URL.
|
11 |
|
@@ -77,6 +77,13 @@ You can contribute (or report bugs) on [Github](https://github.com/markjaquith/p
|
|
77 |
|
78 |
== Changelog ==
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
= 3.2.2 =
|
81 |
* Bug fixes
|
82 |
* Better compat with custom post types in the Block Editor
|
5 |
Tags: page, redirect, link, external link, repoint
|
6 |
Requires at least: 4.8
|
7 |
Tested up to: 5.4
|
8 |
+
Stable tag: 3.3.0
|
9 |
|
10 |
Lets you make a WordPress page (or port or other content type) link to a URL of your choosing (on your site, or on another site), instead of its normal WordPress URL.
|
11 |
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
+
= 3.3.0 =
|
81 |
+
* Move Block Editor UI into its own panel.
|
82 |
+
* Compatibility with Elementor.
|
83 |
+
* Allow posts to load in the customizer (used by some front-end editing plugins).
|
84 |
+
* Allow the "open in new tab" functionality to be completely disabled with a filter.
|
85 |
+
* Make "open in new tab" more reliable.
|
86 |
+
|
87 |
= 3.2.2 =
|
88 |
* Bug fixes
|
89 |
* Better compat with custom post types in the Block Editor
|