Core error when calling remove_menu_page

The error line comes from the following in wp-admin/includes/plugin.php: function remove_menu_page( $menu_slug ) { global $menu; foreach ( $menu as $i => $item ) { if ( $menu_slug === $item[2] ) { unset( $menu[ $i ] ); return $item; } } return false; } The global $menu does not actually get populated until the wp-admin/menu-header.php … Read more

How to use filter in this situation, can not modify the structure using filter

So you’re trying to call the hide_empty_fields() and maybe_add_disclaimer_and_courtesy() methods in the Register_Impress_Shortcodes class, from within a global function, and it’s not impossible to call class methods from within such global functions, but you cannot use $this in your function because $this is only available from within a class method which is called from within … Read more

“CRITICAL Object of class WP_Error could not be converted to string” using templates with twig

wp_get_post_terms() returns a WP_Error on failure. (Are you sure it’s $colection and not $collection in that function call?) You can check the return value using is_wp_error() and decide what you’re going to output if it is, in fact, a WP_Error. For example: $term = wp_get_post_terms( $colection->posts[0]->ID ,’look’ ); if ( is_wp_error( $term ) ) { … Read more