4130eaaa by Jeff Balicki

remove un used plugins

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 98f134de
Showing 341 changed files with 0 additions and 4877 deletions
.learndash-course-grid .arrow {
all: unset;
}
.learndash-course-grid .arrow::after {
all: unset;
}
.learndash-course-grid iframe,
.learndash-course-grid embed,
.learndash-course-grid object,
.learndash-course-grid video {
max-width: 100%;
}
/**
* Elementor compatibility script
*/
( function() {
let gridFound, masonryFound;
const gridObserver = new MutationObserver( function( mutations ) {
mutations.forEach( function( mutationRecord ) {
const grid = mutationRecord.target.querySelector( '.learndash-course-grid' ),
skin = grid.dataset.skin,
display = mutationRecord.target.style.display;
if ( 'none' !== display ) {
if ( 'grid' === skin ) {
gridFound = true;
} else if ( 'masonry' === skin ) {
masonryFound = true;
}
}
} );
if ( gridFound && 'function' === typeof learndash_course_grid_init_grid_responsive_design ) {
learndash_course_grid_init_grid_responsive_design();
}
if ( masonryFound && 'function' === typeof learndash_course_grid_init_masonry_responsive_design ) {
learndash_course_grid_init_masonry_responsive_design();
}
} );
const grids = document.querySelectorAll( '.learndash-course-grid' );
grids.forEach( function( grid ) {
const target = grid.closest( '.elementor-tab-content' );
if ( target ) {
gridObserver.observe( target, { attributes : true, attributeFilter : [ 'style' ] } );
}
} );
} )();
\ No newline at end of file
<?php
namespace LearnDash\Course_Grid;
use WP_Query;
use LearnDash\Course_Grid\Utilities;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
class AJAX {
public function __construct()
{
add_action( 'wp_ajax_ld_cg_load_more', [ $this, 'load_posts' ] );
add_action( 'wp_ajax_nopriv_ld_cg_load_more', [ $this, 'load_posts' ] );
add_action( 'wp_ajax_ld_cg_apply_filter', [ $this, 'load_posts' ] );
add_action( 'wp_ajax_nopriv_ld_cg_apply_filter', [ $this, 'load_posts' ] );
}
public function load_posts()
{
if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( $_REQUEST['nonce'], 'ld_cg_load_posts' ) ) {
wp_die();
}
$action_hook = current_filter();
$hook = false;
if ( strpos( $action_hook, 'ld_cg_load_more' ) !== false ) {
$hook = 'load_more';
} elseif ( strpos( $action_hook, 'ld_cg_apply_filter' ) !== false ) {
$hook = 'apply_filter';
}
if ( ! $hook ) {
wp_die();
}
$filter = json_decode( stripslashes( $_REQUEST['filter'] ), true );
$atts = json_decode( stripslashes( $_REQUEST['course_grid'] ), true );
$post_type = sanitize_text_field( $atts['post_type'] );
$page = intval( $atts['page'] );
$per_page = intval( $atts['per_page'] );
$offset = $page * $per_page;
$orderby = sanitize_text_field( $atts['orderby'] );
$order = sanitize_text_field( $atts['order'] );
$search = isset( $filter['search'] ) ? sanitize_text_field( $filter['search'] ) : null;
$pagination = sanitize_text_field( $atts['pagination'] );
$price_min = isset( $filter['price_min'] ) && is_numeric( $filter['price_min'] ) ? floatval( $filter['price_min'] ) : null;
$price_max = isset( $filter['price_max'] ) && is_numeric( $filter['price_max'] ) ? floatval( $filter['price_max'] ) : null;
if ( isset( $filter['search'] ) ) {
unset( $filter['search'] );
}
if ( isset( $filter['price_min'] ) ) {
unset( $filter['price_min'] );
}
if ( isset( $filter['price_max'] ) ) {
unset( $filter['price_max'] );
}
$posts = [];
$query_args = Utilities::build_posts_query_args( $atts );
$query_args['s'] = $search;
$query_args['offset'] = 0;
if (
in_array( $post_type, [ 'sfwd-courses', 'groups' ] )
&& ( isset( $price_min ) || isset( $price_max ) )
) {
$query_args['posts_per_page'] = -1;
}
if ( $hook === 'load_more' ) {
$offset = $page * $per_page;
$query_args['offset'] = $offset;
if ( $per_page == -1 ) {
echo json_encode( [
'status' => 'success',
'html' => '',
'page' => 'complete',
] );
wp_die();
}
} elseif ( $hook === 'apply_filter' ) {
$offset = 0;
$query_args['offset'] = $offset;
}
$tax_count = 0;
foreach ( $filter as $taxonomy => $values ) {
$tax_count++;
if ( ! empty( $values ) && is_array( $values ) ) {
$values = array_map( function( $id ) {
return intval( $id );
}, $values );
$query_args['tax_query'][] = [
'taxonomy' => $taxonomy,
'field' => 'term_id',
'terms' => $values,
];
if ( count( $query_args['tax_query'] ) > 1 ) {
$query_args['tax_query']['relation'] = 'OR';
}
}
}
$query_args = apply_filters( 'learndash_course_grid_query_args', $query_args, $atts, $filter );
$query = new WP_Query( $query_args );
if ( $query->have_posts() ) {
$posts = $query->get_posts();
}
$html = '';
$html_pagination = '';
if ( ! empty( $posts ) ) {
$card = sanitize_text_field( $atts['card'] );
$template = Utilities::get_card_layout( $card );
$has_pagination = false;
if (
in_array( $post_type, [ 'sfwd-courses', 'groups' ] )
&& ( isset( $price_min ) || isset( $price_max ) )
&& defined( 'LEARNDASH_VERSION' )
) {
// Filter posts
$posts = array_filter( $posts, function( $post ) use ( $price_min, $price_max ) {
$price = false;
$price_number = false;
if ( $post->post_type == 'sfwd-courses' ) {
$price = \learndash_get_course_price( $post->ID );
$price_number = floatval( $price['price'] );
} elseif ( $post->post_type == 'groups' ) {
$price = \learndash_get_group_price( $post->ID );
$price_number = floatval( $price['price'] );
}
$price_min_check = true;
if ( $price_min === 0 || $price_min > 0 ) {
$price_min_check = ( $price_number >= $price_min );
}
$price_max_check = true;
if ( isset( $price_max ) ) {
$price_max_check = ( $price_number <= $price_max ) || ( $price_max == 0 && $price['type'] == 'free' );
}
if ( $price && $price_min_check && $price_max_check ) {
return true;
} else {
return false;
}
} );
$total_posts = count( $posts );
$max_num_pages = ceil( $total_posts / $per_page );
$posts = array_slice( $posts, $offset, $per_page );
} else {
$posts = $query->get_posts();
$max_num_pages = $query->max_num_pages;
}
if ( $max_num_pages > $page ) {
$has_pagination = true;
}
foreach ( $posts as $post ) {
ob_start();
if ( $template ) {
extract( learndash_course_grid_prepare_template_post_attributes( $post, $atts ) );
include $template;
}
$html .= ob_get_clean();
}
$pagination_template = Utilities::get_pagination_template( $pagination );
if ( $pagination_template && $has_pagination ) {
ob_start();
include $pagination_template;
$html_pagination .= ob_get_clean();
}
} else {
if ( $hook === 'apply_filter' ) {
$html .= '<p style="text-align: center;">' . __( 'No results found.', 'learndash-course-grid' ) . '</p>';
}
}
if ( $hook === 'load_more' ) {
$page = empty( $html ) || ( $page + 2 ) > $max_num_pages ? 'complete' : $page + 1;
} elseif ( $hook === 'apply_filter' ) {
$page = 1;
}
echo json_encode( [
'status' => 'success',
'html' => $html,
'html_pagination' => $html_pagination,
'page' => $page,
] );
wp_die();
}
}
\ No newline at end of file
<?php
namespace LearnDash\Course_Grid;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use LearnDash\Course_Grid\Utilities;
class Blocks
{
public function __construct()
{
add_action( 'plugins_loaded', [ $this, 'init_blocks' ] );
}
public function init_blocks()
{
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ], 20 );
$blocks = [
'learndash_course_grid' => 'LearnDash_Course_Grid',
'learndash_course_grid_filter' => 'LearnDash_Course_Grid_Filter',
];
foreach ( $blocks as $id => $class ) {
$classname = '\\LearnDash\\Course_Grid\\Gutenberg\\Blocks\\' . $class;
$this->$id = new $classname();
}
}
public function enqueue_block_editor_assets()
{
$asset_file = include LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'includes/gutenberg/assets/js/index.asset.php';
wp_register_script( 'learndash-course-grid-block-editor-helper', LEARNDASH_COURSE_GRID_PLUGIN_URL . 'includes/gutenberg/assets/js/editor.js', [], LEARNDASH_COURSE_GRID_VERSION );
wp_enqueue_script( 'learndash-course-grid-block-editor', LEARNDASH_COURSE_GRID_PLUGIN_URL . 'includes/gutenberg/assets/js/index.js', array_merge( $asset_file['dependencies'], [ 'learndash-course-grid-block-editor-helper' ] ), $asset_file['version'] );
wp_enqueue_style( 'learndash-course-grid-block-editor', LEARNDASH_COURSE_GRID_PLUGIN_URL . 'includes/gutenberg/assets/css/editor.css', [], LEARNDASH_COURSE_GRID_VERSION );
learndash_course_grid_load_inline_script_locale_data();
wp_localize_script(
'learndash-course-grid-block-editor',
'LearnDash_Course_Grid_Block_Editor',
[
'post_types' => Utilities::get_post_types_for_block_editor(),
'skins' => \LearnDash\course_grid()->skins->get_skins(),
'cards' => \LearnDash\course_grid()->skins->get_cards(),
'editor_fields' => \LearnDash\course_grid()->skins->get_default_editor_fields(),
'image_sizes' => Utilities::get_image_sizes_for_block_editor(),
'orderby' => Utilities::get_orderby_for_block_editor(),
'taxonomies' => Utilities::get_taxonomies_for_block_editor(),
'paginations' => Utilities::get_paginations_for_block_editor(),
'is_learndash_active' => defined( 'LEARNDASH_VERSION' ) ? true : false,
]
);
}
}
\ No newline at end of file
<?php
namespace LearnDash\Course_Grid;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use LearnDash\Course_Grid\Utilities;
class Compatibility
{
public function __construct()
{
add_filter( 'learndash_template', [ $this, 'load_v1_template' ], 100, 5 );
// Elementor
add_action( 'elementor/preview/enqueue_styles', [ $this, 'elementor_preview_enqueue_styles' ], 100 );
add_filter( 'learndash_course_grid_post_extra_course_grids', [ $this, 'elementor_post_extra_course_grids' ], 10, 2 );
add_action( 'learndash_course_grid_assets_loaded', [ $this, 'elementor_assets_loaded' ] );
}
public function load_v1_template( $filepath, $name, $args, $echo, $return_file_path )
{
if (
$name === 'course_list_template'
&& defined( 'LEARNDASH_LMS_PLUGIN_DIR' ) && strpos( $filepath, LEARNDASH_LMS_PLUGIN_DIR ) !== false
) {
if (
filter_var( $args['shortcode_atts']['course_grid'], FILTER_VALIDATE_BOOLEAN ) === false
|| ! isset( $args['shortcode_atts']['course_grid'] )
) {
return $filepath;
}
$template = Utilities::get_skin_item( 'legacy-v1' );
return apply_filters( 'learndash_course_grid_template', $template, $filepath, $name, $args, $return_file_path );
}
return $filepath;
}
/**
* Elementor
*/
public function elementor_preview_enqueue_styles()
{
\LearnDash\course_grid()->skins->enqueue_editor_skin_assets();
}
public function elementor_post_extra_course_grids( $course_grids, $post )
{
if ( ! is_a( $post, 'WP_Post' ) ) {
return $course_grids;
}
$is_elementor = get_post_meta( $post->ID, '_elementor_edit_mode', true );
if ( $is_elementor ) {
global $learndash_course_grid_post_elementor_enabled;
$learndash_course_grid_post_elementor_enabled = true;
$elementor_data = get_post_meta( $post->ID, '_elementor_data', true );
if ( $elementor_data ) {
if ( is_string( $elementor_data ) ) {
$elementor_data = json_decode( $elementor_data, true );
}
$elements = Utilities::associative_list_pluck( $elementor_data, 'elements' );
foreach ( $elements as $element ) {
if ( isset( $element['widgetType'] ) ) {
switch ( $element['widgetType'] ) {
case 'tabs':
foreach ( $element['settings']['tabs'] as $tab ) {
$tags = \LearnDash\course_grid()->skins->parse_content_shortcodes( $tab['tab_content'], [] );
$course_grids[] = $tags;
}
break;
}
}
}
}
}
return $course_grids;
}
public function elementor_assets_loaded()
{
global $learndash_course_grid_post_elementor_enabled;
if ( $learndash_course_grid_post_elementor_enabled ) {
wp_enqueue_script( 'learndash-course-grid-elementor-compatibility', LEARNDASH_COURSE_GRID_PLUGIN_URL . '/assets/js/elementor.js', [], LEARNDASH_COURSE_GRID_VERSION, true );
}
}
public function parse_elementor_data( $data )
{
$elements = Utilities::associative_list_pluck( $data, 'elements' );
}
}
<?php
namespace LearnDash\Course_Grid;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
class Security
{
public function __construct()
{
add_filter( 'wp_kses_allowed_html', [ $this, 'filter_allowed_html' ], 10, 2 );
}
/**
* Filter to allow HTML tags for course grid meta box
*
* @param array $tags List of HTML tags
* @param string $context String of context
* @return array New allowed HTML tags
*/
function filter_allowed_html( $tags, $context )
{
if ( 'learndash_course_grid_embed_code' == $context ) {
$tags['iframe'] = [
'allowfullscreen' => true,
'frameborder' => true,
'height' => true,
'src' => true,
'width' => true,
'allow' => true,
'class' => true,
'data-playerid' => true,
'allowtransparency' => true,
'style' => true,
'name' => true,
'watch-type' => true,
'url-params' => true,
'scrolling' => true,
];
$tags['video'] = [
'controls' => true,
'autoplay' => true,
'height' => true,
'width' => true,
'src' => true,
];
$tags['source'] = [
'src' => true,
'media' => true,
'sizes' => true,
'type' => true,
];
$tags['track'] = [
'default' => true,
'src' => true,
'srclang' => true,
'kind' => true,
'label' => true,
];
}
return $tags;
}
}
<?php
namespace LearnDash\Course_Grid;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
class Shortcodes
{
public function __construct()
{
add_action( 'init', [ $this, 'init_shortcodes' ] );
}
public function init_shortcodes()
{
$shortcodes = [
'learndash_course_grid' => 'LearnDash_Course_Grid',
'learndash_course_grid_filter' => 'LearnDash_Course_Grid_Filter',
];
foreach ( $shortcodes as $tag => $class ) {
$classname = '\\LearnDash\\Course_Grid\\Shortcodes\\' . $class;
$this->$tag = new $classname();
}
}
}
\ No newline at end of file
<?php
namespace LearnDash\Course_Grid;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use LearnDash_Translations;
use LearnDash_Settings_Section;
if ( ( class_exists( 'LearnDash_Settings_Section' ) ) ) {
class Translations extends LearnDash_Settings_Section {
// Must match the Text Domain
private $project_slug = 'learndash-course-grid';
private $registered = false;
function __construct() {
$this->settings_page_id = 'learndash_lms_translations';
// Used within the Settings API to uniquely identify this section
$this->settings_section_key = 'settings_translations_'. $this->project_slug;
// Section label/header
$this->settings_section_label = __( 'LearnDash LMS - Course Grid', 'learndash-course-grid' );
// Class LearnDash_Translations add LD v2.5.0
if ( class_exists( 'LearnDash_Translations' ) ) {
// Method register_translation_slug add LD v2.5.5
if ( method_exists( 'LearnDash_Translations', 'register_translation_slug' ) ) {
$this->registered = true;
LearnDash_Translations::register_translation_slug( $this->project_slug, LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'languages' );
}
}
parent::__construct();
}
function add_meta_boxes( $settings_screen_id = '' ) {
if ( ( $settings_screen_id == $this->settings_screen_id ) && ( $this->registered === true ) ) {
parent::add_meta_boxes( $settings_screen_id );
}
}
function show_meta_box() {
$ld_translations = new LearnDash_Translations( $this->project_slug );
$ld_translations->show_meta_box();
}
}
add_action( 'init', function() {
Translations::add_section_instance();
} );
}
/* Settings */
/* General */
.learndash-course-grid-panel .components-base-control.show {
display: block;
}
.learndash-course-grid-panel .components-base-control.hide {
display: none;
}
.components-base-control .left {
float: left;
width: 48%;
}
.components-base-control .right {
float: right;
width: 48%;
}
.components-base-control .color-wrapper .clear-button {
float: right;
margin-top: 5px;
}
.components-base-control .clear {
clear: both;
}
.learndash-course-grid-panel select[multiple] + .components-input-control__suffix {
display: none;
}
/* Color Components */
.learndash-course-grid-panel .color-picker .components-base-control__label {
display: inline-block;
margin-bottom: 12px;
}
.learndash-course-grid-panel .color-wrapper > .component-color-indicator {
margin: 4px 10px 0px 0px;
display: block;
float: left;
}
.learndash-course-grid-panel .color-wrapper > .components-circular-option-picker {
display: block;
}
.learndash-course-grid-panel .color-wrapper > .components-circular-option-picker > .components-circular-option-picker__custom-clear-wrapper {
display: block;
}
/* Course Grid Filter */
.learndash-block-inner > .learndash-course-grid-filter {
position: relative;
}
.learndash-block-inner .learndash-course-grid-filter .filter {
margin-left: 0;
float: none;
}
.learndash-course-grid-panel .components-input-control__container select[multiple].components-select-control__input,
.learndash-course-grid-filter-panel .components-input-control__container select[multiple].components-select-control__input {
min-height: 100px;
padding: 0;
}
\ No newline at end of file
( function() {
function init_masonry() {
// Masonry
const wrappers = document.querySelectorAll( '.learndash-course-grid[data-skin="masonry"]' );
wrappers.forEach( function( wrapper ) {
const items_wrapper = wrapper.querySelector( '.items-wrapper.masonry' );
if ( items_wrapper ) {
const first_item = items_wrapper.querySelector( '.item' );
if ( ! first_item ) {
return;
}
}
learndash_course_grid_init_masonry( items_wrapper );
} );
}
document.addEventListener( 'click', function( e ) {
const el = e.target;
if ( el.closest( '.learndash-block-inner > .learndash-course-grid' ) || el.closest( '.learndash-block-inner > .learndash-course-grid-filter' ) ) {
e.preventDefault();
}
} );
setInterval( function() {
learndash_course_grid_init_grid_responsive_design();
const temp_css = document.querySelectorAll( '.learndash-course-grid-temp-css' );
if ( temp_css ) {
const css_wrapper = document.getElementById( 'learndash-course-grid-custom-css' );
if ( css_wrapper ) {
let style = '';
temp_css.forEach( function( element ) {
style += element.innerText;
} )
css_wrapper.innerHTML = style;
}
}
}, 500 );
setInterval( function() {
init_masonry();
}, 2000 );
} )();
\ No newline at end of file
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-server-side-render'), 'version' => 'a8f2e2e65b135cb859e151a180066f65');
\ No newline at end of file
/**
* Custom ColorPalette component.
*
* @since 2.0.7
*/
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { BaseControl, Button, ColorPalette as GBColorPalette } from '@wordpress/components';
class ColorPalette extends Component {
constructor( props ) {
super( props );
}
render() {
const {
name,
value,
label,
display_state,
setAttributes
} = this.props;
return(
<BaseControl
className={ typeof display_state[ name ] !== 'undefined' && ! display_state[ name ] ? 'hide color-picker' : 'show color-picker' }
label={ label }
>
<div className="color-wrapper">
<GBColorPalette
colors={ [] }
value={ value || '' }
onChange={ ( new_value ) => {
setAttributes( { [ name ]: new_value } );
} }
clearable={ false }
/>
<Button
className='clear-button'
variant='tertiary'
onClick={ () => {
setAttributes( {
[ name ]: null
} )
} }
>
{ __( 'Clear', 'learndash-course-grid' ) }
</Button>
<div className="clear"></div>
</div>
</BaseControl>
);
}
}
export default ColorPalette;
/**
* FilterPanelBody component
*
* @since 2.0
*/
/**
* Internal block libraries
*/
import { Component } from '@wordpress/element'
import { __ } from '@wordpress/i18n'
import { PanelBody, TextControl, ToggleControl, SelectControl, BaseControl } from '@wordpress/components'
class FilterPanelBody extends Component {
constructor( props ) {
super( props );
}
render() {
const {
context,
course_grid_id,
search,
taxonomies,
price,
price_min,
price_max,
setAttributes
} = this.props;
let search_key = 'search';
let taxonomies_key = 'taxonomies';
let price_key = 'price';
let price_min_key = 'price_min';
let price_max_key = 'price_max';
if ( context == 'page' ) {
search_key = 'filter_search';
taxonomies_key = 'filter_taxonomies';
price_key = 'filter_price';
price_min_key = 'filter_price_min';
price_max_key = 'filter_price_max';
}
const taxonomies_options = LearnDash_Course_Grid_Block_Editor.taxonomies;
return (
<PanelBody
title={ __( 'Filter', 'learndash-course-grid' ) }
initialOpen={ context == 'page' ? false : true }
>
{ context == 'widget' &&
<TextControl
label={ __( 'Course Grid ID', 'learndash-course-grid' ) }
help={ __( 'Course grid ID the filter is for.', 'learndash-course-grid' ) }
value={ course_grid_id || '' }
type={ 'text' }
onChange={ ( course_grid_id ) => setAttributes( { course_grid_id } ) }
/>
}
<ToggleControl
label={ __( 'Search', 'learndash-course-grid' ) }
checked={ search }
onChange={ ( search ) => {
const search_obj = {
[ search_key ]: search,
}
setAttributes( search_obj );
} }
/>
<BaseControl>
<SelectControl
multiple
label={ __( 'Taxonomies', 'learndash-course-grid' ) }
help={ __( 'Hold ctrl on Windows or cmd on Mac to select multiple values.', 'learndash-course-grid' ) }
options={ taxonomies_options }
value={ taxonomies || [] }
onChange={ ( taxonomies ) => {
const taxonomies_obj = {
[ taxonomies_key ]: taxonomies,
}
setAttributes( taxonomies_obj );
} }
/>
</BaseControl>
<ToggleControl
label={ __( 'Price', 'learndash-course-grid' ) }
checked={ price }
onChange={ ( price ) => {
const price_obj = {
[ price_key ]: price,
}
setAttributes( price_obj );
} }
/>
<BaseControl>
<TextControl
label={ __( 'Price Min', 'learndash-course-grid' ) }
className={ 'left' }
value={ price_min || 0 }
type={ 'number' }
onChange={ ( price_min ) => {
const price_min_obj = {
[ price_min_key ]: price_min,
}
setAttributes( price_min_obj );
} }
/>
<TextControl
label={ __( 'Price Max', 'learndash-course-grid' ) }
className={ 'right' }
value={ price_max || 0 }
type={ 'number' }
onChange={ ( price_max ) => {
const price_max_obj = {
[ price_max_key ]: price_max,
}
setAttributes( price_max_obj );
} }
/>
<div style={ { clear: 'both' } }></div>
</BaseControl>
</PanelBody>
);
}
}
export default FilterPanelBody;
\ No newline at end of file
/**
* Import blocks
*/
import './learndash-course-grid';
import './learndash-course-grid-filter';
\ No newline at end of file
/**
* LearnDash Block Functions
*
* This is a collection of common functions used within the LeanDash blocks
*
* @since 2.5.9
* @package LearnDash
*/
/**
* Will retrive meta information about the post being edited. For now
* this is only loaded on post edit screen for Gutenberg. So no checks
* are made to ensure that a post is being edited.
* @param string token Token to return from meta array. If not provided will array is returned.
*/
export function ldlms_get_post_edit_meta( token ) {
if ( ( typeof token !== 'undefined') && (token != '') ) {
if (typeof ldlms_settings['meta']['post'][token] !== 'undefined') {
return ldlms_settings['meta']['post'][token];
}
} else {
if (typeof ldlms_settings['meta']['post'] !== 'undefined') {
return ldlms_settings['meta']['post'];
}
}
}
/**
* Will retrive meta information about the post being edited. For now
* this is only loaded on post edit screen for Gutenberg. So no checks
* are made to ensure that a post is being edited.
* @param string token Token to return from meta array. If not provided will array is returned.
*/
export function ldlms_get_setting(token, default_value) {
if ( ( typeof token !== 'undefined' ) && ( token != '' ) && ( typeof ldlms_settings['settings'][token] !== 'undefined' ) ) {
var token_value = ldlms_settings['settings'][token];
return ldlms_settings['settings'][token];
}
return default_value;
}
/**
* Returns the label for custom label element
* @param string token Will represent the custom label field to retreive Course, Courses, Lesson, Quiz.
*/
export function ldlms_get_custom_label( token ) {
if ((typeof ldlms_settings['meta']['post'] !== 'undefined') && (token != '')) {
if (typeof ldlms_settings['settings']['custom_labels'][token] !== 'undefined') {
token = ldlms_settings['settings']['custom_labels'][token];
}
}
return token;
}
/**
* Returns the lowercase label for custom label element
* @param string token Will represent the custom label field to retreive Course, Courses, Lesson, Quiz.
*/
export function ldlms_get_custom_label_lower(token) {
if ((typeof ldlms_settings['meta']['post'] !== 'undefined') && (token != '')) {
if (typeof ldlms_settings['settings']['custom_labels'][token + '_lower'] !== 'undefined') {
token = ldlms_settings['settings']['custom_labels'][token + '_lower'];
}
}
return token;
}
/**
* Returns the slug for custom label element
* @param string token Will represent the custom label field to retreive Course, Courses, Lesson, Quiz.
*/
export function ldlms_get_custom_label_slug(token) {
if (token != '') {
if (typeof ldlms_settings['settings']['custom_labels'][token + '_slug'] !== 'undefined') {
token = ldlms_settings['settings']['custom_labels'][token + '_slug'];
}
}
return token;
}
/**
* Will retrieve meta information about the post being edited. For now
* this is only loaded on post edit screen for Gutenberg. So no checks
* are made to ensure that a post is being edited.
* @param string token Token to return from meta array. If not provided will array is returned.
*/
export function ldlms_get_per_page(token) {
if ((typeof token !== 'undefined') && (token != '')) {
if (typeof ldlms_settings['settings']['per_page'][token] !== 'undefined') {
return ldlms_settings['settings']['per_page'][token];
}
} else if (typeof ldlms_settings['meta']['posts_per_page'] !== 'undefined') {
return ldlms_settings['meta']['posts_per_page'];
}
}
/**
* Returns integer value for variable.
*
* @param mixed var_value Variable to determin integer from.
*
* @return integer value of zero.
*/
export function ldlms_get_integer_value( var_value ) {
if ( typeof var_value === 'undefined' ) {
var_value = 0;
}
var_value = parseInt(var_value);
if (isNaN(var_value)) {
var_value = 0;
}
return var_value;
}
/**
* LearnDash Block ld-course-grid-filter
*
* @since 2.0
*/
/**
* Internal block libraries
*/
import { __, _x, sprintf } from '@wordpress/i18n'
import { registerBlockType } from '@wordpress/blocks'
import { InspectorControls, InspectorAdvancedControls } from '@wordpress/block-editor'
import { Fragment } from '@wordpress/element'
import { Panel, PanelBody, TextControl, ToggleControl, SelectControl, ColorPalette, ColorIndicator, BaseControl } from '@wordpress/components'
import ServerSideRender from '@wordpress/server-side-render'
import FilterPanelBody from '../components/filter-panel-body.js'
registerBlockType(
'learndash/ld-course-grid-filter',
{
title: __( 'LearnDash Course Grid Filter', 'learndash-course-grid' ),
description: __( 'LearnDash course grid filter widget.', 'learndash-course-grid' ),
icon: 'filter',
category: 'learndash-blocks',
supports: {
customClassName: false,
},
attributes: {
course_grid_id: {
type: 'string',
default: '',
},
search: {
type: 'boolean',
default: 1,
},
taxonomies: {
type: 'array',
default: [ 'category', 'post_tag' ],
},
price: {
type: 'boolean',
default: 1,
},
price_min: {
type: 'string',
default: 0,
},
price_max: {
type: 'string',
default: 1000,
},
preview_show: {
type: 'boolean',
default: 1,
}
},
edit: ( props ) => {
const {
attributes: {
course_grid_id,
search,
taxonomies,
price,
price_min,
price_max,
preview_show
},
setAttributes,
} = props;
const taxonomies_options = LearnDash_Course_Grid_Block_Editor.taxonomies;
const inspectorControls = (
<Fragment key={ 'learndash-course-grid-filter-settings' }>
<InspectorControls
key="controls"
>
<Panel
className={ 'learndash-course-grid-filter-panel' }
>
<FilterPanelBody
context={ 'widget' }
course_grid_id={ course_grid_id }
search={ search }
taxonomies={ taxonomies }
price={ price }
price_min={ price_min }
price_max={ price_max }
setAttributes={ setAttributes }
/>
<PanelBody
title = { __( 'Preview', 'learndash-course-grid' ) }
initialOpen={ false }
>
<ToggleControl
label={ __( 'Show Preview', 'learndash-course-grid' ) }
checked={ !! preview_show }
onChange={ ( preview_show ) =>
setAttributes( { preview_show } )
}
/>
</PanelBody>
</Panel>
</InspectorControls>
</Fragment>
)
function do_serverside_render( attributes ) {
if ( attributes.preview_show == true ) {
// We add the meta so the server knowns what is being edited.
// attributes.meta = ldlms_get_post_edit_meta()
return (
<ServerSideRender
block="learndash/ld-course-grid-filter"
attributes={ attributes }
key="learndash/ld-course-grid-filter"
/>
)
} else {
return __(
'[learndash_course_grid_filter] shortcode output shown here',
'learndash-course-grid'
)
}
}
return [
inspectorControls,
do_serverside_render( props.attributes )
];
},
save: ( props ) => {
},
}
);
<?php
namespace LearnDash\Course_Grid\Gutenberg\Blocks;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use LearnDash\Course_Grid\Lib\LearnDash_Gutenberg_Block;
use LearnDash_Gutenberg_Block as Core_LearnDash_Gutenberg_Block;
use WP_Block;
/**
* Course grid filter block trait
*/
trait LearnDash_Course_Grid_Filter_Block_Trait
{
/**
* Object constructor
*/
public function __construct() {
$this->shortcode_slug = 'learndash_course_grid_filter';
$this->block_slug = 'ld-course-grid-filter';
$this->block_attributes = [
'course_grid_id' => [
'type' => 'string',
],
'search' => [
'type' => 'boolean',
],
'taxonomies' => [
'type' => 'array',
],
'price' => [
'type' => 'boolean',
],
'price_min' => [
'type' => 'integer',
],
'price_max' => [
'type' => 'integer',
],
'preview_show' => [
'type' => 'boolean',
]
];
$this->self_closing = true;
$this->init();
}
/**
* Render Block
*
* This function is called per the register_block_type() function above. This function will output
* the block rendered content.
*
* @param array $attributes Shortcode attrbutes.
* @param string $block_content
* @param WP_Block|null $block Block object.
* @return void The output is echoed.
*/
public function render_block( $attributes = array(), $block_content = '', WP_Block $block = null ) {
$attributes = $this->preprocess_block_attributes( $attributes );
$attributes = apply_filters( 'learndash_block_markers_shortcode_atts', $attributes, $this->shortcode_slug, $this->block_slug, '' );
$shortcode_params_str = '';
foreach ( $attributes as $key => $val ) {
if ( is_null( $val ) ) {
continue;
}
if ( is_array( $val ) ) {
$val = implode( ',', $val );
}
if ( ! empty( $shortcode_params_str ) ) {
$shortcode_params_str .= ' ';
}
$shortcode_params_str .= $key . '="' . esc_attr( $val ) . '"';
}
$shortcode_params_str = '[' . $this->shortcode_slug . ' ' . $shortcode_params_str . ']';
$shortcode_out = do_shortcode( $shortcode_params_str );
if ( ( empty( $shortcode_out ) ) ) {
$shortcode_out = '[' . $this->shortcode_slug . '] placeholder output.';
}
return $this->render_block_wrap( $shortcode_out, true );
}
/**
* Called from the LD function learndash_convert_block_markers_shortcode() when parsing the block content.
*
* @since 2.0
*
* @param array $attributes The array of attributes parse from the block content.
* @param string $shortcode_slug This will match the related LD shortcode ld_profile, ld_course_list, etc.
* @param string $block_slug This is the block token being processed. Normally same as the shortcode but underscore replaced with dash.
* @param string $content This is the orignal full content being parsed.
*
* @return array $attributes.
*/
public function learndash_block_markers_shortcode_atts_filter( $attributes = array(), $shortcode_slug = '', $block_slug = '', $content = '' ) {
if ( $shortcode_slug === $this->shortcode_slug ) {
if ( isset( $shortcode_slug['preview_show'] ) ) {
unset( $attributes['preview_show'] );
}
foreach ( $attributes as $key => $value ) {
if ( is_array( $value ) ) {
$attributes[ $key ] = implode( ', ', $value );
} elseif ( is_string( $value ) ) {
// Remove quotes to prevent the attributes from being stripped out.
$attributes[ $key ] = str_replace( [ '"', '\'' ] , '', $attributes[ $key ] );
}
}
}
return $attributes;
}
}
if ( class_exists( 'Core_LearnDash_Gutenberg_Block' ) ) {
class LearnDash_Course_Grid_Filter extends Core_LearnDash_Gutenberg_Block
{
use LearnDash_Course_Grid_Filter_Block_Trait;
}
} else {
class LearnDash_Course_Grid_Filter extends LearnDash_Gutenberg_Block
{
use LearnDash_Course_Grid_Filter_Block_Trait;
}
}
\ No newline at end of file
<?php
namespace LearnDash\Course_Grid\Gutenberg\Blocks;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use LearnDash;
use LearnDash\Course_Grid\Lib\LearnDash_Gutenberg_Block;
use LearnDash_Gutenberg_Block as Core_LearnDash_Gutenberg_Block;
use WP_Block;
/**
* Course grid block trait
*/
trait LearnDash_Course_Grid_Block_Trait
{
/**
* Object constructor
*/
public function __construct() {
$this->shortcode_slug = 'learndash_course_grid';
$this->block_slug = 'ld-course-grid';
$this->block_attributes = array(
'post_type' => array(
'type' => 'string',
),
'per_page' => array(
'type' => 'integer',
),
'orderby' => array(
'type' => 'string',
),
'order' => array(
'type' => 'string',
),
'taxonomies' => array(
'type' => 'string',
),
'enrollment_status' => array(
'type' => 'string',
),
'progress_status' => array(
'type' => 'string',
),
'thumbnail' => array(
'type' => 'boolean',
),
'thumbnail_size' => array(
'type' => 'string',
),
'ribbon' => array(
'type' => 'boolean',
),
'content' => array(
'type' => 'boolean',
),
'title' => array(
'type' => 'boolean',
),
'title_clickable' => array(
'type' => 'boolean',
),
'description' => array(
'type' => 'boolean',
),
'description_char_max' => array(
'type' => 'integer',
),
'post_meta' => array(
'type' => 'boolean',
),
'button' => array(
'type' => 'boolean',
),
'pagination' => array(
'type' => 'string',
),
'grid_height_equal' => array(
'type' => 'boolean',
),
'progress_bar' => array(
'type' => 'boolean',
),
'filter' => array(
'type' => 'boolean',
),
'skin' => array(
'type' => 'string',
),
'card' => array(
'type' => 'string',
),
'columns' => array(
'type' => 'integer',
),
'min_column_width' => array(
'type' => 'string',
),
'items_per_row' => array(
'type' => 'integer',
),
'font_family_title' => array(
'type' => 'string',
),
'font_family_description' => array(
'type' => 'string',
),
'font_size_title' => array(
'type' => 'string',
),
'font_size_description' => array(
'type' => 'string',
),
'font_color_title' => array(
'type' => 'string',
),
'font_color_description' => array(
'type' => 'string',
),
'background_color_title' => array(
'type' => 'string',
),
'background_color_description' => array(
'type' => 'string',
),
'background_color_ribbon' => array(
'type' => 'string',
),
'font_color_ribbon' => array(
'type' => 'string',
),
'background_color_icon' => array(
'type' => 'string',
),
'font_color_icon' => array(
'type' => 'string',
),
'background_color_button' => array(
'type' => 'string',
),
'font_color_button' => array(
'type' => 'string',
),
// Misc
'id' => array(
'type' => 'string',
),
'className' => array(
'type' => 'string',
),
'preview_show' => array(
'type' => 'boolean',
),
'display_state' => array(
'type' => 'object'
),
// Filter
'filter_search' => [
'type' => 'boolean',
],
'filter_taxonomies' => [
'type' => 'array',
],
'filter_price' => [
'type' => 'boolean',
],
'filter_price_min' => [
'type' => 'string',
],
'filter_price_max' => [
'type' => 'string',
],
);
$this->self_closing = true;
$this->init();
}
/**
* Render Block
*
* This function is called per the register_block_type() function above. This function will output
* the block rendered content.
*
* @param array $attributes Shortcode attrbutes.
* @param string $block_content
* @param WP_Block|null $block Block object.
* @return void The output is echoed.
*/
public function render_block( $attributes = array(), $block_content = '', WP_Block $block = null ) {
$attributes = $this->preprocess_block_attributes( $attributes );
$attributes = apply_filters( 'learndash_block_markers_shortcode_atts', $attributes, $this->shortcode_slug, $this->block_slug, '' );
$shortcode_params_str = '';
foreach ( $attributes as $key => $val ) {
if ( is_null( $val ) ) {
continue;
}
if ( is_array( $val ) ) {
$val = implode( ',', $val );
}
if ( ! empty( $shortcode_params_str ) ) {
$shortcode_params_str .= ' ';
}
$shortcode_params_str .= $key . '="' . esc_attr( $val ) . '"';
}
$shortcode_params_str = '[' . $this->shortcode_slug . ' ' . $shortcode_params_str . ']';
$args = LearnDash\course_grid()->skins->parse_shortcode_tags( $shortcode_params_str );
$style = LearnDash\course_grid()->skins->generate_custom_css( $args );
ob_start();
?>
<div class="learndash-course-grid-temp-css" style="display: none;">
<?php echo html_entity_decode( $style ); ?>
</div>
<?php
$script = ob_get_clean();
$shortcode_out = $script;
$shortcode_out .= do_shortcode( $shortcode_params_str );
if ( ( empty( $shortcode_out ) ) ) {
$shortcode_out = '[' . $this->shortcode_slug . '] placeholder output.';
}
return $this->render_block_wrap( $shortcode_out, true );
}
/**
* Called from the LD function learndash_convert_block_markers_shortcode() when parsing the block content.
*
* @since 2.0
*
* @param array $attributes The array of attributes parse from the block content.
* @param string $shortcode_slug This will match the related LD shortcode ld_profile, ld_course_list, etc.
* @param string $block_slug This is the block token being processed. Normally same as the shortcode but underscore replaced with dash.
* @param string $content This is the orignal full content being parsed.
*
* @return array $attributes.
*/
public function learndash_block_markers_shortcode_atts_filter( $attributes = array(), $shortcode_slug = '', $block_slug = '', $content = '' ) {
if ( $shortcode_slug === $this->shortcode_slug ) {
if ( isset( $attributes['preview_show'] ) ) {
unset( $attributes['preview_show'] );
}
if ( isset( $attributes['className'] ) ) {
$attributes['class_name'] = $attributes['className'];
unset( $attributes['className'] );
}
if ( isset( $attributes['display_state'] ) ) {
unset( $attributes['display_state'] );
}
if ( ! isset( $attributes['filter_taxonomies'] ) ) {
$attributes['filter_taxonomies'] = '';
}
foreach ( $attributes as $key => $value ) {
if ( is_array( $value ) ) {
$attributes[ $key ] = implode( ', ', $value );
} elseif ( is_string( $value ) ) {
// Remove quotes to prevent the attributes from being stripped out.
$attributes[ $key ] = str_replace( [ '"', '\'' ] , '', $attributes[ $key ] );
}
}
}
return $attributes;
}
}
if ( class_exists( 'Core_LearnDash_Gutenberg_Block' ) ) {
class LearnDash_Course_Grid extends Core_LearnDash_Gutenberg_Block
{
use LearnDash_Course_Grid_Block_Trait;
}
} else {
class LearnDash_Course_Grid extends LearnDash_Gutenberg_Block
{
use LearnDash_Course_Grid_Block_Trait;
}
}
<?php
namespace LearnDash\Course_Grid\Shortcodes;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use WP_Query;
use LearnDash\Course_Grid\Utilities;
class LearnDash_Course_Grid_Filter
{
public $tag;
public function __construct()
{
$this->tag = 'learndash_course_grid_filter';
$this->register();
}
public function register()
{
add_shortcode( $this->tag, [ $this, 'render' ] );
}
public function get_default_atts()
{
return apply_filters( 'learndash_course_grid_filter_default_shortcode_attributes', [
'course_grid_id' => '',
'search' => true,
'taxonomies' => 'category, post_tag',
'default_taxonomies' => '',
'price' => true,
'price_min' => 0,
'price_max' => 1000,
] );
}
public function render( $shortcode_atts = [], $content = '' )
{
$atts = shortcode_atts( $this->get_default_atts(), $shortcode_atts, $this->tag );
if ( empty( $atts['course_grid_id'] ) ) {
$output = __( 'Missing course_grid_id attribute.', 'learndash-course-grid' );
return $output;
}
$default_taxonomies = Utilities::parse_taxonomies( $atts['default_taxonomies'] );
// Get the template file
$template = Utilities::get_template( 'filter/layout' );
// Include the template file
ob_start();
echo '<div class="learndash-course-grid-filter" data-course_grid_id="' . esc_attr( $atts['course_grid_id'] ) . '" data-taxonomies="' . esc_attr( $atts['taxonomies'] ) . '">';
$atts['taxonomies'] = array_map( function( $tax ) {
return trim( $tax );
}, array_filter( explode( ',', $atts['taxonomies'] ) ) );
if ( '' === $atts['price_min'] ) {
$atts['price_min'] = 0;
}
if ( '' === $atts['price_max'] ) {
$atts['price_max'] = 1000;
}
$atts['price_step'] = ( $atts['price_max'] - $atts['price_min'] ) / 2 / 10;
$atts['price_step'] = ceil( $atts['price_step'] );
if ( $template ) {
include $template;
}
echo '</div>';
// Return the template HTML string
return ob_get_clean();
}
}
<?php
namespace LearnDash\Course_Grid\Shortcodes;
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use WP_Query;
use LearnDash\Course_Grid\Utilities;
class LearnDash_Course_Grid
{
public $tag;
public function __construct()
{
$this->tag = 'learndash_course_grid';
$this->register();
}
public function register()
{
add_shortcode( $this->tag, [ $this, 'render' ] );
}
public function get_default_atts()
{
return apply_filters( 'learndash_course_grid_default_shortcode_attributes', [
// Query
'post_type' => defined( 'LEARNDASH_VERSION' ) ? 'sfwd-courses' : 'post',
'per_page' => 9,
'orderby' => 'ID',
'order' => 'DESC',
'taxonomies' => '',
'enrollment_status' => '',
'progress_status' => '',
// Elements
'thumbnail' => true,
'thumbnail_size' => 'thumbnail',
'ribbon' => true,
'video' => false,
/**
* Content includes title, description and button
*/
'content' => true,
'title' => true,
'title_clickable' => true,
'description' => true,
'description_char_max' => 120,
'button' => true,
'filter' => true,
/**
* Accepts:
*
* 'button' : Load more button
* 'infinite' : Infinite scrolling
* 'pages' : Normal AJAX pagination with number 1, 2, 3, and so on
* 'false' : Doesn't have pagination
*/
'pagination' => 'button',
'grid_height_equal' => false,
'progress_bar' => false,
'post_meta' => true,
// Template
/**
* Accepts:
*
* All values available in templates/skins
*/
'skin' => 'grid',
'card' => 'grid-1',
/**
* Only used in certain skin such as 'grid' and 'masonry'
*/
'columns' => 3,
'min_column_width' => 250,
/**
* Only used in certain skin such as 'carousel'
*/
'items_per_row' => 3,
// Styles
'font_family_title' => '',
'font_family_description' => '',
'font_size_title' => '',
'font_size_description' => '',
'font_color_title' => '',
'font_color_description' => '',
'background_color_title' => '',
'background_color_description' => '',
'background_color_ribbon' => '',
'font_color_ribbon' => '',
'background_color_icon' => '',
'font_color_icon' => '',
'background_color_button' => '',
'font_color_button' => '',
// Misc
'class_name' => '',
/**
* Random unique ID for CSS styling purpose
*/
'id' => '',
// Filter
'filter_search' => true,
'filter_taxonomies' => '',
'filter_price' => true,
'filter_price_min' => 0,
'filter_price_max' => 1000,
] );
}
public function render( $atts = [], $content = '' )
{
$atts = shortcode_atts( $this->get_default_atts(), $atts, $this->tag );
$query_args = Utilities::build_posts_query_args( $atts );
// Query the posts
$query = new WP_Query( $query_args );
$posts = $query->get_posts();
$max_num_pages = $query->max_num_pages;
if ( $max_num_pages > 1 ) {
$has_pagination = true;
} else {
$has_pagination = false;
}
$empty_id = false;
if ( empty( $atts['id'] ) ) {
$empty_id = true;
$atts['id'] = Utilities::generate_random_id();
}
$filter = filter_var( $atts['filter'], FILTER_VALIDATE_BOOLEAN );
// Get the template file
$template = Utilities::get_skin_layout( $atts['skin'] );
$pagination_template = Utilities::get_pagination_template( $atts['pagination'] );
// Include the template file
ob_start();
if ( $empty_id ) {
echo sprintf( '<!-- %s -->', __( 'The LearnDash course grid element below doesn\'t have "id" attribute set in the shortcode so it\'s generated randomyly each time it renders. Please set the "id" attribute in the shortcode so it will be consistent each time it renders. If it\'s not consistent, custom CSS rules in the site that uses the element particular ID may not work.', 'learndash-course-grid' ) );
}
echo '<div id="' . esc_attr( $atts['id'] ) . '" class="learndash-course-grid ' . esc_attr( $atts['class_name'] ) . '" data-page="1" ' . $this->process_attributes_as_html_attributes( $atts ) . '>';
if ( $filter === true ) {
echo '<button class="toggle-filter">' . __( 'Filter', 'learndash-course-grid' ) . '</button>';
echo do_shortcode( '[learndash_course_grid_filter course_grid_id="' . esc_attr( $atts['id'] ) . '" search="' . esc_attr( $atts['filter_search'] ) . '" taxonomies="' . esc_attr( $atts['filter_taxonomies'] ) . '" default_taxonomies="' . esc_attr( $atts['taxonomies'] ) . '" price="' . esc_attr( $atts['filter_price'] ) . '" price_min="' . esc_attr( $atts['filter_price_min'] ) . '" price_max="' . esc_attr( $atts['filter_price_max'] ) . '"]' );
}
if ( $template ) {
include $template;
}
if ( $pagination_template && $has_pagination ) {
include $pagination_template;
}
echo '</div>';
// Return the template HTML string
return ob_get_clean();
}
public function process_attributes_as_html_attributes( $atts = [] )
{
$attributes = '';
foreach ( $atts as $key => $value ) {
if ( is_array( $value ) ) {
$value = implode( ',', $value );
}
$attributes .= ' data-' . $key . '="' . $value . '"';
}
return $attributes;
}
}
<?php
namespace LearnDash;
/**
* Plugin Name: LearnDash LMS - Course Grid
* Plugin URI: https://www.learndash.com/
* Description: Build LearnDash course grid easily.
* Version: 2.0.7
* Author: LearnDash
* Author URI: https://www.learndash.com/
* Text Domain: learndash-course-grid
* Doman Path: languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use LearnDash\Course_Grid\Admin\Meta_Boxes;
use LearnDash\Course_Grid\Security;
use LearnDash\Course_Grid\Skins;
use LearnDash\Course_Grid\AJAX;
use LearnDash\Course_Grid\Shortcodes;
use LearnDash\Course_Grid\Blocks;
use LearnDash\Course_Grid\Compatibility;
class Course_Grid {
private static $instance;
public $shortcodes;
public $blocks;
public $skins;
public $posts;
public static function instance()
{
if ( ! isset( self::$instance ) || ! self::$instance instanceof self ) {
self::$instance = new self;
}
return self::$instance;
}
public function __construct()
{
$this->define_constants();
spl_autoload_register( [ $this, 'autoload' ] );
add_action( 'plugins_loaded', [ $this, 'load_translations' ] );
$this->security = new Security();
$this->skins = new Skins();
$this->ajax = new AJAX();
$this->shortcodes = new Shortcodes();
$this->blocks = new Blocks();
$this->compatibility = new Compatibility();
// Include files manually
include_once LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'includes/functions.php';
// Admin
if ( is_admin() ) {
$this->admin = new \stdClass();
$this->admin->meta_boxes = new Meta_Boxes();
}
}
public function define_constants()
{
if ( ! defined( 'LEARNDASH_COURSE_GRID_VERSION' ) ) {
define( 'LEARNDASH_COURSE_GRID_VERSION', '2.0.7' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_FILE' ) ) {
define( 'LEARNDASH_COURSE_GRID_FILE', __FILE__ );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_PATH' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_URL' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_PATH' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_PATH', LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'templates/' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_URL' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_URL', LEARNDASH_COURSE_GRID_PLUGIN_URL . 'templates/' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_PATH' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_PATH', LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'assets/' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL', LEARNDASH_COURSE_GRID_PLUGIN_URL . 'assets/' );
}
// Added for backward compatibility.
if ( ! defined( 'LEARNDASH_COURSE_GRID_COLUMNS' ) ) {
define( 'LEARNDASH_COURSE_GRID_COLUMNS', 3 );
}
}
public function autoload( $class )
{
$class_components = explode( '\\', $class );
$class_file = str_replace( '_', '-', strtolower( $class_components[ count( $class_components ) - 1 ] ) );
$filename = $class_file . '.php';
$file = false;
if ( strpos( $class, 'LearnDash\\Course_Grid\\Shortcodes\\' ) !== false ) {
$file = 'includes/shortcodes/class-' . $filename;
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\Gutenberg\\Blocks\\' ) !== false ) {
$file = 'includes/gutenberg/blocks/' . $class_file . '/index.php';
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\Admin\\' ) !== false ) {
$file = 'includes/admin/class-' . $filename;
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\Lib' ) !== false ) {
$file = 'includes/lib/class-' . $filename;
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\' ) !== false ) {
$file = 'includes/class-' . $filename;
}
if ( $file && file_exists( LEARNDASH_COURSE_GRID_PLUGIN_PATH . $file ) ) {
include_once LEARNDASH_COURSE_GRID_PLUGIN_PATH . $file;
}
}
public function load_translations()
{
$locale = apply_filters( 'plugin_locale', get_locale(), 'learndash-course-grid' );
load_textdomain( 'learndash-course-grid', WP_LANG_DIR . '/plugins/learndash-course-grid-' . $locale . '.mo' );
load_plugin_textdomain( 'learndash-course-grid', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
include LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'includes/class-translations.php';
}
}
function course_grid()
{
return Course_Grid::instance();
}
course_grid();
\ No newline at end of file
=== LearnDash Course Grid ===
Author: LearnDash
Author URI: https://learndash.com
Plugin URI: https://learndash.com/add-on/course-grid/
LD Requires at least: 3.0
Slug: learndash-course-grid
Tags: grid, view, display
Requires at least: 5.0
Tested up to: 6.0
Requires PHP: 7.0
Stable tag: 2.0.7
Transform the course list created with shortcode [ld_course_list] to grid view.
== Description ==
The Course Grid add-on gives you the ability to create a responsive course library that can be inserted on any page or post of your site. This is a perfect feature if you have a variety of course offerings and want to give users the ability to filter through them by category.
= Add-on Features =
* Responsive grid layout of courses
* Filtering by category
* Display course featured image and short description
* Featured video support
* Dynamic course price listing
* Dynamic course status listing
See the [Add-on](https://learndash.com/add-on/course-grid/) page for more information.
== Installation ==
If the auto-update is not working, verify that you have a valid LearnDash LMS license via LEARNDASH LMS > SETTINGS > LMS LICENSE.
Alternatively, you always have the option to update manually. Please note, a full backup of your site is always recommended prior to updating.
1. Deactivate and delete your current version of the add-on.
1. Download the latest version of the add-on from our [support site](https://support.learndash.com/article-categories/free/).
1. Upload the zipped file via PLUGINS > ADD NEW, or to wp-content/plugins.
1. Activate the add-on plugin via the PLUGINS menu.
== Changelog ==
= 2.0.7 =
* Update remove ColorIndicator component as ColorPalette element now shows color sample clearly
* Update POT file
* Update upgrade LearnDash_Gutenberg_Block class from LD 4.3.0 and prioritize core class before using included class in CG addon
* Update LD gutenberg block lib from the latest LD core version
* Update in-app documentation text
* Fix breaking error opening style tab breaks the Gutenberg block
* Fix overflown video width
* Fix DB query for multisite install
* Fix PHP notice and warning errors
* Fix missing text domain on some strings
* Fix fatal error with Elementor page
* Fix color picker component doesn't have clear value button
* Fix duplicating course grid block and changing styles of one block also changes style of other block
= 2.0.6 =
* Added translation support for block strings
* Updated added back learndash_course_grid_custom_button_text filter hook
* Fixed missing course grid translations
* Fixed slow queries in sites with a large number of users (10,000+)
* Fixed allow max/min prices to be empty
* Fixed correctly set max-min width
* Fixed shortcodes having additional parameters in their tag
* Fixed don't show ribbon if course is closed or has no price
* Fixed grids not displaying correctly in Elementor
* Fixed skin and card assets not correctly loading in Elementor
* Fixed incorrect shared steps URL
* Fixed incorrect variable type for implode
* Fixed meta box styling
* Fixed skins and cards not being filterable
* Fixed incorrect post results if taxonimies attribute values are wrapped in quotes
= 2.0.5 =
* Added pre-defined taxonomies in filter dropdown
* Added support for new global currency in LearnDash core
* Added LearnDash specific selector for CSS to avoid conflicts
* Updated improve ribbon text logic
* Fixed conflict with other plugins that execute the_content() on the front-end
* Fixed taxonomies filter not being able to have more than 1 working term
* Fixed enrolled courses query returning all courses for logged out users
* Fixed undefined functions
* Fixed remove box sizing CSS rule to avoid conflicts with other themes/plugins
* Fixed masonry styles not working correctly
= 2.0.4 =
* Added icon supported element for cards
* Added conditional for element color selector
* Added custom color selector for ribbon, icon, and button elements
* Updated not started label text on CG 2.0 templates based on user activity for LD lesson and topic post type
* Updated not Started label based on user activity for lesson and topic
* Fixed card layouts and styles
* Fixed minor cards layout and CSS styles
* Fixed block editor meta setting value is not passed to front end templates
* Fixed incorrect variable name
* Fixed translations meta box on translations setting page is not loaded
* Fixed update translations metabox to match with plugin name
* Fixed undefined index error
* Fixed undefined JS function
* Fixed missing translation slug
* Fixed legacy v1 course grid is not detected if the shortcode already stored in HTML format in DB
= 2.0.3 =
* Updated masonry script
* Updated grid skin selector
* Fixed PHP deprecated notice
* Fixed legacy v1 assets are not loaded when using ld course list block
* Fixed compatibility error with Elementor for v1 course grid element
= 2.0.2 =
* Fixed asset loading for legacy course grids
= 2.0.1 =
* Added course enrollment status attributes and block option
* Udated removed fixed 4:3 aspect ratio to prevent distorted images
* Fixed course grid assets not loading when Elementor is being used
= 2.0.0 =
* Added course grid Gutenberg block
* Added learndash_course_grid shortcode
* Added learndash_course_grid_filter shortcode
* Added ability to add and use custom template
* Added support for CG 1.0 shortcode
= 1.7.0 =
* Added ability to use HTML in the short description box
* Added custom text support for groups in the Course Grid
* Added Completed/In Progress/Not Available status for Course Grid ribbons
* Added support for the Course Grid ribbon to show for students enrolled in a group
* Added filter 'learndash_course_grid_load_resources' to load styles/scripts dynamically wherever they are wanted using conditional logic
* Updated deprecated .load in jQuery with .on('load)' instead
* Fixed Course Grid styles not being loaded when the shortcode is used in Elementor
* Fixed groups progress indicator
* Fixed undefined variable
* Fixed array index error
= 1.6.0 =
* Added hook to filter course grid html output
* Added docblock for html output filter
* Added class container class names and its filter hook
* Updated ribbon text escaping to wp_kses_post instead of esc_attr
* Updated load grid resources on LD courses archive page
* Updated plugin name and description
* Updated LD get course price helper function to allow users filter the values
* Updated to remove #ld_course_list wrapper on course grid shortcode to prevent conflicts with page builder plugins
* Fixed thumbnail course URL redirects to bare URL instead of nested URL
* Fixed short description unable to be set to empty because legacy value is not saved when saving new value
* Fixed undefined index error
View the full changelog [here](https://www.learndash.com/add-on/course-grid/).
\ No newline at end of file
<div class="item grid-1">
<article id="post-<?php echo esc_attr( $post->ID ); ?>" <?php post_class( 'post', $post->ID ); ?>>
<?php if ( $atts['thumbnail'] == true ) : ?>
<div class="thumbnail">
<?php if ( $atts['ribbon'] == true && ! empty( $ribbon_text ) ) : ?>
<div class="<?php echo esc_attr( $ribbon_class ); ?>">
<?php echo esc_html( $ribbon_text ); ?>
</div>
<?php endif; ?>
<?php if ( $video == true ) : ?>
<div class="video">
<?php echo wp_kses( $video_embed_code, 'learndash_course_grid_embed_code' ); ?>
</div>
<?php elseif ( has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<?php echo get_the_post_thumbnail( $post->ID, $atts['thumbnail_size'] ); ?>
</a>
</div>
<?php elseif ( ! has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<img alt="" src="<?php echo LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL . 'img/thumbnail.jpg'; ?>"/>
</a>
</div>
<?php endif;?>
</div>
<?php endif; ?>
<?php if ( $atts['content'] == true ) : ?>
<div class="content">
<div class="top-meta">
<?php if ( $atts['title'] == true ) : ?>
<h3 class="entry-title">
<?php if ( $atts['title_clickable'] == true ) : ?>
<a href="<?php echo esc_url( $button_link ); ?>">
<?php endif; ?>
<?php echo esc_html( $title ); ?>
<?php if ( $atts['title_clickable'] == true ) : ?>
</a>
<?php endif; ?>
</h3>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true && ! empty( $author ) ) : ?>
<div class="author">
<span><?php printf( _x( 'By %s', 'By author name', 'learndash-course-grid' ), $author['name'] ); ?></span>
</div>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true && ! empty( $reviews ) ) : ?>
<?php
$reviews_floored = floor( $reviews );
$reviews_ceil = ceil( $reviews );
$reviews_number = number_format( $reviews, 1 );
$reviews_max = 5;
?>
<div class="reviews">
<span class="label"><?php printf( __( 'Review %s', 'learndash-course-grid' ), "( {$reviews_number} )" ); ?></span>
<span class="stars">
<?php for ( $i = 1; $i <= $reviews_max; $i++ ) : ?>
<?php
if ( $i <= $reviews_floored ) {
$star_class = 'star-filled';
} elseif ( $i > $reviews_floored && floatval( $reviews_number ) > $reviews_floored && $i <= $reviews_ceil ) {
$star_class = 'star-half';
} else {
$star_class = 'star-empty';
}
?>
<span class="icon dashicons dashicons-<?php echo esc_attr( $star_class ); ?>"></span>
<?php endfor; ?>
</span>
</div>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true && ! empty( $categories ) ) : ?>
<div class="categories">
<span class="icon dashicons dashicons-category"></span>
<span><?php echo esc_html( $categories ); ?></span>
</div>
<?php endif; ?>
</div>
<?php if ( $atts['post_meta'] == true ) : ?>
<hr class="separator">
<div class="bottom-meta">
<?php if ( $duration ) : ?>
<div class="section duration">
<span class="icon dashicons dashicons-clock"></span>
<span class="wrapper">
<span class="label">
<?php _e( 'Duration', 'learndash-course-grid' ); ?>
</span>
<span class="value">
<?php echo esc_html( $duration ); ?>
</span>
</span>
</div>
<?php endif; ?>
<?php if ( $students ) : ?>
<div class="section total-students">
<span class="icon dashicons dashicons-groups"></span>
<span class="wrapper">
<span class="label">
<?php _e( 'Total Students', 'learndash-course-grid' ); ?>
</span>
<span class="value">
<?php echo esc_html( $students['count'] ); ?>
</span>
</span>
</div>
<?php endif; ?>
<?php if ( $lessons ) : ?>
<div class="section total-lessons">
<span class="icon dashicons dashicons-text-page"></span>
<span class="wrapper">
<span class="label">
<?php _e( 'Total Lessons', 'learndash-course-grid' ); ?>
</span>
<span class="value">
<?php echo esc_html( $lessons['count'] ); ?>
</span>
</span>
</div>
<?php endif; ?>
<?php if ( $quizzes ) : ?>
<div class="section total-quizzes">
<span class="icon dashicons dashicons-format-chat"></span>
<span class="wrapper">
<span class="label">
<?php _e( 'Total Quizzes', 'learndash-course-grid' ); ?>
</span>
<span class="value">
<?php echo esc_html( $quizzes['count'] ); ?>
</span>
</span>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $atts['progress_bar'] == true && defined( 'LEARNDASH_VERSION' ) ) : ?>
<?php if ( $post->post_type == 'sfwd-courses' ) : ?>
<?php echo do_shortcode( '[learndash_course_progress course_id="' . $post->ID . '" user_id="' . $user_id . '"]' ); ?>
<?php elseif ( $post->post_type == 'groups' ) : ?>
<div class="learndash-wrapper learndash-widget">
<?php $progress = learndash_get_user_group_progress( $post->ID, $user_id ); ?>
<?php learndash_get_template_part(
'modules/progress-group.php',
array(
'context' => 'group',
'user_id' => $user_id,
'group_id' => $post->ID,
),
true
); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
</article>
</div>
\ No newline at end of file
.learndash-course-grid .items-wrapper .grid-1 .post {
line-height: 1.428571429;
background-color: #ffffff;
border: 1px solid #dddddd;
border-radius: 4px;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
display: inline-block;
max-width: 100%;
height: auto;
display: block;
position: relative;
padding: 0;
margin: 0;
box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
-moz-box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
-webkit-box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
}
.learndash-course-grid .items-wrapper .grid-1 .ribbon {
text-shadow: 0 1px rgb( 0 0 0 / 30% );
position: absolute;
z-index: 2;
top: 20px;
right: 20px;
left: auto;
padding: 10px 12px;
border-radius: 6px;
color: #fff;
background: #fd6703;
font-weight: bold;
font-size: 1rem;
}
.learndash-course-grid .items-wrapper .grid-1 .ribbon::before {
}
.learndash-course-grid .items-wrapper .grid-1 .thumbnail {
margin: 0;
padding: 0;
}
.learndash-course-grid .items-wrapper .grid-1 .video > * {
border-radius: 5px;
}
.learndash-course-grid .items-wrapper .grid-1 .thumbnail img {
margin: 0 auto;
padding: 0;
width: 100%;
height: auto;
}
.learndash-course-grid .items-wrapper .grid-1 .content {
padding: 30px 22px;
color: #333333;
}
.learndash-course-grid .items-wrapper .grid-1 .content > *:not(:last-child) {
margin-bottom: 20px;
}
.learndash-course-grid .items-wrapper .grid-1 .content .top-meta > *:not(:last-child) {
margin-bottom: 20px;
}
.learndash-course-grid .items-wrapper .grid-1 .content .entry-title {
font-size: 1.2rem;
font-weight: bold;
line-height: 1.2;
color: #333;
}
.learndash-course-grid .items-wrapper .grid-1 .content .entry-title a {
text-decoration: none;
color: #333;
font-size: 1.2rem;
line-height: 1.2;
font-weight: bold;
}
.learndash-course-grid .items-wrapper .grid-1 .content .entry-content {
margin-bottom: 20px ;
}
.learndash-course-grid .items-wrapper .grid-1 .content .entry-content > * {
margin: 0;
}
.learndash-course-grid .items-wrapper .grid-1 .content .author {
font-size: 0.875rem;
color: #949ca1;
}
.learndash-course-grid .items-wrapper .grid-1 .content .reviews,
.learndash-course-grid .items-wrapper .grid-1 .content .categories {
font-size: 0.875rem;
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .grid-1 .icon {
justify-content: center;
margin-right: 3px;
}
.learndash-course-grid .items-wrapper .grid-1 .content .categories .icon {
font-size: 0.875rem;
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .grid-1 .content .reviews .label {
margin-right: 10px;
}
.learndash-course-grid .items-wrapper .grid-1 .content .reviews .stars {
color: #ffb703;
}
.learndash-course-grid .items-wrapper .grid-1 .bottom-meta {
display: grid;
grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
font-size: 0.75rem;
gap: 15px;
}
.learndash-course-grid .items-wrapper .grid-1 .bottom-meta .section {
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .grid-1 .bottom-meta .section .icon {
width: auto;
height: auto;
display: block;
font-size: 1rem;
padding: 5px;
background: #00bcb6;
color: #fff;
border-radius: 5px;
}
.learndash-course-grid .items-wrapper .grid-1 .bottom-meta .section .wrapper {
margin-left: 5px;
}
.learndash-course-grid .items-wrapper .grid-1 .bottom-meta .section .wrapper .label {
font-weight: bold;
}
.learndash-course-grid .items-wrapper .grid-1 .bottom-meta .section .wrapper > * {
display: block;
}
\ No newline at end of file
<div class="item grid-2">
<article id="post-<?php echo esc_attr( $post->ID ); ?>" <?php post_class( 'post', $post->ID ); ?>>
<?php if ( $atts['thumbnail'] == true ) : ?>
<div class="thumbnail">
<?php if ( $atts['ribbon'] == true && ! empty( $ribbon_text ) ) : ?>
<div class="<?php echo esc_attr( $ribbon_class ); ?>">
<?php echo esc_html( $ribbon_text ); ?>
</div>
<?php endif; ?>
<?php if ( $video == true ) : ?>
<div class="video">
<?php echo htmlspecialchars_decode( $video_embed_code ); ?>
</div>
<?php elseif( has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<?php echo get_the_post_thumbnail( $post->ID, $atts['thumbnail_size'] ); ?>
</a>
</div>
<?php elseif( ! has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<img alt="" src="<?php echo LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL . 'img/thumbnail.jpg'; ?>"/>
</a>
</div>
<?php endif;?>
<div class="arrow button"><a href="<?php echo esc_url( $button_link ); ?>"><span class="dashicons dashicons-arrow-right-alt2"></span></a></div>
</div>
<?php endif; ?>
<?php if ( $atts['content'] == true ) : ?>
<div class="content">
<?php if ( $atts['post_meta'] == true ) : ?>
<div class="meta">
<?php if ( $author ) : ?>
<div class="author">
<img class="avatar" src="<?php echo esc_url( $author['avatar'] ) ; ?>" alt="<?php echo $author['name'] ?>">
<div class="wrapper">
<span class="name"><?php echo esc_html( $author['name'] ); ?></span>
<span class="inner-wrapper">
<?php if ( $duration ) : ?>
<span class="duration"><?php printf( __( 'Duration: %s', 'learndash-course-grid' ), $duration ); ?></span>
<?php endif; ?>
<?php if ( $lessons ) : ?>
<span class="lessons"><?php printf( __( '%d Lessons', 'learndash-course-grid' ), $lessons['count'] ); ?></span>
<?php endif; ?>
</span>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $atts['title'] == true ) : ?>
<h3 class="entry-title">
<?php if ( $atts['title_clickable'] == true ) : ?>
<a href="<?php echo esc_url( $button_link ); ?>">
<?php endif; ?>
<?php echo esc_html( $title ); ?>
<?php if ( $atts['title_clickable'] == true ) : ?>
</a>
<?php endif; ?>
</h3>
<?php endif; ?>
<?php if ( $atts['description'] == true && ! empty( $description ) ) : ?>
<div class="entry-content">
<?php echo wp_kses( $description, 'post' ); ?>
</div>
<?php endif; ?>
<?php if ( $atts['progress_bar'] == true && defined( 'LEARNDASH_VERSION' ) ) : ?>
<?php if ( $post->post_type == 'sfwd-courses' ) : ?>
<?php echo do_shortcode( '[learndash_course_progress course_id="' . $post->ID . '" user_id="' . $user_id . '"]' ); ?>
<?php elseif ( $post->post_type == 'groups' ) : ?>
<div class="learndash-wrapper learndash-widget">
<?php $progress = learndash_get_user_group_progress( $post->ID, $user_id ); ?>
<?php learndash_get_template_part(
'modules/progress-group.php',
array(
'context' => 'group',
'user_id' => $user_id,
'group_id' => $post->ID,
),
true
); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ( $atts['button'] == true ) : ?>
<div class="button">
<a role="button" href="<?php echo esc_url( $button_link ); ?>" rel="bookmark"><?php echo esc_attr( $button_text ); ?></a>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</article>
</div>
\ No newline at end of file
.learndash-course-grid .items-wrapper .grid-2 .post {
line-height: 1.428571429;
background-color: #ffffff;
border: 1px solid #dddddd;
border-radius: 4px;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
display: inline-block;
max-width: 100%;
height: auto;
display: block;
position: relative;
padding: 0;
margin: 0;
box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
-moz-box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
-webkit-box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
}
.learndash-course-grid .items-wrapper .grid-2 .ribbon {
text-shadow: 0 1px rgb( 0 0 0 / 30% );
position: absolute;
z-index: 2;
top: 20px;
right: 15px;
left: auto;
padding: 10px 12px;
border-radius: 6px;
color: #fff;
background: #0f69aa;
font-weight: bold;
font-size: 1rem;
}
.learndash-course-grid .items-wrapper .grid-2 .ribbon::before {
}
.learndash-course-grid .items-wrapper .grid-2 .thumbnail {
margin: 0;
padding: 0;
position: relative;
}
.learndash-course-grid .items-wrapper .grid-2 .thumbnail img {
margin: 0 auto;
padding: 0;
width: 100%;
height: auto;
}
.learndash-course-grid .items-wrapper .grid-2 .thumbnail .arrow {
position: absolute;
right: 10px;
bottom: -18px;
left: initial;
top: initial;
overflow: visible;
z-index: 1000;
height: auto;
width: auto;
margin: 0;
padding: 0;
border-radius: 100px;
}
.learndash-course-grid .items-wrapper .grid-2 .thumbnail .arrow a {
border-radius: 100px;
display: block;
}
.learndash-course-grid .items-wrapper .grid-2 .thumbnail .arrow * {
text-decoration: none;
}
.learndash-course-grid .items-wrapper .grid-2 .thumbnail .arrow .dashicons {
background: #fd9752;
color: #fff;
font-size: 25px;
width: auto;
height: auto;
padding: 5px;
border-radius: 100px;
}
.learndash-course-grid .items-wrapper .grid-2 .content {
padding: 30px 22px;
color: #333333;
}
.learndash-course-grid .items-wrapper .grid-2 .content > *:not(:last-child) {
margin-bottom: 20px;
}
.learndash-course-grid .items-wrapper .grid-2 .content .author {
display: flex;
gap: 15px;
}
.learndash-course-grid .items-wrapper .grid-2 .content .author .avatar {
width: 43px;
height: 43px;
border-radius: 30px;
display: block;
}
.learndash-course-grid .items-wrapper .grid-2 .content .author .wrapper {
display: grid;
width: 100%;
}
.learndash-course-grid .items-wrapper .grid-2 .content .author .name {
font-weight: bold;
font-size: 1rem;
}
.learndash-course-grid .items-wrapper .grid-2 .content .author .wrapper .lessons {
float: right;
}
.learndash-course-grid .items-wrapper .grid-2 .content .entry-title {
font-size: 1.2rem;
font-weight: bold;
line-height: 1.2;
color: #333;
}
.learndash-course-grid .items-wrapper .grid-2 .content .entry-title a {
text-decoration: none;
color: #333;
font-size: 1.2rem;
line-height: 1.2;
font-weight: bold;
}
.learndash-course-grid .items-wrapper .grid-2 .content .entry-content {
margin-bottom: 20px;
color: #949ca1;
font-size: 0.875rem;
}
.learndash-course-grid .items-wrapper .grid-2 .content .entry-content > * {
margin: 0;
}
.learndash-course-grid .items-wrapper .grid-2 .content .author {
font-size: 0.875rem;
color: #949ca1;
}
.learndash-course-grid .items-wrapper .grid-2 .content .button {
margin: 0;
padding: 0;
background: none;
border: none;
border-radius: 5px;
width: 100%;
}
.learndash-course-grid .items-wrapper .grid-2 .content .button a {
color: #ffffff;
font-weight: bold;
text-decoration: none;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
text-align: center;
display: -ms-flexbox;
display: flex;
justify-content: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
background-color: #143f5e;
border-color: #143f5e;
border-radius: 5px;
font-size: 1rem;
padding: 12px 0;
}
.learndash-course-grid .items-wrapper .grid-2 .content .button a:hover {
background: #29648f;
border-color: #29648f;
}
\ No newline at end of file
<div class="item grid-3">
<article id="post-<?php echo esc_attr( $post->ID ); ?>" <?php post_class( 'post', $post->ID ); ?>>
<?php if ( $atts['thumbnail'] == true ) : ?>
<div class="thumbnail">
<?php if ( $video == true && ! empty( $video_embed_code ) ) : ?>
<div class="video">
<?php echo wp_kses( $video_embed_code, 'learndash_course_grid_embed_code' ); ?>
</div>
<?php elseif( has_post_thumbnail( $post->ID ) ) : ?>
<div class="thumbnail">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<?php echo get_the_post_thumbnail( $post->ID, $atts['thumbnail_size'] ); ?>
</a>
</div>
<?php elseif( ! has_post_thumbnail( $post->ID ) ) : ?>
<div class="thumbnail">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<img alt="" src="<?php echo LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL . 'img/thumbnail.jpg'; ?>"/>
</a>
</div>
<?php endif;?>
</div>
<?php endif; ?>
<?php if ( $atts['content'] == true ) : ?>
<div class="content">
<?php if ( $atts['title'] == true ) : ?>
<h3 class="entry-title">
<?php if ( $atts['title_clickable'] == true ) : ?>
<a href="<?php echo esc_url( $button_link ); ?>">
<?php endif; ?>
<?php echo esc_html( $title ); ?>
<?php if ( $atts['title_clickable'] == true ) : ?>
</a>
<?php endif; ?>
</h3>
<?php endif; ?>
<?php if ( $atts['post_meta'] ) : ?>
<div class="meta">
<?php if ( $author ) : ?>
<div class="author">
<img src="<?php echo esc_url( $author['avatar'] ); ?>" alt="<?php echo esc_attr( $author['name'] ); ?>">
<span><?php printf( _x( 'By %s', 'By author name', 'learndash-course-grid' ), '<span class="name">' . $author['name'] . '</span>' ); ?></span>
</div>
<?php endif; ?>
<?php if ( $categories ) : ?>
<div class="categories">
<?php echo esc_html( $categories ); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $atts['description'] == true && ! empty( $description ) ) : ?>
<div class="entry-content">
<?php echo wp_kses( $description, 'post' ); ?>
</div>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true ) : ?>
<div class="meta price-wrapper">
<div class="trial">
<?php if ( $trial_price && $trial_duration ) : ?>
<span><?php printf( _x( '%s for %s then', 'Price X for X duration', 'learndash-course-grid' ), $currency . $trial_price, $trial_duration ); ?></span>
<?php else: ?>
<span><?php _e( 'Price', 'learndash-course-grid' ); ?></span>
<?php endif; ?>
</div>
<?php if ( $price_text ) : ?>
<div class="price">
<?php echo esc_html( $price_text ); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $atts['progress_bar'] == true && defined( 'LEARNDASH_VERSION' ) ) : ?>
<?php if ( $post->post_type == 'sfwd-courses' ) : ?>
<?php echo do_shortcode( '[learndash_course_progress course_id="' . $post->ID . '" user_id="' . $user_id . '"]' ); ?>
<?php elseif ( $post->post_type == 'groups' ) : ?>
<div class="learndash-wrapper learndash-widget">
<?php $progress = learndash_get_user_group_progress( $post->ID, $user_id ); ?>
<?php learndash_get_template_part(
'modules/progress-group.php',
array(
'context' => 'group',
'user_id' => $user_id,
'group_id' => $post->ID,
),
true
); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ( $atts['button'] == true ) : ?>
<div class="button">
<a role="button" href="<?php echo esc_url( $button_link ); ?>" rel="bookmark"><?php echo esc_attr( $button_text ); ?></a>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</article>
</div>
\ No newline at end of file
.learndash-course-grid .items-wrapper .grid-3 .post {
line-height: 1.428571429;
background-color: #ffffff;
border: 1px solid #dddddd;
border-radius: 5px;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
display: inline-block;
max-width: 100%;
height: auto;
display: block;
position: relative;
padding: 20px;
margin: 0;
box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
-moz-box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
-webkit-box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 5%);
}
.learndash-course-grid .items-wrapper .grid-3 .thumbnail {
margin: 0;
padding: 0;
}
.learndash-course-grid .items-wrapper .grid-3 .thumbnail img {
margin: 0 auto;
padding: 0;
width: 100%;
height: auto;
border-radius: 5px;
}
.learndash-course-grid .items-wrapper .grid-3 .content {
padding: 30px 0 0;
color: #333333;
}
.learndash-course-grid .items-wrapper .grid-3 .content .entry-title {
font-size: 1.2rem;
font-weight: bold;
line-height: 1.2;
color: #333;
margin-bottom: 15px;
}
.learndash-course-grid .items-wrapper .grid-3 .content .entry-title a {
text-decoration: none;
color: #333;
font-size: 1.2rem;
line-height: 1.2;
font-weight: bold;
}
.learndash-course-grid .items-wrapper .grid-3 .content .entry-content {
margin-bottom: 20px ;
color: #949ca1;
font-size: 0.875rem;
}
.learndash-course-grid .items-wrapper .grid-3 .content .entry-content > * {
margin: 0;
}
.learndash-course-grid .items-wrapper .grid-3 .content .meta {
display: flex;
align-items: center;
gap: 10px;
color: #949ca1;
font-size: 0.875rem;
margin-bottom: 20px;
}
.learndash-course-grid .items-wrapper .grid-3 .content .author {
display: flex;
align-items: center;
gap: 10px;
}
.learndash-course-grid .items-wrapper .grid-3 .content .author img {
width: 30px;
height: 30px;
display: block;
border-radius: 30px;
border: 2px solid #fd8739;
}
.learndash-course-grid .items-wrapper .grid-3 .content .author .name {
font-weight: bold;
}
.learndash-course-grid .items-wrapper .grid-3 .content .price-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
color: #333333;
}
.learndash-course-grid .items-wrapper .grid-3 .content .price-wrapper > * {
width: 50%;
}
.learndash-course-grid .items-wrapper .grid-3 .content .price-wrapper .trial {
text-align: left;
}
.learndash-course-grid .items-wrapper .grid-3 .content .price-wrapper .price {
text-align: right;
}
.learndash-course-grid .items-wrapper .grid-3 .content .button {
margin: 0;
padding: 0;
background: none;
border: none;
width: 100%;
}
.learndash-course-grid .items-wrapper .grid-3 .content .button a {
text-decoration: none;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
text-align: center;
display: -ms-flexbox;
display: flex;
justify-content: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
color: #ffffff;
background-color: #fd6906;
border-color: #fd6906;
border-radius: 5px;
font-size: 1rem;
font-weight: bold;
padding: 6px 0;
margin: 0 auto;
max-width: 70%;
}
.learndash-course-grid .items-wrapper .grid-3 .content .button a:hover {
background: #fd8739;
border-color: #fd8739;
}
\ No newline at end of file
<div class="item list-1">
<article id="post-<?php echo esc_attr( $post->ID ); ?>" <?php post_class( 'post', $post->ID ); ?>>
<?php if ( $atts['thumbnail'] == true ) : ?>
<div class="thumbnail">
<?php if ( $atts['post_meta'] == true && ! empty( $reviews ) ) : ?>
<div class="reviews">
<span class="icon dashicons dashicons-star-filled"></span>
<span class="number"><?php echo esc_html( $reviews ); ?></span>
</div>
<?php endif; ?>
<?php if ( $video == true && ! empty( $video_embed_code ) ) : ?>
<div class="video">
<?php echo wp_kses( $video_embed_code, 'learndash_course_grid_embed_code' ); ?>
</div>
<?php elseif( has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<?php echo get_the_post_thumbnail( $post->ID, $atts['thumbnail_size'] ); ?>
</a>
</div>
<?php elseif( ! has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<img alt="" src="<?php echo LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL . 'img/thumbnail.jpg'; ?>"/>
</a>
</div>
<?php endif;?>
</div>
<?php endif; ?>
<div class="content">
<?php if ( $atts['ribbon'] == true && ! empty( $ribbon_text ) ) : ?>
<div class="ribbon">
<?php echo esc_html( $ribbon_text ); ?>
</div>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true && ! empty( $categories ) ) : ?>
<div class="categories">
<?php echo esc_html( $categories ); ?>
</div>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true && ! empty( $author ) ) : ?>
<div class="author">
<img class="avatar" src="<?php echo esc_url( $author['avatar']) ; ?>" alt="<?php echo $author['name'] ?>">
<span><?php printf( _x( 'By %s', 'By author name', 'learndash-course-grid' ), '<span class="name">' . $author['name'] . '</span>' ); ?></span>
</div>
<?php endif; ?>
<h3 class="entry-title">
<?php if ( $atts['title_clickable'] == true ) : ?>
<a href="<?php echo esc_url( $button_link ); ?>">
<?php endif; ?>
<?php echo esc_html( $title ); ?>
<?php if ( $atts['title_clickable'] == true ) : ?>
</a>
<?php endif; ?>
</h3>
<?php if ( $atts['post_meta'] == true ) : ?>
<div class="meta">
<?php if ( $students ) : ?>
<div class="students">
<span class="icon dashicons dashicons-groups"></span>
<span><?php printf( _nx( '%s Student', '%s Students', $students['count'], 'Total students', 'learndash-course-grid' ), $students['count'] ); ?></span>
</div>
<?php endif; ?>
<?php if ( $duration ) : ?>
<div class="duration">
<span class="icon dashicons dashicons-clock"></span>
<span><?php echo esc_html( $duration ); ?></span>
</div>
<?php endif; ?>
<?php if ( $lessons ) : ?>
<div class="lessons">
<span class="icon dashicons dashicons-text-page"></span>
<span><?php printf( _nx( '%s Lesson', '%s Lessons', $lessons['count'], 'Total lessons', 'learndash-course-grid' ), $lessons['count'] ); ?></span>
</div>
<?php endif; ?>
<?php if ( $forums ) : ?>
<div class="forums">
<span class="icon dashicons dashicons-buddicons-forums"></span>
<span><?php printf( _nx( '%s Forum', '%s Forums', $forums['count'], 'Total forums', 'learndash-course-grid' ), $forums['count'] ); ?></span>
</div>
<?php endif; ?>
<?php if ( $quizzes ) : ?>
<div class="quizzes">
<span class="icon dashicons dashicons-format-chat"></span>
<span><?php printf( _nx( '%s Quiz', '%s Quizzes', $quizzes['count'], 'Total quizzes', 'learndash-course-grid' ), $quizzes['count'] ); ?></span>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $atts['description'] == true && ! empty( $description ) ) : ?>
<div class="entry-content">
<?php echo wp_kses( $description, 'post' ); ?>
</div>
<?php endif; ?>
<?php if ( $atts['progress_bar'] == true && defined( 'LEARNDASH_VERSION' ) ) : ?>
<?php if ( $post->post_type == 'sfwd-courses' ) : ?>
<?php echo do_shortcode( '[learndash_course_progress course_id="' . $post->ID . '" user_id="' . $user_id . '"]' ); ?>
<?php elseif ( $post->post_type == 'groups' ) : ?>
<div class="learndash-wrapper learndash-widget">
<?php $progress = learndash_get_user_group_progress( $post->ID, $user_id ); ?>
<?php learndash_get_template_part(
'modules/progress-group.php',
array(
'context' => 'group',
'user_id' => $user_id,
'group_id' => $post->ID,
),
true
); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ( $atts['button'] == true ) : ?>
<div class="button-wrapper">
<a class="link" role="button" href="<?php echo esc_url( $button_link ); ?>" rel="bookmark"><?php echo esc_attr( $button_text ); ?></a>
<div class="button">
<div class="arrow"><a href="<?php echo esc_url( $button_link ); ?>"><span class="dashicons dashicons-arrow-right-alt"></span></a></div>
</div>
</div>
<?php endif; ?>
</div>
</article>
</div>
\ No newline at end of file
.learndash-course-grid .items-wrapper .list-1 .post {
display: flex;
flex-direction: row;
gap: 60px;
margin-bottom: 60px;
}
.learndash-course-grid .items-wrapper .list-1 .ribbon {
text-shadow: 0 1px rgb( 0 0 0 / 30% );
position: absolute;
z-index: 2;
top: 0;
right: 0;
left: auto;
padding: 10px 12px;
color: #fff;
background: #00bcb6;
font-weight: bold;
font-size: 1rem;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
}
.learndash-course-grid .items-wrapper .list-1 .ribbon::before {
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail {
margin: 0;
padding: 0;
position: relative;
width: 50%;
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail .reviews {
position: absolute;
right: 24px;
top: 14px;
padding: 5px 10px;
display: flex;
gap: 5px;
align-items: center;
background: #ffb703;
color: #fff;
border-radius: 5px;
}
.learndash-course-grid .items-wrapper .list-1 .icon {
justify-content: center;
margin-right: 3px;
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail .reviews .icon {
font-size: 1rem;
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail img {
margin: 0 auto;
padding: 0;
width: 100%;
height: 100%;
max-height: 280px;
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail .arrow {
position: absolute;
right: 17px;
bottom: -18px;
}
.learndash-course-grid .items-wrapper .list-1 .arrow::after {
display: none;
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail .arrow * {
text-decoration: none;
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail .arrow .icon {
background: #fd9752;
color: #fff;
font-size: 25px;
width: auto;
height: auto;
padding: 5px;
border-radius: 100px;
}
.learndash-course-grid .items-wrapper .list-1 .content {
color: #333333;
position: relative;
width: 50%;
}
.learndash-course-grid .items-wrapper .list-1 .content .categories {
color: #fd8534;
font-weight: bold;
margin-bottom: 20px;
}
.learndash-course-grid .items-wrapper .list-1 .content .author {
display: flex;
gap: 5px;
font-size: 0.875rem;
color: #949ca1;
margin-bottom: 25px;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-1 .content .author .avatar {
width: 30px;
height: 30px;
border-radius: 30px;
display: block;
border: 2px solid #ff7e55;
}
.learndash-course-grid .items-wrapper .list-1 .content .author .wrapper {
display: grid;
width: 100%;
}
.learndash-course-grid .items-wrapper .list-1 .content .author .name {
font-weight: bold;
}
.learndash-course-grid .items-wrapper .list-1 .content .author .wrapper .lessons {
float: right;
}
.learndash-course-grid .items-wrapper .list-1 .content .meta {
display: flex;
gap: 15px;
font-size: 0.875rem;
color: #b1b2b2;
margin-bottom: 20px;
}
.learndash-course-grid .items-wrapper .list-1 .content .meta > div {
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-1 .content .meta .icon {
font-size: 1rem;
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-1 .content .entry-title {
font-size: 1.4rem;
font-weight: bold;
line-height: 1.2;
color: #333;
margin-bottom: 10px;
}
.learndash-course-grid .items-wrapper .list-1 .content .entry-title a {
text-decoration: none;
color: #333;
font-size: 1.4rem;
line-height: 1.2;
font-weight: bold;
}
.learndash-course-grid .items-wrapper .list-1 .content .entry-content {
margin-bottom: 20px;
color: #b1b2b2;
font-size: 0.875rem;
}
.learndash-course-grid .items-wrapper .list-1 .content .entry-content > * {
margin: 0;
}
.learndash-course-grid .items-wrapper .list-1 .content .button-wrapper {
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-1 .content a.link {
background: none;
color: #a9aaaa;
text-decoration: none;
padding-bottom: 5px;
border-bottom: 2px solid #a9aaaa;
}
.learndash-course-grid .items-wrapper .list-1 .content .button {
background: none;
border: none;
border-radius: 5px;
padding: 0;
display: flex;
justify-content: space-between;
align-items: center;
margin-left: auto;
min-height: 30px;
}
.learndash-course-grid .items-wrapper .list-1 .content .button a:hover {
color: #d5d6d6;
}
.learndash-course-grid .items-wrapper .list-1 .content .button .arrow {
background: #f6617b;
padding: 0px 10px;
color: #fff;
border-radius: 5px;
width: initial;
height: initial;
overflow: initial;
position: initial;
margin: initial
}
.learndash-course-grid .items-wrapper .list-1 .content .button .arrow a {
text-decoration: none;
color: #fff;
border: none;
padding: 0;
display: flex;
align-items: center;
}
@media only screen and ( max-width: 768px ) {
.learndash-course-grid .items-wrapper .list-1 .post {
flex-direction: column;
}
.learndash-course-grid .items-wrapper .list-1 .thumbnail {
width: 100%;
}
.learndash-course-grid .items-wrapper .list-1 .content {
width: 100%;
}
}
\ No newline at end of file
<div class="item <?php echo esc_attr( $atts['card'] ); ?>">
<article id="post-<?php echo esc_attr( $post->ID ); ?>" <?php post_class( 'post', $post->ID ); ?>>
<?php if ( $atts['thumbnail'] == true ) : ?>
<div class="thumbnail">
<?php if ( $video == true && ! empty( $video_embed_code ) ) : ?>
<div class="video">
<?php echo wp_kses( $video_embed_code, 'learndash_course_grid_embed_code' ); ?>
</div>
<?php elseif ( has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<?php echo get_the_post_thumbnail( $post->ID, $atts['thumbnail_size'] ); ?>
</a>
</div>
<?php elseif ( ! has_post_thumbnail( $post->ID ) ) : ?>
<div class="image">
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<img alt="" src="<?php echo LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL . 'img/thumbnail.jpg'; ?>"/>
</a>
</div>
<?php endif;?>
</div>
<?php endif; ?>
<div class="content">
<div class="wrapper">
<div class="title-wrapper">
<?php if ( $atts['title'] == true ) : ?>
<h3 class="entry-title">
<?php if ( $atts['title_clickable'] == true ) : ?>
<a href="<?php echo esc_url( $button_link ); ?>">
<?php endif; ?>
<?php echo esc_html( $title ); ?>
<?php if ( $atts['title_clickable'] == true ) : ?>
</a>
<?php endif; ?>
</h3>
<?php endif; ?>
<div class="meta top-meta">
<?php if ( $atts['post_meta'] == true && ! empty( $author ) ) : ?>
<div class="author">
<span class="name"><?php echo esc_html( $author['name'] ); ?></span>
</div>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true && ! empty( $categories ) ) : ?>
<div class="categories">
<?php echo esc_html( $categories ); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php if ( $atts['ribbon'] == true && ! empty( $ribbon_text ) ) : ?>
<div class="ribbon">
<?php echo esc_html( $ribbon_text ); ?>
</div>
<?php endif; ?>
</div>
<?php if ( $atts['description'] == true && ! empty( $description ) ) : ?>
<div class="entry-content">
<?php echo wp_kses( $description, 'post' ); ?>
</div>
<?php endif; ?>
<?php if ( $atts['post_meta'] == true ) : ?>
<div class="meta bottom-meta">
<?php if ( $duration ) : ?>
<div class="duration">
<span class="icon dashicons dashicons-clock"></span>
<span><?php echo esc_html( $duration ); ?></span>
</div>
<?php endif; ?>
<?php if ( $lessons ) : ?>
<div class="lessons">
<span class="icon dashicons dashicons-text-page"></span>
<span><?php printf( _nx( '%s Lesson', '%s Lessons', $lessons['count'], 'Total lessons', 'learndash-course-grid' ), $lessons['count'] ); ?></span>
</div>
<?php endif; ?>
<?php if ( $students ) : ?>
<div class="students">
<span class="icon dashicons dashicons-groups"></span>
<span><?php printf( _nx( '%s Student', '%s Students', $students['count'], 'Total students', 'learndash-course-grid' ), $students['count'] ); ?></span>
</div>
<?php endif; ?>
<?php if ( $reviews ) : ?>
<?php
$reviews_floored = floor( $reviews );
$reviews_ceil = ceil( $reviews );
$reviews_number = number_format( $reviews, 1 );
$reviews_max = 5;
?>
<div class="reviews">
<span class="label"><?php printf( '%s', $reviews_number ); ?></span>
<span class="stars">
<?php for ( $i = 1; $i <= $reviews_max; $i++ ) : ?>
<?php
if ( $i <= $reviews_floored ) {
$star_class = 'star-filled';
} elseif ( $i > $reviews_floored && floatval( $reviews_number ) > $reviews_floored && $i <= $reviews_ceil ) {
$star_class = 'star-half';
} else {
$star_class = 'star-empty';
}
?>
<span class="icon dashicons dashicons-<?php echo esc_attr( $star_class ); ?>"></span>
<?php endfor; ?>
</span>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $atts['progress_bar'] == true && defined( 'LEARNDASH_VERSION' ) ) : ?>
<?php if ( $post->post_type == 'sfwd-courses' ) : ?>
<?php echo do_shortcode( '[learndash_course_progress course_id="' . $post->ID . '" user_id="' . $user_id . '"]' ); ?>
<?php elseif ( $post->post_type == 'groups' ) : ?>
<div class="learndash-wrapper learndash-widget">
<?php $progress = learndash_get_user_group_progress( $post->ID, $user_id ); ?>
<?php learndash_get_template_part(
'modules/progress-group.php',
array(
'context' => 'group',
'user_id' => $user_id,
'group_id' => $post->ID,
),
true
); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</article>
</div>
\ No newline at end of file
.learndash-course-grid .items-wrapper .list-2 .post {
display: flex;
flex-direction: row;
gap: 50px;
margin-bottom: 60px;
padding: 20px;
border-radius: 20px;
box-shadow: 3px 4px 4px 4px rgb(0 0 0 / 10%);
-moz-box-shadow: 3px 4px 4px 4px rgb(0 0 0 / 10%);
-webkit-box-shadow: 3px 4px 4px 4px rgb(0 0 0 / 10%);
}
.learndash-course-grid .items-wrapper .list-2 .ribbon {
text-shadow: 0 1px rgb( 0 0 0 / 30% );
position: absolute;
z-index: 2;
top: 0;
right: 0;
left: auto;
padding: 10px 12px;
color: #fff;
background: #f43e5e;
font-weight: bold;
font-size: 1rem;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
max-width: 20%;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail {
margin: 0;
padding: 0;
position: relative;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail .reviews {
position: absolute;
right: 24px;
top: 14px;
padding: 5px 10px;
display: flex;
gap: 5px;
align-items: center;
background: #ffb703;
color: #fff;
border-radius: 5px;
}
.learndash-course-grid .items-wrapper .list-2 .content .reviews {
margin-left: auto;
}
.learndash-course-grid .items-wrapper .list-2 .icon {
justify-content: center;
margin-right: 3px;
}
.learndash-course-grid .items-wrapper .list-2 .reviews .icon {
font-size: 1rem;
display: flex;
align-items: center;
color: #ffb703;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail > div {
height: 100%;
width: auto;
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail img {
margin: 0 auto;
padding: 0;
margin: 0 auto;
padding: 0;
height: 150px;
width: 150px;
max-width: initial;
border-radius: 20px;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail .arrow {
position: absolute;
right: 17px;
bottom: -18px;
}
.learndash-course-grid .items-wrapper .list-2 .arrow::after {
display: none;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail .arrow * {
text-decoration: none;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail .arrow .icon {
background: #fd9752;
color: #fff;
font-size: 25px;
width: auto;
height: auto;
padding: 5px;
border-radius: 100px;
}
.learndash-course-grid .items-wrapper .list-2 .content {
color: #333333;
position: relative;
width: 100%;
display: flex;
flex-direction: column;
}
.learndash-course-grid .items-wrapper .list-2 .content > .wrapper {
display: flex;
flex-wrap: wrap;
}
.learndash-course-grid .items-wrapper .list-2 .content .top-meta {
display: flex;
flex-wrap: wrap;
gap: 15px;
align-items: center;
font-size: 0.875rem;
}
.learndash-course-grid .items-wrapper .list-2 .content .categories {
color: #949ca1;
}
.learndash-course-grid .items-wrapper .list-2 .content .author {
color: #949ca1;
}
.learndash-course-grid .items-wrapper .list-2 .content .author .name {
font-weight: bold;
}
.learndash-course-grid .items-wrapper .list-2 .content .author .wrapper .lessons {
float: right;
}
.learndash-course-grid .items-wrapper .list-2 .content .meta {
display: flex;
gap: 15px;
font-size: 0.875rem;
color: #b1b2b2;
}
.learndash-course-grid .items-wrapper .list-2 .content .meta > div {
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-2 .content .meta .icon {
font-size: 1rem;
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-2 .content .meta .reviews {
gap: 5px;
}
.learndash-course-grid .items-wrapper .list-2 .content .meta .stars {
display: flex;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-2 .content .bottom-meta {
margin-top: auto;
margin-bottom: 0;
}
.learndash-course-grid .items-wrapper .list-2 .content .title-wrapper {
margin-bottom: 25px;
max-width: 75%;
}
.learndash-course-grid .items-wrapper .list-2 .content .entry-title {
font-size: 1.4rem;
font-weight: bold;
line-height: 1.2;
color: #333;
margin-bottom: 10px;
}
.learndash-course-grid .items-wrapper .list-2 .content .entry-title a {
text-decoration: none;
color: #333;
font-size: 1.4rem;
line-height: 1.2;
font-weight: bold;
}
.learndash-course-grid .items-wrapper .list-2 .content .entry-content {
margin-bottom: 20px;
color: #b1b2b2;
font-size: 0.875rem;
}
.learndash-course-grid .items-wrapper .list-2 .content .entry-content > * {
margin: 0;
}
.learndash-course-grid .items-wrapper .list-2 .content .button {
background: none;
border: none;
padding: 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.learndash-course-grid .items-wrapper .list-2 .content .button a {
background: none;
color: #a9aaaa;
text-decoration: none;
padding-bottom: 5px;
border-bottom: 2px solid #a9aaaa;
}
.learndash-course-grid .items-wrapper .list-2 .content .button a:hover {
color: #d5d6d6;
}
.learndash-course-grid .items-wrapper .list-2 .content .button .arrow {
background: #f6617b;
padding: 5px 10px;
color: #fff;
border-radius: 5px;
width: initial;
height: initial;
overflow: initial;
position: initial;
margin: initial
}
.learndash-course-grid .items-wrapper .list-2 .content .button .arrow a {
text-decoration: none;
color: #fff;
border: none;
padding: 0;
display: flex;
align-items: center;
}
@media only screen and ( max-width: 768px ) {
.learndash-course-grid .items-wrapper .list-2 .post {
flex-direction: column;
gap: 25px;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail {
width: 100%;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail > div {
display: initial;
}
.learndash-course-grid .items-wrapper .list-2 .thumbnail img {
width: 100%;
height: auto;
}
.learndash-course-grid .items-wrapper .list-2 .content {
width: 100%;
}
.learndash-course-grid .items-wrapper .list-2 .content .title-wrapper {
margin-bottom: 10px;
}
.learndash-course-grid .items-wrapper .list-2 .content .meta {
flex-wrap: wrap;
}
.learndash-course-grid .items-wrapper .list-2 .content .ribbon {
display: none;
}
}
\ No newline at end of file
<?php
use LearnDash\Course_Grid\Utilities;
?>
<div class="filter-wrapper">
<form method="POST" name="learndash_course_grid_filter">
<?php wp_nonce_field( 'ld_cg_apply_filter' ); ?>
<?php if ( $atts['search'] == true ) : ?>
<div class="filter search">
<label for="search-<?php echo esc_attr( $atts['course_grid_id'] ); ?>"><?php _e( 'Keyword', 'learndash-course-grid' ); ?></label>
<input type="text" name="search" id="search-<?php echo esc_attr( $atts['course_grid_id'] ); ?>">
</div>
<?php endif; ?>
<?php if ( ! empty( $atts['taxonomies'] ) ) : ?>
<div class="filter taxonomies">
<div class="taxonomies-wrapper">
<?php foreach ( $atts['taxonomies'] as $taxonomy ) : ?>
<?php
$tax_object = get_taxonomy( $taxonomy );
if ( is_a( $tax_object, 'WP_Taxonomy' ) ) :
$terms = get_terms( [
'taxonomy' => $taxonomy,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
] );
?>
<div class="taxonomy <?php echo esc_attr( $taxonomy ); ?>">
<label><?php echo esc_html( $tax_object->labels->name ); ?></label>
<ul class="terms">
<?php foreach ( $terms as $term ) : ?>
<li class="term">
<label
for="<?php echo esc_attr( $atts['course_grid_id'] ) . '-' . esc_attr( $taxonomy ) . '-' . esc_attr( $term->slug ); ?>"
>
<input
id="<?php echo esc_attr( $atts['course_grid_id'] ) . '-' . esc_attr( $taxonomy ) . '-' . esc_attr( $term->slug ); ?>"
type="checkbox"
name="<?php echo esc_attr( $taxonomy ); ?>[]"
value="<?php echo esc_attr( $term->term_id ); ?>"
<?php Utilities::checked_array( @$term->slug, @$default_taxonomies[ $taxonomy ]['terms'], true ); ?>
>
<?php echo esc_html( $term->name ) ?>
</label>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if ( $atts['price'] == true ) : ?>
<div class="filter price">
<label><?php _e( 'Price', 'learndash-course-grid' ); ?></label>
<div class="range-wrapper">
<input name="price_min_range" class="range" id="price_min_range-<?php echo esc_attr( $atts['course_grid_id'] ); ?>" type="range" min="<?php echo esc_attr( $atts['price_min' ] ); ?>" max="<?php echo esc_attr( $atts['price_max' ] / 2 ); ?>" step="<?php echo esc_attr( $atts['price_step' ] ); ?>">
<input name="price_max_range" class="range" id="price_max_range-<?php echo esc_attr( $atts['course_grid_id'] ); ?>" type="range" min="<?php echo esc_attr( $atts['price_max' ] / 2 ); ?>" max="<?php echo esc_attr( $atts['price_max' ] ); ?>" step="<?php echo esc_attr( $atts['price_step' ] ); ?>">
<div style="clear: both;"></div>
</div>
<div class="number-wrapper left">
<label for="price_min-<?php echo esc_attr( $atts['course_grid_id'] ); ?>"><?php _ex( 'Min', 'Minimum', 'learndash-course-grid' ); ?></label>
<input type="number" name="price_min" id="price_min-<?php echo esc_attr( $atts['course_grid_id'] ); ?>" min="<?php echo esc_attr( $atts['price_min' ] ); ?>" step="<?php echo esc_attr( $atts['price_step' ] ); ?>">
</div>
<div class="number-wrapper right">
<label for="price_max-<?php echo esc_attr( $atts['course_grid_id'] ); ?>"><?php _ex( 'Max', 'Maximum', 'learndash-course-grid' ); ?></label>
<input type="number" name="price_max" id="price_max-<?php echo esc_attr( $atts['course_grid_id'] ); ?>" max="<?php echo esc_attr( $atts['price_max' ] ); ?>" step="<?php echo esc_attr( $atts['price_step' ] ); ?>">
</div>
<div style="clear: both;"></div>
</div>
<?php endif; ?>
<div class="buttons">
<button class="button apply blue"><?php _e( 'Apply', 'learndash-course-grid' ); ?></button>
<button class="button clear grey"><?php _e( 'Clear', 'learndash-course-grid' ); ?></button>
</div>
</form>
</div>
\ No newline at end of file
.toggle-filter {
position: sticky;
left: 100%;
margin-bottom: 20px;
}
.toggle-filter.opened::before {
content: "\f158";
font-family: 'Dashicons';
padding-right: 10px;
top: 1px;
position: relative;
}
.learndash-course-grid {
position: relative;
}
.learndash-course-grid .learndash-course-grid-filter {
position: absolute;
max-width: 300px;
}
.learndash-course-grid .learndash-course-grid-filter {
display: none;
}
.learndash-course-grid-filter {
max-width: 300px;
min-width: 300px;
background: white;
padding: 15px 20px;
border-radius: 5px;
z-index: 2000;
margin: 0 auto;
border: 2px solid #ddd;
}
.learndash-course-grid .learndash-course-grid-filter {
right: 0;
position: absolute;
}
.learndash-course-grid-filter form {
margin: 0;
}
.learndash-course-grid-filter form input:focus,
.learndash-course-grid-filter form select:focus {
outline: none;
}
/* Range Input */
.learndash-course-grid-filter form input[type=range] {
-webkit-appearance: none;
margin: 18px 0;
width: 100%;
}
.learndash-course-grid-filter form input[type=range]:focus {
outline: none;
}
.learndash-course-grid-filter form input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 8.4px;
cursor: pointer;
background: #0077ff;
border-radius: 1.3px;
}
.learndash-course-grid-filter form input[type="range"]:first-child::-webkit-slider-runnable-track {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
border-right: none;
}
.learndash-course-grid-filter form input[type="range"]:nth-child(2)::-webkit-slider-runnable-track {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-left: none;
}
.learndash-course-grid-filter form input[type=range]::-webkit-slider-thumb {
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 16px;
width: 16px;
border-radius: 10px;
background: #ffffff;
cursor: pointer;
-webkit-appearance: none;
margin-top: -5px;
}
.learndash-course-grid-filter form input[type=range]:focus::-webkit-slider-runnable-track {
background: #0077ff;
}
.learndash-course-grid-filter form input[type=range]::-moz-range-track {
width: 100%;
height: 8.4px;
cursor: pointer;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
background: #0077ff;
border-radius: 1.3px;
border: 0.2px solid #010101;
}
.learndash-course-grid-filter form input[type=range]::-moz-range-thumb {
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 16px;
width: 16px;
border-radius: 10px;
background: #ffffff;
cursor: pointer;
}
.learndash-course-grid-filter form input[type=range]::-ms-track {
width: 100%;
height: 8.4px;
cursor: pointer;
background: transparent;
border-color: transparent;
border-width: 16px 0;
color: transparent;
}
.learndash-course-grid-filter form input[type=range]::-ms-fill-lower {
background: #2a6495;
border: 0.2px solid #010101;
border-radius: 2.6px;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
.learndash-course-grid-filter form input[type=range]::-ms-fill-upper {
background: #0077ff;
border: 0.2px solid #010101;
border-radius: 2.6px;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
.learndash-course-grid-filter form input[type=range]::-ms-thumb {
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 16px;
width: 16px;
border-radius: 10px;
background: #ffffff;
cursor: pointer;
}
.learndash-course-grid-filter form input[type=range]:focus::-ms-fill-lower {
background: #0077ff;
}
.learndash-course-grid-filter form input[type=range]:focus::-ms-fill-upper {
background: #0077ff;
}
/* End Range Input */
.learndash-course-grid-filter .filter {
margin-bottom: 15px;
}
.learndash-course-grid-filter .taxonomies-wrapper .terms {
list-style-type: none;
padding: 0 0 15px 20px;
margin: 0;
max-height: 150px;
overflow: auto;
}
.learndash-course-grid-filter .filter.price label {
display: block;
}
/* .learndash-course-grid-filter .filter.price .range-wrapper {
position: relative;
left: 8px;
} */
.learndash-course-grid-filter .filter.price .range-wrapper :first-child {
width: 50%;
float: left;
}
.learndash-course-grid-filter .filter.price .range-wrapper :nth-child(2) {
width: 50%;
float: right;
}
.learndash-course-grid-filter .filter.price .number-wrapper.left {
float: left;
text-align: left;
}
.learndash-course-grid-filter .filter.price .number-wrapper.right {
float: right;
text-align: right;
}
.learndash-course-grid-filter .filter.price .number-wrapper label,
.learndash-course-grid-filter .filter.price .number-wrapper input {
display: block;
}
.learndash-course-grid-filter .filter.price .number-wrapper input {
width: 80px;
}
.learndash-course-grid-filter .filter.price input[type="range"] {
margin-bottom: 10px;
}
.learndash-course-grid-filter input[type="text"],
.learndash-course-grid-filter input[type="range"] {
display: block;
width: 100%;
}
.learndash-course-grid-filter input[type="text"] {
padding: 5px;
}
.learndash-course-grid-filter .buttons {
margin-top: 0;
}
.toggle-filter,
.learndash-course-grid-filter .buttons .button {
display: block;
margin-bottom: 10px;
border-radius: 3px;
padding: 0.5rem 1rem;
font-weight: 600;
text-decoration: none;
font-size: 1rem;
border: 3px solid #ddd;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
text-align: center;
display: -ms-flexbox;
display: flex;
justify-content: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
}
.learndash-course-grid-filter .buttons .button {
width: 100%;
}
.learndash-course-grid-filter .buttons .button.blue {
color: #ffffff;
background-color: #235af4;
border-color: #235af4;
}
.learndash-course-grid-filter .buttons .button.blue:hover {
background: #0d9dff;
border-color: #0d9dff;
}
.toggle-filter,
.learndash-course-grid-filter .buttons .button.grey {
color: #333333;
background-color: #eeeeee;
border-color: #eeeeee;
}
.toggle-filter:hover,
.learndash-course-grid-filter .buttons .button.grey:hover {
background-color: #d5d5d5;
border-color: #d5d5d5;
}
\ No newline at end of file
<div class="pagination">
<button class="load-more"><?php _e( 'Load More', 'learndash-course-grid' ) ?></button>
</div>
\ No newline at end of file
<div class="pagination">
</div>
\ No newline at end of file
.learndash-course-grid .pagination {
text-align: center;
border: 0;
margin: 0;
padding: 0;
}
.learndash-course-grid .pagination::before,
.learndash-course-grid .pagination::after {
display: none;
}
.learndash-course-grid .pagination .load-more {
margin: 0 auto;
border-radius: 3px;
background-color: #fd6703;
color: #ffffff;
padding: 10px 50px;
padding: 0.75rem 2rem;
font-weight: 600;
text-decoration: none;
font-size: 1.4rem;
border: 3px solid #fd6703;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
text-align: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
}
.learndash-course-grid .pagination .load-more:hover {
background-color: #f7883e;
border-color: #f7883e;
}
\ No newline at end of file
<?php
/**
* Available variables:
*
* $posts Array of WP_Post objects, result of the WP_Query->get_posts()
* $atts Shortcode/Block editor attributes that call this template
*/
?>
<div class="items-wrapper <?php echo esc_attr( $atts['skin'] ); ?>">
<?php foreach ( $posts as $post ) : ?>
<?php learndash_course_grid_load_card_template( $atts, $post ); ?>
<?php endforeach; ?>
</div>
\ No newline at end of file
/**
* Responsive design
*/
function learndash_course_grid_init_grid_responsive_design() {
const wrappers = document.querySelectorAll( '.learndash-course-grid[data-skin="grid"]' );
wrappers.forEach( function( wrapper ) {
const items_wrapper = wrapper.querySelector( '.items-wrapper.grid' );
if ( ! items_wrapper ) {
return;
}
const first_item = items_wrapper.firstElementChild;
if ( ! first_item ) {
return;
}
// Set columns
const min_width = wrapper.dataset.min_column_width;
let columns = wrapper.dataset.columns;
columns = parseInt( columns );
let new_columns = wrapper.dataset.new_columns || columns;
new_columns = parseInt( new_columns );
const wrapper_width = wrapper.offsetWidth;
let upper_columns = new_columns + 1;
upper_columns = upper_columns > columns ? columns : upper_columns;
const min_item_width = wrapper_width / upper_columns;
new_columns = Math.floor( wrapper_width / min_width );
let item_width = first_item.offsetWidth;
if ( item_width < min_width ) {
new_columns = new_columns > columns ? columns : new_columns;
new_columns = new_columns < 1 ? 1 : new_columns;
wrapper.dataset.new_columns = new_columns;
items_wrapper.style.gridTemplateColumns = 'repeat( ' + new_columns + ', minmax( 0, 1fr ) )';
} else if ( min_item_width > min_width ) {
new_columns = new_columns > columns ? columns : new_columns;
new_columns = new_columns < 1 ? 1 : new_columns;
wrapper.dataset.new_columns = new_columns;
items_wrapper.style.gridTemplateColumns = 'repeat( ' + new_columns + ', minmax( 0, 1fr ) )';
}
const items = items_wrapper.querySelectorAll( '.item' );
items.forEach( function( item ) {
// Display item
item.style.visibility = 'visible';
} );
} );
}
( function() {
window.addEventListener( 'resize', function() {
learndash_course_grid_init_grid_responsive_design();
} );
window.addEventListener( 'load', function() {
learndash_course_grid_init_grid_responsive_design();
} );
} )();
.learndash-course-grid .items-wrapper.grid {
display: grid;
grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
column-gap: 30px;
row-gap: 30px;
margin-bottom: 30px;
}
.learndash-course-grid .items-wrapper.grid .item {
visibility: hidden;
}
.learndash-course-grid .items-wrapper.grid .item .content .entry-content {
float: none;
margin: auto;
width: auto;
}
\ No newline at end of file
<?php
/**
* @package nmbs
*/
$col = empty( $shortcode_atts['col'] ) ? LEARNDASH_COURSE_GRID_COLUMNS : intval( $shortcode_atts['col'] );
$col = $col > 6 ? 6 : $col;
$smcol = $col == 1 ? 1 : $col / 2;
$col = 12 / $col;
$smcol = intval( ceil( 12 / $smcol ) );
$col = is_float( $col ) ? number_format( $col, 1 ) : $col;
$col = str_replace( '.', '-', $col );
global $post; $post_id = $post->ID;
$post_atts = learndash_course_grid_prepare_template_post_attributes( $post, [], $shortcode_atts );
extract( $post_atts );
$post_type = get_post_type( $post->ID );
$course_id = $post_id;
$user_id = get_current_user_id();
// Retrive oembed HTML if URL provided
if ( preg_match( '/^http/', $video_embed_code ) ) {
$video_embed_code = wp_oembed_get( $video_embed_code, array( 'height' => 600, 'width' => 400 ) );
}
$course_options = get_post_meta( $post_id, "_sfwd-courses", true );
/**
* Filter: individual grid class
*
* @param int $course_id Course ID
* @param array $course_options Course options
* @var string
*/
$grid_class = apply_filters( 'learndash_course_grid_class', '', $course_id, $course_options );
$course_class = apply_filters( 'learndash_course_grid_course_class', '', $course_id, $course_options );
$thumb_size = isset( $shortcode_atts['thumb_size'] ) && ! empty( $shortcode_atts['thumb_size'] ) ? $shortcode_atts['thumb_size'] : 'medium';
ob_start();
?>
<div class="ld_course_grid col-sm-<?php echo $smcol; ?> col-md-<?php echo $col; ?> <?php echo esc_attr( $grid_class ); ?>">
<article id="post-<?php the_ID(); ?>" <?php post_class( $course_class . ' thumbnail course' ); ?>>
<?php if ( $shortcode_atts['show_thumbnail'] == 'true' ) : ?>
<?php if ( ! empty( $ribbon_text ) ) : ?>
<div class="<?php echo esc_attr( $ribbon_class ); ?>">
<?php echo wp_kses_post( $ribbon_text ); ?>
</div>
<?php endif; ?>
<?php if ( 1 == $video && ! empty( $video_embed_code ) ) : ?>
<div class="ld_course_grid_video_embed">
<?php echo $video_embed_code; ?>
</div>
<?php elseif( has_post_thumbnail() ) :?>
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<?php the_post_thumbnail( $thumb_size ); ?>
</a>
<?php else : ?>
<a href="<?php echo esc_url( $button_link ); ?>" rel="bookmark">
<img alt="" src="<?php echo LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL . 'img/thumbnail.jpg'; ?>"/>
</a>
<?php endif;?>
<?php endif; ?>
<?php if ( $shortcode_atts['show_content'] == 'true' ) : ?>
<div class="caption">
<h3 class="entry-title"><?php the_title(); ?></h3>
<?php if ( ! empty( $description ) ) : ?>
<div class="entry-content"><?php echo do_shortcode( htmlspecialchars_decode( $description ) ); ?></div>
<?php endif; ?>
<div class="ld_course_grid_button"><a class="btn btn-primary" role="button" href="<?php echo esc_url( $button_link ); ?>" rel="bookmark"><?php echo esc_attr( $button_text ); ?></a></div>
<?php if ( isset( $shortcode_atts['progress_bar'] ) && $shortcode_atts['progress_bar'] == 'true' ) : ?>
<?php if ( $post_type == 'sfwd-courses' ) : ?>
<?php echo do_shortcode( '[learndash_course_progress course_id="' . get_the_ID() . '" user_id="' . get_current_user_id() . '"]' ); ?>
<?php elseif ( $post_type == 'groups' ) : ?>
<div class="learndash-wrapper learndash-widget">
<?php $progress = learndash_get_user_group_progress( $post_id, $user_id ); ?>
<?php learndash_get_template_part(
'modules/progress-group.php',
array(
'context' => 'group',
'user_id' => $user_id,
'group_id' => $post_id,
),
true
); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div><!-- .entry-header -->
<?php endif; ?>
</article><!-- #post-## -->
</div><!-- .ld_course_grid -->
<?php
/**
* Tag to detect if v1 course grid exists on a page
*
* Make sure to include this tag when using custom template or modify the template via filter hook.
*/
$tag = '<!-- LearnDash Course Grid v1 -->';
/**
* Filter: course grid HTML output
*
* @param string $output Individual course grid HTML output
* @param object $post LD course WP_Post object
* @param array $shortcode_atts Shortcode attributes used for this course grid output
* @param int $user_id Current user ID this course grid is displayed to
* @return string Filtered course grid HTML output
*/
echo apply_filters( 'learndash_course_grid_html_output', $tag . ob_get_clean(), $post, $shortcode_atts, $user_id );
\ No newline at end of file
<?php
/**
* Available variables:
*
* $posts Array of WP_Post objects, result of the WP_Query->get_posts()
* $atts Shortcode/Block editor attributes that call this template
*/
?>
<div class="items-wrapper <?php echo esc_attr( $atts['skin'] ); ?>">
<?php foreach ( $posts as $post ) : ?>
<?php learndash_course_grid_load_card_template( $atts, $post ); ?>
<?php endforeach; ?>
</div>
\ No newline at end of file
<?php
/**
* Available variables:
*
* $posts Array of WP_Post objects, result of the WP_Query->get_posts()
* $atts Shortcode/Block editor attributes that call this template
*/
?>
<div class="items-wrapper <?php echo esc_attr( $atts['skin'] ); ?>">
<?php foreach ( $posts as $post ) : ?>
<?php learndash_course_grid_load_card_template( $atts, $post ); ?>
<?php endforeach; ?>
</div>
\ No newline at end of file
function learndash_course_grid_init_masonry( items_wrapper ) {
const course_grid = items_wrapper.closest( '.learndash-course-grid' );
const columns = parseInt( course_grid.dataset.columns );
const min_width = parseInt( course_grid.dataset.min_column_width );
const width = items_wrapper.offsetWidth;
const items = items_wrapper.querySelectorAll( '.item' );
if ( items.length < 1 ) {
return;
}
const padding = 10;
let max_columns = Math.floor( width / min_width );
max_columns = max_columns > columns ? columns : max_columns;
items.forEach( function( item ) {
item.style.padding = padding + 'px';
item.style.maxWidth = ( width / max_columns ) + 'px';
item.style.width = ( width / max_columns ) + 'px';
item.style.visibility = 'visible';
} );
const masonry = new Masonry( items_wrapper, {
itemSelector: '.item',
fitWidth: true,
horizontalOrder: true,
} );
}
function learndash_course_grid_init_masonry_responsive_design() {
const wrappers = document.querySelectorAll( '.learndash-course-grid[data-skin="masonry"]' );
wrappers.forEach( function( wrapper ) {
const items_wrapper = wrapper.querySelector( '.items-wrapper.masonry' );
learndash_course_grid_init_masonry( items_wrapper );
} );
}
( function() {
window.addEventListener( 'resize', function() {
learndash_course_grid_init_masonry_responsive_design();
} );
window.addEventListener( 'load', function() {
learndash_course_grid_init_masonry_responsive_design();
} );
} )();
\ No newline at end of file
.learndash-course-grid .masonry {
display: grid;
grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
column-gap: 30px;
row-gap: 30px;
margin: 0 auto;
margin-bottom: 30px;
width: 100% !important;
}
.learndash-course-grid .items-wrapper.masonry .item {
visibility: hidden;
}
\ No newline at end of file
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitddfc61f6647a593b58a61b47a842cf39::getLoader();
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitddfc61f6647a593b58a61b47a842cf39
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitddfc61f6647a593b58a61b47a842cf39', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitddfc61f6647a593b58a61b47a842cf39', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitddfc61f6647a593b58a61b47a842cf39::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitddfc61f6647a593b58a61b47a842cf39
{
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->classMap = ComposerStaticInitddfc61f6647a593b58a61b47a842cf39::$classMap;
}, null, ClassLoader::class);
}
}
{
"packages": [],
"dev": false,
"dev-package-names": []
}
<?php return array(
'root' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '92dc9ed3efd0f92db72ec19dfc782b02b69b1dac',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '92dc9ed3efd0f92db72ec19dfc782b02b69b1dac',
'dev_requirement' => false,
),
),
);
.wp-admin .media-toolbar-secondary select {
margin: 11px 16px 0 0;
}
.media-term-section {
margin: 0 0 20px;
}
.media-terms {
background: #fff;
border: 1px solid #dfdfdf;
border-radius: 3px;
max-height: 145px;
overflow: auto;
padding: 6px 8px;
}
.wp-admin .media-terms label {
display: block;
}
.wp-admin .media-terms input[type="checkbox"] {
margin: 0 5px 0 0;
position: relative;
top: -1px;
width: auto;
}
.media-terms ul ul {
padding: 10px 0 5px 10px;
}
.media-terms ul li:last-child {
margin: 0;
}
.add-new-term {
display: none;
}
.media-save-terms {
position: relative;
}
.media-save-terms:before {
background: url( '../images/saving.gif ') no-repeat #fff;
content: '';
display: block;
height: 16px;
position: absolute;
right: 5px;
top: 5px;
width: 16px
}
.media-save-terms label {
opacity: .5
}
/* Add new media term */
.toggle-add-media-term {
display: inline-block;
margin: 5px 0;
}
.toggle-add-media-term:before {
content: '+ ';
}
.add-new-term {
margin: 0 0 5px;
}
jQuery(document).ready(function(){
var media = wp.media;
/*
// for debug : trace every event triggered in the Region controller
var originalTrigger = wp.media.view.MediaFrame.prototype.trigger;
wp.media.view.MediaFrame.prototype.trigger = function(){
console.log('MediaFrame Event: ', arguments[0]);
originalTrigger.apply(this, Array.prototype.slice.call(arguments));
}; //
// for Network debug
var originalAjax = media.ajax;
media.ajax = function( action ) {
console.log( 'media.ajax: action = ' + JSON.stringify( action ) );
return originalAjax.apply(this, Array.prototype.slice.call(arguments));
};
*/
/**
* Extended Filters dropdown with taxonomy term selection values
*/
if ( media ) {
jQuery.each(mediaTaxonomies,function(key,label){
media.view.AttachmentFilters[key] = media.view.AttachmentFilters.extend({
className: key,
createFilters: function() {
var filters = {};
_.each( mediaTerms[key] || {}, function( term ) {
var query = {};
query[key] = {
taxonomy: key,
term_id: parseInt( term.id, 10 ),
term_slug: term.slug
};
filters[ term.slug ] = {
text: term.label,
props: query
};
});
this.filters = filters;
}
});
/**
* Replace the media-toolbar with our own
*/
var myDrop = media.view.AttachmentsBrowser;
media.view.AttachmentsBrowser = media.view.AttachmentsBrowser.extend({
createToolbar: function() {
media.model.Query.defaultArgs.filterSource = 'filter-media-taxonomies';
myDrop.prototype.createToolbar.apply(this,arguments);
this.toolbar.set( key, new media.view.AttachmentFilters[key]({
controller: this.controller,
model: this.collection.props,
priority: -80
}).render()
);
}
});
});
}
/* Save taxonomy */
jQuery('html').delegate( '.media-terms input', 'change', function(){
var obj = jQuery(this),
container = obj.parents('.media-terms'),
row = container.parent(),
data = {
action: 'save-media-terms',
term_ids: [],
attachment_id: container.data('id'),
taxonomy: container.data('taxonomy')
};
container.find('input:checked').each(function(){
data.term_ids.push( jQuery(this).val() );
});
row.addClass('media-save-terms');
container.find('input').prop('disabled', 'disabled');
jQuery.post( ajaxurl, data, function( response ){
row.removeClass('media-save-terms');
container.find('input').removeProp('disabled');
});
});
// Add new taxonomy
jQuery('html').delegate('.toggle-add-media-term', 'click', function(e){
e.preventDefault();
jQuery(this).parent().find('.add-new-term').toggle();
});
// Save new taxnomy
jQuery('html').delegate('.save-media-term', 'click', function(e){
var obj = jQuery(this),
termField = obj.parent().find('input'),
termParent = obj.parent().find('select'),
data = {
action: 'add-media-term',
attachment_id: obj.data('id'),
taxonomy: obj.data('taxonomy'),
parent: termParent.val(),
term: termField.val()
};
// No val
if ( '' == data.term ) {
termField.focus();
return;
}
jQuery.post(ajaxurl, data, function(response){
obj.parents('.field').find('.media-terms ul:first').html( response.checkboxes );
obj.parents('.field').find('select').replaceWith( response.selectbox );
console.log( response );
termField.val('');
}, 'json' );
});
});