/**
  * Get all core classes from config.xml in core directory
  *
  */
 public function getShortcodes()
 {
     if (self::$shortCodesSet == true) {
         return;
     }
     //If the user doesn't use shortcodes
     if (ABH_Classes_Tools::getOption('abh_shortcode') == 0) {
         return;
     }
     self::$shortCodesSet = true;
     /* if config allready in cache */
     if (!isset(ABH_Classes_ObjController::$config)) {
         $config_file = _ABH_CORE_DIR_ . 'config.xml';
         if (!file_exists($config_file)) {
             return;
         }
         /* load configuration blocks data from core config files */
         $data = file_get_contents($config_file);
         ABH_Classes_ObjController::$config = json_decode(json_encode((array) simplexml_load_string($data)), 1);
     }
     // echo '<pre>' . print_r(ABH_Classes_ObjController::$config['block'], true) . '</br>';
     //print_r(ABH_Classes_ObjController::$config);
     if (is_array(ABH_Classes_ObjController::$config)) {
         foreach (ABH_Classes_ObjController::$config['block'] as $block) {
             if (isset($block['name'])) {
                 if (isset($block['active']) && $block['active'] == 1) {
                     if (isset($block['shortcodes']['shortcode'])) {
                         $instance = ABH_Classes_ObjController::getController($block['name']);
                         if (!is_array($block['shortcodes']['shortcode'])) {
                             if (is_callable(array($instance, 'hookShortWidget' . ucfirst($block['shortcodes']['shortcode'])))) {
                                 add_action('widget_text', array($instance, 'hookShortWidget' . ucfirst($block['shortcodes']['shortcode'])), 10, 1);
                             }
                             add_shortcode($block['shortcodes']['shortcode'], array($instance, 'hookShort' . ucfirst($block['shortcodes']['shortcode'])));
                         } else {
                             foreach ($block['shortcodes']['shortcode'] as $shortcode) {
                                 if (is_callable(array($instance, 'hookShortWidget' . ucfirst($shortcode)))) {
                                     add_action('widget_text', array($instance, 'hookShortWidget' . ucfirst($shortcode)), 10, 1);
                                 }
                                 add_shortcode($shortcode, array($instance, 'hookShort' . ucfirst($shortcode)));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Get all core classes from config.xml in core directory
  *
  * @param string $for
  */
 public function getBlocks($for)
 {
     /* if config allready in cache */
     if (!isset(self::$config)) {
         $config_file = _ABH_CORE_DIR_ . 'config.xml';
         if (!file_exists($config_file)) {
             return;
         }
         /* load configuration blocks data from core config files */
         $data = file_get_contents($config_file);
         self::$config = json_decode(json_encode((array) simplexml_load_string($data)), 1);
     }
     //print_r(self::$config);
     if (is_array(self::$config)) {
         foreach (self::$config['block'] as $block) {
             if (isset($block['active']) && $block['active'] == 1) {
                 if (isset($block['controllers']['controller'])) {
                     if (!is_array($block['controllers']['controller'])) {
                         /* if the block should load for the current controller */
                         if ($for == $block['controllers']['controller']) {
                             ABH_Classes_ObjController::getBlock($block['name'])->init();
                         }
                     } else {
                         foreach ($block['controllers']['controller'] as $controller) {
                             /* if the block should load for the current controller */
                             if ($for == $controller) {
                                 ABH_Classes_ObjController::getBlock($block['name'])->init();
                             }
                         }
                     }
                 }
             }
         }
     }
 }