diff --git a/README.md b/README.md index 85a18ba..71be1f2 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ attrs - 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 +- box_title : (Optional) Titolo del Box example ======= diff --git a/ai1ec_box.php b/ai1ec_box.php new file mode 100644 index 0000000..3fa1020 --- /dev/null +++ b/ai1ec_box.php @@ -0,0 +1,221 @@ +prefix; + $join .=" LEFT JOIN ".$db_prefix."ai1ec_events + ON $wpdb->posts.ID = ".$db_prefix."ai1ec_events.post_id"; + + return $join; +} + +function set_ai1ec_where( $where, &$wp_query ){ + global $wpdb; + + if(! is_admin() && $wp_query->post_type ='ai3ec_event'){ + date_default_timezone_set("Europe/Rome"); + $now=time(); + + $where .= ' AND (' . $wpdb->ai1ec_events.start .' >= \''.$now.'\' '. + 'OR ' . $wpdb->ai1ec_events.end .' >= \''.$now.'\' )'; + + return $where; + } +} + +function set_ai1ec_limits( $limit, $query ) { + + if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { + return 'LIMIT 0, 6'; + } + + return $limit; +} + +add_filter('posts_orderby', 'set_ai1ec_orderby'); +function set_ai1ec_orderby($orderby) { + $orderby = $wpdb->ai1ec_events.start." ASC"; + return $orderby; +} + +function get_ai1ec_box($attrs){ ?> + 'ai1ec_event', + 'no_found_rows' => 1, + 'posts_per_page' =>$Posts, + 'offset'=> '', + ); + + add_filter('posts_join', 'set_ai1ec_join',10,2); + add_filter( 'posts_where', 'set_ai1ec_where', 10, 2 ); + add_filter('posts_orderby', 'set_ai1ec_orderby'); + add_filter( 'post_limits', 'set_ai1ec_limits', 10, 2 ); + $cat_query = new WP_Query($args); + remove_filter('posts_join', 'set_ai1ec_join'); + remove_filter( 'posts_where', 'set_ai1ec_where'); + remove_filter('posts_orderby', 'set_ai1ec_orderby'); + remove_filter( 'post_limits', 'set_ai1ec_limits'); + $count = 0; +?> + + +
+
+

+
+
+
+ + have_posts()): ?> + + + +
+
+ + + +
+
+

+
+
+
+ + have_posts()): ?> + +
+ + +
+
+ + + +
+
+

+
+
+
+ + have_posts()): ?> + +
+ + +
+
+ + + \ No newline at end of file diff --git a/index.php b/index.php index 3f701e8..db77281 100644 --- a/index.php +++ b/index.php @@ -2,24 +2,23 @@ /* 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. +Description: Permette di ottenere dei box in stile sahifa per le pagine usando uno shortcode, se usato con il plugin all-in-event-calender con il medesimo modo si possono anche ottenere 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'){ + require_once 'page_box.php'; get_page_box($attrs); } else if ($attrs['type']=='event') { - + require_once 'ai1ec_box.php'; + get_ai1ec_box($attrs); } } } \ No newline at end of file diff --git a/home-cats.php b/page_box.php similarity index 99% rename from home-cats.php rename to page_box.php index ee26ab5..42045ac 100644 --- a/home-cats.php +++ b/page_box.php @@ -1,6 +1,5 @@ - //$post_type=ai1ec_event if( !empty($attrs['ids']) ) $page_ids=explode(",",$attrs['ids']); - $home_layout = '2c'; + $home_layout = ''; if( !empty($attrs['layout']) ) $home_layout = $attrs['layout']; @@ -29,6 +28,7 @@ function get_page_box($attrs){ ?> 'orderby' => 'rand' ); + $cat_query = new WP_Query($args); $count = 0; @@ -181,4 +181,4 @@ function get_page_box($attrs){ ?> - \ No newline at end of file +