This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Customizations to Display Posts | |
* | |
* @package CoreFunctionality | |
* @version 2.0 | |
* @author Bill Erickson <bill@billerickson.net> | |
* @copyright Copyright (c) 2018, Bill Erickson | |
* @license GPL-2.0+ | |
*/ | |
class BE_DPS_Customizations { | |
public function __construct() { | |
// Layout = editors-choice | |
add_filter( 'display_posts_shortcode_wrapper_open', array( $this, 'layout_editors_choice_open' ), 10, 2 ); | |
add_filter( 'display_posts_shortcode_output', array( $this, 'layout_editors_choice_item' ), 10, 2 ); | |
add_filter( 'display_posts_shortcode_wrapper_close', array( $this, 'layout_editors_choice_close' ), 10, 2 ); | |
} | |
/** | |
* Layout = editors choice, open | |
* @author Bill Erickson | |
*/ | |
function layout_editors_choice_open( $output, $atts ) { | |
if( empty( $atts['layout'] ) || 'editors-choice' !== $atts['layout'] ) | |
return $output; | |
$classes = array( 'display-posts-listing', 'table', 'table-striped', 'table-small' ); | |
if( !empty( $atts['wrapper_class'] ) ) | |
$classes[] = $atts['wrapper_class']; | |
$output = '<table class="' . join( ' ', $classes ) . '">'; | |
$output .= '<thead><tr role="row" class="row-1"><th>Brand + Product</th><th>Company Report</th><th>Rating</th></tr></thead>'; | |
$output .= '<tbody>'; | |
return $output; | |
} | |
/** | |
* Layout = editors chocie, single item | |
* @author Bill Erickson | |
*/ | |
function layout_editors_choice_item( $output, $atts ) { | |
if( empty( $atts['layout'] ) || 'editors-choice' !== $atts['layout'] ) | |
return $output; | |
$output = '<tr>'; | |
$output .= '<td><a href="' . get_permalink() . '">' . get_the_title() . '</a></td>'; | |
$output .= '<td>' . ea_report_link() . '</td>'; | |
$output .= '<td>' . ea_dog_food_rating() . '</td>'; | |
$output .= '</tr>'; | |
return $output; | |
} | |
/** | |
* Layout = editors choice, close | |
* @author Bill Erickson | |
*/ | |
function layout_editors_choice_close( $output, $atts ) { | |
if( empty( $atts['layout'] ) || 'editors-choice' !== $atts['layout'] ) | |
return $output; | |
$output = '</tbody></table>'; | |
return $output; | |
} | |
} | |
new BE_DPS_Customizations(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment