markjaquith / page-links-to

#WordPressPlugin: Lets you make a WordPress page (or other content type) link to an external URL of your choosing, instead of its WordPress URL.
GNU General Public License v2.0
110 stars 46 forks source link

Error when posting page #76

Open pcdoc2010 opened 5 years ago

pcdoc2010 commented 5 years ago

When posting on WP 5.2, I get this error: TypeError: Cannot read property '_links_to' of undefined at LinksTo.getUrl (http://ask/wp-content/plugins/page-links-to/js/gutenberg.min.js?ver=3.1.1:53:27) at LinksTo.getDisplayUrl (http://ask/wp-content/plugins/page-links-to/js/gutenberg.min.js?ver=3.1.1:60:16) at LinksTo.render (http://ask/wp-content/plugins/page-links-to/js/gutenberg.min.js?ver=3.1.1:162:20) at ce (http://ask/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.8.4:98:136) at qg (http://ask/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.8.4:97:440) at hi (http://ask/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.8.4:104:285) at Qg (http://ask/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.8.4:144:217) at Rg (http://ask/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.8.4:145:76) at Sc (http://ask/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.8.4:158:109) at Z (http://ask/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.8.4:156:492)

hazuremon commented 5 years ago

Came across this same error on custom post type where the post cannot create new custom permalink or update existing permalink. For existing custom permalinks, the option was not selected nor the custom link was in the input box.

Was running Page Links To 3.1.1 with WP Version 5.2.1

Currently able to add/update permalink by downgrading the plugin back to 3.0.1

hazuremon commented 5 years ago

Just test it with latest version of Page Links To v3.1.2, but still experiencing the same error with custom post type.

TypeError: Cannot read property '_links_to' of undefined at LinksTo.getUrl (https://[URL]/wp-content/plugins/page-links-to/js/gutenberg.min.js?ver=3.1.2:53:27) at LinksTo.getDisplayUrl (https://[URL]/wp-content/plugins/page-links-to/js/gutenberg.min.js?ver=3.1.2:60:16) at LinksTo.render (https://[URL]/wp-content/plugins/page-links-to/js/gutenberg.min.js?ver=3.1.2:162:20) at ce (https://[URL]/wp-content/plugins/gutenberg/vendor/react-dom.min.js:98:136) at qg (https://[URL]/wp-content/plugins/gutenberg/vendor/react-dom.min.js:97:440) at hi (https://[URL]/wp-content/plugins/gutenberg/vendor/react-dom.min.js:104:285) at Qg (https://[URL]/wp-content/plugins/gutenberg/vendor/react-dom.min.js:144:217) at Rg (https://[URL]/wp-content/plugins/gutenberg/vendor/react-dom.min.js:145:76) at Sc (https://[URL]/wp-content/plugins/gutenberg/vendor/react-dom.min.js:158:109) at Z (https://[URL]/wp-content/plugins/gutenberg/vendor/react-dom.min.js:156:492)

srdesigns commented 5 years ago

Having same issue myself - @hazuremon by chance are you using Elementor or Jupiter X as the theme? Trying to identify if the theme or that plugin are the cause as there is another bug listed saying Elementor has an issue.

hazuremon commented 5 years ago

Having same issue myself - @hazuremon by chance are you using Elementor or Jupiter X as the theme? Trying to identify if the theme or that plugin are the cause as there is another bug listed saying Elementor has an issue.

No, I am on a custom theme.

hazuremon commented 5 years ago

The latest v3.1.2 allows creating and updating of custom permalink on custom post type, but the option checkbox is still not selected nor display the custom link after update.

WP 5.2.2 Page Links To 3.1.2

ed-richards commented 5 years ago

I'm also experiencing this issue. Adding or editing custom links on Pages works without a problem but on all custom post types, the editor brings up the following message after trying to Publish/Update with a custom link:

Screenshot 2019-09-04 at 15 16 59

The error itself is the same as pcdoc2010 originally posted.

For now I've downgraded to 3.0.1 which resolves the problems but it would be great to see a fix soon! 👍

WordPress 5.2.2 Page Links To 3.1.1 (also tested 3.1.2)

roryashfordbentley commented 5 years ago

@ed-richards I have also just noticed its specific to Custom Post Type posts. Could it possibly be down to they way the post type has been setup?

Here is my config if it helps at all:

    $post_type_name = "library";
    $single_name    = "Library Document";
    $plural_name    = "Library";
    $description    = "";
    $icon           = "dashicons-format-aside";

    $post_type_options = array(
        'label'                 => $single_name,
        'description'           => $description,
        'public'                => true,
        'menu_icon'             => $icon,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'capability_type'       => 'post',
        'rewrite'               => array(
            'slug'                 => '',
            'with_front'           => false
        ),
        'query_var'             => true,
        'has_archive'           => false,
        'supports'              => array(
            'title',
            'revisions',
            'excerpt',
            'editor',
            'thumbnail',
            'page-attributes',
        ),
        'labels'                => array(
            'name'                  => $plural_name,
            'singular_name'         => $single_name,
            'menu_name'             => $plural_name,
            'add_new'               => 'Add ' . $single_name,
            'add_new_item'          => 'Add New ' . $single_name . ' item',
            'edit'                  => 'Edit',
            'edit_item'             => 'Edit ' . $single_name,
            'new_item'              => 'New '. $single_name,
            'view'                  => 'View '. $single_name,
            'view_item'             => 'View '. $single_name . ' item',
            'search_items'          => 'Search ' . $plural_name,
            'not_found'             => 'No '. $single_name . ' Found',
            'not_found_in_trash'    => 'No '. $plural_name .' Found in Trash',
            'parent'                => 'Parent '. $single_name
        ),
    );
    register_post_type($post_type_name, $post_type_options);
rodrigo-arias commented 5 years ago

Same issue here. It seems that the error happens in custom post types and using Gutenberg. Maybe there is some necessary setting in the register post type to avoid the error @markjaquith? Thanks

hazuremon commented 4 years ago

With the latest Page Links To version: 3.2.1

Still having issue where the entered permalink did not get save nor display in the Custom Permalink box in custom post type. There is no error message though, with the latest update.

WP: 5.3

markjaquith commented 4 years ago

Can you all please try version 3.2.2? I made some changes to the custom post type handling to fix this.

Basically the issue is that if you don't register your post type with right type of support, it can't save post meta via the REST API which is required with Gutenberg.

I made a change to "on the fly" add support for post meta if necessary.

earwickerh commented 4 years ago

Hi @markjaquith, I'm still having this issue with custom post types not allowing me to save a custom link on version 3.3.2. It's only custom post types though, everything else works. In your most recent comment you said " if you don't register your post type with right type of support, it can't save post meta via the REST API ". I tried activating all the types of supports to no avail. I noticed that weirdly if i explicitly set all supports as false in CPT UI, it works... (but this disables the editor and makes it unusable of course) . I'll keep testing, hope we can find a solution. Thanks!

rodrigo-arias commented 4 years ago

Hi @markjaquith I have tried with version 3.3.3 and indeed the issue is no longer there. I do not receive any error. However, I have fallen into this #102. Everything works in the classic editor or in Gutenberg in pages and posts, but I cannot save the redirection URLs in my CPTs. I have tried enabling show_in_rest and making sure of the editor support but that did not work. Thanks

edvinkuric commented 4 years ago

Hey @markjaquith, i have the same issue like @rodrigo-arias - i cannot save custom-urls on CPTs with Gutenberg-editor, using the "show_in_rest"-flag and "editor"-support when registering the CPT. The same behvaiour is given when adding new posts as well as editing existing posts (CPT).

Tested with plugin-version 3.3.3 and current WP.

If you need help fixing this issue, i can maybe take a look - just let me know where i can start looking at @markjaquith

Thank you very much :-)