Class variables not correct on page

When you write that code

<?php $pageopi = new opi; ?>
// 1. object created
// 2. __construct is called
// 3. init action hook is set but is never executed so is o_check method
<?php echo $pageopi->mg; ?>

At this stage, init hook was executed long time before $pageopi is created actually, when page is loaded. init action hook is executed even before page.php start to execute.

Solution:

  1. You should use the global $opi; object page.php instead of create new one.

  2. Or create a new global object before the init action hook (in
    plugins_loaded hook) and use it on page.php