コード例 #1
0
$context['sidebar_elements'] = array('static/dubte_forum.twig', 'baixades.twig', 'links.twig');
$context['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom');
$context['post'] = $post;
$logo = get_img_from_id($post->logotip);
$context['logotip'] = $logo;
$custom_logo_filter = function ($img) use($logo) {
    return $logo;
};
add_filter('wpseo_twitter_image', $custom_logo_filter);
add_filter('wpseo_opengraph_image', $custom_logo_filter);
$context['links'] = $post->get_field('link');
$context['credits'] = $post->get_field('credit');
if (is_array($post->responsable)) {
    $context['responsables'] = get_users_metadata($post->responsable);
} else {
    $context['responsables'] = false;
}
//Contact Form Data
$context['contact']['to_email'] = '*****@*****.**';
$context['contact']['nom_from'] = 'Projectes de Softcatalà';
$context['contact']['assumpte'] = '[Projectes] Contacte des del formulari';
//Related subpages
$query = array('post_id' => $post->ID, 'subpage_type' => 'projecte');
$args = get_post_query_args('page', SearchQueryType::PagePrograma, $query);
query_posts($args);
$context['related_pages'] = Timber::get_posts($args);
if (post_password_required($post->ID)) {
    Timber::render('single-password.twig', $context);
} else {
    Timber::render(array('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig'), $context);
}
コード例 #2
0
$context_holder['categories']['temes'] = Timber::get_terms('esdeveniment_cat');
$context_holder['filters'] = get_the_event_filters();
//Search and filters
$search = get_query_var('cerca');
$tema = get_query_var('tema');
$filter = get_query_var('data');
$filterdate = get_final_time($filter);
//Generate $args query
if (!empty($search) || !empty($tema) || !empty($filter)) {
    $search_args = get_post_query_args('esdeveniment', SearchQueryType::Search, $search);
    $args = wp_parse_args($search_args, $wp_query->query);
    //search + active args
    $date_filter_args = get_post_query_args('esdeveniment', SearchQueryType::FilteredDate, $filterdate);
    $args = wp_parse_args($date_filter_args, $args);
    //all filters applied
    $date_filter_args = get_post_query_args('esdeveniment', SearchQueryType::FilteredTema, $tema);
    $args = wp_parse_args($date_filter_args, $args);
    //all filters applied
    $context_holder['selected_filter_tema'] = $tema;
    $context_holder['selected_filter_data'] = $filter;
    $context_holder['cerca'] = $search;
    $title = 'Esdeveniments - ';
    !empty($search) ? $title .= 'cerca: ' . $search . ' - ' : '';
    !empty($tema) ? $title .= 'tema: ' . get_term_name_by_slug($tema, 'esdeveniment_cat') . ' - ' : '';
    !empty($filter) ? $title .= 'data: ' . get_the_filter_date_name($filter) . ' - ' : '';
    $title .= 'Softcatalà';
} else {
    $title = 'Esdeveniments - Softcatalà';
    $description = 'Esdeveniments relacionats amb el món de la tecnologia i el català.';
    $args = $wp_query->query;
}
コード例 #3
0
ファイル: home-sc.php プロジェクト: softcatala/wp-softcatala
<?php

/**
 * Template Name: Home Softcatala
 *
 * @package wp-softcatala
 */
//Template initialization
$templates = array('home-sc.twig');
$context = Timber::get_context();
$context['ads_container'] = generate_ads_html(array('13', '17'));
//Sections population
$context['slides'] = Timber::get_posts(array('post_type' => 'slide'));
$args = array('post_type' => 'post', 'numberposts' => '3', 'post_status' => 'publish');
$context['posts'] = Timber::get_posts($args);
$args = get_post_query_args('esdeveniment', SearchQueryType::Highlight);
add_filter('posts_orderby', 'orderbyreplace');
query_posts($args);
$context['esdeveniments'] = Timber::get_posts($args);
remove_filter('posts_orderby', 'orderbyreplace');
$context['programari'] = get_top_downloads_home();
Timber::render($templates, $context);
コード例 #4
0
ファイル: index.php プロジェクト: softcatala/wp-softcatala
    $context_holder['title'] = $search;
    $query['s'] = $search;
    $query['categoria'] = array();
    if ($tema) {
        $tema_cat = get_category_by_slug($tema);
        $query['categoria'][] = $tema_cat->term_id;
    }
    if ($tipus) {
        $tipus_cat = get_category_by_slug($tipus);
        $query['categoria'][] = $tipus_cat->term_id;
    }
    $title = 'Notícies - ';
    !empty($search) ? $title .= 'cerca: ' . $search . ' - ' : '';
    !empty($tipus) ? $title .= 'tipus: ' . get_term_name_by_slug($tipus, 'category') . ' - ' : '';
    !empty($tema) ? $title .= 'tema: ' . get_term_name_by_slug($tema, 'category') . ' - ' : '';
    $title .= 'Softcatalà';
    $args = get_post_query_args('post', SearchQueryType::Post, $query);
} else {
    $title = 'Notícies - Softcatalà';
    $args = $wp_query->query;
}
//Posts and pagination
query_posts($args);
$context_holder['posts'] = Timber::get_posts($args);
$context_holder['pagination'] = Timber::get_pagination();
//Context initialization
$description = 'Notícies de llengua catalana, tecnologia en català.';
$context_filterer = new SC_ContextFilterer($context_holder);
$context_overrides = array('title' => $title, 'description' => $description);
$context = $context_filterer->get_filtered_context($context_overrides, false);
Timber::render($templates, $context);
コード例 #5
0
    $query['s'] = $search;
    $query['categoria-programa'] = $categoria_programa;
    $query['sistema-operatiu-programa'] = $sistema_operatiu;
    $args = get_post_query_args('programa', SearchQueryType::Programa, $query);
    //Selected values
    $context_holder['cerca'] = $search;
    $context_holder['selected_filter_categoria'] = isset($args['filter_categoria']) ? $args['filter_categoria'] : '';
    $context_holder['selected_filter_so'] = isset($args['filter_sistema_operatiu']) ? $args['filter_sistema_operatiu'] : '';
    $title = 'Programes - ';
    !empty($search) ? $title .= 'cerca: ' . $search . ' - ' : '';
    !empty($categoria_programa) ? $title .= 'categoria: ' . $categoria_programa . ' - ' : '';
    !empty($sistema_operatiu) ? $title .= 'sistema operatiu: ' . $sistema_operatiu . ' - ' : '';
    $title .= 'Softcatalà';
} elseif (!isset($args)) {
    $title = 'Programes - Softcatalà';
    $args = get_post_query_args('programa', SearchQueryType::Programa);
}
//Posts and pagination
query_posts($args);
$context_holder['posts'] = Timber::get_posts($args);
$context_holder['pagination'] = Timber::get_pagination();
//Contact Form
$context_holder['contact']['to_email'] = get_option('email_rebost');
if (count($context_holder['posts']) == 0 && $flag_search == true) {
    throw_error('404', 'No programs found');
}
//Context initialization
$context_filterer = new SC_ContextFilterer($context_holder);
$context_overrides = array('title' => $title, 'description' => $description);
$context = $context_filterer->get_filtered_context($context_overrides, false);
Timber::render($templates, $context);
コード例 #6
0
/**
 * Function to look up a program with a title similar to the title from the search on the add program form
 *
 * @return json response
 */
function sc_search_program()
{
    if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], $_POST["action"])) {
        $result['text'] = "S'ha produït un error en cercar el programa. Podeu continuar igualment.";
    } else {
        check_is_ajax_call();
        $nom_programa = sanitize_text_field($_POST["nom_programa"]);
        $result = array();
        if (!empty($nom_programa)) {
            $query['s'] = $nom_programa;
            $args = get_post_query_args('programa', SearchQueryType::Programa, $query);
            $result_full = query_posts($args);
        }
        $programs = array_map('generate_post_url_link', $result_full);
        if (count($programs) > 0) {
            $result['programs'] = Timber::fetch('ajax/programs-list.twig', array('programs' => $programs));
            $result['text'] = "El programa que proposeu és algun dels que es mostren a continuació?";
        } else {
            $result['text'] = "El programa no està a la nostra base de dades. Podeu continuar!";
        }
    }
    $response = json_encode($result);
    die($response);
}
コード例 #7
0
ファイル: archive.php プロジェクト: softcatala/wp-softcatala
    //Any other query asking for date parameters will display just news
    $context['categories']['temes'] = Timber::get_terms('category', array('parent' => get_category_id('temes')));
    $context['categories']['tipus'] = Timber::get_terms('category', array('parent' => get_category_id('tipus')));
    if (is_day()) {
        $context['title'] = 'Arxiu ' . get_the_date('j F Y');
    } else {
        if (is_month()) {
            $context['title'] = 'Arxiu ' . get_the_date('F Y');
        } else {
            if (is_year()) {
                $context['title'] = 'Arxiu ' . get_the_date('Y');
            }
        }
    }
}
$context['links'] = $post->get_field('link');
$context['sidebar_top'] = Timber::get_widgets('sidebar_top');
$context['sidebar_elements'] = array('baixades.twig', 'links.twig');
$context['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom');
//Get the posts depending on the parameters
if (isset($filter)) {
    $context['selected_filter'] = $filter;
    $args = get_post_query_args('esdeveniment', SearchQueryType::FilteredDate, $filterdate);
    query_posts($args);
    $context['posts'] = Timber::get_posts($args);
} else {
    $context['posts'] = Timber::get_posts();
}
$context['pagination'] = Timber::get_pagination();
Timber::render($templates, $context);
/* Functions */
コード例 #8
0
<?php

$templates = array('archive-esdeveniment.twig');
$title = 'Esdeveniments: ' . single_term_title('', false) . ' - Softcatalà';
$contextFilterer = new SC_ContextFilterer();
$context = $contextFilterer->get_filtered_context(array('title' => $title));
$post = retrieve_page_data('esdeveniment');
$context['cat_link'] = get_term_link(get_query_var('term'), 'esdeveniment_cat');
$context['post'] = $post;
$context['links'] = $post->get_field('link');
$context['sidebar_top'] = Timber::get_widgets('sidebar_top');
$context['sidebar_elements'] = array('baixades.twig', 'links.twig');
$context['sidebar_bottom'] = Timber::get_widgets('sidebar_bottom');
$context['categories']['temes'] = Timber::get_terms('esdeveniment_cat');
$context['filters'] = get_the_event_filters();
$context['selected_filter'] = get_query_var('filtre');
$context['content_title'] = 'Esdeveniments';
if (get_query_var('filtre')) {
    $filter = get_query_var('filtre');
    $filterdate = get_final_time($filter);
    $context['selected_filter'] = $filter;
    $date_filter_args = get_post_query_args(SearchQueryType::FilteredDate, $filterdate);
    query_posts($date_filter_args);
    $context['posts'] = Timber::get_posts($date_filter_args);
} else {
    $context['posts'] = Timber::get_posts();
}
$context['posts'] = Timber::get_posts();
$context['pagination'] = Timber::get_pagination();
Timber::render($templates, $context);
コード例 #9
0
ファイル: aparell.php プロジェクト: softcatala/wp-softcatala
//Filters population
$context_holder['categories']['sistemesoperatius'] = Timber::get_terms('so_aparell');
$context_holder['categories']['tipus'] = Timber::get_terms('tipus_aparell');
$context_holder['categories']['fabricants'] = Timber::get_terms('fabricant');
//Search and filters
$search = get_query_var('cerca');
$sistema_operatiu = get_query_var('sistema_operatiu');
$tipus_aparell = get_query_var('tipus_aparell');
$fabricant = get_query_var('fabricant');
//Generate $args query
if (!empty($search) || !empty($sistema_operatiu) || !empty($tipus_aparell) || !empty($fabricant)) {
    $query_aparell['s'] = $search;
    $query_aparell['so_aparell'] = $sistema_operatiu;
    $query_aparell['tipus_aparell'] = $tipus_aparell;
    $query_aparell['fabricant'] = $fabricant;
    $args = get_post_query_args('aparell', SearchQueryType::Aparell, $query_aparell);
    $title = 'Aparells - ';
    !empty($search) ? $title .= 'cerca: ' . $search . ' - ' : '';
    !empty($tipus_aparell) ? $title .= 'tipus: ' . get_term_name_by_slug($tipus_aparell, 'tipus_aparell') . ' - ' : '';
    !empty($sistema_operatiu) ? $title .= 'sistema operatiu: ' . get_term_name_by_slug($sistema_operatiu, 'so_aparell') . ' - ' : '';
    !empty($fabricant) ? $title .= 'fabricant: ' . get_term_name_by_slug($fabricant, 'fabricant') . ' - ' : '';
    $title .= 'Softcatalà';
} else {
    $title = 'Aparells - Softcatalà';
    $args = array('post_type' => 'aparell', 'posts_per_page' => -1, 'order' => 'ASC');
}
$context_holder['cerca'] = $search;
$context_holder['selected_filter_so'] = isset($args['filter_so']) ? $args['filter_so'] : '';
$context_holder['selected_filter_tipus'] = isset($args['filter_tipus']) ? $args['filter_tipus'] : '';
$context_holder['selected_filter_fabricant'] = isset($args['filter_fabricant']) ? $args['filter_fabricant'] : '';
//Posts and pagination