和前面的问题一样,如果你调用了任何类方法来引用该类,请回答。所以你需要更换这条线
$theme_options = $mafongroup_menu_page_creation_method( $page_title, $menu_title, $capability, $menu_slug, $function,\'dashicons-image-filter\', \'2.111111\');
用这个-
$theme_options = $mafongroup_menu_page_creation_method( $page_title, $menu_title, $capability, $menu_slug, array( $this, $function ),\'dashicons-image-filter\', \'2.111111\');
因此,您的上述代码如下所示-
class mafongroup_admin {
public function __construct() {
add_action( \'admin_menu\', array( $this, \'mafongroup_admin_menu\' ) );
add_action( \'admin_init\', array( $this, \'mafongroup_admin_menu_function\' ));
}
public function mafongroup_admin_menu(){
if ( current_user_can( \'edit_theme_options\' ) ){
$page_title="MAFON GROUP";
$menu_title="MAFON GROUP";
$capability="administrator";
$menu_slug="mafongroup_admin_settings";
$function="mafongroup_admin_menu_function";
$mafongroup_menu_page_creation_method = \'add_menu_page\';
$mafongroup_submenu_page_creation_method = \'add_submenu_page\';
$theme_options = $mafongroup_menu_page_creation_method( $page_title, $menu_title, $capability, $menu_slug, array( $this, $function ),\'dashicons-image-filter\', \'2.111111\');
}
}
public function mafongroup_admin_menu_function(){
echo \'do something\';
}
}
new mafongroup_admin();
希望这有帮助。