Cornerstone does not allow menus to be built dynamically

I have an application where I want users to be able to put new pages into the menu without giving
When trying to building or update nav menus dynamically wp_update_nav_menu_item using I get a
“Are you sure you want to do this?”
Which is blocking my code.( and not telling me where it comes from!).
By disabling my plugins one by one I have localized it to Cornerstone.
Do you know any workaround, or can you tell me where in your code the block is happening, or give me any other cluse.

Hi there,

Thanks for writing in.

There is a parse error originating from your oelejr plugin and can’t login due to that. Please fix that first, that error isn’t related to cornerstone. Then please provide your FTP login credentials as well so I could trace the error related to the menu and cornerstone.

Thanks!

Hi Rad,
Thanks for reply
Sorry for the errors.
What I want to do is to make a my menu structure follow my page structure, so when I update the page structure I want to update the menus.
The function I try to use and which does not work with Cornerstone is called:
wp_update_nav_menu_item
I have tried to solve it using a plugin that is called Auto Menu From Pages.


The plugin cannot activate if conrerstone is activated. (so it is an easy thing for you to test.)

Then I deactivated cornerstone and then I could install the plugin, so YES there is a problem with Cornerstone.
And it is now easier to demonstrate the error
Unforturnatly the plugin does not work for me…

Best regards

oleviolin

HI there

I have found the bug, and some solutions. First with this ugly HACK: (which I enclose so you can see the problem area in the cornerstone code

Commenting out line 96 in
/wp-content/plugins/cornerstone/includes/menu-item-custom-fields/menu-item-custom-fields-map.php

This is a better option (to put in my own code):

<form method="post" >	

<input type="submit" value="Update Menus"  />
<?php wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ) ?>

</form>

I appreciate if you do something about this issue. I have used quite some time to verify it. Other people should know about, maybe you can even fix it.

I could suggeest

  1. Update your coding guidlines with the following: never put a “NONCE” directly on standard WP-functions And make an update of Cornerstone accordingly
  2. Put the above solution as FAQ somehwere in your support forum that does not get erased after 10 days

Number 2 is easiest, number 1 is prefered,
I have been working with support and I know that if one guy finds something the next week there will be 10 guys finding the same thing.

best regards
oleviolin

Thanks for reporting. I’ll post this to our issue tracker so our development team could be made aware once they go through the list of reports.

Thank you very much.

You’re welcome! :slight_smile:

Thanks for brining this up. I’ve looked into this and can confirm the problem. Here’s the change I made for this update:

public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {

    if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ! isset( $_POST['update-nav-menu-nonce'])) {
      return;
    }

   check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );

   ...

With this method it will only try to proceed if the nonce is present in the request, otherwise it leaves silently.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.