public static function bootstrap()
 {
     global $wp_query;
     // Create local reference to the main query:
     if (empty(self::$query)) {
         self::$query = $wp_query;
     }
     CMA_Thread::initAnonymousVotingCookie();
     self::initSessions();
     add_filter('preprocess_comment', function ($commentdata) {
         // Resolve conflict with Responsible Shop Theme
         $types = array(CMA_Answer::COMMENT_TYPE, CMA_Comment::COMMENT_TYPE, CMA_Thread::POST_TYPE);
         if (!empty($commentdata['comment_type']) and in_array($commentdata['comment_type'], $types)) {
             $className = 'white_label_themes';
             if (class_exists($className) and isset($GLOBALS['CORE']) and is_object($GLOBALS['CORE']) and get_class($GLOBALS['CORE']) == $className) {
                 remove_filter('preprocess_comment', array($GLOBALS['CORE'], '_preprocess_comment'));
             }
         }
         return $commentdata;
     }, 1);
     add_filter('comment_row_actions', array(__CLASS__, 'adminCommentRowActionsFilter'), 10, 2);
     // Initialize CMA fake page
     self::initFakePage();
     // Initialize custom Questions Index page
     CMA_Shortcodes::initCustomQuestionsIndexPage();
     CMA_RelatedQuestionsMetaBox::bootstrap();
     self::_addAdminPages();
     self::$_titles = get_option(self::OPTION_TITLES, array());
     $controllersDir = dirname(__FILE__);
     /*
      * Loop the controllers
      */
     foreach (scandir($controllersDir) as $name) {
         if ($name != '.' && $name != '..' && $name != basename(__FILE__) && strpos($name, 'Controller.php') !== false) {
             $controllerName = substr($name, 0, strpos($name, 'Controller.php'));
             $controllerClassName = CMA_PREFIX . $controllerName . 'Controller';
             $controller = strtolower($controllerName);
             include_once $controllersDir . DIRECTORY_SEPARATOR . $name;
             $controllerClassName::initialize();
             $args = array();
             /*
              * Loop the methods in each controller
              */
             foreach (get_class_methods($controllerClassName) as $methodName) {
                 if (strpos($methodName, 'Action') !== false && substr($methodName, 0, 1) != '_') {
                     $action = substr($methodName, 0, strpos($methodName, 'Action'));
                     $query_arg = self::_getQueryArg($controller, $action);
                     $newArgs = array('query_arg' => self::_getQueryArg($controller, $action), 'slug' => self::_getSlug($controller, $action), 'title' => self::_getTitle($controller, $action, true), 'viewPath' => self::_getViewPath($controller, $action), 'contentCallback' => array($controllerClassName, $methodName), 'controller' => $controller, 'action' => $action);
                     if (!isset($args[$query_arg])) {
                         $args[$query_arg] = array();
                     }
                     $args[$query_arg] = array_merge($args[$query_arg], $newArgs);
                 } elseif (strpos($methodName, 'Header') !== false && substr($methodName, 0, 1) != '_') {
                     $action = substr($methodName, 0, strpos($methodName, 'Header'));
                     $query_arg = self::_getQueryArg($controller, $action);
                     $newArgs = array('query_arg' => self::_getQueryArg($controller, $action), 'slug' => self::_getSlug($controller, $action), 'title' => self::_getTitle($controller, $action), 'viewPath' => self::_getViewPath($controller, $action), 'headerCallback' => array($controllerClassName, $methodName), 'controller' => $controller, 'action' => $action);
                     if (!isset($args[$query_arg])) {
                         $args[$query_arg] = array();
                     }
                     $args[$query_arg] = array_merge($args[$query_arg], $newArgs);
                 } elseif (strpos($methodName, 'Title') !== false && substr($methodName, 0, 1) != '_') {
                     $action = substr($methodName, 0, strpos($methodName, 'Title'));
                     $query_arg = self::_getQueryArg($controller, $action);
                     $newArgs = array('query_arg' => self::_getQueryArg($controller, $action), 'slug' => self::_getSlug($controller, $action), 'title' => self::_getTitle($controller, $action), 'viewPath' => self::_getViewPath($controller, $action), 'titleCallback' => array($controllerClassName, $methodName), 'controller' => $controller, 'action' => $action);
                     if (!isset($args[$query_arg])) {
                         $args[$query_arg] = array();
                     }
                     $args[$query_arg] = array_merge($args[$query_arg], $newArgs);
                 }
             }
             foreach ($args as $query_arg => $data) {
                 self::_registerAction($query_arg, $data);
             }
         }
     }
     if (is_admin() and basename($_SERVER['REQUEST_URI']) == 'edit-comments.php') {
         // Filter answers from wp comments list
         add_filter('comments_clauses', array(__CLASS__, 'filterWPCommentsList'));
     }
     self::registerPages();
     self::replaceCommentSystem();
 }