Ejemplo n.º 1
0
 static function get_instance()
 {
     if (empty(self::$instance)) {
         self::$instance = new WPRP_Log();
     }
     return self::$instance;
 }
Ejemplo n.º 2
0
            } else {
                $actions[$action] = wprp_format_user_obj(get_user_by('id', $user_id));
            }
            break;
        case 'enable_log':
            update_option('wprp_enable_log', true);
            $actions[$action] = true;
            break;
        case 'disable_log':
            delete_option('wprp_enable_log');
            $actions[$action] = true;
            break;
        case 'get_log':
            if (class_exists('WPRP_Log')) {
                $actions[$action] = WPRP_Log::get_instance()->get_items();
                WPRP_Log::get_instance()->delete_items();
            } else {
                $actions[$action] = new WP_Error('log-not-enabled', 'Logging is not enabled');
            }
            break;
        default:
            $actions[$action] = 'not-implemented';
            break;
    }
}
foreach ($actions as $key => $action) {
    if (is_wp_error($action)) {
        $actions[$key] = (object) array('errors' => $action->errors);
    }
}
echo json_encode($actions);