<?php 
/**
	Admin Page Framework v3.8.34 by Michael Uno 
	Generated by PHP Class Files Script Generator <https://github.com/michaeluno/PHP-Class-Files-Script-Generator>
	<http://en.michaeluno.jp/index-wp-mysql-for-speed>
	Copyright (c) 2013-2021, Michael Uno; Licensed under MIT <http://opensource.org/licenses/MIT> */
class Imfs_AdminPageFramework_View__PageMetaboxEnabler extends Imfs_AdminPageFramework_FrameworkUtility {
    public $oFactory;
    public function __construct($oFactory) {
        $this->oFactory = $oFactory;
        add_action('admin_head', array($this, '_replyToEnableMetaBox'));
    }
    public function _replyToEnableMetaBox() {
        if (!$this->_isMetaBoxAdded()) {
            return;
        }
        $_sCurrentScreenID = $this->getCurrentScreenID();
        do_action("add_meta_boxes_{$_sCurrentScreenID}", null);
        do_action('add_meta_boxes', $_sCurrentScreenID, null);
        wp_enqueue_script('postbox');
        $_iColumns = $this->getAOrB($this->doesMetaBoxExist('side'), 2, 1);
        add_screen_option('layout_columns', array('max' => $_iColumns, 'default' => $_iColumns,));
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        if (isset($GLOBALS['page_hook'])) {
            add_action("admin_footer-{$GLOBALS['page_hook']}", array($this, '_replyToAddMetaboxScript'));
        }
    }
    private function _isMetaBoxAdded() {
        $_aPageMetaBoxClasses = $this->getElementAsArray($GLOBALS, array('aImfs_AdminPageFramework', 'aMetaBoxForPagesClasses'));
        if (empty($_aPageMetaBoxClasses)) {
            return false;
        }
        $_sPageSlug = $this->getHTTPQueryGET('page', '');
        if (!$_sPageSlug) {
            return false;
        }
        foreach ($_aPageMetaBoxClasses as $_sClassName => $_oMetaBox) {
            if ($this->_isPageOfMetaBox($_sPageSlug, $_oMetaBox)) {
                return true;
            }
        }
        return false;
    }
    private function _isPageOfMetaBox($sPageSlug, $oMetaBox) {
        if (in_array($sPageSlug, $oMetaBox->oProp->aPageSlugs)) {
            return true;
        }
        if (!array_key_exists($sPageSlug, $oMetaBox->oProp->aPageSlugs)) {
            return false;
        }
        $_aTabs = $oMetaBox->oProp->aPageSlugs[$sPageSlug];
        $_sCurrentTabSlug = $this->oFactory->oProp->getCurrentTabSlug();
        return ($_sCurrentTabSlug && in_array($_sCurrentTabSlug, $_aTabs));
    }
    public function _replyToAddMetaboxScript() {
        $_bLoaded = $this->getElement($GLOBALS, array('aImfs_AdminPageFramework', 'bAddedMetaBoxScript'), false);
        if ($_bLoaded) {
            return;
        }
        $GLOBALS['aImfs_AdminPageFramework']['bAddedMetaBoxScript'] = true;
        $_sScript = <<<JAVASCRIPTS
jQuery( document).ready( function(){ 
    postboxes.add_postbox_toggles( pagenow ); 
});
JAVASCRIPTS;
        echo '<script class="index-wp-mysql-for-speed-insert-metabox-script">' . '/* <![CDATA[ */' . $_sScript . '/* ]]> */' . '</script>';
    }
    }
    