/**
 * display or register modules content with position
 * @param $name
 * @param $callback
 */
function __position($name, $callback = null)
{
    if ($callback) {
        HW_Module_Positions::add_position_hook($name, $callback);
    } else {
        HW_Module_Positions::implement_position($name);
    }
}
Exemplo n.º 2
0
 /**
  * desploy modules with positions
  */
 private function desploy_modules_position()
 {
     if (is_admin()) {
         return;
     }
     $modules_positions = $this->get_field_value('modules_position');
     if (is_array($modules_positions)) {
         foreach ($modules_positions as $module => $item) {
             //if($item['condition'] == 0) continue;
             $match = 1;
             //check condition before module can display
             $dynamic_settings = HW_Condition::get_active_conditions_settings();
             $condition = $item['condition'];
             //condition id
             if ($condition) {
                 if (!isset($dynamic_settings[$condition])) {
                     continue;
                 }
                 $setting = array($condition => $dynamic_settings[$condition]);
                 $setting_conditions = HW__Template_Condition::parse_template_conditions($setting);
                 #_print($setting_conditions);
                 foreach ($setting_conditions as $pages_condition) {
                     //and, or condition
                     if (isset($pages_condition) && is_array($pages_condition)) {
                         //get template alternate with AND relation
                         foreach ($pages_condition as $temp => $meet_condition) {
                             if ($meet_condition['result']) {
                                 $match = 1;
                                 //break;  //first occurence
                             } else {
                                 $match = 0;
                             }
                         }
                     }
                 }
             }
             if ($match) {
                 //add action for module position
                 $module_inst = HW_Module_Settings_page::get_modules($module);
                 if (!empty($module_inst)) {
                     HW_Module_Positions::add_position_hook($item['position'], $module_inst->get_module_content_cb());
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * desploy modules with positions
  */
 private function desploy_sidebars_position()
 {
     if (is_admin()) {
         return;
     }
     $sidebars_positions = $this->get_tab('sidebars_pos')->get_field_value('sidebars_position');
     if (is_array($sidebars_positions)) {
         foreach ($sidebars_positions as $sidebar => $item) {
             //if($item['condition'] == 0) continue;
             $match = 1;
             //check condition before module can display
             //$dynamic_settings = HW_Condition::get_active_conditions_settings();
             //$condition = $item['condition']; //condition id
             /*if($condition) {
                             if(!isset($dynamic_settings[$condition])) continue;
             
                             $setting = array($condition => $dynamic_settings[$condition]);
                             $setting_conditions = HW__Template_Condition::parse_template_conditions($setting);#_print($setting_conditions);
             
                             foreach($setting_conditions as $pages_condition) {   //and, or condition
                                 if(isset($pages_condition) && is_array($pages_condition)) {     //get template alternate with AND relation
             
                                     foreach ($pages_condition as $temp => $meet_condition) {
                                         if($meet_condition['result']) {
                                             $match = 1;
                                             //break;  //first occurence
                                         }
                                         else {
                                             $match = 0;
                                         }
                                     }
                                 }
                             }
                         }*/
             if ($match) {
                 //add action for sidebar position
                 HW_Module_Positions::add_position_hook($item['position'], function () use($sidebar, $item) {
                     if (is_active_sidebar($sidebar)) {
                         if (function_exists('hw_dynamic_sidebar')) {
                             hw_dynamic_sidebar($sidebar);
                         } else {
                             dynamic_sidebar($sidebar);
                         }
                     }
                 });
             }
         }
     }
 }