Ejemplo n.º 1
0
 /**
  * @hook before_switch_theme
  */
 public function _before_switch_theme()
 {
     //check theme for validate
     if (!HW__Template::validate_theme()) {
         $this->msg->put_msg('Lỗi theme không hợp lệ !');
         return false;
     }
     return true;
 }
 public function __construct()
 {
     //list layouts
     $this->layouts = HW__Template::getTemplates();
     //only accept widget with id base 'hw_taxonomy_post_list_widget'
     if (class_exists('AWC_WidgetFeature_saveconfig')) {
         $this->saved_widgets_settings = AWC_WidgetFeature_saveconfig::get_widgets_settings(' where widget="hw_taxonomy_post_list_widget"');
     }
 }
 public function get_fields(&$sections)
 {
     global $wp_filter;
     $hw_register_hooks = array('hw_before_main_content' => 'hw_before_main_content', 'hw_after_main_content' => 'hw_after_main_content', 'hw_after_header' => 'hw_after_header', 'hw_before_loop' => 'hw_before_loop', 'hw_after_loop' => 'hw_after_loop');
     /*foreach($wp_filter as $tag => $priority){
           //echo "<br />&gt;&gt;&gt;&gt;&gt;t<strong>$tag</strong><br />";
           ksort($priority);
           $data[$tag] = $tag;
       }*/
     $layouts = HW__Template::getTemplates();
     //get template layouts
     /*float left right advertising*/
     $sections['template'] = array('icon' => NHP_OPTIONS_URL . 'img/glyphicons/glyphicons_064_lightbulb.png', 'title' => 'Giao diện', 'fields' => array('content_classes' => array('id' => 'content_classes', 'type' => 'hw_table_fields', 'title' => 'Thêm class vào thẻ body và loop post.', 'desc' => 'Thêm class vào thẻ body và loop post.', 'data_base_field' => 'col1', 'show_root_field' => true, 'fields' => array('col1' => array('options' => $layouts), 'col2' => array('name' => 'body_class', 'type' => 'text', 'description' => 'Thêm class vào thẻ body', 'attributes' => array('style' => 'border:1px solid red;', 'class' => 'hw-class')), 'col3' => array('name' => 'post_class', 'type' => 'text', 'description' => 'Thêm class vào filter post_class'), 'col4' => array('name' => 'remove_default', 'type' => 'checkbox', 'description' => 'Xóa classes mặc định.')), 'table_header' => array('col1' => 'Template/trang', 'col2' => 'Body class', 'col3' => 'Post class', 'col4' => 'Xóa mặc định')), 'show_breadcrumb' => array('id' => 'show_breadcrumb', 'type' => 'select', 'title' => 'Hiển thị thanh định hướng', 'desc' => 'Hiển thị thanh định hướng (breadcrumb) vào trước nội dung hook này.', 'options' => $hw_register_hooks)));
 }
Ejemplo n.º 4
0
 /**
  * Triggered when the tab is loaded.
  * @param $oAdminPage
  */
 public function replyToAddFormElements($oAdminPage)
 {
     $modules_pos = HW_Modules_Manager::get_modules_displayable();
     //list displayable modules
     $avaiable_pages = HW__Template::get_pages_select();
     //pages
     //get all register positions
     $positions = HW_Module_Positions::get_positions();
     HW_UI_Component::empty_select_option($positions);
     //condition
     $conditions = array();
     $dynamic_settings = HW_Condition::get_active_conditions_settings();
     foreach ($dynamic_settings as $id => $item) {
         $conditions[$id] = $item['title'];
     }
     HW_UI_Component::empty_select_option($conditions);
     $this->addFieldLabel('Cấu hình vị trí của các modules');
     $this->addFields(array('field_id' => 'modules_position', 'type' => 'hw_table_fields', 'title' => '', 'show_title_column' => false, 'repeatable' => false, 'show_root_field' => true, 'data_base_field' => 'col1', 'attributes' => array('hw_table_fields' => array()), 'fields' => array('col1' => array('name' => 'module', 'type' => 'select', 'options' => $modules_pos, 'description' => ''), 'col2' => array('name' => 'condition', 'type' => 'select', 'options' => $conditions, 'description' => ''), 'col3' => array('name' => 'page', 'type' => 'select', 'options' => $avaiable_pages, 'description' => ''), 'col4' => array('name' => 'position', 'type' => 'select', 'options' => $positions)), 'table_header' => array('col1' => 'Module', 'col2' => 'Điều kiện', 'col3' => 'Trang hiển thị', 'col4' => 'Vị trí')));
 }
Ejemplo n.º 5
0
 /**
  * add export widgets for the module
  */
 public function add_export_widgets()
 {
     $theme_config = HW__Template::get_theme_config();
     if ($theme_config && $theme_config->item('sidebars')) {
         foreach ($theme_config->item('sidebars') as $sidebar => $item) {
             if (isset($item['widgets'])) {
                 foreach ($item['widgets'] as $widget) {
                     $this->load_widgets($widget);
                     //init widget
                     $wxr_widget = $this->widgets->get($widget);
                     if (!$wxr_widget) {
                         continue;
                     }
                     //widget not exists
                     $wxr_widget->get()->setAttribute('sidebar', $sidebar);
                     //add widget to sidebar
                     if ($this->widgets->get($widget)) {
                         $this->add_export($wxr_widget->get());
                     }
                 }
             }
         }
     }
 }
/**
 * register theme activation hook
 * @param $code
 * @param $function
 */
function hw_register_theme_activation_hook($code, $function)
{
    HW__Template::register_theme_activation_hook($code, $function);
}
/**
 * main loop
 */
function hw_theme_get_main()
{
    HW__Template::hw_theme_get_main();
}
 /**
  * ajax handle callback to get act object values
  */
 public function _hw_apf_rules_field_get_values()
 {
     if (!wp_verify_nonce($_REQUEST['nonce'], "hw_apf_rules_field_get_values_nonce")) {
         exit("hacked !");
     }
     //params
     if (isset($_POST['object']) && $_POST['object']) {
         $name = $_POST['object'];
     }
     //get object name
     if (isset($_POST['aField'])) {
         //get apf rules field setting
         $aField = $_POST['aField'];
         $aField = unserialize(base64_decode($aField));
     }
     if (isset($_POST['id'])) {
         $field_id = $_POST['id'];
     }
     if (isset($_POST['bindingFields'])) {
         $bindingFields = $_POST['bindingFields'];
     }
     //binding Fields
     //valid
     if (!isset($aField) || !isset($field_id)) {
         return;
     }
     //parse attribute
     $fname = 'act_values';
     $field_id = explode('__', $field_id);
     $field_name = $field_id[0] . '[' . $field_id[1] . '][' . $fname . ']';
     //field name
     $field_id = self::generate_id($field_name);
     //field id
     //list all post types
     if ($name == 'post_types') {
         $postypes = get_post_types('', 'names');
         $field = array('name' => $fname, 'type' => 'select', 'options' => $postypes);
     } elseif ($name == 'templates') {
         $field = array('name' => $fname, 'type' => 'select', 'options' => HW__Template::getTemplates());
     } elseif ($name == 'taxonomies') {
         $taxes = get_taxonomies();
         $field = array('name' => $fname, 'type' => 'select', 'options' => $taxes);
     } elseif ($name == 'terms') {
         $terms_tax = self::get_all_terms_taxonomies('');
         //field terms placeholder
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } elseif ($name == 'users') {
         //users options placeholder
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } elseif ($name == 'pages') {
         //placeholder
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } elseif ($name == 'posts') {
         $field = array('name' => $fname, 'type' => 'select', 'options' => '');
     } else {
         $field = apply_filters('apf_rules_field_get_values', array('name' => $fname, 'type' => 'select', 'options' => ''), $name);
     }
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         //$result = json_encode($result);
         //display form field
         if (isset($field)) {
             if (!isset($field['attributes'])) {
                 $field['attributes'] = array();
             }
             $field['attributes']['id'] = $field_id;
             $field['attributes']['name'] = $field_name;
             $field['attributes']['data-id'] = $_POST['id'];
             //field tag id
             $field['attributes']['data-name'] = $fname;
             $field['attributes']['data-fieldname'] = $_POST['fname'];
             //inject some data
             $aField['selected_act'] = $name;
             //inject 'act' field value
             if (isset($bindingFields)) {
                 $aField['bindingFields'] = $bindingFields;
             }
             //binding fields
             //display field tag
             echo $this->renderField($field, $aField);
         }
     } else {
         header("Location: " . $_SERVER["HTTP_REFERER"]);
     }
     die;
 }
 /**
  * get content_classes option base current context
  * @param $field field to return value
  * @return mixed
  */
 private function get_nhp__content_classes($field = 'post_class')
 {
     static $classes_page = null;
     if (!$classes_page) {
         $classes_page = hw_option('content_classes');
     }
     //valid
     if (!in_array($field, array('post_class', 'body_class'))) {
         return;
     }
     if (is_array($classes_page)) {
         foreach ($classes_page as $page => $class) {
             if (HW__Template::check_template_page($page)) {
                 return $class[$field];
                 break;
             }
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * main loop
  */
 public static function hw_theme_get_main()
 {
     //init
     //hw_taxonomy_post_list_widget widget setting
     $setting = array();
     //default sidebar params
     $sidebar_params = array('before_widget' => '<div id="%1$s" class="hw-widget %2$s *1" >', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title %1$s {css_title}">', 'after_title' => '</h3>');
     //override loop template base context
     $loop_temp = HW__Template::get_current_context_loop_template();
     global $wp_registered_sidebars;
     global $wp_registered_widgets;
     if (!empty($loop_temp)) {
         //$widg = AWC_WidgetFeature_saveconfig::get_widget_setting($loop_temp['widget_config']);
         $setting = AWC_WidgetFeature_saveconfig::get_widget_setting_instance($loop_temp['widget_config'], array('widget' => 'hw_taxonomy_post_list_widget', 'group' => 'main_loop'));
         //valid data
         if (!isset($setting['query_data'])) {
             $setting['query_data'] = 'current_context';
         }
         //get global $wp_query
         //$setting['widget_title'] = 'sdfgdg';  //set widget title by skin
         //get sidebar box
         if ($loop_temp['sidebar'] && isset($wp_registered_sidebars[$loop_temp['sidebar']])) {
             $sidebar = $loop_temp['sidebar'];
             //sidebar id
             $sidebar_params = $wp_registered_sidebars[$sidebar];
             if (isset($loop_temp['sidebar_widget_skin'])) {
                 $sidebar_widget_skin = $loop_temp['sidebar_widget_skin'];
                 //get change default sidebar skin, here we create 4 holder: sidebar_default, skin1,skin2,skin3
                 $skin_data = HW_AWC_Sidebar_Settings::get_sidebar_setting($sidebar_widget_skin, $sidebar);
                 HW_SKIN::apply_skin_data($skin_data, 'HW__Template::_hw_skin_resume_skin_data', array('sidebar' => $sidebar, 'sidebar_widget_skin' => $sidebar_widget_skin, 'sidebar_params' => &$sidebar_params));
             }
         }
         list($widget_id, $t) = each($wp_registered_widgets);
         //get first widget as demo
         $sidebar_params = HW_AWC::format_widget_sidebar_params($widget_id, $sidebar_params, array('classname' => 'main-content hw-awc-override', 'widget_id' => 'hw-main-loop-content'));
         //override sidebar params from awc feature assign to widget
         if (isset($sidebar_params) && isset($sidebar)) {
             $sidebar_params = HW_AWC::format_sidebar_params($sidebar, $sidebar_params, $setting);
         }
         //important: since any sidebar skin use wrapper class 'hw-awc-override'
         //$sidebar_params['before_widget'] = sprintf($sidebar_params['before_widget'], /*$widget_id, $classname*/'hw-main-loop-content','main-content hw-awc-override');
         do_action('hw_before_loop');
         /**
          * output widget, when using the_widget to show widget content,
          *
          * note that you set up & enable sidebar skin at /admin.php?page=hw_sidebar_widgets_settings this mean sidebar apply to yarpp it work for that skin
          * And no related to active sidebar that using on website, which call by function 'dynamic_sidebar' /hw_dynamic_sidebar
          */
         if (class_exists('HW_Taxonomy_Post_List_widget')) {
             the_widget('HW_Taxonomy_Post_List_widget', $setting, $sidebar_params);
         }
         do_action('hw_after_loop');
     } elseif (APF_Page_Templates::get_instance()->hw_loop_template()) {
         //do nothing
     } else {
         $context = HW__Template::get_current_template_file();
         //determine current template
         $current = self::get_current_template();
         if ($current && method_exists($current, 'Main')) {
             $current->Main();
             //display main content of current template
         }
         //filter default template
         do_action('hw_theme_get_main_default', $context);
     }
 }
 /**
  * prepare hook
  * @hook after_setup_theme
  */
 public function _setup_theme()
 {
     //no, because this trigger before init
     if (empty($this->theme_config)) {
         $this->theme_config = HW__Template::get_theme_config();
     }
 }