You have to change this add_action('admin_menu','mafongroup_admin_menu');
to add_action('admin_menu',array( $this, 'mafongroup_admin_menu' ) );
. Cause you’r here calling a class method. So you’ve to give reference to the class.
And also if you put public
before declaring mafongroup_admin_menu()
function, it would be more readable and would be helpful in future I think. See the updated class code of your’s below-
class mafongroup_admin {
public function __construct() {
add_action('admin_menu',array( $this, 'mafongroup_admin_menu' ) );
}
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, $function,'dashicons-image-filter', '2.111111');
}
}
}
function mafongroup_admin_menu_function(){
echo "<h1>TESTING</h1>";
}
new mafongroup_admin();
Hope it helps.