Ejemplo n.º 1
0
/**
 *
 * enqueue all active skins resource
 * @hook wp_enqueue_scripts
 */
function _hwskin_wp_enqueue_scripts()
{
    //validation
    if (!class_exists('HW_Condition')) {
        return;
    }
    $skins = hwskin_get_actived_skins();
    #$dynamic_settings = HW__Template_Condition::get_active_templates_settings();
    $dynamic_settings = HW_Condition::get_active_conditions_settings();
    foreach ($skins as $id => $skin) {
        if (!empty($skin->instance)) {
            if (isset($skin->hwskin_condition) && isset($dynamic_settings[$skin->hwskin_condition])) {
                $setting = array($skin->hwskin_condition => $dynamic_settings[$skin->hwskin_condition]);
                $setting_conditions = HW__Template_Condition::parse_template_conditions($setting);
                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']) {
                                #$_name = HW_Validation::valid_objname($file);
                                HW_SKIN::enqueue_skins($skin);
                                break;
                                //first occurence
                            }
                        }
                    }
                }
            } else {
                HW_SKIN::enqueue_skins($skin);
            }
        }
    }
}