Skip to content

Instantly share code, notes, and snippets.

@live-mesh
Last active July 2, 2020 10:33
Show Gist options
  • Save live-mesh/fc197105186bbefc511e70d4c9e8b1d9 to your computer and use it in GitHub Desktop.
Save live-mesh/fc197105186bbefc511e70d4c9e8b1d9 to your computer and use it in GitHub Desktop.
Example filters and hooks for Livemesh SiteOrigin Widgets
// Example filters and hooks for Livemesh SiteOrigin Widgets
add_filter('lsow_post_item_media_title_html', 'mytheme_post_item_media_title_html', 10, 3);
function mytheme_post_item_media_title_html($output, $module) {
$output = '';
if ($module->settings['display_title_on_thumbnail']) :
$target = $module->settings['post_link_new_window'] ? ' target="_blank"' : '';
$output = '<h3 class="lsow-post-title">';
if (get_post_type($module->post_ID) == 'project') :
$project_url = get_post_meta($module->post_ID, '_project_link_field', true);
$output .= '<a href="' . $project_url . '" title="' . get_the_title($module->post_ID) . '" rel="bookmark"' . $target . '>' . get_the_title($module->post_ID) . '</a>';
elseif (get_post_type($module->post_ID) == 'partners') :
$partner_url = get_post_meta($module->post_ID, '_partner_link_field', true);
$output .= '<a href="' . $partner_url . '" title="' . get_the_title($module->post_ID) . '" rel="bookmark"' . $target . '>' . get_the_title($module->post_ID) . '</a>';
else :
$output .= '<a href="' . get_permalink($module->post_ID) . '" title="' . get_the_title($module->post_ID) . '" rel="bookmark"' . $target . '>' . get_the_title($module->post_ID) . '</a>';
endif;
$output .= '</h3>';
endif;
return $output;
}
add_filter('lsow_post_item_media_title_html', 'mytheme_post_item_media_title_html', 10, 3);
function mytheme_post_item_media_title_html($output, $module) {
$output = '';
if ($module->settings['display_title_on_thumbnail']) :
$target = $module->settings['post_link_new_window'] ? ' target="_blank"' : '';
$output = '<h3 class="lsow-post-title">';
if (get_post_type($module->post_ID) == 'project') :
$project_url = get_field('partner_website', $module->post_ID);
$project_url = get_permalink($module->post_ID);
$output .= '<a href="' . $project_url . '" title="' . get_the_title($module->post_ID) . '" rel="bookmark"' . $target . '>' . get_the_title($module->post_ID) . '</a>';
elseif (get_post_type($module->post_ID) == 'partners') :
$partner_url = get_field('partner_website', $module->post_ID);
$output .= '<a href="' . $partner_url . '" title="' . get_the_title($module->post_ID) . '" rel="bookmark"' . $target . '>' . get_the_title($module->post_ID) . '</a>';
else :
$output .= '<a href="' . get_permalink($module->post_ID) . '" title="' . get_the_title($module->post_ID) . '" rel="bookmark"' . $target . '>' . get_the_title($module->post_ID) . '</a>';
endif;
$output .= '</h3>';
endif;
return $output;
}
add_filter('lsow_block_header_1_taxonomy_filter_output', 'mytheme_modify_posts_grid_filter', 10, 2);
function mytheme_modify_posts_grid_filter($header_output, $header_obj) {
$header_output = ''; // custom html - pls look at method get_block_taxonomy_filter() in includes/blocks/block-header.php
return $header_output;
}
add_filter('lsow_posts_carousel_entry_excerpt', 'mytheme_modify_posts_carousel_excerpt', 10, 3);
function mytheme_modify_posts_carousel_excerpt($output, $post_id, $settings) {
$output .= '<div class="lsow-read-more">';
$output .= '<a href="' . get_the_permalink($post_id) . '">' . __('Read More', 'my-theme') . '</a>';
$output .= '</div>';
return $output;
}
/* --- Start : Move the entry meta above the title in posts carousel -- */
add_filter('lsow_posts_carousel_entry_title', 'mytheme_posts_carousel_entry_title', 10, 3);
function mytheme_posts_carousel_entry_title($output, $post_id, $settings) {
$output = '<div class="lsow-entry-meta">';
if ($settings['post_meta']['display_author']):
$output .= lsow_entry_author();
endif;
if ($settings['post_meta']['display_post_date']):
$output .= lsow_entry_published();
endif;
if ($settings['post_meta']['display_taxonomy']):
$output .= lsow_get_info_for_taxonomies($taxonomies);
endif;
$output .= '</div>';
$output .= '<h3 class="entry-title">';
$output .= '<a href="' . get_permalink()
. '" title="' . get_the_title()
. '" target="' . $settings["link_target"]
. '" rel="bookmark">' . get_the_title()
. '</a>';
$output .= '</h3>';
return $output;
}
add_filter('lsow_posts_carousel_entry_meta', 'mytheme_posts_carousel_entry_meta');
function mytheme_posts_carousel_entry_meta() {
return ''; // Do not populate any entry meta
}
/* --- END : Move the entry meta above the title in posts carousel -- */
add_filter('lsow_block_module_13', 'mytheme_block_module_13', 10, 2);
function mytheme_block_module_13($output, $module) {
ob_start();
?>
<article
class="lsow-module-13 <?php echo $module->get_module_classes(); ?> <?php echo join(' ', get_post_class('', $module->post_ID)); ?>">
<?php if ($thumbnail_exists = has_post_thumbnail($module->post_ID)): ?>
<div class="lsow-module-image">
<div class="lsow-module-thumb">
<?php echo $module->get_media(); ?>
<?php echo $module->get_lightbox(); ?>
</div>
<div class="lsow-module-image-info">
<div class="lsow-module-entry-info">
<?php echo $module->get_media_title(); ?>
<?php echo $module->get_media_taxonomy(); ?>
</div>
</div>
</div>
<?php endif; ?>
<div class="lsow-module-entry-text">
<div class="lsow-module-meta">
<?php echo $module->get_author(); ?>
<?php echo $module->get_date(); ?>
<?php echo $module->get_comments(); ?>
<?php echo $module->get_taxonomies_info(); ?>
</div>
<?php echo $module->get_title(); ?>
<div class="lsow-excerpt">
<?php echo $module->get_excerpt(); ?>
</div>
<?php echo $module->get_read_more_link(); ?>
</div>
</article><!-- .hentry -->
<?php $output = ob_get_clean();
return $output;
}
add_filter('lsow_posts_carousel_entry_excerpt', 'mytheme_modify_posts_carousel_excerpt', 10, 3);
function mytheme_modify_posts_carousel_excerpt($output, $post_id, $settings) {
$excerpt = '<div class="entry-summary">';
$excerpt .= get_the_excerpt();
$excerpt .= '</div>';
return $excerpt;
}
function mytheme_modify_posts_carousel_title($entry_title, $post_id, $settings) {
$entry_title = '<h3 class="entry-title">';
$link = 'https://aquin.blackflamingo.eu/das-aquin-team/#anker-aquin-vorstand';
$entry_title .= '<a href="' . $link
. '" title="' . get_the_title()
. '" target="' . $settings["link_target"]
. '" rel="bookmark">' . get_the_title()
. '</a>';
$entry_title .= '</h3>';
return $entry_title;
}
add_filter('lsow_posts_carousel_entry_title', 'mytheme_modify_posts_carousel_title', 10, 3);
function mytheme_modify_posts_carousel_thumbnail_html($thumbnail_html, $post_id, $settings) {
$link = 'https://aquin.blackflamingo.eu/das-aquin-team/#anker-aquin-vorstand';
$thumbnail_html = '<a href="' . $link
. '" target="' . $settings['link_target']
. '">' . get_the_post_thumbnail($post_id, $settings['image_size'])
. '</a>';
return $thumbnail_html;
}
add_filter('lsow_posts_carousel_thumbnail_html', 'mytheme_modify_posts_carousel_thumbnail_html', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment