Gestione dello shortcode di tipo page e README
This commit is contained in:
parent
e72eaac4cf
commit
37f0db614a
3 changed files with 225 additions and 1 deletions
17
README.md
17
README.md
|
@ -1,4 +1,19 @@
|
|||
sahifa-box-em-all
|
||||
=================
|
||||
|
||||
Plugin per wordpress che permette di creare dei box sul modello di quelli di sahifa
|
||||
Plugin per wordpress che permette di creare dei box sul modello di quelli di sahifa. Il tema Sahifa è necessario.
|
||||
|
||||
attrs
|
||||
=====
|
||||
|
||||
- type = page | event : (Required) Tipo di post
|
||||
- ids : (Required) Serie di numeri concatenati da virgole. Gli id da prelevare.
|
||||
- num = (Default 12) : (Optional) Numero di articoli da inserire nella box
|
||||
- layout = 1c | 2c : (Optional) Tipo di Layout da ottenere
|
||||
|
||||
example
|
||||
=======
|
||||
|
||||
- [sbea type="page" ids="11,22"]
|
||||
- [sbea type="page" ids="11,22" layout="1c" num="4"]
|
||||
|
||||
|
|
184
home-cats.php
Normal file
184
home-cats.php
Normal file
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
function get_page_box($attrs){ ?>
|
||||
//$post_type=ai1ec_event
|
||||
<?php
|
||||
global $count2 ;
|
||||
$box_title = "Collettivi/Progetti";
|
||||
if( !empty($attrs['box_title']) )
|
||||
$box_title = $attrs['box_title'];
|
||||
|
||||
$Posts = 12;
|
||||
if( !empty($attrs['num']) )
|
||||
$Posts = $attrs['num'];
|
||||
|
||||
//$page_ids_arr=Array('80','71','16');
|
||||
$page_ids=Array();
|
||||
if( !empty($attrs['ids']) )
|
||||
$page_ids=explode(",",$attrs['ids']);
|
||||
|
||||
$home_layout = '2c';
|
||||
if( !empty($attrs['layout']) )
|
||||
$home_layout = $attrs['layout'];
|
||||
|
||||
$args=Array(
|
||||
'post_type'=> 'page',
|
||||
'post__in' => $page_ids,
|
||||
'no_found_rows' => 1,
|
||||
'posts_per_page' =>$Posts,
|
||||
'offset'=> '',
|
||||
'orderby' => 'rand'
|
||||
);
|
||||
|
||||
$cat_query = new WP_Query($args);
|
||||
|
||||
$count = 0;
|
||||
|
||||
?>
|
||||
<?php if( $home_layout == '2c'): //************** 2C ****************************************************** ?>
|
||||
<?php $count2++; ?>
|
||||
<section class="cat-box column2 <?php if($count2 == 2) { echo 'last-column'; $count2=0; } ?>">
|
||||
<div class="cat-box-title">
|
||||
<h2><?php echo $box_title ; ?></h2>
|
||||
<div class="stripe-line"></div>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<div class="cat-box-content">
|
||||
|
||||
<?php if($cat_query->have_posts()): ?>
|
||||
<ul>
|
||||
<?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
|
||||
<?php if($count == 1) : ?>
|
||||
<li <?php tie_post_class('first-news'); ?>>
|
||||
<div class="inner-content">
|
||||
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
|
||||
<?php tie_thumb( 'tie-medium' ); ?>
|
||||
<span class="overlay-icon"></span>
|
||||
</a>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<?php endif; ?>
|
||||
|
||||
<h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
|
||||
|
||||
<div class="entry">
|
||||
<?php tie_excerpt_home() ?>
|
||||
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More »', 'tie' ) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</li><!-- .first-news -->
|
||||
<?php else: ?>
|
||||
<li <?php tie_post_class(); ?>>
|
||||
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<?php endif; ?>
|
||||
<h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endwhile;?>
|
||||
</ul>
|
||||
|
||||
<?php endif; ?>
|
||||
</div><!-- .cat-box-content /-->
|
||||
</section> <!-- Two Columns -->
|
||||
|
||||
|
||||
<?php elseif( $home_layout == '1c' ): //************** 1C ****************************************************** ?>
|
||||
<section class="cat-box wide-box">
|
||||
<div class="cat-box-title">
|
||||
<h2><?php echo $box_title ; ?></h2>
|
||||
<div class="stripe-line"></div>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<div class="cat-box-content">
|
||||
|
||||
<?php if($cat_query->have_posts()): ?>
|
||||
<ul>
|
||||
<?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
|
||||
<?php if($count == 1) : ?>
|
||||
<li <?php tie_post_class( 'first-news' ); ?>>
|
||||
<div class="inner-content">
|
||||
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
|
||||
<?php tie_thumb( 'tie-large' ); ?>
|
||||
<span class="overlay-icon"></span>
|
||||
</a>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<?php endif; ?>
|
||||
|
||||
<h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
|
||||
<div class="entry">
|
||||
<?php tie_excerpt_home() ?>
|
||||
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More »', 'tie' ) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</li><!-- .first-news -->
|
||||
<?php else: ?>
|
||||
<li <?php tie_post_class(); ?>>
|
||||
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<?php endif; ?>
|
||||
<h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endwhile;?>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div><!-- .cat-box-content /-->
|
||||
</section><!-- Wide Box -->
|
||||
|
||||
<?php else : //************** list ********************************************************************************** ?>
|
||||
|
||||
<section class="cat-box list-box">
|
||||
<div class="cat-box-title">
|
||||
<h2><?php echo $box_title ; ?></h2>
|
||||
<div class="stripe-line"></div>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<div class="cat-box-content">
|
||||
|
||||
<?php if($cat_query->have_posts()): ?>
|
||||
<ul>
|
||||
<?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
|
||||
<?php if($count == 1) : ?>
|
||||
<li <?php tie_post_class( 'first-news' ); ?>>
|
||||
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
|
||||
<?php tie_thumb( 'tie-medium' ); ?>
|
||||
<span class="overlay-icon"></span>
|
||||
</a>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<?php endif; ?>
|
||||
|
||||
<h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
|
||||
|
||||
<div class="entry">
|
||||
<?php tie_excerpt_home() ?>
|
||||
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More »', 'tie' ) ?></a>
|
||||
</div>
|
||||
</li><!-- .first-news -->
|
||||
<?php else: ?>
|
||||
<li <?php tie_post_class( 'other-news' ); ?>>
|
||||
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
|
||||
</div><!-- post-thumbnail /-->
|
||||
<?php endif; ?>
|
||||
<h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endwhile;?>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div><!-- .cat-box-content /-->
|
||||
</section><!-- List Box -->
|
||||
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
25
index.php
Normal file
25
index.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: Sahifa Box'em'all
|
||||
Plugin URI:
|
||||
Description: permette tramite shortcode di ottenere dei box in stile sahifa, se usato con il plugin all-in-event-calender, anche dei box di eventi.
|
||||
Version: 0.1
|
||||
Author: gin(e)
|
||||
Author URI: http://ginex.indivia.net
|
||||
License: BSD(3-clause) Licence
|
||||
*/
|
||||
|
||||
require_once 'home-cats.php';
|
||||
|
||||
add_shortcode('sbea', 'sbea_inject_box');
|
||||
//add_filter('','sbea_inject_content');
|
||||
function sbea_inject_box($attrs){
|
||||
if( is_home() &&
|
||||
isset($attrs['type']) && isset($attrs['ids'])){
|
||||
if($attrs['type']=='page'){
|
||||
get_page_box($attrs);
|
||||
} else if ($attrs['type']=='event') {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue