How to avoid creating first submenu page that is same as menu page?

You can set slug of a subpage to be the same as slug of parent page. For example: public function onixion_admin_menu_option() { add_menu_page(‘onixion’, ‘Onixion’, ‘manage_options’, ‘onixion-admin-menu’, array(&$this, ‘onixion_main_page’ ), ‘dashicons-chart-area’, ‘200’ ); add_submenu_page( ‘onixion-admin-menu’, ‘scripts’, ‘Scripts’, ‘manage_options’, ‘onixion-admin-menu’, // <– here we set the same slug as for parent page array(&$this, ‘onixion_scripts_page’ ) ); add_submenu_page( … Read more

multiple functions with same filter

There’s nothing technically wrong with this. It will work, but it’s very important to make sure the usage of the filter is consistent everywhere it’s used, otherwise you could experience issues. My suggestion would be to abstract the powers check into a separate function, and use the filter there. For example, the filter could be … Read more

htmlentities and editing text

Do I need to sanitize the data before putting the text back in a text box for edit. You “sanitize” data that you are receiving. Then “escape” it when outputting. Depending on your exact code (which you did not provide any examples of), you may want to do more than stripslashes() (or replace that altogether). … Read more

Error “Call to a member function switch_to_locale() on null” during insert_with_markers

From your comment: Those htaccess changes don’t happen as a result of an add_action. Perhaps they should? Yes, they should. And here’s why insert_with_markers() calls switch_to_locale() which uses $GLOBALS[‘wp_locale_switcher’] (or $wp_locale_switcher) which is initialized in wp-settings.php, but only after WordPress runs the setup_theme hook. And looking at the error in question and line #1582 in … Read more