functions – get_current_screen() in plugin __construct() or check the current action is edit


Hi is there any way to get value for get_current_screen() inside the __construct() of a plugin class ? I want to get the value of a get_current_screen() when we edit a wordpress page or preview a page inside a plugin . But when i use this function indie __construct() it saying get_current_screen() is not defined .

What i need is when we edit a post or page in wordpress or when we preview a page then inside the __construct() function of plugin class i need to make a if condition that is checking that currently the page is editing or previewing.

// construct of my plugin 

public function __construct() {

  if (get_current_screen() == edit.php) {
    Do something


Please help.

Abilash Erikson 3 weeks 2021-11-08T04:03:44-05:00 0 Answers 0 views 0

Leave an answer