' . sprintf( __( 'Admin Notice: You need to upgrade to GridMaster Pro in order to use Advanced Post Type Selection feature.', 'ajax-filter-posts' ), esc_url( GRIDMASTER_PRO_LINK ) ) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
// Default attributes.
$default_atts = array(
'post_type' => 'post',
'posts_per_page' => 9,
'orderby' => 'menu_order date', // Display posts sorted by ‘menu_order’ with a fallback to post ‘date’.
'order' => 'DESC',
'tax_query' => array(),
'meta_query' => array(),
'title_length' => 50,
'content_from' => 'excerpt',
'excerpt_type' => 'words',
'excerpt_length' => 15,
'show_read_more' => 'yes',
'read_more_text' => '',
// START OLD ATTRIBUTES.
'show_filter' => 'yes',
'btn_all' => 'yes',
// 'initial' => "-1",
'cat' => '',
'paginate' => 'no',
'hide_empty' => 0,
'pagination_type' => '',
'infinite_scroll' => '',
'animation' => '',
// END OLD ATTRIBUTES.
'grid_style' => 'default', // master ID
'grid_id' => 'gm-' . wp_generate_password( 8, false ), // grid ID.
'taxonomy' => 'category',
'terms' => '',
'grid_image_size' => 'full',
'filter_style' => 'default',
'filter_heading' => '',
'toggle_filter_items' => '',
'id' => 0,
);
// If id is set then get args from the database and render the grid.
// Otherwise render the grid from the shortcode attributes.
// Grid ID.
$grid_id = isset( $atts['id'] ) ? intval( $atts['id'] ) : null;
// Get Grid.
if ( $grid_id ) {
$get_grid = gm_get_grid( $grid_id );
if ( $get_grid ) {
// Route modern v2 grids to the GridMaster 2.0 rendering engine (ONLY if not rolled back to legacy).
$is_v2 = ( isset( $get_grid->migration_status ) && in_array( $get_grid->migration_status, array( 'converted', 'new_builder' ), true ) )
|| ( isset( $get_grid->schema_version ) && $get_grid->schema_version >= 2 && 'legacy' !== $get_grid->migration_status );
if ( $is_v2 ) {
if ( ! class_exists( 'GridMaster\Engine\Grid_Renderer' ) ) {
require_once GRIDMASTER_PATH . '/inc/Engine/Grid_Renderer.php';
}
return \GridMaster\Engine\Grid_Renderer::render_grid( $grid_id );
}
// $atts = $get_grid->attributes;
$atts = wp_parse_args( $atts, $get_grid->attributes );
// Keep the old way for now.
$atts['grid_id'] = 'gm-' . $grid_id;
}
}
// Enqueue legacy frontend scripts and styles conditionally when legacy grid is rendered.
wp_enqueue_script( 'gridmaster-frontend' );
wp_enqueue_style( 'gridmaster-frontend' );
// Shortcode attributes.
$atts = shortcode_atts(
$default_atts,
$atts,
'gridmaster'
);
// Grid Style.
$grid_style = $atts['grid_style'];
// Render dynamic styles.
$this->render_styles(
array(
'grid_style' => $grid_style,
)
);
extract( $atts );
// Pagination
$pagination_type = $atts['pagination_type'];
// Public Attributes
$public_atts = apply_filters( 'gridmaster_shortcode_public_atts', $atts );
// Unset for Public Attributes
unset( $public_atts['grid_col_gap'] );
unset( $public_atts['grid_row_gap'] );
unset( $public_atts['grid_item_per_row'] );
unset( $public_atts['tax_query'] );
unset( $public_atts['meta_query'] );
// unset( $public_atts['grid_style'] ); // Didn't know why put this here
unset( $public_atts['filter_style'] );
// Wrapper Classes
$wrapper_classes = array(
'am_ajax_post_grid_wrap',
$grid_id,
'gridmaster-' . $grid_style,
);
// Add Slider Class
if ( isset( $atts['enable_slider'] ) ) {
$wrapper_classes[] = 'gm-enable-slider-' . $atts['enable_slider'];
}
ob_start();
?>
' . sprintf( __( 'Admin Notice: You need to upgrade to GridMaster Pro in order to use custom taxonomy filters with selected terms.', 'ajax-filter-posts' ), esc_url( GRIDMASTER_PRO_LINK ) ) . '