Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bricks support #2876

Draft
wants to merge 19 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelogs/bricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: minor
type: added
entry: Initial support for the Bricks theme.
45 changes: 45 additions & 0 deletions assets/css/bricks-editor.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions class-lifterlms.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public function init() {
( new LLMS_Media_Protector() )->register_callbacks();

include_once 'includes/class-llms-elementor-migrate.php';
include_once 'includes/class-llms-bricks.php';
include_once 'includes/class-llms-beaver-builder.php';
include_once 'includes/class-llms-beaver-builder-migrate.php';

Expand Down
105 changes: 105 additions & 0 deletions includes/bricks/class-llms-bricks-element-course-author.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* LifterLMS Course Author class.
*
* @since [version]
*/
class LLMS_Bricks_Element_Course_Author extends \Bricks\Element {
public $block = 'llms/course-author';
public $category = 'lifterlms';
public $name = 'llms-course-author';
public $icon = 'llms-bricks-icon llms-bricks-icon-course-author';
public $css_selector = '.llms-course-author-wrapper';
public $scripts = array();

public function get_label() {
return esc_html__( 'Course Author', 'lifterlms' );
}

public function set_control_groups() {
}

public function set_controls() {
$this->controls['avatar_size'] = array(
'tab' => 'content',
'label' => esc_html__( 'Avatar size', 'lifterlms' ),
'type' => 'slider',
'units' => array(
'px' => array(
'min' => 1,
'max' => 300,
'step' => 1,
),
),
'default' => 48,
'description' => esc_html__( 'The size of the avatar in pixels.', 'lifterlms' ),
);

$this->controls['bio'] = array(
'tab' => 'content',
'label' => esc_html__( 'Display Bio', 'lifterlms' ),
'type' => 'checkbox',
'inline' => false,
'small' => true,
'default' => true, // Default: false
);

$courses_posts = get_posts(
array(
'post_type' => 'course',
'posts_per_page' => -1, // Retrieve all posts
'post_status' => 'publish', // Only published posts
)
);
$courses = array(
'inherit' => __( 'Inherit from current course', 'lifterlms' ),
);
foreach ( $courses_posts as $course ) {
$courses[ $course->ID ] = $course->post_title;
}

$this->controls['course_id'] = array(
'tab' => 'content',
'label' => esc_html__( 'Course', 'lifterlms' ),
'type' => 'select',
'options' => $courses,
'inline' => false,
'clearable' => false,
'pasteStyles' => false,
'default' => 'inherit',
);
}

public function enqueue_scripts() {
}

public function convert_block_to_element_settings( $block, $attributes ) {
$element_settings = array(
'avatar_size' => isset( $attributes['avatar_size'] ) ? intval( $attributes['avatar_size'] ) : 48,
'bio' => ( isset( $attributes['bio'] ) && 'no' === $attributes['bio'] ) ? false : true,
'course_id' => isset( $attributes['course_id'] ) ? intval( $attributes['course_id'] ) : 'inherit',
);

return $element_settings;
}

public function render() {
$root_classes[] = 'llms-course-author-wrapper';

$this->set_attribute( '_root', 'class', $root_classes );

$avatar_size = isset( $this->settings['avatar_size'] ) && $this->settings['avatar_size'] ? intval( $this->settings['avatar_size'] ) : 48;
$bio = isset( $this->settings['bio'] ) && $this->settings['bio'] ? '' : 'no';
$course_id = isset( $this->settings['course_id'] ) && is_numeric( $this->settings['course_id'] ) ? intval( $this->settings['course_id'] ) : '';

echo "<div {$this->render_attributes( '_root' )}>"; // Element root attributes

echo do_shortcode( '[lifterlms_course_author avatar_size="' . esc_attr( $avatar_size ) . '" bio="' . esc_attr( $bio ) . '" course_id="' . $course_id . '"]' );

echo '</div>';
}
}
77 changes: 77 additions & 0 deletions includes/bricks/class-llms-bricks-element-course-continue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* LifterLMS Bricks Course Progress with Continue Button class.
*
* @since [version]
*/
class LLMS_Bricks_Element_Course_Continue extends \Bricks\Element {
public $block = 'llms/course-continue';
public $category = 'lifterlms';
public $name = 'llms-course-continue';
public $icon = 'llms-bricks-icon llms-bricks-icon-course-continue';
public $css_selector = '.llms-course-continue';
public $scripts = array();

public function get_label() {
return esc_html__( 'Course Progress with Continue Button', 'lifterlms' );
}

public function set_control_groups() {
}

public function set_controls() {
$courses_posts = get_posts(
array(
'post_type' => 'course',
'posts_per_page' => -1, // Retrieve all posts
'post_status' => 'publish', // Only published posts
)
);
$courses = array(
'inherit' => __( 'Inherit from current course', 'lifterlms' ),
);
foreach ( $courses_posts as $course ) {
$courses[ $course->ID ] = $course->post_title;
}

$this->controls['course_id'] = array(
'tab' => 'content',
'label' => esc_html__( 'Course', 'lifterlms' ),
'type' => 'select',
'options' => $courses,
'inline' => false,
'clearable' => false,
'pasteStyles' => false,
'default' => 'inherit',
);
}

public function enqueue_scripts() {
}

public function convert_block_to_element_settings( $block, $attributes ) {
$element_settings = array(
'course_id' => isset( $attributes['course_id'] ) ? intval( $attributes['course_id'] ) : 'inherit',
);

return $element_settings;
}

public function render() {
$root_classes[] = 'llms-course-meta-info';

$this->set_attribute( '_root', 'class', $root_classes );

$course_id = isset( $this->settings['course_id'] ) && is_numeric( $this->settings['course_id'] ) ? intval( $this->settings['course_id'] ) : '';

echo "<div {$this->render_attributes( '_root' )}>"; // Element root attributes

echo do_shortcode( '[lifterlms_course_continue course_id="' . $course_id . '"]' );

echo '</div>';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* LifterLMS Bricks Course Information class.
*
* @since [version]
*/
class LLMS_Bricks_Element_Course_Information extends \Bricks\Element {
public $block = 'llms/course-information';
public $category = 'lifterlms';
public $name = 'llms-course-information';
public $icon = 'llms-bricks-icon llms-bricks-icon-course-information';
public $css_selector = '.llms-course-information-wrapper';
public $scripts = array();

public function get_label() {
return esc_html__( 'Course Information', 'lifterlms' );
}

public function set_control_groups() {
}

public function set_controls() {
// Convert to nested elements.
$this->controls['title'] = array(
'tab' => 'content',
'label' => esc_html__( 'Title', 'lifterlms' ),
'type' => 'text',
'default' => esc_html__( 'Course Information', 'lifterlms' ),
);

$this->controls['title_size'] = array(
'tab' => 'content',
// 'group' => 'settings',
'label' => esc_html__( 'Title Headline Size', 'lifterlms' ),
'type' => 'select',
'options' => array(
'h1' => esc_html__( 'h1', 'lifterlms' ),
'h2' => esc_html__( 'h2', 'lifterlms' ),
'h3' => esc_html__( 'h3', 'lifterlms' ),
'h4' => esc_html__( 'h4', 'lifterlms' ),
'h5' => esc_html__( 'h5', 'lifterlms' ),
'h6' => esc_html__( 'h6', 'lifterlms' ),
),
'inline' => true,
'clearable' => false,
'pasteStyles' => false,
'default' => 'h2',
);
}

public function enqueue_scripts() {
}

public function convert_block_to_element_settings( $block, $attributes ) {
$element_settings = array(
'title' => isset( $attributes['title'] ) ? $attributes['title'] : __( 'Course Information', 'lifterlms' ),
'title_size' => isset( $attributes['title_size'] ) ? $attributes['title_size'] : 'h2',
);

return $element_settings;
}

public function render() {
$root_classes[] = 'llms-course-information-wrapper';

$this->set_attribute( '_root', 'class', $root_classes );

$title = $this->settings['title'] ? $this->settings['title'] : __( 'Course Information', 'lifterlms' );
$title_size = $this->settings['title_size'] ? $this->settings['title_size'] : 'h2';

echo "<div {$this->render_attributes( '_root' )}>"; // Element root attributes

echo wp_kses_post( "<{$title_size} class='llms-meta-title'>{$title}</{$title_size}>" );

echo do_shortcode( '[lifterlms_course_meta_info]' );

echo '</div>';
}
}
Loading
Loading