src/MocaBonita.php
public static function plugin(\Closure $pluginStructure, $audit = false, $tag = "plugins_loaded")
    {
        $mocaBonita = self::getInstance();
        $mocaBonita->audit = (bool) $audit;

        if ($mocaBonita->audit) {

            MbWPActionHook::addActionCallback('plugins_loaded', function () use ($mocaBonita) {
                try {
                    MbDatabase::enableQueryLog();
                    $mocaBonita->getMbAudit()->setMocaBonita($mocaBonita);
                    $mocaBonita->getMbAudit()->setUser(MbWpUser::getCurrentUser(true));
                } catch (\Exception $e) {
                    $mocaBonita->getMbResponse()->setContent($e);
                }
            });

            MbWPActionHook::addActionCallback('shutdown', function () use ($mocaBonita) {
                try {
                    $mocaBonita->getMbAudit()->run();
                } catch (\Exception $e) {
                    error_log($e->getMessage());
                } finally {
                    MbDatabase::disableQueryLog();
                }
            });

        }

        MbWPActionHook::addActionCallback($tag, function () use ($pluginStructure, $mocaBonita) {
            try {
                call_user_func_array($pluginStructure, [$mocaBonita]);
                $mocaBonita->runPlugin();
            } catch (\Exception $e) {
                $mocaBonita->mbResponse->setContent($e);
            } finally {
                $mocaBonita->runHookCurrentAction();
                $mocaBonita->getMbAudit()->setResponseStatusCode($mocaBonita->mbResponse->status());
                $mocaBonita->getMbAudit()->setResponseHeader($mocaBonita->mbResponse->headers->all());
                $mocaBonita->mbResponse->sendHeaders();
            }
        });
    }
public static function plugin(\Closure $pluginStructure, $audit = false, $tag = "plugins_loaded")
    {
        $mocaBonita = self::getInstance();
        $mocaBonita->audit = (bool) $audit;

        if ($mocaBonita->audit) {

            MbWPActionHook::addActionCallback('plugins_loaded', function () use ($mocaBonita) {
                try {
                    MbDatabase::enableQueryLog();
                    $mocaBonita->getMbAudit()->setMocaBonita($mocaBonita);
                    $mocaBonita->getMbAudit()->setUser(MbWpUser::getCurrentUser(true));
                } catch (\Exception $e) {
                    $mocaBonita->getMbResponse()->setContent($e);
                }
            });

            MbWPActionHook::addActionCallback('shutdown', function () use ($mocaBonita) {
                try {
                    $mocaBonita->getMbAudit()->run();
                } catch (\Exception $e) {
                    error_log($e->getMessage());
                } finally {
                    MbDatabase::disableQueryLog();
                }
            });

        }

        MbWPActionHook::addActionCallback($tag, function () use ($pluginStructure, $mocaBonita) {
            try {
                call_user_func_array($pluginStructure, [$mocaBonita]);
                $mocaBonita->runPlugin();
            } catch (\Exception $e) {
                $mocaBonita->mbResponse->setContent($e);
            } finally {
                $mocaBonita->runHookCurrentAction();
                $mocaBonita->getMbAudit()->setResponseStatusCode($mocaBonita->mbResponse->status());
                $mocaBonita->getMbAudit()->setResponseHeader($mocaBonita->mbResponse->headers->all());
                $mocaBonita->mbResponse->sendHeaders();
            }
        });
    }
public static function plugin ( \ Closure $ pluginStructure , $ audit = false , $ tag = "plugins_loaded" ) { $ mocaBonita = self :: getInstance ( ) ; $ mocaBonita -> audit = ( bool ) $ audit ; if ( $ mocaBonita -> audit ) { MbWPActionHook :: addActionCallback ( 'plugins_loaded' , function ( ) use ( $ mocaBonita ) { try { MbDatabase :: enableQueryLog ( ) ; $ mocaBonita -> getMbAudit ( ) -> setMocaBonita ( $ mocaBonita ) ; $ mocaBonita -> getMbAudit ( ) -> setUser ( MbWpUser :: getCurrentUser ( true ) ) ; } catch ( \ Exception $ e ) { $ mocaBonita -> getMbResponse ( ) -> setContent ( $ e ) ; } } ) ; MbWPActionHook :: addActionCallback ( 'shutdown' , function ( ) use ( $ mocaBonita ) { try { $ mocaBonita -> getMbAudit ( ) -> run ( ) ; } catch ( \ Exception $ e ) { error_log ( $ e -> getMessage ( ) ) ; } finally { MbDatabase :: disableQueryLog ( ) ; } } ) ; } MbWPActionHook :: addActionCallback ( $ tag , function ( ) use ( $ pluginStructure , $ mocaBonita ) { try { call_user_func_array ( $ pluginStructure , [ $ mocaBonita ] ) ; $ mocaBonita -> runPlugin ( ) ; } catch ( \ Exception $ e ) { $ mocaBonita -> mbResponse -> setContent ( $ e ) ; } finally { $ mocaBonita -> runHookCurrentAction ( ) ; $ mocaBonita -> getMbAudit ( ) -> setResponseStatusCode ( $ mocaBonita -> mbResponse -> status ( ) ) ; $ mocaBonita -> getMbAudit ( ) -> setResponseHeader ( $ mocaBonita -> mbResponse -> headers -> all ( ) ) ; $ mocaBonita -> mbResponse -> sendHeaders ( ) ; } } ) ; }
Set the callback that has the plugin's structure

@param        $pluginStructure \Closure Callback that will be called
@param bool   $audit           Set status audit

@param string $tag

@return void
Set the callback that has the plugin s structure