Skip to content

Instantly share code, notes, and snippets.

@bravokeyl
Last active January 5, 2016 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bravokeyl/bbe1ac531d99d9c1af59 to your computer and use it in GitHub Desktop.
Save bravokeyl/bbe1ac531d99d9c1af59 to your computer and use it in GitHub Desktop.
Difff
<?php
remove_action('genesis_before_loop', 'genesis_do_breadcrumbs');
remove_action('genesis_entry_header', 'genesis_entry_header_markup_open', 5);
remove_action('genesis_entry_header', 'genesis_do_post_title');
remove_action('genesis_entry_header', 'genesis_post_info', 12);
remove_action('genesis_entry_header', 'genesis_entry_header_markup_close', 15);
remove_action('genesis_entry_content', 'genesis_do_post_image', 8);
remove_action('genesis_entry_footer', 'genesis_post_meta');
remove_action('genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action('genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
remove_action('genesis_sidebar', 'genesis_do_sidebar' );
remove_action('genesis_loop', 'genesis_do_loop');
add_filter('post_class', 'eo_custom_post_class');
function eo_custom_post_class($classes) {
$new_class = 'post';
$classes[] = esc_attr(sanitize_html_class($new_class));
return $classes;
}
add_filter('body_class', 'eo_custom_body_class');
function eo_custom_body_class($classes) {
$new_class = 'category';
$classes[] = esc_attr(sanitize_html_class($new_class));
return $classes;
}
add_action('genesis_before', 'isoc_show_category_header', 11);
add_action('genesis_before', 'parent_breadcrumbs', 14);
add_action('genesis_before', 'share_category', 15);
add_action( 'genesis_entry_content', 'genesis_do_post_image', 1 );
add_action( 'genesis_entry_content', 'image_layer', 2 );
add_action( 'genesis_entry_content', 'content_wrapper_open', 3 );
add_action( 'genesis_entry_content', 'genesis_do_post_title', 4 );
add_action( 'genesis_entry_content', 'be_grid_content', 9 ); // For Genesis 2.x
add_action( 'genesis_entry_content', 'post_format', 5 );
add_action( 'genesis_entry_content', 'content_wrapper_close', 15 );
function isoc_show_category_header() { ?>
<div class="entry-header">
<div class="wrap" id="main" tabindex="0">
<h1 id="cat-name"> <?php echo get_queried_object()->name;?></h1>
<div class="two-thirds">
<h2 id="cat-desc"><?php echo get_queried_object()->description; ?></h2>
</div>
<div class="one-third">
<?php }
function parent_breadcrumbs() {
$child = get_queried_object();
$parent = $child->parent;
$taxonomy = 'event-categories';
if($parent){
$tax_term = get_terms($taxonomy,'include='. $parent)[0];
echo '<a href=' . esc_attr(get_term_link($tax_term, $taxonomy)) . ' class="breadcrumb" >חזרה ל' . $tax_term->name . '</a>';
}
else
echo '<a href=' . get_home_url() . ' class="breadcrumb" >חזרה לדף הבית</a>';
return;
}
function share_category() {
include 'share.php';
echo "</div></div></div>";
}
function slider() {
$args = array(
'tax_query' => array(
array(
'terms' => get_queried_object()->term_id,
),
),
);
if ($args['tax_query'][0]['terms'] === 66){
echo do_shortcode('[new_royalslider id="1"]');
}
if ($args['tax_query'][0]['terms'] === 65){
echo do_shortcode('[new_royalslider id="2"]');
}
}
function generate_post_image() {
global $featured;
if ($featured) {
echo '<div id="main-featured">
<div class="featured-bg" style="background-image:url(' . $featured[0] . ');"></div>
<div class="image-layer"></div>
<div class="wrap">
<div class="featured">';
} else {
echo '<div id="main-featured">
<div class="featured-bg" style="background-image:url(/wp-content/uploads/2015/03/audience1.jpg);"></div>
<div class="image-layer"></div>
<div class="wrap">
<div class="featured">';
}
}
function feature_content_wrapper() {
$args = array(
'post_type' => 'event',
'posts_per_page' => 1,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'event-categories',
'field' => 'id',
'terms' => get_queried_object()->term_id,
'operator' => 'IN'
),
),
);
$fea_query = new WP_Query($args);
if ($fea_query->have_posts()) :
while ($fea_query->have_posts()) : $fea_query->the_post();
$title = get_the_title();
$content = get_the_content();
$featured = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
$permalink = get_the_permalink();
endwhile;
endif;
wp_reset_postdata();
echo '<h1 class="entry-title" itemprop="headline">
<a href="' . $permalink . '" rel="bookmark">' . $title . '</a>
</h1>';
echo '<p>' . wp_trim_words($content, 26) . '</p>';
echo '<a class="more-link" href="' . $permalink . '" rel="nofollow" title="">' . __( 'Read this article', 'isoc' ) . '</a>';
}
function feature_content_wrapper_close() {
echo "</div></div></div>";
}
if ($args['tax_query'][0]['terms'] === 66 || $args['tax_query'][0]['terms'] === 65){
add_action('genesis_before', 'slider', 17);
} else {
add_action('genesis_before', 'generate_post_image', 17);
add_action('genesis_before', 'feature_content_wrapper', 21);
add_action('genesis_before', 'feature_content_wrapper_close', 22);
}
function header_main() {
echo '<h2 class="more-in-cat">' . __( 'More in', 'genesis' ) . ' ' . get_queried_object()->name . '</h2>';
}
function header_side() {
return __('By tags', 'genesis');
}
function header_main_for_main_page() {
echo '<h2 class="more-in-cat">' . __( 'In categories', 'genesis' ) . ' ' . get_queried_object()->name . '</h2>';
}
function header_side_for_main_page() {
echo '<h2 class="more-in-cat">' . __( 'Upcoming Events', 'genesis' ) . '</h2>';
}
// Event Category Tag Cloud
// =============================================================================
/*
* Get by db query the term_id of tags associated with current category
* (posibale to parent category too).
*
* @author ROTEM VAKNIN rotem.v@isoc.org.il‏
* @global wpdb $wpdb Using it to execute an SQL query statement that returns a PHP object
* @param Boolean $with_parent_tags Flag which define whether to return parent category tags too or not.
* @return Strin|Boolean $incluse - The tag_id separate by comma if exists ,else return False.
*/
function get_current_category_tag($with_parent_tags = True) {
// ROTV:
global $wpdb;
$current_category = get_queried_object();
$category = $current_category->term_id;
if ($category) {
$query = "select t.term_id from $wpdb->term_relationships rt, $wpdb->term_taxonomy t where rt.term_taxonomy_id = t.term_id and rt.object_id in (SELECT r.object_id FROM $wpdb->term_relationships r where r.term_taxonomy_id = %s) and rt.term_taxonomy_id != %s ";
$terms = $wpdb->get_results(sprintf($query, $category, $category));
if ($with_parent_tags) {
$category = $current_category->parent;
if ($category)
$terms = array_merge($terms, $wpdb->get_results(sprintf($query, $category, $category)));
}
if ($terms) {
$include = implode(',', array_unique(array_map(function($val) {
return $val->term_id;
}, $terms)));
return $include;
}
}
return False;
}
function get_args_tag_cloud_event_category(){
return $args = array(
'number' => 15,
'taxonomy' => 'event-tags',
'include' => get_current_category_tag(),
'format' => 'list'
);
}
add_filter('widget_tag_cloud_args', 'get_args_tag_cloud_event_category');
function show_tags_cloud(){
$tag_cloud_event = new WP_Widget_Tag_Cloud();
$tag_cloud_event->widget($args = array(
'before_title' => '<h4 class="widget-title widgettitle">',
'after_title' => '</h4>',
'before_widget' => '<div class="widget-wrap"><section id="tag_cloud-6" class="widget widget_tag_cloud">',
'after_widget' => '</section></div>'
), '');
}
// END Event Category Tag Cloud
// =============================================================================
function show_future_event() {
//TODO: Fix the css and html of event content
echo do_shortcode('[events_list scope="future" limit=3][/events_list]');
}
function show_main_grid() {
$args = array(
'post_type' => 'event',
'posts_per_page' => 1,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'event-categories',
'field' => 'id',
'terms' => get_queried_object()->term_id,
'operator' => 'IN'
),
),
);
//TODO: Fix the css and html of event content
if ( $args['tax_query'][0]['terms'] === 66 ){
echo do_shortcode('[ess_grid alias="e-commerce"]');
} elseif ( $args['tax_query'][0]['terms'] === 65 ){
echo do_shortcode('[ess_grid alias="academy"]');
}
}
// ROTV: If the page is the main e-commerce page
if ($args['tax_query'][0]['terms'] === 66 || $args['tax_query'][0]['terms'] === 65){
add_action('genesis_before_loop', 'header_main_for_main_page', 1);
add_action('genesis_before_loop', 'show_main_grid', 2);
add_action('genesis_before_sidebar_widget_area', 'header_side_for_main_page', 1);
// Future events
add_action('genesis_before_sidebar_widget_area', 'show_future_event', 2);
// Articles group
//TODO: Add here the articles group
}
else {
add_action('genesis_before_loop', 'header_main', 1);
add_filter('widget_title', 'header_side');
// Tags cloud
add_action('genesis_before_sidebar_widget_area', 'show_tags_cloud', 2);
// More articles in the subject
add_action('genesis_loop', 'child_do_custom_loop');
}
//* Add featured Image
//* Modify the length of post excerpts
add_filter( 'excerpt_length', 'sp_excerpt_length' );
function sp_excerpt_length( $length ) {
return 34;
}
// Edit the read more link text
add_filter( 'excerpt_more', 'custom_read_more_link');
add_filter('get_the_content_more_link', 'custom_read_more_link');
add_filter('the_content_more_link', 'custom_read_more_link');
function custom_read_more_link() {
//$title = get_the_title();
//return '<a class="more-link" href="' . get_permalink() . '" rel="nofollow" title="' . $title . '">המשיכו לקראו כתבה זו</a>';
//echo '<div class="gradient-overlay"></div>';
}
function content_wrapper_open() {
echo '<div class="content-wrapper">';
}
function image_layer() {
//$rand = rand(1,4);
echo '<div class="image-layer"></div>';
}
function be_grid_content() {
// Only display excerpt if not a teaser
$length = 40;
$title = get_the_title();
// Remove default content so we don't get both
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
if( get_the_excerpt() == '' )
{
echo '<p>' . wp_trim_words( get_the_content(), $length ) . '</p>';
} else {
echo '<p>' . wp_trim_words( get_the_excerpt(), $length ) . '</p>';
}
echo '<a class="more-link" href="' . get_permalink() . '" rel="nofollow" title="' . $title . '">' . __( 'Read this article', 'genesis' ) . '</a>';
}
function post_format() {
// Display post format
if (get_field('event-video-1') != "") { ?>
<span class="video format"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php _e( 'Watch the video', 'genesis' ) ?></a></span>
<?php } if ( has_post_format( 'audio' )) { ?>
<span class="audio format"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php _e( 'Listen to the audio', 'genesis' ) ?></a></span>
<?php }
}
function content_wrapper_close() {
echo '<footer class="entry-footer"></footer></div>';
}
function child_do_custom_loop() {
global $query_args;
$args = array(
'post_type' => 'event',
'posts_per_page' => 5,
'post_status' => 'publish',
'offset' => 1,
'tax_query' => array(
array(
'taxonomy' => 'event-categories',
'field' => 'id',
'terms' => get_queried_object()->term_id,
'operator' => 'IN'
),
),
);
genesis_custom_loop(wp_parse_args($query_args, $args));
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment