Last active
February 18, 2019 11:26
-
-
Save geeac/c8602cfac3eb132e6340b4025f256a31 to your computer and use it in GitHub Desktop.
modify class AgentPress_Listings to change the [property_details] shortcode and display data on 3 columns instead of 2
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
class AgentPress_Listings { | |
public $settings_field = 'agentpress_taxonomies'; | |
public $menu_page = 'register-taxonomies'; | |
/** | |
* Property details array. | |
*/ | |
public $property_details; | |
/** | |
* Construct Method. | |
*/ | |
function __construct() { | |
$this->property_details = apply_filters( 'agentpress_property_details', array( | |
'col1' => array( | |
__( 'Price:', 'agentpress-listings' ) => '_listing_price', | |
__( 'Address:', 'agentpress-listings' ) => '_listing_address', | |
__( 'City:', 'agentpress-listings' ) => '_listing_city', | |
__( 'State:', 'agentpress-listings' ) => '_listing_state', | |
__( 'ZIP:', 'agentpress-listings' ) => '_listing_zip' | |
), | |
'col2' => array( | |
__( 'MLS #:', 'agentpress-listings' ) => '_listing_mls', | |
__( 'Square Feet:', 'agentpress-listings' ) => '_listing_sqft', | |
__( 'Bedrooms:', 'agentpress-listings' ) => '_listing_bedrooms', | |
__( 'Bathrooms:', 'agentpress-listings' ) => '_listing_bathrooms', | |
__( 'Basement:', 'agentpress-listings' ) => '_listing_basement' | |
) | |
) ); | |
add_action( 'init', array( $this, 'create_post_type' ) ); | |
add_filter( 'manage_edit-listing_columns', array( $this, 'columns_filter' ) ); | |
add_action( 'manage_posts_custom_column', array( $this, 'columns_data' ) ); | |
add_action( 'admin_menu', array( $this, 'register_meta_boxes' ), 5 ); | |
add_action( 'save_post', array( $this, 'metabox_save' ), 1, 2 ); | |
add_shortcode( 'property_details', array( $this, 'property_details_shortcode' ) ); | |
add_shortcode( 'property_map', array( $this, 'property_map_shortcode' ) ); | |
add_shortcode( 'property_video', array( $this, 'property_video_shortcode' ) ); | |
#add_action( 'admin_head', array( $this, 'admin_style' ) ); | |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_js' ) ); | |
add_filter( 'search_template', array( $this, 'search_template' ) ); | |
add_filter( 'genesis_build_crumbs', array( $this, 'breadcrumbs' ), 10, 2 ); | |
} | |
} |
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
add_action('init', 'gc_extend_ap'); | |
function gc_extend_ap() { | |
if ( class_exists('AgentPress_Listings') ) { | |
class My_AgentPress_Listings extends AgentPress_Listings { | |
function __construct() { | |
parent::__construct(); | |
remove_shortcode( 'property_details' ); | |
add_shortcode( 'property_details', array( $this, 'property_details_shortcode_3col' ) ); | |
} | |
function property_details_shortcode_3col( $atts ) { | |
global $post; | |
$output = ''; | |
$output .= '<div class="property-details">'; | |
$output .= '<div class="property-details-col1 one-half first">'; | |
foreach ( (array) $this->property_details['col1'] as $label => $key ) { | |
$output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) ); | |
} | |
$output .= '</div><div class="property-details-col2 one-half">'; | |
foreach ( (array) $this->property_details['col2'] as $label => $key ) { | |
$output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) ); | |
} | |
//$output .= '</div><div class="clear">'; | |
//$output .= sprintf( '<p><b>%s</b><br /> %s</p></div>', __( 'Additional Features:', 'agentpress-listings' ), get_the_term_list( $post->ID, 'features', '', ', ', '' ) ); | |
$output .= '</div>'; | |
return $output; | |
} // end property_details_shortcode_3col | |
} //end class | |
$gc_agentpress_listings = new My_AgentPress_Listings; | |
}// end if | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment