Version Description
- Block Editor bugfixes
Download this release
Release Info
| Developer | markjaquith |
| Plugin | |
| Version | 3.1.1 |
| Comparing to | |
| See all releases | |
Code changes from version 3.1.0 to 3.1.1
- classes/plugin.php +33 -4
- page-links-to.php +1 -1
- readme.txt +4 -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.1.
|
| 35 |
|
| 36 |
/**
|
| 37 |
* Whether to replace WP links with their specified URLs.
|
|
@@ -173,6 +173,9 @@ class CWS_PageLinksTo {
|
|
| 173 |
$this->hook( 'admin_enqueue_scripts' );
|
| 174 |
$this->hook( 'admin_menu' );
|
| 175 |
|
|
|
|
|
|
|
|
|
|
| 176 |
// Page row actions.
|
| 177 |
$this->hook( 'page_row_actions' );
|
| 178 |
$this->hook( 'post_row_actions', 'page_row_actions' );
|
|
@@ -192,6 +195,26 @@ class CWS_PageLinksTo {
|
|
| 192 |
}
|
| 193 |
}
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
/**
|
| 196 |
* Registers a post meta key for a given post type.
|
| 197 |
*
|
|
@@ -204,7 +227,7 @@ class CWS_PageLinksTo {
|
|
| 204 |
'post',
|
| 205 |
$key,
|
| 206 |
array(
|
| 207 |
-
'
|
| 208 |
'type' => 'string',
|
| 209 |
'single' => true,
|
| 210 |
'show_in_rest' => true,
|
|
@@ -289,7 +312,9 @@ class CWS_PageLinksTo {
|
|
| 289 |
}
|
| 290 |
|
| 291 |
// Gutenberg.
|
| 292 |
-
|
|
|
|
|
|
|
| 293 |
}
|
| 294 |
|
| 295 |
/**
|
|
@@ -424,7 +449,11 @@ class CWS_PageLinksTo {
|
|
| 424 |
* @param string $type The post type to check.
|
| 425 |
* @return bool Whether this post type supports custom links.
|
| 426 |
*/
|
| 427 |
-
public static function is_supported_post_type( $type ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
if ( is_object( $type ) ) {
|
| 429 |
if ( isset( $type->id ) ) {
|
| 430 |
$type = $type->id;
|
| 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.1.1';
|
| 35 |
|
| 36 |
/**
|
| 37 |
* Whether to replace WP links with their specified URLs.
|
| 173 |
$this->hook( 'admin_enqueue_scripts' );
|
| 174 |
$this->hook( 'admin_menu' );
|
| 175 |
|
| 176 |
+
// Gutenberg.
|
| 177 |
+
$this->hook( 'use_block_editor_for_post', 99999 );
|
| 178 |
+
|
| 179 |
// Page row actions.
|
| 180 |
$this->hook( 'page_row_actions' );
|
| 181 |
$this->hook( 'post_row_actions', 'page_row_actions' );
|
| 195 |
}
|
| 196 |
}
|
| 197 |
|
| 198 |
+
/**
|
| 199 |
+
* Checks if the specified post is going to use the block editor, and adds custom-fields support.
|
| 200 |
+
*
|
| 201 |
+
* We have to do this because PLT requires custom-fields support to update post meta in the block editor.
|
| 202 |
+
* So if you add a custom post type without 'custom-fields' support, you'll get an error.
|
| 203 |
+
* We check that this post is going to use the block editor, and that its post type supports the block editor,
|
| 204 |
+
* and only then do we add 'custom-fields' support for the post type.
|
| 205 |
+
*
|
| 206 |
+
* @param boolean $use_block_editor Whether they are going to use the block editor for this post.
|
| 207 |
+
* @param WP_Post $post The post they are editing.
|
| 208 |
+
* @return boolean We return the original value of their decision.
|
| 209 |
+
*/
|
| 210 |
+
public function use_block_editor_for_post( $use_block_editor, $post ) {
|
| 211 |
+
if ( $use_block_editor && self::is_supported_post_type( get_post_type( $post ) ) ) {
|
| 212 |
+
add_post_type_support( get_post_type( $post ), 'custom-fields' );
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
return $use_block_editor;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
/**
|
| 219 |
* Registers a post meta key for a given post type.
|
| 220 |
*
|
| 227 |
'post',
|
| 228 |
$key,
|
| 229 |
array(
|
| 230 |
+
'object_subtype' => $post_type,
|
| 231 |
'type' => 'string',
|
| 232 |
'single' => true,
|
| 233 |
'show_in_rest' => true,
|
| 312 |
}
|
| 313 |
|
| 314 |
// Gutenberg.
|
| 315 |
+
if ( self::is_block_editor() && self::is_supported_post_type() ) {
|
| 316 |
+
wp_enqueue_script( 'plt-gutenberg', $this->get_url() . 'js/gutenberg.min.js', array( 'wp-edit-post', 'wp-element', 'wp-plugins' ), self::CSS_JS_VERSION, true );
|
| 317 |
+
}
|
| 318 |
}
|
| 319 |
|
| 320 |
/**
|
| 449 |
* @param string $type The post type to check.
|
| 450 |
* @return bool Whether this post type supports custom links.
|
| 451 |
*/
|
| 452 |
+
public static function is_supported_post_type( $type = null ) {
|
| 453 |
+
if ( is_null( $type ) ) {
|
| 454 |
+
$type = get_post_type();
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
if ( is_object( $type ) ) {
|
| 458 |
if ( isset( $type->id ) ) {
|
| 459 |
$type = $type->id;
|
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.1.
|
| 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.1.1
|
| 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: http://txfx.net/wordpress-plugins/donate
|
|
| 5 |
Tags: page, redirect, link, external link, repoint
|
| 6 |
Requires at least: 4.8
|
| 7 |
Tested up to: 5.2
|
| 8 |
-
Stable tag: 3.1.
|
| 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,9 @@ You can contribute (or report bugs) on [Github](https://github.com/markjaquith/p
|
|
| 77 |
|
| 78 |
== Changelog ==
|
| 79 |
|
|
|
|
|
|
|
|
|
|
| 80 |
= 3.1.0 =
|
| 81 |
* Support for the Block Editor (Gutenberg)
|
| 82 |
|
| 5 |
Tags: page, redirect, link, external link, repoint
|
| 6 |
Requires at least: 4.8
|
| 7 |
Tested up to: 5.2
|
| 8 |
+
Stable tag: 3.1.1
|
| 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.1.1 =
|
| 81 |
+
* Block Editor bugfixes
|
| 82 |
+
|
| 83 |
= 3.1.0 =
|
| 84 |
* Support for the Block Editor (Gutenberg)
|
| 85 |
|
