Title: add_submenu_page debugging
Last modified: November 16, 2019

---

# add_submenu_page debugging

 *  Resolved [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/)
 * Hello!
 * I am a fellow WordPress developer and have noticed an error being logged caused
   by this plugin’s `Ch_Th_Gen_Admin::create_menu()` code.
 * In `/wp-content/plugins/child-theme-generator/admin`, line 122, a dashicons icon
   name is provided as a seventh parameter in the `add_submenu_page()` call. Because
   of this, the menu priority is not the seventh/last parameter.
 * A submenu page does not take an icon as a parameter like a toplevel admin page:
   [https://developer.wordpress.org/reference/functions/add_submenu_page/](https://developer.wordpress.org/reference/functions/add_submenu_page/)
 * Here is the debug notice that gets displayed from this:
    `Notice: add_submenu_page
   was called incorrectly. The seventh parameter passed to add_submenu_page() should
   be an integer representing menu position. Please see Debugging in WordPress for
   more information. (This message was added in version 5.3.0.) in /var/www/html/
   wp-includes/functions.php on line 4903`
 * Have a nice day!
 * Michelle

Viewing 15 replies - 1 through 15 (of 25 total)

1 [2](https://wordpress.org/support/topic/add_submenu_page-debugging/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/add_submenu_page-debugging/page/2/?output_format=md)

 *  Plugin Author [Serafino](https://wordpress.org/support/users/seraph63/)
 * (@seraph63)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12146555)
 * Hi Michelle,
    thank you for error reporting, I have fixed and the issue would
   be solved.
 * If you would check and let me know.
 * Thanks & Regards
 *  Thread Starter [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12146665)
 * Hello Serafino,
 * The error is still there and I do not see any changes to that function in the
   code. Did you not commit your changes?
 * All you need to do is delete line 122: [https://plugins.trac.wordpress.org/browser/child-theme-generator/tags/2.2.4/admin/class-child-theme-generator-admin.php#L122](https://plugins.trac.wordpress.org/browser/child-theme-generator/tags/2.2.4/admin/class-child-theme-generator-admin.php#L122)
 * Also, the changelog says v2.1.4, but the downloaded and most recent version on
   here is tagged 2.2.4.
 *  Plugin Author [Serafino](https://wordpress.org/support/users/seraph63/)
 * (@seraph63)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12147130)
 * Changes was made only in trunk folder, sorry.
    Tags/2.2.4 now is updated, please
   check.
 *  Thread Starter [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12151516)
 * Great! I see the change and have updated the plugin. The error is now gone.
 * Thank you for the super quick fix and great plugin! Cheers!
 *  [juliesuccess](https://wordpress.org/support/users/juliesuccess/)
 * (@juliesuccess)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12152268)
 * Hi Michelle [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/),
   
   I’m newer to WordPress Development. Can you tell me how you found out which plugin
   was the problem? I have the exact error: Notice: add_submenu_page was called 
   incorrectly. The seventh parameter passed to add_submenu_page() should be an 
   integer representing menu position. Please see Debugging in WordPress for more
   information. (This message was added in version 5.3.0.) in /var/www/html/wp-includes/
   functions.php on line 4903 but I don’t have this plugin. Any help would be appreciated!
   Thanks!
 *  Thread Starter [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12156115)
 * Hello [@juliesuccess](https://wordpress.org/support/users/juliesuccess/) . Thank
   you for asking because this is probably a common issue since upgrading to WP 
   5.3.0 for some people.
    ……………………………………..
 * After upgrading to WordPress 5.3.0, you may notice this error notice that was
   added:
 *     ```
       Notice: add_submenu_page was called incorrectly. The seventh parameter passed to add_submenu_page() should be an integer representing menu position. Please see Debugging in WordPress for more information. (This message was added in version 5.3.0.) in /var/www/html/wp-includes/functions.php on line 4903
       ```
   
 * To find out where the code is that’s originally causing the error, we can review
   the stacktrace of execution. PHP’s `debug_backtrace` is the function to call 
   to review part of the stacktrace, [https://www.php.net/manual/en/function.debug-backtrace.php](https://www.php.net/manual/en/function.debug-backtrace.php).
 * The error notice tells us where we should put this code: `/var/www/html/wp-includes/
   functions.php on line 4903`
 * That line looks like this:
    `trigger_error( sprintf( __( '%1$s was called <strong
   >incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );`
 * After that line is where we’ll put a [backtrace print](https://www.php.net/manual/en/function.debug-print-backtrace.php)
   to review some of the stacktrace:
 *     ```
       debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 5 );
       ```
   
 * Once the code changes have been uploaded, you can refresh the page that is outputting
   the errors to now see 5 steps back of the stacktrace, which is hopefully enough
   for you to identify the source. Here’s what it output for me:
 *     ```
       #0 _doing_it_wrong() called at [/var/www/html/wp-admin/includes/plugin.php:1385]
       #1 add_submenu_page() called at [/var/www/html/wp-content/plugins/child-theme-generator/admin/class-child-theme-generator-admin.php:122]
       #2 Ch_Th_Gen_Admin->create_menu() called at [/var/www/html/wp-includes/class-wp-hook.php:288]
       #3 WP_Hook->apply_filters() called at [/var/www/html/wp-includes/class-wp-hook.php:312]
       #4 WP_Hook->do_action() called at [/var/www/html/wp-includes/plugin.php:478]
       ```
   
 * If you still can’t find where the original function call was made, increase the
   backtrace limit integer parameter. In this case, we were looking for where the
   problematic `add_submenu_page()` was called. It shows as #1 in my backtrace.
 * After finding the root of the error, it’s good to remove all code changes made
   to WordPress Core files since they will be overwritten when updating WordPress
   again. It’s best to keep your WordPress install as pure as possible so that all
   your code changes are somewhere more manageable.
 * **To not even edit WP Core code to begin with**, you can utilize the `doing_it_wrong_run`
   action hook:
 *     ```
       /**
        * Fires when the given function is being used incorrectly.
        *
        * @since 3.1.0
        *
        * @param string $function The function that was called.
        * @param string $message  A message explaining what has been done incorrectly.
        * @param string $version  The version of WordPress where the message was added.
        */
       do_action( 'doing_it_wrong_run', $function, $message, $version );
       ```
   
 *  [juliesuccess](https://wordpress.org/support/users/juliesuccess/)
 * (@juliesuccess)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12160908)
 * [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/)
   That’s so nice of you. I have a basic understanding of code so I will be trying
   this. I may get back to you with more questions if I get stuck! 😉 Thanks again!
 *  [neumeith](https://wordpress.org/support/users/neumeith/)
 * (@neumeith)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12171692)
 * Hi guys,
 * 1. Thx for the good plugin.
 * 2. i also have this problem with the line 4903:
 * PHP Notice: add_submenu_page wurde **fehlerhaft aufgerufen**. Der siebte Paramater,
   der an `add_submenu_page()` übergeben wird, sollte ein ganzzahliger Wert sein,
   der eine Menüposition repräsentiert. Weitere Informationen: [Debugging in WordPress (engl.)](https://wordpress.org/support/article/debugging-in-wordpress/)(
   Diese Meldung wurde in Version 5.3.0 hinzugefügt.) in /var/home/murau-botschafter_at/
   www/wp-includes/functions.php on line 4903
 * 3. Do i need to solve it?
 * 4. How should i solve it?
 * 5. Just upgrade to next version?
 * Thx. Best regards.
    Thomas
 *  [juliesuccess](https://wordpress.org/support/users/juliesuccess/)
 * (@juliesuccess)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12201733)
 * [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/)
   I got it! Thanks. Is it best to contact the plugin developer, or can I change
   it myself? I understand what you mean about the core and that it will update.
   Thanks.
 *  [juliesuccess](https://wordpress.org/support/users/juliesuccess/)
 * (@juliesuccess)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12201737)
 * [@neumeith](https://wordpress.org/support/users/neumeith/): [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/)
   answered it above. It worked! 🙂
 *  Thread Starter [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12201748)
 * [@juliesuccess](https://wordpress.org/support/users/juliesuccess/) I recommend
   notifying the plugin developer of the problematic code because you will have 
   to patch it every time you update the plugin. Your fix will be replaced by all
   of their code if you make edits directly. (Just like editing and updating WP 
   Core directly.)
 * So I recommend notifying the plugin developer, but also noting the fix yourself
   in case the plugin developer does not implement the fix for future releases. 
   Also, you’ll have the fix in place immediately while waiting on the plugin developer
   to implement the fix on their end. 🙂
 *  [juliesuccess](https://wordpress.org/support/users/juliesuccess/)
 * (@juliesuccess)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12201764)
 * [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/)
   Thanks again! 🙂
 *  [Salle32](https://wordpress.org/support/users/salle32/)
 * (@salle32)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12226960)
 * [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/)
   Very helpful – thanks! Solved my problem!
 *  [joey12](https://wordpress.org/support/users/joey12/)
 * (@joey12)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12411605)
 * Hi Michelle,
    [@michelleblanchette](https://wordpress.org/support/users/michelleblanchette/)
 * I’m having the same issue, but mine deals with OceanWP child theme.
 * So to solve this issue in your example did you delete line 122 in class-child-
   theme-generator-admin.php? What were the steps you made to resolve this issue
   after the backtrace print?
 * ” #1 add_submenu_page() called at [/var/www/html/wp-content/plugins/child-theme-
   generator/admin/class-child-theme-generator-admin.php:122]”
 *  Thread Starter [Michelle Blanchette](https://wordpress.org/support/users/michelleblanchette/)
 * (@michelleblanchette)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/#post-12412782)
 * Hi [@joey12](https://wordpress.org/support/users/joey12/) ,
 * The backtrace print shows you where in the code you need to be looking for issues.
   In my case, I knew the parameters provided in the function call were incorrect
   and I also knew how it gets fixed. More specifically, there was an extra parameter
   provided to the function call. Comparing the problematic usage to the function’s
   documentation/source clues you in to if a function is being used properly, which
   helped me know, for instance, which parameter needed to be removed.
 * If you are struggling to understand the issue in the code and why it is throwing
   an error, I definitely suggest reaching out to the plugin developer and telling
   them what the error is. Even better, you can now tell them that you at least 
   found the file and line that are the root of the problem!
 * Even if you _have_ fixed the problem for yourself, it’s still good to notify 
   the developer so they can implement the fix for later releases.
 * I hope this helps!

Viewing 15 replies - 1 through 15 (of 25 total)

1 [2](https://wordpress.org/support/topic/add_submenu_page-debugging/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/add_submenu_page-debugging/page/2/?output_format=md)

The topic ‘add_submenu_page debugging’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/child-theme-generator_7895a9.svg)
 * [Child Theme Generator](https://wordpress.org/plugins/child-theme-generator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/child-theme-generator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/child-theme-generator/)
 * [Active Topics](https://wordpress.org/support/plugin/child-theme-generator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/child-theme-generator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/child-theme-generator/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [development](https://wordpress.org/support/topic-tag/development/)

 * 25 replies
 * 12 participants
 * Last reply from: [daval](https://wordpress.org/support/users/daval/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/add_submenu_page-debugging/page/2/#post-13107777)
 * Status: resolved