Comments (4)
Hey y'all. I have an issues/gutenberg
branch that I'm using to track Gutenberg stuff. Thanks for the notice head start, @dhuyck!
Right now, both the meta box, and the new Gutenberg powered UI are active.
The toggle for the Gutenberg UI is currently broken, so this is very much a work-in-progress.
from page-links-to.
As a quick patch, I added these three lines to my downloaded version of the plugin in the is_supported_post_type()
method (added as lines 380-382):
if ( is_object( $type ) ) {
$type = $type->id;
}
This will show the metabox properly, but there would be additional work to make the ajax/React code update the notices properly in Gutenberg.
from page-links-to.
I did a little further work to make admin notices work in WP5+. It's a little raw and optimized to our installation (where we can assume browser up-to-date-ness), but it's working. I have updated the notify_of_external_link()
function like so:
/**
* Outputs a notice that the current post item is pointed to a custom URL.
*
* @return void
*/
public static function notify_of_external_link() {
?>
<div class="notice updated" id="page-links-to-notice"><p><?php _e( '<strong>Note</strong>: This content is pointing to a custom URL. Use the “Page Links To” box to change this behavior.', 'page-links-to' ); ?></p></div>
<?php
// verify we are using WP5+ and the block editor before generating our own block editor (Gutenberg) admin notices
global $current_screen;
if ( ! isset( $current_screen ) ) {
$current_screen = get_current_screen();
}
$is_admin_user = ( current_user_can( 'administrator' ) ) ? 'true' : 'false';
if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
?>
<script>
document.addEventListener('DOMContentLoaded', function (event) {
const isAdminUser = <?php echo $is_admin_user; ?>;
if (isAdminUser) console.log('page-links-to: DOM loaded');
if (wp.data !== undefined) {
const pltNoticesHandle = 'page-links-to-notice';
const pltNotices = document.querySelector('#' + pltNoticesHandle);
const cleanupNoticeContent = function (contentObj) {
const dismissButton = document.querySelector('#' + pltNoticesHandle + ' button.notice-dismiss');
if (dismissButton) {
contentObj.removeChild(dismissButton);
}
return contentObj.innerText; // only allows plaintext at this time
};
const pltNoticeContent = cleanupNoticeContent(pltNotices);
if (pltNotices.classList.contains('notice-error')) {
if (isAdminUser) console.log('page-links-to: error notice added');
wp.data.dispatch('core/notices').createErrorNotice(pltNoticeContent, {isDismissible: true, id: pltNoticesHandle});
} else if (pltNotices.classList.contains('notice-warning')) {
if (isAdminUser) console.log('page-links-to: warning notice added');
wp.data.dispatch('core/notices').createWarningNotice(pltNoticeContent, {isDismissible: true, id: pltNoticesHandle});
} else if (pltNotices.classList.contains('notice')) {
if (isAdminUser) console.log('page-links-to: info notice added');
wp.data.dispatch('core/notices').createInfoNotice(pltNoticeContent, {isDismissible: true, id: pltNoticesHandle});
}
}
});
</script>
<?php
}
}
from page-links-to.
Glad I could contribute! We love the single-purpose-ness of the plugin, and it gracefully solves a need we have in our multisite deployment. We have distributed admin users across our college campus, and a simple, intuitive UI like this one means fewer training hours for our departmental admins and other frequent editors. I look forward to upgrading to a fully-gutenbergged version instead of my hacked and patched version!
from page-links-to.
Related Issues (20)
- Target blank doesn't work on posts loaded via AJAX
- Could not rechange link HOT 1
- All cpt entries automatically set to redirect HOT 2
- Delay before redirect
- Option to disable for custom post types? HOT 1
- Target Blank (Open in new window not working) HOT 2
- Link attributes HOT 1
- "Open this link in a new tab" not working HOT 4
- Use http instead of https
- Javascript File called for Every Page when viewed by Visitor HOT 1
- Deprecation notice in block editor for block-editor.js
- Jetpack Search returning wrong URL (3.3.6)
- Usage of discouraged functions
- Please update Plugin HOT 4
- Updating failed. Sorry, you are not allowed to edit the _links_to custom field
- Open Link in New Tab not working for all media like PDFs and on some URLs HOT 2
- Open link in new tab not working
- Consider supporting only publicly queryable post types by default
- Untranslatable strings
- Add PHP plugin headers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from page-links-to.