Skip to content

Commit

Permalink
Integrazione con Amministrazione Trasparente
Browse files Browse the repository at this point in the history
  • Loading branch information
webgrafia committed Sep 26, 2019
1 parent 6522241 commit 104cab2
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 40 deletions.
7 changes: 6 additions & 1 deletion footer.php
Expand Up @@ -40,8 +40,13 @@
<?php dynamic_sidebar( 'footer-4' ); ?>
</div><!-- /col-lg-3 -->
</div><!-- /row -->
</div><!-- /container -->

<div class="row variable-gutters mb-3">
<div class="col-lg-12">
<?php wp_nav_menu(array("theme_location" => "menu-footer", "depth" => 1, "menu_class" => "footer-inline-menu", "container" => "")) ?>
</div>

</div><!-- /container -->
</footer>
</div><!-- /push_container -->

Expand Down
112 changes: 79 additions & 33 deletions inc/activation.php
Expand Up @@ -142,6 +142,32 @@ function dsi_create_pages_on_theme_activation() {
}
}



// template page per Amministrazione Trasparente
$new_page_title = __( 'Amministrazione Trasparente', 'design_scuole_italia' ); // Page's title
$new_page_content = '[at-sezioni col="2" bar="0" con="0"]'; // Content goes here
$page_check = get_page_by_title( $new_page_title ); // Check if the page already exists
// Store the above data in an array
$new_page = array(
'post_type' => 'page',
'post_title' => $new_page_title,
'post_content' => $new_page_content,
'post_status' => 'publish',
'post_author' => 1,
'post_slug' => 'amministrazione-trasparente'
);
// If the page doesn't already exist, create it
if ( ! isset( $page_check->ID ) ) {
$amministrazione_trasparente_page_id = wp_insert_post( $new_page );

}else{
$amministrazione_trasparente_page_id = $page_check->ID;
}
// setto il setup di amministrazione trasparente
$amm_options = get_option('wpgov_at');
$amm_options["page_id"] = $amministrazione_trasparente_page_id;
update_option("wpgov_at", $amm_options);
/**
* popolamento delle materie
*/
Expand Down Expand Up @@ -347,45 +373,65 @@ function dsi_create_pages_on_theme_activation() {
update_option( 'menu_check', true );


/**
* creo il menu Didattica
*/
$name = __('Didattica', "design_scuole_italia");

wp_delete_nav_menu($name);
$menu_id = wp_create_nav_menu($name);
$menu = get_term_by( 'id', $menu_id, 'nav_menu' );

// todo
wp_update_nav_menu_item($menu->term_id, 0, array(
'menu-item-title' => __('I cicli scolastici e le classi', "design_scuole_italia"),
'menu-item-url' => "#",
'menu-item-status' => 'publish',
'menu-item-type' => 'custom', // optional
));
/**
* creo il menu Didattica
*/
$name = __('Didattica', "design_scuole_italia");

wp_delete_nav_menu($name);
$menu_id = wp_create_nav_menu($name);
$menu = get_term_by( 'id', $menu_id, 'nav_menu' );

// todo
wp_update_nav_menu_item($menu->term_id, 0, array(
'menu-item-title' => __('I cicli scolastici e le classi', "design_scuole_italia"),
'menu-item-url' => "#",
'menu-item-status' => 'publish',
'menu-item-type' => 'custom', // optional
));


wp_update_nav_menu_item($menu->term_id, 0, array(
'menu-item-title' => __('Le schede didattiche', "design_scuole_italia"),
'menu-item-status' => 'publish',
'menu-item-object' => 'scheda_didattica',
'menu-item-type' => 'post_type_archive'
));

wp_update_nav_menu_item($menu->term_id, 0, array(
'menu-item-title' => __('I progetti delle classi', "design_scuole_italia"),
'menu-item-status' => 'publish',
'menu-item-object' => 'scheda_progetto',
'menu-item-type' => 'post_type_archive'
));

$locations_primary_arr = get_theme_mod( 'nav_menu_locations' );
$locations_primary_arr["menu-didattica"] = $menu->term_id;
set_theme_mod( 'nav_menu_locations', $locations_primary_arr );
update_option( 'menu_check', true );

/**
* creo il menu Footer
*/
$name = __('Footer', "design_scuole_italia");

wp_update_nav_menu_item($menu->term_id, 0, array(
'menu-item-title' => __('Le schede didattiche', "design_scuole_italia"),
'menu-item-status' => 'publish',
'menu-item-object' => 'scheda_didattica',
'menu-item-type' => 'post_type_archive'
));
wp_delete_nav_menu($name);
$menu_id = wp_create_nav_menu($name);
$menu = get_term_by( 'id', $menu_id, 'nav_menu' );

wp_update_nav_menu_item($menu->term_id, 0, array(
'menu-item-title' => __('I progetti delle classi', "design_scuole_italia"),
'menu-item-status' => 'publish',
'menu-item-object' => 'scheda_progetto',
'menu-item-type' => 'post_type_archive'
));
wp_update_nav_menu_item($menu->term_id, 0, array(
'menu-item-title' => __('Amministrazione Trasparente', "design_scuole_italia"),
'menu-item-url' => get_page_link( get_page_by_path( 'amministrazione-trasparente' ) ),
'menu-item-status' => 'publish',
'menu-item-type' => 'custom', // optional
));

$locations_primary_arr = get_theme_mod( 'nav_menu_locations' );
$locations_primary_arr["menu-didattica"] = $menu->term_id;
set_theme_mod( 'nav_menu_locations', $locations_primary_arr );
update_option( 'menu_check', true );
$locations_primary_arr = get_theme_mod( 'nav_menu_locations' );
$locations_primary_arr["menu-footer"] = $menu->term_id;
set_theme_mod( 'nav_menu_locations', $locations_primary_arr );


/**
/**
* creo i permessi e le capabilities
*/

Expand Down
42 changes: 38 additions & 4 deletions inc/admin/documento.php
Expand Up @@ -2,7 +2,7 @@
/**
* Definisce post type e tassonomie relative ai documenti
*/
add_action( 'init', 'dsi_register_documento_post_type', 0 );
add_action( 'init', 'dsi_register_documento_post_type', 100 );
function dsi_register_documento_post_type() {

/** documenti **/
Expand Down Expand Up @@ -56,8 +56,12 @@ function dsi_register_documento_post_type() {

register_taxonomy( 'tipologia-documento', array( 'documento' ), $args );

}

register_taxonomy_for_object_type( 'category', 'documento' );
register_taxonomy_for_object_type( 'tipologie', 'documento' );

unregister_post_type( 'amm-trasparente' );
}

/**
* Crea i metabox del post type eventi
Expand Down Expand Up @@ -87,8 +91,38 @@ function dsi_add_documento_metaboxes() {
),
) );



// if ( is_plugin_active( 'amministrazione-trasparente/amministrazionetrasparente.php' ) ) {


$cmb_sottotitolo->add_field(array(
'id' => $prefix . 'is_amministrazione_trasparente',
'name' => __('Amministrazione Trasparente *', 'design_scuole_italia'),
'desc' => __('Seleziona se il documento fa parte di Amministrazione Trasparente', 'design_scuole_italia'),
'type' => 'radio_inline',
'default' => 'false',
'options' => array(
'true' => __('Si', 'design_scuole_italia'),
'false' => __('No', 'design_scuole_italia'),
),
));



$cmb_sottotitolo->add_field(array(
'name' => __('Tipologia di Amministrazione Trasparente ', 'design_scuole_italia'),
'desc' => __('Collega alla sezione di Amministrazione Trasparente. ', 'design_scuole_italia'),
'id' => $prefix . 'tipologia_ammtrasp',
'taxonomy' => 'tipologie', //Enter Taxonomy Slug
'type' => 'taxonomy_select',
'remove_default' => true, // Removes the default metabox provided by WP core.
'attributes' => array(
'data-conditional-id' => $prefix . 'is_amministrazione_trasparente',
'data-conditional-value' => "true",
),
)
);

// }
$cmb_aftercontent = new_cmb2_box( array(
'id' => $prefix . 'box_elementi_dati',
'title' => __( 'Dati Pubblici', 'design_scuole_italia' ),
Expand Down
9 changes: 7 additions & 2 deletions inc/breadcrumb.php
Expand Up @@ -344,8 +344,13 @@ protected function add_items() {

if ( is_post_type_archive() )
$this->add_post_type_archive_items();
elseif (is_tax("tipologie") ){
$ammlink = get_page_link( get_page_by_path( 'amministrazione-trasparente' ) );
$this->items[] = "<a href='".$ammlink."'>".__("Amministrazione Trasparente", "design_scuole_italia")."</a>";
$this->add_term_archive_items();

elseif ( is_category() || is_tag() || is_tax() )
}
elseif ( is_category() || is_tag() || is_tax() )
$this->add_term_archive_items();

elseif ( is_author() )
Expand Down Expand Up @@ -623,7 +628,7 @@ protected function add_term_archive_items() {
}

// If there's a single post type for the taxonomy, use it.
if ( false === $done_post_type && 1 === count( $taxonomy->object_type ) && post_type_exists( $taxonomy->object_type[0] ) ) {
if ( false === $done_post_type && 1 === count( $taxonomy->object_type ) && isset($taxonomy->object_type[0]) && post_type_exists( $taxonomy->object_type[0] ) ) {

// If the post type is 'post'.
if ( 'post' === $taxonomy->object_type[0] ) {
Expand Down
17 changes: 17 additions & 0 deletions inc/cmb2.php
Expand Up @@ -91,6 +91,23 @@ function dsi_get_classe_options( $query_args = false) {
return $options;
}

function dsi_get_tipologie_amministrazione_trasparente( $query_args = false) {

$classi = get_terms( array(
'taxonomy' => 'tipologie',
'hide_empty' => false,
));

$options = array();
if ( $classi ) {
foreach ( $classi as $classe ) {
$options[ $classe->term_id ] = $classe->name;
}
}

return $options;
}


/**
* Lista di tipologia di servizi
Expand Down
5 changes: 5 additions & 0 deletions inc/theme-dependencies.php
Expand Up @@ -95,6 +95,11 @@ function dsi_register_required_plugins() {
'slug' => 'disable-gutenberg',
'required' => true,
),
array(
'name' => 'Amministrazione Trasparente',
'slug' => 'amministrazione-trasparente',
'required' => true,
),
array(
'name' => 'Members',
'slug' => 'members',
Expand Down
18 changes: 18 additions & 0 deletions style.css
Expand Up @@ -157,3 +157,21 @@ table td ul{
}
/** fine tables **/


.footer-inline-menu {
display: flex;
font-weight: 600;
}
.footer-inline-menu ul {
list-style: none !important;
padding: 0;
margin: 0;
}
.footer-inline-menu ul li{
float:left;
padding:20px;
}

.at-tableclass a{
text-decoration:none !important;
}
71 changes: 71 additions & 0 deletions taxonomy-tipologie.php
@@ -0,0 +1,71 @@
<?php
/**
* The template for displaying archive of Amministrazione Trasparente
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#archive
*
* @package Design_Scuole_Italia
*/

get_header();
?>
<main id="main-container" class="main-container petrol">
<?php get_template_part("template-parts/common/breadcrumb"); ?>
<section class="section bg-white py-2 py-lg-3 py-xl-5">
<div class="container">
<div class="row variable-gutters">
<div class="col-lg-12 ">
<div class="section-title">
<?php the_archive_title( '<h2 class="mb-0">', '</h2>' ); ?>
<?php the_archive_description("<p>","</p>"); ?>
</div><!-- /title-section -->
</div><!-- /col-lg-5 col-md-8 offset-lg-2 -->

</div><!-- /row -->
</div><!-- /container -->
</section><!-- /section -->



<section class="section bg-white border-top border-bottom d-block d-lg-none">
<div class="container d-flex justify-content-between align-items-center py-3">
<h3 class="h6 text-uppercase mb-0 label-filter"><strong><?php _e("Filtri", "design_scuole_italia"); ?></strong></h3>
<a class="toggle-search-results-mobile toggle-menu menu-search push-body mb-0" href="#">
<svg class="svg-filters"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#svg-filters"></use></svg>
</a>
</div>
</section>
<section class="section bg-gray-light">
<div class="container">
<div class="row variable-gutters sticky-sidebar-container">
<div class="col-lg-3 bg-white bg-white-left">
<?php get_template_part("template-parts/search/filters", "amministrazione"); ?>
</div>
<div class="col-lg-7 offset-lg-1 pt84">
<?php if ( have_posts() ) : ?>
<?php
/* Start the Loop */
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/list/article', get_post_type() );

endwhile;
?>
<nav class="pagination-wrapper justify-content-center col-12" aria-label="Navigazione centrata">
<?php echo dsi_bootstrap_pagination(); ?>
</nav>
<?php
else :

get_template_part( 'template-parts/content', 'none' );

endif;
?>
</div><!-- /col-lg-8 -->
</div><!-- /row -->
</div><!-- /container -->
</section>
</main>

<?php
get_footer();
32 changes: 32 additions & 0 deletions template-parts/search/filters-amministrazione.php
@@ -0,0 +1,32 @@
<?php
$post_type = get_query_var("post_type");
;
?>
<aside class="aside-list sticky-sidebar search-results-filters">
<form role="search" method="get" class="search-form" action="<?php echo home_url(""); ?>">
<?php if(isset($post_type) && !is_array($post_type) && $post_type != ""){ ?>
<input type="hidden" name="post_type" value="<?php echo $post_type; ?>">
<?php } ?>
<h3 class="h6 text-uppercase"><strong><?php _e("Sezioni", "design_scuole_italia"); ?></strong></h3>
<ul>
<?php
$terms = get_terms( array(
'taxonomy' => 'tipologie',
'hide_empty' => true,
) );
foreach ( $terms as $term ) {
?>
<li>
<div class="custom-control custom-checkbox custom-checkbox-outline">
<input type="radio" class="custom-control-input" name="tipologie" value="<?php echo $term->slug; ?>" id="check-<?php echo $term->slug; ?>" <?php if($term->term_id == get_query_var("tipologie")) echo " checked "; ?> onChange="this.form.submit()">
<label class="custom-control-label" for="check-<?php echo $term->slug; ?>"><?php echo $term->name; ?></label>
</div>
</li>

<?php
}
?>
</ul>

</form>
</aside>

0 comments on commit 104cab2

Please sign in to comment.