From f1cb3ebb7394e5f7b257d69ac287ca3d4c0862ac Mon Sep 17 00:00:00 2001 From: eoxia-amandine Date: Thu, 11 Apr 2024 14:53:36 +0200 Subject: [PATCH 01/11] #41 Add: Beflex URL registration redirect --- acf-json/group_6617dbb4efcd8.json | 65 +++++++++++++++++++++++++++++++ functions.php | 14 +++++++ inc/blocks/bfs-login/view.php | 11 ++++-- sensei/functions.php | 13 +++++++ 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 acf-json/group_6617dbb4efcd8.json diff --git a/acf-json/group_6617dbb4efcd8.json b/acf-json/group_6617dbb4efcd8.json new file mode 100644 index 0000000..5cb0116 --- /dev/null +++ b/acf-json/group_6617dbb4efcd8.json @@ -0,0 +1,65 @@ +{ + "key": "group_6617dbb4efcd8", + "title": "Beflex Settings", + "fields": [ + { + "key": "field_6617dbb50e861", + "label": "Réglages généraux", + "name": "", + "aria-label": "", + "type": "tab", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "placement": "left", + "endpoint": 0 + }, + { + "key": "field_6617dbdb0e862", + "label": "Page d'inscription \/ connexion", + "name": "page_url_register", + "aria-label": "", + "type": "page_link", + "instructions": "A utiliser pour modifier la page d'inscription par défaut de Sensei LMS", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "post_type": [ + "page" + ], + "post_status": "", + "taxonomy": "", + "allow_archives": 1, + "multiple": 0, + "allow_null": 0 + } + ], + "location": [ + [ + { + "param": "options_page", + "operator": "==", + "value": "theme-general-settings" + } + ] + ], + "menu_order": 0, + "position": "normal", + "style": "default", + "label_placement": "top", + "instruction_placement": "label", + "hide_on_screen": "", + "active": true, + "description": "", + "show_in_rest": 0, + "modified": 1712839735 +} diff --git a/functions.php b/functions.php index 7240221..3cd9ccb 100644 --- a/functions.php +++ b/functions.php @@ -81,6 +81,20 @@ function beflex_add_custom_classes_to_body( $classes ) { } add_filter( 'body_class', 'beflex_add_custom_classes_to_body' ); +/** + * Création admin page for theme settings + */ +if( function_exists('acf_add_options_page') ) { + + acf_add_options_page( array( + 'page_title' => esc_html__('BeFlex Settings', 'beflex'), + 'menu_title' => esc_html__('BeFlex Settings', 'beflex'), + 'menu_slug' => 'theme-general-settings', + 'parent_slug' => 'themes.php', + 'capability' => 'edit_pages', + )); + +} // Block patterns. require_once 'inc/block-patterns.php'; diff --git a/inc/blocks/bfs-login/view.php b/inc/blocks/bfs-login/view.php index afaf880..6b2274d 100644 --- a/inc/blocks/bfs-login/view.php +++ b/inc/blocks/bfs-login/view.php @@ -27,13 +27,16 @@ settings->settings['my_course_page'] ); - $my_courses_url = get_permalink( $my_account_page_id ); + $beflex_registration_url = get_field( 'page_url_register', 'options' ); + if ( empty( $beflex_registration_url ) ) : + $my_account_page_id = intval( Sensei()->settings->settings['my_course_page'] ); + $beflex_registration_url = get_permalink( $my_account_page_id ); + endif; - if ( ! empty( $my_courses_url ) ) : + if ( ! empty( $beflex_registration_url ) ) : ?>
- + diff --git a/sensei/functions.php b/sensei/functions.php index 901f99e..b2aa948 100644 --- a/sensei/functions.php +++ b/sensei/functions.php @@ -178,3 +178,16 @@ function myplugin_user_register( $user_id ) { update_user_meta( $user_id, 'last_name', trim( $_POST['last_name'] ) ); } } + +/** + * Change the redirect of login page + */ +add_filter( 'sensei_registration_url', 'beflex_registration_url', 10, 2 ); +function beflex_registration_url( $registration_url, $redirect) { + $beflex_registration_url = get_field( 'page_url_register', 'options' ); + if ( ! empty( $beflex_registration_url ) ) { + $registration_url = esc_url( $beflex_registration_url ); + } + + return $registration_url; +} From c0a975e0cada708488a058a12519843bc07a05bf Mon Sep 17 00:00:00 2001 From: eoxia-amandine Date: Thu, 11 Apr 2024 14:54:16 +0200 Subject: [PATCH 02/11] Theme version update --- style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/style.css b/style.css index bb33e9f..90bba0b 100644 --- a/style.css +++ b/style.css @@ -6,7 +6,7 @@ Description: BeFlex is a free Theme Block. Imagination is the only limit. Requires at least: 5.9 Tested up to: 6.1.1 Requires PHP: 7.3 -Version: 2.3.0 +Version: 2.4.0 License: AGPLv3 License URI: https://spdx.org/licenses/AGPL-3.0-or-later.html Text Domain: beflex-sensei From 03b619e38f9795896667f138d5f6a3aea0901903 Mon Sep 17 00:00:00 2001 From: eoxia-amandine Date: Wed, 15 May 2024 15:42:31 +0200 Subject: [PATCH 03/11] Fix: Fatal error if sensei desactived --- inc/block-blocks.php | 15 +++++++++------ inc/block-patterns.php | 26 +++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/inc/block-blocks.php b/inc/block-blocks.php index 4c0f79a..58a6376 100644 --- a/inc/block-blocks.php +++ b/inc/block-blocks.php @@ -7,12 +7,15 @@ */ function beflex_acf_blocks_init() { - require get_template_directory() . '/inc/blocks/bfs-course-tax/bfs-course-tax.php'; - require get_template_directory() . '/inc/blocks/bfs-course-lessons/bfs-course-lessons.php'; - require get_template_directory() . '/inc/blocks/bfs-course-time/bfs-course-time.php'; -// require get_template_directory() . '/inc/blocks/bfs-course-completion/bfs-course-completion.php'; - require get_template_directory() . '/inc/blocks/bfs-login/bfs-login.php'; - require get_template_directory() . '/inc/blocks/bfs-course-signup/bfs-course-signup.php'; + if ( class_exists( 'Sensei_Main', true ) ) { + require get_template_directory() . '/inc/blocks/bfs-course-tax/bfs-course-tax.php'; + require get_template_directory() . '/inc/blocks/bfs-course-lessons/bfs-course-lessons.php'; + require get_template_directory() . '/inc/blocks/bfs-course-time/bfs-course-time.php'; + require get_template_directory() . '/inc/blocks/bfs-login/bfs-login.php'; + require get_template_directory() . '/inc/blocks/bfs-course-signup/bfs-course-signup.php'; + + // require get_template_directory() . '/inc/blocks/bfs-course-completion/bfs-course-completion.php'; + } } add_action( 'acf/init', 'beflex_acf_blocks_init' ); diff --git a/inc/block-patterns.php b/inc/block-patterns.php index fff8b2d..fbbc2c2 100644 --- a/inc/block-patterns.php +++ b/inc/block-patterns.php @@ -43,14 +43,13 @@ function beflex_register_block_patterns() { 'header-photo', 'query-standard', 'query-background', - 'query-course', - 'course-default' ); $sensei_block_patterns = array( + 'course-default', + 'query-course' ); - /** * Filters the theme block patterns. * @@ -68,5 +67,26 @@ function beflex_register_block_patterns() { require $pattern_file ); } + + if ( class_exists( 'Sensei_Main', true ) ) { + + /** + * Filters the theme block patterns. + * + * @since Twenty Twenty-Two 1.0 + * + * @param array $block_patterns List of block patterns by name. + */ + $sensei_block_patterns = apply_filters( 'beflex_sensei_block_patterns', $sensei_block_patterns ); + + foreach ( $sensei_block_patterns as $block_pattern ) { + $pattern_file = get_theme_file_path( '/inc/patterns/' . $block_pattern . '.php' ); + + register_block_pattern( + 'beflex/' . $block_pattern, + require $pattern_file + ); + } + } } add_action( 'init', 'beflex_register_block_patterns', 9 ); From 7735b280e088ea14a1787f94b031f6fb48b76e62 Mon Sep 17 00:00:00 2001 From: eoxia-amandine Date: Thu, 23 May 2024 10:44:04 +0200 Subject: [PATCH 04/11] #47 Add BFS Course template --- assets/css/style-sensei.css | 3 +- assets/css/style-sensei.min.css | 2 +- assets/scss/sensei/block/_block-outline.scss | 3 +- inc/block-patterns.php | 1 + inc/patterns/course-default.php | 40 +++++++++++++++++--- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/assets/css/style-sensei.css b/assets/css/style-sensei.css index 79e523f..8fdd0be 100644 --- a/assets/css/style-sensei.css +++ b/assets/css/style-sensei.css @@ -434,7 +434,8 @@ body.sensei-template-old .wp-block-sensei-lms-course-list-filter { } .wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-module__lessons-title, .wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-module__lessons-title { - background: none; + background: none !important; + font-size: 10px; } .wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-lesson > span, .wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-lesson > span { diff --git a/assets/css/style-sensei.min.css b/assets/css/style-sensei.min.css index 948716d..dd88e23 100644 --- a/assets/css/style-sensei.min.css +++ b/assets/css/style-sensei.min.css @@ -1 +1 @@ -.sensei-course-filters{display:none}.sensei-ordering{display:none}.post.course{border-bottom:0}.post.course .entry{border:1px solid rgba(0,0,0,.2)}.post.course .course-thumbnail img{display:block;float:none;width:100%;margin-bottom:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.post.course .course-thumbnail img:hover{opacity:.8}.post.course .course-content-container{padding:1em}.post.course .course-tax{line-height:1}.post.course .course-tax a{margin-left:.8em;text-transform:uppercase;font-weight:700;font-size:12px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.post.course .course-tax a:hover{opacity:.6}.post.course .course-tax a:first-child{margin-left:0}.post.course .course-title{line-height:1}.post.course .course-title a{color:var(--wp--preset--color--black);font-size:18px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.post.course .course-title a:hover{opacity:.6}.post.course .course-meta{color:rgba(0,0,0,.6);font-size:14px;margin:1em 0 0 0}.post.course .course-meta>*{display:inline-block;margin-left:1em}.post.course .course-meta>*:first-child{margin-left:0}.post.course .course-completion{display:block;position:relative;width:100%;height:10px;background:rgba(0,0,0,.1)}.post.course .course-completion.progress-0{background:#fff}.post.course .course-completion .course-progress-bar{position:absolute;left:0;height:100%;background:var(--wp--preset--color--vivid-green-cyan)}body.learner-profile .wp-site-blocks>*+*,body.learner-archive-message .wp-site-blocks>*+*,body.single-sensei_message .wp-site-blocks>*+*{margin-top:0 !important}body.learner-profile .profile-setting h2,body.learner-profile .profile-setting #learner-info,body.learner-archive-message .profile-setting h2,body.learner-archive-message .profile-setting #learner-info,body.single-sensei_message .profile-setting h2,body.single-sensei_message .profile-setting #learner-info{display:none}body.learner-profile .my-messages-link-container,body.learner-archive-message .my-messages-link-container,body.single-sensei_message .my-messages-link-container{display:none}body.learner-profile .wp-block-spacer,body.learner-archive-message .wp-block-spacer,body.single-sensei_message .wp-block-spacer{display:none}body.learner-profile article.post:not(.course),body.learner-archive-message article.post:not(.course),body.single-sensei_message article.post:not(.course){display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:0}body.learner-profile article.post:not(.course) .profile-sidebar,body.learner-archive-message article.post:not(.course) .profile-sidebar,body.single-sensei_message article.post:not(.course) .profile-sidebar{width:30%;-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1;background:#fff;border-right:1px solid rgba(0,0,0,.1)}body.learner-profile article.post:not(.course) #learner-container,body.learner-archive-message article.post:not(.course) #learner-container,body.single-sensei_message article.post:not(.course) #learner-container{width:70%;-webkit-box-ordinal-group:3;-ms-flex-order:2;order:2;background:rgba(0,0,0,.05);-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}body.learner-profile #learner-container,body.learner-archive-message #learner-container,body.single-sensei_message #learner-container{padding:0 10% 2em 2em}.profile-box{background:#fff;border-radius:6px;padding:1em;margin-bottom:1em}.profile-box .box-line{margin-bottom:.6em}.profile-box .box-line:last-child{margin-bottom:0}.profile-box .box-line strong{display:inline-block;min-width:100px}body.learner-profile .post.course{background:#fff;padding-bottom:0}body.learner-profile .post.course .entry{border:0}body.learner-profile .post.course .course-author,body.learner-profile .post.course .course-excerpt{display:none}body.learner-profile .post.course .thumbnail{margin-bottom:0}body.learner-profile .post.course .meter{margin:0;border-radius:0}body.learner-profile .post.course .meter .value{border-radius:0}.profile-sidebar .profile-sidebar-content{margin-left:250px;padding-top:2em;padding-right:4em}.profile-sidebar .profile-sidebar-content svg{max-width:12px}.profile-sidebar .profile-nav{display:block;color:#000;font-size:14px;margin-bottom:1.5em}.profile-sidebar .profile-nav svg{margin-right:.4em}.profile-sidebar .profile-nav.spacer{margin-top:3em}.profile-sidebar .profile-nav-active,body.sensei.learner-archive-message .profile-sidebar .nav-messages,body.sensei.learner-profile .profile-sidebar .nav-courses{background:var(--wp--preset--color--primary);color:#fff;padding:.6em 1em;border-radius:6px}.profile-sidebar .profile-nav-active svg,body.sensei.learner-archive-message .profile-sidebar .nav-messages svg,body.sensei.learner-profile .profile-sidebar .nav-courses svg{fill:#fff}body.learner-archive-message .archive-header{display:none}body.learner-archive-message .message-container a{padding:1em 1.5em;background:#fff;color:#000;display:-webkit-box;display:-ms-flexbox;display:flex;border-bottom:1px solid rgba(0,0,0,.2);-webkit-transition:background .2s ease-out;transition:background .2s ease-out}body.learner-archive-message .message-container a:hover{background:rgba(0,0,0,.05)}@media(max-width: 599px){body.learner-archive-message .message-container a{display:block}}body.learner-archive-message .message-container a:first-child{border-top-left-radius:6px;border-top-right-radius:6px}body.learner-archive-message .message-container a:last-child{border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-bottom:0}body.learner-archive-message .message-container a .message-title{font-weight:700}body.learner-archive-message .message-container a .message-data-container{margin-left:auto;min-width:200px;text-align:right}body.learner-archive-message .message-container a .message-data-container .message-data{opacity:.6;margin-left:.5em}body.learner-archive-message .message-container a .message-data-container .message-data svg{max-width:12px}body.single-sensei_message .wp-block-post-title{display:none}body.single-sensei_message .message-header{display:-webkit-box;display:-ms-flexbox;display:flex;margin:1.6em 0 0 0}body.single-sensei_message .message-header a{-ms-flex-item-align:center;align-self:center;font-size:30px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;margin-right:.5em}body.single-sensei_message .message-header a svg{width:20px}body.single-sensei_message .message-header a:hover{opacity:.7}body.single-sensei_message .message-header .message-title{margin:0}body.single-sensei_message .comment-respond .comment-form{display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:1em}body.single-sensei_message .comment-respond .comment-form .comment-form-comment{width:100%}body.single-sensei_message .comment-respond .comment-form textarea{display:block;width:100%;background:#fff;padding:1em;border-radius:6px;font-family:var(--wp--preset--font-family--open-sans)}body.single-sensei_message .comment-respond .comment-form .form-submit{margin:auto}body.single-sensei_message .comment-respond .comment-form #submit{border:1px solid var(--wp--preset--color--primary);color:var(--wp--preset--color--primary);border-radius:6px;margin:auto 0 auto 1em;padding:1em;min-width:120px;text-transform:uppercase;font-weight:600;-webkit-transition:all .2s ease-out;transition:all .2s ease-out;background:none}body.single-sensei_message .comment-respond .comment-form #submit:hover{background:var(--wp--preset--color--primary);color:#fff}body.single-sensei_message .message-comment{display:-webkit-box;display:-ms-flexbox;display:flex;margin:1.5em 0}body.single-sensei_message .message-comment .avatar{border-radius:50%;margin:auto 1.5em auto 0}body.single-sensei_message .message-comment .comment-container{background:#fff;width:100%;padding:1.2em;border-radius:6px}body.single-sensei_message .message-comment .comment-container .comment-meta{margin-top:1.5em}body.single-sensei_message .message-comment .comment-container .comment-meta .message-data{opacity:.6;margin-left:.5em;font-size:14px}body.single-sensei_message .message-comment .comment-container .comment-meta svg{margin-right:.3em;max-width:14px}body.single-sensei_message .message-comment.message-author .avatar{-webkit-box-ordinal-group:3;-ms-flex-order:2;order:2;margin:auto 0 auto 1.5em}body.single-sensei_message .message-comment.message-author .comment-container{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1;background:var(--wp--preset--color--primary);color:#fff}body.single-sensei_message .message-comment.message-author .comment-container svg{fill:#fff}#my-courses .col2-set{display:grid;grid-template-columns:repeat(2, 1fr);grid-gap:2em 2em}@media(max-width: 599px){#my-courses .col2-set{grid-template-columns:repeat(1, 1fr)}}#my-courses .col-2{background:var(--wp--preset--color--light-grey);border:1px solid rgba(0,0,0,.2);padding:20px}#my-courses .col-2 .col2-set{grid-gap:0 1em}#my-courses .col-2 h2{margin:0}#my-courses .col-2 .required{color:red}body.sensei-template-old .site-header>.header-sticky>.wp-block-group>.wp-block-group{max-width:1200px;margin-left:auto !important;margin-right:auto !important;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}body.sensei-template-old .wp-block-sensei-lms-course-list-filter{display:none !important}.header-course.wp-block-template-part .wp-block-post-featured-image img{border-radius:6px}.wp-block-query .wp-block-post.course{border-bottom:0}.wp-block-query .wp-block-post.course .wp-block-post-featured-image{-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.wp-block-query .wp-block-post.course .wp-block-post-featured-image:hover{opacity:.8}.wp-block-query .wp-block-post.course .wp-block-post-title{-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.wp-block-query .wp-block-post.course .wp-block-post-title:hover{opacity:.6}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module,.wp-block-sensei-lms-course-outline-module.is-style-beflex{background:var(--wp--preset--color--light-grey);border-color:rgba(0,0,0,.2) !important}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-module__header,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-module__header{background-color:transparent !important;color:var(--wp--preset--color--anthracite) !important}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-module__description,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-module__description{padding:0 16px 16px 16px;font-size:14px}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-module__lessons-title,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-module__lessons-title{background:none}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-lesson>span,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-lesson>span{padding:10px 16px}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-lesson:last-child>span,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-lesson:last-child>span{padding-bottom:16px}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-completed .sensei-lms-course-navigation-lesson__link{color:#0ec986}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-completed .sensei-lms-course-navigation-lesson__link:hover *{color:#0ec986}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-in-progress .sensei-lms-course-navigation-lesson__link{color:#e4612e}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-in-progress .sensei-lms-course-navigation-lesson__link:hover *{color:#e4612e}.wp-block-query.query-course .wp-block-post .wp-block-post-featured-image{margin:0}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories{margin:0}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories a{background:none;text-transform:uppercase;color:var(--wp--preset--color--primary);font-weight:700;font-size:12px;padding:0;margin-right:6px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories a span{color:var(--wp--preset--color--primary)}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories a:hover{opacity:.7}.wp-block-query.query-course .wp-block-post .sensei-progress-bar__label{display:none} \ No newline at end of file +.sensei-course-filters{display:none}.sensei-ordering{display:none}.post.course{border-bottom:0}.post.course .entry{border:1px solid rgba(0,0,0,.2)}.post.course .course-thumbnail img{display:block;float:none;width:100%;margin-bottom:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.post.course .course-thumbnail img:hover{opacity:.8}.post.course .course-content-container{padding:1em}.post.course .course-tax{line-height:1}.post.course .course-tax a{margin-left:.8em;text-transform:uppercase;font-weight:700;font-size:12px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.post.course .course-tax a:hover{opacity:.6}.post.course .course-tax a:first-child{margin-left:0}.post.course .course-title{line-height:1}.post.course .course-title a{color:var(--wp--preset--color--black);font-size:18px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.post.course .course-title a:hover{opacity:.6}.post.course .course-meta{color:rgba(0,0,0,.6);font-size:14px;margin:1em 0 0 0}.post.course .course-meta>*{display:inline-block;margin-left:1em}.post.course .course-meta>*:first-child{margin-left:0}.post.course .course-completion{display:block;position:relative;width:100%;height:10px;background:rgba(0,0,0,.1)}.post.course .course-completion.progress-0{background:#fff}.post.course .course-completion .course-progress-bar{position:absolute;left:0;height:100%;background:var(--wp--preset--color--vivid-green-cyan)}body.learner-profile .wp-site-blocks>*+*,body.learner-archive-message .wp-site-blocks>*+*,body.single-sensei_message .wp-site-blocks>*+*{margin-top:0 !important}body.learner-profile .profile-setting h2,body.learner-profile .profile-setting #learner-info,body.learner-archive-message .profile-setting h2,body.learner-archive-message .profile-setting #learner-info,body.single-sensei_message .profile-setting h2,body.single-sensei_message .profile-setting #learner-info{display:none}body.learner-profile .my-messages-link-container,body.learner-archive-message .my-messages-link-container,body.single-sensei_message .my-messages-link-container{display:none}body.learner-profile .wp-block-spacer,body.learner-archive-message .wp-block-spacer,body.single-sensei_message .wp-block-spacer{display:none}body.learner-profile article.post:not(.course),body.learner-archive-message article.post:not(.course),body.single-sensei_message article.post:not(.course){display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:0}body.learner-profile article.post:not(.course) .profile-sidebar,body.learner-archive-message article.post:not(.course) .profile-sidebar,body.single-sensei_message article.post:not(.course) .profile-sidebar{width:30%;-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1;background:#fff;border-right:1px solid rgba(0,0,0,.1)}body.learner-profile article.post:not(.course) #learner-container,body.learner-archive-message article.post:not(.course) #learner-container,body.single-sensei_message article.post:not(.course) #learner-container{width:70%;-webkit-box-ordinal-group:3;-ms-flex-order:2;order:2;background:rgba(0,0,0,.05);-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}body.learner-profile #learner-container,body.learner-archive-message #learner-container,body.single-sensei_message #learner-container{padding:0 10% 2em 2em}.profile-box{background:#fff;border-radius:6px;padding:1em;margin-bottom:1em}.profile-box .box-line{margin-bottom:.6em}.profile-box .box-line:last-child{margin-bottom:0}.profile-box .box-line strong{display:inline-block;min-width:100px}body.learner-profile .post.course{background:#fff;padding-bottom:0}body.learner-profile .post.course .entry{border:0}body.learner-profile .post.course .course-author,body.learner-profile .post.course .course-excerpt{display:none}body.learner-profile .post.course .thumbnail{margin-bottom:0}body.learner-profile .post.course .meter{margin:0;border-radius:0}body.learner-profile .post.course .meter .value{border-radius:0}.profile-sidebar .profile-sidebar-content{margin-left:250px;padding-top:2em;padding-right:4em}.profile-sidebar .profile-sidebar-content svg{max-width:12px}.profile-sidebar .profile-nav{display:block;color:#000;font-size:14px;margin-bottom:1.5em}.profile-sidebar .profile-nav svg{margin-right:.4em}.profile-sidebar .profile-nav.spacer{margin-top:3em}.profile-sidebar .profile-nav-active,body.sensei.learner-archive-message .profile-sidebar .nav-messages,body.sensei.learner-profile .profile-sidebar .nav-courses{background:var(--wp--preset--color--primary);color:#fff;padding:.6em 1em;border-radius:6px}.profile-sidebar .profile-nav-active svg,body.sensei.learner-archive-message .profile-sidebar .nav-messages svg,body.sensei.learner-profile .profile-sidebar .nav-courses svg{fill:#fff}body.learner-archive-message .archive-header{display:none}body.learner-archive-message .message-container a{padding:1em 1.5em;background:#fff;color:#000;display:-webkit-box;display:-ms-flexbox;display:flex;border-bottom:1px solid rgba(0,0,0,.2);-webkit-transition:background .2s ease-out;transition:background .2s ease-out}body.learner-archive-message .message-container a:hover{background:rgba(0,0,0,.05)}@media(max-width: 599px){body.learner-archive-message .message-container a{display:block}}body.learner-archive-message .message-container a:first-child{border-top-left-radius:6px;border-top-right-radius:6px}body.learner-archive-message .message-container a:last-child{border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-bottom:0}body.learner-archive-message .message-container a .message-title{font-weight:700}body.learner-archive-message .message-container a .message-data-container{margin-left:auto;min-width:200px;text-align:right}body.learner-archive-message .message-container a .message-data-container .message-data{opacity:.6;margin-left:.5em}body.learner-archive-message .message-container a .message-data-container .message-data svg{max-width:12px}body.single-sensei_message .wp-block-post-title{display:none}body.single-sensei_message .message-header{display:-webkit-box;display:-ms-flexbox;display:flex;margin:1.6em 0 0 0}body.single-sensei_message .message-header a{-ms-flex-item-align:center;align-self:center;font-size:30px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;margin-right:.5em}body.single-sensei_message .message-header a svg{width:20px}body.single-sensei_message .message-header a:hover{opacity:.7}body.single-sensei_message .message-header .message-title{margin:0}body.single-sensei_message .comment-respond .comment-form{display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:1em}body.single-sensei_message .comment-respond .comment-form .comment-form-comment{width:100%}body.single-sensei_message .comment-respond .comment-form textarea{display:block;width:100%;background:#fff;padding:1em;border-radius:6px;font-family:var(--wp--preset--font-family--open-sans)}body.single-sensei_message .comment-respond .comment-form .form-submit{margin:auto}body.single-sensei_message .comment-respond .comment-form #submit{border:1px solid var(--wp--preset--color--primary);color:var(--wp--preset--color--primary);border-radius:6px;margin:auto 0 auto 1em;padding:1em;min-width:120px;text-transform:uppercase;font-weight:600;-webkit-transition:all .2s ease-out;transition:all .2s ease-out;background:none}body.single-sensei_message .comment-respond .comment-form #submit:hover{background:var(--wp--preset--color--primary);color:#fff}body.single-sensei_message .message-comment{display:-webkit-box;display:-ms-flexbox;display:flex;margin:1.5em 0}body.single-sensei_message .message-comment .avatar{border-radius:50%;margin:auto 1.5em auto 0}body.single-sensei_message .message-comment .comment-container{background:#fff;width:100%;padding:1.2em;border-radius:6px}body.single-sensei_message .message-comment .comment-container .comment-meta{margin-top:1.5em}body.single-sensei_message .message-comment .comment-container .comment-meta .message-data{opacity:.6;margin-left:.5em;font-size:14px}body.single-sensei_message .message-comment .comment-container .comment-meta svg{margin-right:.3em;max-width:14px}body.single-sensei_message .message-comment.message-author .avatar{-webkit-box-ordinal-group:3;-ms-flex-order:2;order:2;margin:auto 0 auto 1.5em}body.single-sensei_message .message-comment.message-author .comment-container{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1;background:var(--wp--preset--color--primary);color:#fff}body.single-sensei_message .message-comment.message-author .comment-container svg{fill:#fff}#my-courses .col2-set{display:grid;grid-template-columns:repeat(2, 1fr);grid-gap:2em 2em}@media(max-width: 599px){#my-courses .col2-set{grid-template-columns:repeat(1, 1fr)}}#my-courses .col-2{background:var(--wp--preset--color--light-grey);border:1px solid rgba(0,0,0,.2);padding:20px}#my-courses .col-2 .col2-set{grid-gap:0 1em}#my-courses .col-2 h2{margin:0}#my-courses .col-2 .required{color:red}body.sensei-template-old .site-header>.header-sticky>.wp-block-group>.wp-block-group{max-width:1200px;margin-left:auto !important;margin-right:auto !important;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}body.sensei-template-old .wp-block-sensei-lms-course-list-filter{display:none !important}.header-course.wp-block-template-part .wp-block-post-featured-image img{border-radius:6px}.wp-block-query .wp-block-post.course{border-bottom:0}.wp-block-query .wp-block-post.course .wp-block-post-featured-image{-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.wp-block-query .wp-block-post.course .wp-block-post-featured-image:hover{opacity:.8}.wp-block-query .wp-block-post.course .wp-block-post-title{-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.wp-block-query .wp-block-post.course .wp-block-post-title:hover{opacity:.6}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module,.wp-block-sensei-lms-course-outline-module.is-style-beflex{background:var(--wp--preset--color--light-grey);border-color:rgba(0,0,0,.2) !important}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-module__header,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-module__header{background-color:transparent !important;color:var(--wp--preset--color--anthracite) !important}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-module__description,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-module__description{padding:0 16px 16px 16px;font-size:14px}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-module__lessons-title,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-module__lessons-title{background:none !important;font-size:10px}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-lesson>span,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-lesson>span{padding:10px 16px}.wp-block-sensei-lms-course-outline.is-style-beflex .wp-block-sensei-lms-course-outline-module .wp-block-sensei-lms-course-outline-lesson:last-child>span,.wp-block-sensei-lms-course-outline-module.is-style-beflex .wp-block-sensei-lms-course-outline-lesson:last-child>span{padding-bottom:16px}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-completed .sensei-lms-course-navigation-lesson__link{color:#0ec986}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-completed .sensei-lms-course-navigation-lesson__link:hover *{color:#0ec986}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-in-progress .sensei-lms-course-navigation-lesson__link{color:#e4612e}.sensei-lms-course-navigation .sensei-lms-course-navigation-lesson.status-in-progress .sensei-lms-course-navigation-lesson__link:hover *{color:#e4612e}.wp-block-query.query-course .wp-block-post .wp-block-post-featured-image{margin:0}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories{margin:0}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories a{background:none;text-transform:uppercase;color:var(--wp--preset--color--primary);font-weight:700;font-size:12px;padding:0;margin-right:6px;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories a span{color:var(--wp--preset--color--primary)}.wp-block-query.query-course .wp-block-post .wp-block-sensei-lms-course-categories a:hover{opacity:.7}.wp-block-query.query-course .wp-block-post .sensei-progress-bar__label{display:none} \ No newline at end of file diff --git a/assets/scss/sensei/block/_block-outline.scss b/assets/scss/sensei/block/_block-outline.scss index b86dfd1..d5e4173 100644 --- a/assets/scss/sensei/block/_block-outline.scss +++ b/assets/scss/sensei/block/_block-outline.scss @@ -16,7 +16,8 @@ font-size: 14px; } .wp-block-sensei-lms-course-outline-module__lessons-title { - background: none; + background: none !important; + font-size: 10px; } .wp-block-sensei-lms-course-outline-lesson { > span { diff --git a/inc/block-patterns.php b/inc/block-patterns.php index fbbc2c2..1d7be8b 100644 --- a/inc/block-patterns.php +++ b/inc/block-patterns.php @@ -88,5 +88,6 @@ function beflex_register_block_patterns() { ); } } + } add_action( 'init', 'beflex_register_block_patterns', 9 ); diff --git a/inc/patterns/course-default.php b/inc/patterns/course-default.php index 7f35764..bc10343 100644 --- a/inc/patterns/course-default.php +++ b/inc/patterns/course-default.php @@ -1,10 +1,40 @@ esc_html__('BFS Sensei - course template', 'beflex'), - 'categories' => [ \Sensei_Block_Patterns::get_patterns_category_name() ], - 'keywords' => [ \Sensei_Block_Patterns::get_post_content_block_type_name() ], - 'content' => '
coucou
', + 'title' => esc_html__( 'BFS Sensei - course template', 'beflex' ), + 'blockTypes' => array( 'sensei-lms/post-content' ), + 'categories' => array( 'sensei-lms' ), + 'keywords' => array( 'beflex', 'header' ), + 'content' => ' +
+
+

Sous-titre

+ + + +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus at tempus est. Suspendisse placerat elit auctor tincidunt molestie. Proin augue elit, elementum eget neque vestibulum, commodo sodales leo. Nam vitae lacus turpis. Sed rutrum vehicula enim quis lobortis. Duis semper elementum congue. Aenean dapibus dignissim odio a ultrices.

+ + + +

Sous-titre

+ + + +

Suspendisse vestibulum est et posuere vestibulum. Aliquam aliquet nec leo ac pretium. Curabitur in porttitor nunc, sit amet eleifend enim. Sed sit amet convallis tortor. Duis augue turpis, venenatis sit amet tristique id, dignissim a magna. Phasellus maximus ante nec dolor congue cursus. Praesent tincidunt libero a fringilla volutpat. Donec ac sollicitudin orci. Cras vitae est sodales, porttitor nibh eget, pulvinar risus. Nullam sed auctor orci, quis ornare justo. Suspendisse non iaculis enim.

+ + + +
+
+ + + +
+ +
+
+', ); From 7388badeffd992c4c7183b275c079c05166c845c Mon Sep 17 00:00:00 2001 From: eoxia-amandine Date: Thu, 23 May 2024 15:24:03 +0200 Subject: [PATCH 05/11] #49 Rework: ACF Blocks --- block-template-parts/entete-cours.html | 10 +- block-templates/archive-course.html | 48 ++-- functions.php | 2 +- gulpfile.js | 2 +- inc/block-blocks.php | 42 --- inc/blocks.php | 37 +++ .../assets/css/style.css | 16 -- .../assets/css/style.min.css | 1 - .../assets/scss/style.scss | 18 -- .../bfs-course-completion.php | 42 --- inc/blocks/bfs-course-completion/view.php | 39 --- .../bfs-course-lesson/assets/css/style.css | 14 + .../assets/css/style.min.css | 1 + .../assets/images/list-check-solid.svg | 0 .../assets/js/bfs-course-lesson.js | 27 ++ .../bfs-course-lesson/assets/json/block.json | 26 ++ .../assets/scss/style.scss | 8 +- .../bfs-course-lesson/bfs-course-lesson.php | 43 +++ inc/blocks/bfs-course-lesson/view.php | 56 ++++ .../bfs-course-lessons/assets/css/style.css | 11 - .../assets/css/style.min.css | 1 - .../bfs-course-lessons/bfs-course-lessons.php | 42 --- inc/blocks/bfs-course-lessons/view.php | 45 --- .../assets/js/bfs-course-signup.js | 27 ++ .../bfs-course-signup/assets/json/block.json | 22 ++ .../bfs-course-signup/assets/scss/style.scss | 3 + .../bfs-course-signup/bfs-course-signup.php | 52 ++-- inc/blocks/bfs-course-signup/view.php | 58 ++-- .../bfs-course-tax/assets/css/style.css | 3 + .../assets/js/bfs-course-tax.js | 27 ++ .../bfs-course-tax/assets/json/block.json | 26 ++ .../bfs-course-tax/assets/scss/style.scss | 5 +- inc/blocks/bfs-course-tax/bfs-course-tax.php | 53 ++-- inc/blocks/bfs-course-tax/view.php | 51 ++-- .../bfs-course-time/assets/css/style.css | 5 +- .../bfs-course-time/assets/css/style.min.css | 2 +- .../assets/js/bfs-course-time.js | 27 ++ .../bfs-course-time/assets/json/block.json | 25 ++ .../bfs-course-time/assets/scss/style.scss | 6 +- .../bfs-course-time/bfs-course-time.php | 53 ++-- inc/blocks/bfs-course-time/view.php | 51 ++-- inc/blocks/bfs-login/assets/css/style.css | 3 + inc/blocks/bfs-login/assets/js/bfs-login.js | 27 ++ inc/blocks/bfs-login/assets/json/block.json | 22 ++ inc/blocks/bfs-login/assets/scss/style.scss | 4 + inc/blocks/bfs-login/bfs-login.php | 53 ++-- inc/blocks/bfs-login/view.php | 45 ++- inc/generateBlock.js | 262 ++++++++++++++++++ 48 files changed, 973 insertions(+), 470 deletions(-) delete mode 100644 inc/block-blocks.php create mode 100644 inc/blocks.php delete mode 100644 inc/blocks/bfs-course-completion/assets/css/style.css delete mode 100644 inc/blocks/bfs-course-completion/assets/css/style.min.css delete mode 100644 inc/blocks/bfs-course-completion/assets/scss/style.scss delete mode 100644 inc/blocks/bfs-course-completion/bfs-course-completion.php delete mode 100644 inc/blocks/bfs-course-completion/view.php create mode 100644 inc/blocks/bfs-course-lesson/assets/css/style.css create mode 100644 inc/blocks/bfs-course-lesson/assets/css/style.min.css rename inc/blocks/{bfs-course-lessons => bfs-course-lesson}/assets/images/list-check-solid.svg (100%) create mode 100644 inc/blocks/bfs-course-lesson/assets/js/bfs-course-lesson.js create mode 100644 inc/blocks/bfs-course-lesson/assets/json/block.json rename inc/blocks/{bfs-course-lessons => bfs-course-lesson}/assets/scss/style.scss (61%) create mode 100644 inc/blocks/bfs-course-lesson/bfs-course-lesson.php create mode 100644 inc/blocks/bfs-course-lesson/view.php delete mode 100644 inc/blocks/bfs-course-lessons/assets/css/style.css delete mode 100644 inc/blocks/bfs-course-lessons/assets/css/style.min.css delete mode 100644 inc/blocks/bfs-course-lessons/bfs-course-lessons.php delete mode 100644 inc/blocks/bfs-course-lessons/view.php create mode 100644 inc/blocks/bfs-course-signup/assets/js/bfs-course-signup.js create mode 100644 inc/blocks/bfs-course-signup/assets/json/block.json create mode 100644 inc/blocks/bfs-course-signup/assets/scss/style.scss create mode 100644 inc/blocks/bfs-course-tax/assets/js/bfs-course-tax.js create mode 100644 inc/blocks/bfs-course-tax/assets/json/block.json create mode 100644 inc/blocks/bfs-course-time/assets/js/bfs-course-time.js create mode 100644 inc/blocks/bfs-course-time/assets/json/block.json create mode 100644 inc/blocks/bfs-login/assets/js/bfs-login.js create mode 100644 inc/blocks/bfs-login/assets/json/block.json create mode 100644 inc/generateBlock.js diff --git a/block-template-parts/entete-cours.html b/block-template-parts/entete-cours.html index 0c596fe..4751b60 100644 --- a/block-template-parts/entete-cours.html +++ b/block-template-parts/entete-cours.html @@ -1,18 +1,18 @@ -
+
-
+
-
+
-
+
-
+
diff --git a/block-templates/archive-course.html b/block-templates/archive-course.html index d438072..3bd9a47 100644 --- a/block-templates/archive-course.html +++ b/block-templates/archive-course.html @@ -3,35 +3,35 @@ -
-
- -
+
+
+ +
- -
-
- + +
+
+ -
- +
+ - -
+ +
-
- +
+ -
- - +
+ + - - + + - + - -
-
- + +
+
+ \ No newline at end of file diff --git a/functions.php b/functions.php index 3cd9ccb..8ea92ec 100644 --- a/functions.php +++ b/functions.php @@ -99,6 +99,6 @@ function beflex_add_custom_classes_to_body( $classes ) { // Block patterns. require_once 'inc/block-patterns.php'; // Theme blocks -require_once 'inc/block-blocks.php'; +require_once 'inc/blocks.php'; // Sensei functions require_once 'sensei/functions.php'; diff --git a/gulpfile.js b/gulpfile.js index d26e1c2..5739598 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -12,7 +12,7 @@ var scss_paths = [ 'assets/scss/**/*.scss', 'inc/blocks/bfs-course-tax/assets/scss/**/*.scss', - 'inc/blocks/bfs-course-lessons/assets/scss/**/*.scss', + 'inc/blocks/bfs-course-lesson/assets/scss/**/*.scss', 'inc/blocks/bfs-course-time/assets/scss/**/*.scss', 'inc/blocks/bfs-course-completion/assets/scss/**/*.scss', 'inc/blocks/bfs-login/assets/scss/**/*.scss' diff --git a/inc/block-blocks.php b/inc/block-blocks.php deleted file mode 100644 index 58a6376..0000000 --- a/inc/block-blocks.php +++ /dev/null @@ -1,42 +0,0 @@ -post ) ) { - array_unshift( - $block_categories, - array( - 'slug' => 'beflex', - 'title' => __( 'Beflex', 'custom-plugin' ), - 'icon' => 'admin-appearance', - ) - ); - } - return $block_categories; -} - -add_filter( 'block_categories_all', 'beflex_create_block_category', 10, 2 ); diff --git a/inc/blocks.php b/inc/blocks.php new file mode 100644 index 0000000..833ef10 --- /dev/null +++ b/inc/blocks.php @@ -0,0 +1,37 @@ +post ) ) { + array_unshift( + $block_categories, + array( + 'slug' => 'beflex', + 'title' => __( 'Beflex', 'custom-plugin' ), + 'icon' => 'admin-appearance', + ) + ); + } + return $block_categories; +} + +add_filter( 'block_categories_all', 'beflex_create_block_category', 10, 2 ); diff --git a/inc/blocks/bfs-course-completion/assets/css/style.css b/inc/blocks/bfs-course-completion/assets/css/style.css deleted file mode 100644 index 2d05019..0000000 --- a/inc/blocks/bfs-course-completion/assets/css/style.css +++ /dev/null @@ -1,16 +0,0 @@ -.bfs-course-completion { - display: block; - position: relative; - width: 100%; - height: 10px; - background: rgba(0, 0, 0, 0.1); -} -.bfs-course-completion.progress-0 { - background: #fff; -} -.bfs-course-completion .bfs-course-completion__progress-bar { - position: absolute; - left: 0; - height: 100%; - background: var(--wp--preset--color--vivid-green-cyan); -} \ No newline at end of file diff --git a/inc/blocks/bfs-course-completion/assets/css/style.min.css b/inc/blocks/bfs-course-completion/assets/css/style.min.css deleted file mode 100644 index 3bbf9cd..0000000 --- a/inc/blocks/bfs-course-completion/assets/css/style.min.css +++ /dev/null @@ -1 +0,0 @@ -.bfs-course-completion{display:block;position:relative;width:100%;height:10px;background:rgba(0,0,0,.1)}.bfs-course-completion.progress-0{background:#fff}.bfs-course-completion .bfs-course-completion__progress-bar{position:absolute;left:0;height:100%;background:var(--wp--preset--color--vivid-green-cyan)} \ No newline at end of file diff --git a/inc/blocks/bfs-course-completion/assets/scss/style.scss b/inc/blocks/bfs-course-completion/assets/scss/style.scss deleted file mode 100644 index 0429853..0000000 --- a/inc/blocks/bfs-course-completion/assets/scss/style.scss +++ /dev/null @@ -1,18 +0,0 @@ -.bfs-course-completion { - display: block; - position: relative; - width: 100%; - height: 10px; - background: rgba(0,0,0,0.1); - - &.progress-0 { - background: #fff; - } - - .bfs-course-completion__progress-bar { - position: absolute; - left: 0; - height: 100%; - background: var(--wp--preset--color--vivid-green-cyan), - } -} diff --git a/inc/blocks/bfs-course-completion/bfs-course-completion.php b/inc/blocks/bfs-course-completion/bfs-course-completion.php deleted file mode 100644 index 2c3efc0..0000000 --- a/inc/blocks/bfs-course-completion/bfs-course-completion.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 3.0.0 - * @package beflex-child - * - */ - -if ( function_exists( 'acf_register_block_type' ) ) { - acf_register_block_type( - array( - 'name' => 'bfs_course_completion', - 'title' => esc_html__( 'Course completion', 'beflex' ), - 'description' => esc_html__( 'Display completion length of a course', 'beflex' ), - 'category' => 'beflex', - 'mode' => 'preview', - 'icon' => '', - 'keywords' => array( 'beflex', 'sensei', 'bfs', 'block', 'time', 'completion', 'course' ), - 'render_callback' => 'bfs_course_completion_render_callback', - 'enqueue_assets' => function() { - wp_enqueue_style( 'block-bfs-course-completion-style', get_template_directory_uri() . '/inc/blocks/bfs-course-completion/assets/css/style.min.css' ); -// wp_enqueue_script( 'block-bfs-course-completion-script', get_template_directory_uri() . '/inc/blocks/bfs-course-completion/assets/js/bf-process.js', array('jquery'), '', true ); - } - ) - ); -} - - -/** - * Diaporama Block Callback Function. - * - * @param array $block The block settings and attributes. - * @param string $content The block inner HTML (empty). - * @param bool $is_preview True during AJAX preview. - * @param int $post_id The post ID this block is saved to. - */ -function bfs_course_completion_render_callback( $block, $content = '', $is_preview = false, $post_id = 0 ) { - include get_template_directory() . '/inc/blocks/bfs-course-completion/view.php'; -} diff --git a/inc/blocks/bfs-course-completion/view.php b/inc/blocks/bfs-course-completion/view.php deleted file mode 100644 index 89fd9cb..0000000 --- a/inc/blocks/bfs-course-completion/view.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 2.0.0 - * @package beflex-sensei - * - */ - -// That block only works with courses custom post types. -if ( is_admin() ) : - esc_html_e( 'Display course completion', 'beflex' ); - return; -endif; - -if ( 'course' != get_post_type( get_the_ID() ) ) : - return; -endif; - -$classes = 'bfs-course-completion'; -if ( !empty( $block['className'] ) ) : - $classes .= sprintf( ' %s', $block['className'] ); -endif; -if ( !empty( $block['align'] ) ) : - $classes .= sprintf( ' align%s', $block['align'] ); -endif; - -$completed = count( Sensei()->course->get_completed_lesson_ids( get_the_ID(), get_current_user_id() ) ); -$total_lessons = Sensei()->course->course_lesson_count( get_the_ID() ); -$percentage = Sensei_Utils::quotient_as_absolute_rounded_percentage( $completed, $total_lessons, 2 ); -$classes .= sprintf(' progress-%s', ! empty( esc_attr( $percentage ) ) ? esc_attr( $percentage ) : '0' ); - -?> -
-
-
- diff --git a/inc/blocks/bfs-course-lesson/assets/css/style.css b/inc/blocks/bfs-course-lesson/assets/css/style.css new file mode 100644 index 0000000..a025501 --- /dev/null +++ b/inc/blocks/bfs-course-lesson/assets/css/style.css @@ -0,0 +1,14 @@ +/** + * Style CSS de bfs-course-lesson +*/ +.bfs-course-lesson { + color: rgba(0, 0, 0, 0.6); + font-size: 14px; +} +.bfs-course-lesson .bfs-course-lesson__icon { + width: 16px; + vertical-align: text-top; +} +.bfs-course-lesson span { + vertical-align: text-bottom; +} \ No newline at end of file diff --git a/inc/blocks/bfs-course-lesson/assets/css/style.min.css b/inc/blocks/bfs-course-lesson/assets/css/style.min.css new file mode 100644 index 0000000..cd38388 --- /dev/null +++ b/inc/blocks/bfs-course-lesson/assets/css/style.min.css @@ -0,0 +1 @@ +.bfs-course-lesson{color:rgba(0,0,0,.6);font-size:14px}.bfs-course-lesson .bfs-course-lesson__icon{width:16px;vertical-align:text-top}.bfs-course-lesson span{vertical-align:text-bottom} \ No newline at end of file diff --git a/inc/blocks/bfs-course-lessons/assets/images/list-check-solid.svg b/inc/blocks/bfs-course-lesson/assets/images/list-check-solid.svg similarity index 100% rename from inc/blocks/bfs-course-lessons/assets/images/list-check-solid.svg rename to inc/blocks/bfs-course-lesson/assets/images/list-check-solid.svg diff --git a/inc/blocks/bfs-course-lesson/assets/js/bfs-course-lesson.js b/inc/blocks/bfs-course-lesson/assets/js/bfs-course-lesson.js new file mode 100644 index 0000000..3895165 --- /dev/null +++ b/inc/blocks/bfs-course-lesson/assets/js/bfs-course-lesson.js @@ -0,0 +1,27 @@ +(function($){ + /** + * initializeBlock + * + * Adds custom JavaScript to the block HTML. + * + * @param object $block The block jQuery element. + * @param object attributes The block attributes (only available when editing). + * @return void + */ + var initializeBlock = function( $block ) { + } + + // Initialize each block on page load (front end). + $(document).ready(function(){ + $('.bfs-course-lesson').each(function(){ + initializeBlock( $(this) ); + }); + }); + + // Initialize dynamic block preview (editor). + if( window.acf ) { + window.acf.addAction( 'render_block_preview/type=bfs-course-lesson', initializeBlock ); + } + +})(jQuery); + \ No newline at end of file diff --git a/inc/blocks/bfs-course-lesson/assets/json/block.json b/inc/blocks/bfs-course-lesson/assets/json/block.json new file mode 100644 index 0000000..4cd721c --- /dev/null +++ b/inc/blocks/bfs-course-lesson/assets/json/block.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "name": "beflex/course-lesson", + "title": "BFS Course lessons", + "description": "Display lessons associated to a course", + "style": [ "block-bfs-course-lesson-style" ], + "viewScript": [], + "category": "beflex", + "icon": "", + "apiVersion": 2, + "textdomain": "beflex", + "keywords": [ + "beflex", + "sensei", + "bfs", + "lesson", + "count", + "course-lesson" + ], + "supports": { + }, + "acf": { + "mode": "preview", + "renderTemplate": "../../view.php" + } +} diff --git a/inc/blocks/bfs-course-lessons/assets/scss/style.scss b/inc/blocks/bfs-course-lesson/assets/scss/style.scss similarity index 61% rename from inc/blocks/bfs-course-lessons/assets/scss/style.scss rename to inc/blocks/bfs-course-lesson/assets/scss/style.scss index b421dc6..c13698a 100644 --- a/inc/blocks/bfs-course-lessons/assets/scss/style.scss +++ b/inc/blocks/bfs-course-lesson/assets/scss/style.scss @@ -1,8 +1,11 @@ -.bfs-course-lessons { +/** + * Style CSS de bfs-course-lesson +*/ +.bfs-course-lesson { color: rgba(0,0,0,0.6); font-size: 14px; - .bfs-course-lessons__icon { + .bfs-course-lesson__icon { width: 16px; vertical-align: text-top; } @@ -10,4 +13,3 @@ vertical-align: text-bottom; } } - diff --git a/inc/blocks/bfs-course-lesson/bfs-course-lesson.php b/inc/blocks/bfs-course-lesson/bfs-course-lesson.php new file mode 100644 index 0000000..233d999 --- /dev/null +++ b/inc/blocks/bfs-course-lesson/bfs-course-lesson.php @@ -0,0 +1,43 @@ + + * @link https://developer.wordpress.org/themes/basics/theme-functions/ + * @since 4.0.0 + * @package beflex-child + * + */ + +if ( ! defined( 'BFS_COURSE_LESSON_DIR' ) ) { + define( 'BFS_COURSE_LESSON_DIR', dirname(__DIR__, 1) . '/bfs-course-lesson' ); +} +if ( ! defined( 'BFS_COURSE_LESSON_URL' ) ) { + define( 'BFS_COURSE_LESSON_URL', get_stylesheet_directory_uri() . '/inc/blocks/bfs-course-lesson' ); +} + +/** + * Generate block + * + * @return void + */ +function bfs_course_lesson_register_acf_blocks() { + wp_register_style( 'block-bfs-course-lesson-style', BFS_COURSE_LESSON_URL . '/assets/css/style.min.css' ); + wp_register_script( 'block-bfs-course-lesson-script', BFS_COURSE_LESSON_URL . '/assets/js/bfs-course-lesson.js', array('jquery'), '', true ); + register_block_type( BFS_COURSE_LESSON_DIR . '/assets/json/' ); +} +add_action( 'init', 'bfs_course_lesson_register_acf_blocks', 5 ); + +/** + * Load Json fields + * + * @param array $paths Json path + * + * @return array $paths Json path + */ +function bfs_course_lesson_load_json( $paths ) { + $paths[] = BFS_COURSE_LESSON_DIR . '/assets/json'; + return $paths; +} +add_filter( 'acf/settings/load_json', 'bfs_course_lesson_load_json' ); + \ No newline at end of file diff --git a/inc/blocks/bfs-course-lesson/view.php b/inc/blocks/bfs-course-lesson/view.php new file mode 100644 index 0000000..19aa509 --- /dev/null +++ b/inc/blocks/bfs-course-lesson/view.php @@ -0,0 +1,56 @@ +course->course_lesson_count( get_the_ID() ); + +if ( ! empty( $lesson_count ) ) : + ?> +
class=""> + %2$s %3$s', + esc_url( BFS_COURSE_LESSON_URL . '/assets/images/list-check-solid.svg' ), + esc_html( $lesson_count ), + esc_html__( 'lessons', 'beflex' ) + ); + ?> +
+ diff --git a/inc/blocks/bfs-course-lessons/assets/css/style.css b/inc/blocks/bfs-course-lessons/assets/css/style.css deleted file mode 100644 index 0b1d17e..0000000 --- a/inc/blocks/bfs-course-lessons/assets/css/style.css +++ /dev/null @@ -1,11 +0,0 @@ -.bfs-course-lessons { - color: rgba(0, 0, 0, 0.6); - font-size: 14px; -} -.bfs-course-lessons .bfs-course-lessons__icon { - width: 16px; - vertical-align: text-top; -} -.bfs-course-lessons span { - vertical-align: text-bottom; -} \ No newline at end of file diff --git a/inc/blocks/bfs-course-lessons/assets/css/style.min.css b/inc/blocks/bfs-course-lessons/assets/css/style.min.css deleted file mode 100644 index 79febb7..0000000 --- a/inc/blocks/bfs-course-lessons/assets/css/style.min.css +++ /dev/null @@ -1 +0,0 @@ -.bfs-course-lessons{color:rgba(0,0,0,.6);font-size:14px}.bfs-course-lessons .bfs-course-lessons__icon{width:16px;vertical-align:text-top}.bfs-course-lessons span{vertical-align:text-bottom} \ No newline at end of file diff --git a/inc/blocks/bfs-course-lessons/bfs-course-lessons.php b/inc/blocks/bfs-course-lessons/bfs-course-lessons.php deleted file mode 100644 index ecfff63..0000000 --- a/inc/blocks/bfs-course-lessons/bfs-course-lessons.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 3.0.0 - * @package beflex-child - * - */ - -if ( function_exists( 'acf_register_block_type' ) ) { - acf_register_block_type( - array( - 'name' => 'bfs_course_lessons', - 'title' => esc_html__( 'Course lessons', 'beflex' ), - 'description' => esc_html__( 'Display lessons associated to a course', 'beflex' ), - 'category' => 'beflex', - 'mode' => 'preview', - 'icon' => '', - 'keywords' => array( 'beflex', 'sensei', 'bfs', 'block', 'lessons', 'count', 'course' ), - 'render_callback' => 'bfs_course_lessons_render_callback', - 'enqueue_assets' => function() { - wp_enqueue_style( 'block-bfs-course-lessons-style', get_template_directory_uri() . '/inc/blocks/bfs-course-lessons/assets/css/style.min.css' ); -// wp_enqueue_script( 'block-bfs-course-lessons-script', get_template_directory_uri() . '/inc/blocks/bf-process/assets/js/bf-process.js', array('jquery'), '', true ); - } - ) - ); -} - - -/** - * Diaporama Block Callback Function. - * - * @param array $block The block settings and attributes. - * @param string $content The block inner HTML (empty). - * @param bool $is_preview True during AJAX preview. - * @param int $post_id The post ID this block is saved to. - */ -function bfs_course_lessons_render_callback( $block, $content = '', $is_preview = false, $post_id = 0 ) { - include get_template_directory() . '/inc/blocks/bfs-course-lessons/view.php'; -} diff --git a/inc/blocks/bfs-course-lessons/view.php b/inc/blocks/bfs-course-lessons/view.php deleted file mode 100644 index d67dc80..0000000 --- a/inc/blocks/bfs-course-lessons/view.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 2.0.0 - * @package beflex-sensei - * - */ - -// That block only works with courses custom post types. -if ( is_admin() ) : - esc_html_e( 'Display course lessons', 'beflex' ); - return; -endif; - -if ( 'course' != get_post_type( get_the_ID() ) ) : - return; -endif; - -$classes = 'bfs-course-lessons'; -if ( !empty( $block['className'] ) ) : - $classes .= sprintf( ' %s', $block['className'] ); -endif; -if ( !empty( $block['align'] ) ) : - $classes .= sprintf( ' align%s', $block['align'] ); -endif; - -$lesson_count = Sensei()->course->course_lesson_count( get_the_ID() ); - -if ( ! empty( $lesson_count ) ) : - ?> -
- %2$s %3$s', - esc_url( get_template_directory_uri() . '/inc/blocks/bfs-course-lessons/assets/images/list-check-solid.svg' ), - esc_html( $lesson_count ), - esc_html__( 'lessons', 'beflex' ) - ); - ?> -
- ", + "apiVersion": 2, + "textdomain": "beflex", + "keywords": [ + "beflex", + "course-signup" + ], + "supports": { + }, + "acf": { + "mode": "preview", + "renderTemplate": "../../view.php" + } +} diff --git a/inc/blocks/bfs-course-signup/assets/scss/style.scss b/inc/blocks/bfs-course-signup/assets/scss/style.scss new file mode 100644 index 0000000..7aa3791 --- /dev/null +++ b/inc/blocks/bfs-course-signup/assets/scss/style.scss @@ -0,0 +1,3 @@ +/** + * Style CSS de bfs-course-signup +*/ \ No newline at end of file diff --git a/inc/blocks/bfs-course-signup/bfs-course-signup.php b/inc/blocks/bfs-course-signup/bfs-course-signup.php index be804cd..0a2a910 100644 --- a/inc/blocks/bfs-course-signup/bfs-course-signup.php +++ b/inc/blocks/bfs-course-signup/bfs-course-signup.php @@ -1,42 +1,42 @@ * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 3.0.0 + * @since 4.0.0 * @package beflex-child * */ -if ( function_exists( 'acf_register_block_type' ) ) { - acf_register_block_type( - array( - 'name' => 'bfs_course_signup', - 'title' => esc_html__( 'Sensei Course signup', 'beflex' ), - 'description' => esc_html__( 'Display button to take course', 'beflex' ), - 'category' => 'beflex', - 'mode' => 'preview', - 'icon' => '', - 'keywords' => array( 'beflex', 'sensei', 'bfs', 'block', 'course', 'take', 'signup' ), - 'render_callback' => 'bfs_course_signup_render_callback', - 'enqueue_assets' => function() { -// wp_enqueue_style( 'block-bfs-course-signup-style', get_template_directory_uri() . '/inc/blocks/bfs-course-signup/assets/css/style.min.css' ); -// wp_enqueue_script( 'block-bfs-course-signup-script', get_template_directory_uri() . '/inc/blocks/bfs-course-signup/assets/js/bf-login.js', array('jquery'), '', true ); - } - ) - ); +if ( ! defined( 'BFS_COURSE_SIGNUP_DIR' ) ) { + define( 'BFS_COURSE_SIGNUP_DIR', dirname(__DIR__, 1) . '/bfs-course-signup' ); +} +if ( ! defined( 'BFS_COURSE_SIGNUP_URL' ) ) { + define( 'BFS_COURSE_SIGNUP_URL', get_stylesheet_directory_uri() . '/inc/blocks/bfs-course-signup' ); } +/** + * Generate block + * + * @return void + */ +function bfs_course_signup_register_acf_blocks() { +// wp_register_style( 'block-bfs-course-signup-style', BFS_COURSE_SIGNUP_URL . '/assets/css/style.min.css' ); +// wp_register_script( 'block-bfs-course-signup-script', BFS_COURSE_SIGNUP_URL . '/assets/js/bfs-course-signup.js', array('jquery'), '', true ); + register_block_type( BFS_COURSE_SIGNUP_DIR . '/assets/json/' ); +} +add_action( 'init', 'bfs_course_signup_register_acf_blocks', 5 ); /** - * Login Block Callback Function. + * Load Json fields + * + * @param array $paths Json path * - * @param array $block The block settings and attributes. - * @param string $content The block inner HTML (empty). - * @param bool $is_preview True during AJAX preview. - * @param int $post_id The post ID this block is saved to. + * @return array $paths Json path */ -function bfs_course_signup_render_callback( $block, $content = '', $is_preview = false, $post_id = 0 ) { - include get_template_directory() . '/inc/blocks/bfs-course-signup/view.php'; +function bfs_course_signup_load_json( $paths ) { + $paths[] = BFS_COURSE_SIGNUP_DIR . '/assets/json'; + return $paths; } +add_filter( 'acf/settings/load_json', 'bfs_course_signup_load_json' ); diff --git a/inc/blocks/bfs-course-signup/view.php b/inc/blocks/bfs-course-signup/view.php index f8285e0..f8ef330 100644 --- a/inc/blocks/bfs-course-signup/view.php +++ b/inc/blocks/bfs-course-signup/view.php @@ -1,32 +1,54 @@ - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 2.0.0 - * @package beflex-sensei + * course-signup. * + * @param array $block The block settings and attributes. + * @param string $content The block inner HTML (empty). + * @param bool $is_preview True during backend preview render. + * @param int $post_id The post ID the block is rendering content against. + * This is either the post ID currently being displayed inside a query loop, + * or the post ID of the post hosting this block. + * @param array $context The context provided to the block by the post or its parent block. */ -// That block only works with courses custom post types. +// Support custom "anchor" values. +$anchor = ''; +if ( ! empty( $block['anchor'] ) ) { + $anchor = 'id="' . esc_attr( $block['anchor'] ) . '" '; +} + +// Create class attribute allowing for custom "className" and "align" values. +$class_name = 'bfs-course-signup'; + +if ( ! empty( $block['className'] ) ) { + $class_name .= ' ' . $block['className']; +} +if ( ! empty( $block['align'] ) ) { + $class_name .= ' align' . $block['align']; +} + +// Admin classes if ( is_admin() ) : + $class_name .= ' is-admin'; esc_html_e( 'Display course signup button', 'beflex' ); - return; endif; if ( 'course' != get_post_type( get_the_ID() ) ) : return; endif; +?> -if ( Sensei()->course->is_user_enrolled( get_the_ID(), get_current_user_id() ) ) : - global $post; - $lesson_url = Sensei()->course->alter_redirect_url_after_enrolment( '', $post ); - if ( ! empty( $lesson_url ) ) : - echo ''; +
class=""> + course->is_user_enrolled( get_the_ID(), get_current_user_id() ) ) : + global $post; + $lesson_url = Sensei()->course->alter_redirect_url_after_enrolment( '', $post ); + if ( ! empty( $lesson_url ) ) : + echo ''; + endif; + else : + $content = ''; + echo Sensei()->blocks->course->take_course->render_take_course_block( '', $content ); endif; -else : - $content = ''; - echo Sensei()->blocks->course->take_course->render_take_course_block( '', $content ); -endif; - + ?> +
diff --git a/inc/blocks/bfs-course-tax/assets/css/style.css b/inc/blocks/bfs-course-tax/assets/css/style.css index 4c90721..004eae4 100644 --- a/inc/blocks/bfs-course-tax/assets/css/style.css +++ b/inc/blocks/bfs-course-tax/assets/css/style.css @@ -1,3 +1,6 @@ +/** + * Style CSS de bfs-course-tax +*/ .bfs-course-tax { display: block; } diff --git a/inc/blocks/bfs-course-tax/assets/js/bfs-course-tax.js b/inc/blocks/bfs-course-tax/assets/js/bfs-course-tax.js new file mode 100644 index 0000000..7ff8fc9 --- /dev/null +++ b/inc/blocks/bfs-course-tax/assets/js/bfs-course-tax.js @@ -0,0 +1,27 @@ +(function($){ + /** + * initializeBlock + * + * Adds custom JavaScript to the block HTML. + * + * @param object $block The block jQuery element. + * @param object attributes The block attributes (only available when editing). + * @return void + */ + var initializeBlock = function( $block ) { + } + + // Initialize each block on page load (front end). + $(document).ready(function(){ + $('.bfs-course-tax').each(function(){ + initializeBlock( $(this) ); + }); + }); + + // Initialize dynamic block preview (editor). + if( window.acf ) { + window.acf.addAction( 'render_block_preview/type=bfs-course-tax', initializeBlock ); + } + +})(jQuery); + \ No newline at end of file diff --git a/inc/blocks/bfs-course-tax/assets/json/block.json b/inc/blocks/bfs-course-tax/assets/json/block.json new file mode 100644 index 0000000..d673f81 --- /dev/null +++ b/inc/blocks/bfs-course-tax/assets/json/block.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "name": "beflex/course-tax", + "title": "BFS Course categories", + "description": "Display categories associated to a course", + "style": [ "block-bfs-course-tax-style" ], + "viewScript": [], + "category": "beflex", + "icon": "", + "apiVersion": 2, + "textdomain": "beflex", + "keywords": [ + "beflex", + "sensei", + "bfs", + "taxonomie", + "course", + "course-tax" + ], + "supports": { + }, + "acf": { + "mode": "preview", + "renderTemplate": "../../view.php" + } +} diff --git a/inc/blocks/bfs-course-tax/assets/scss/style.scss b/inc/blocks/bfs-course-tax/assets/scss/style.scss index d3d96f4..e1e8d91 100644 --- a/inc/blocks/bfs-course-tax/assets/scss/style.scss +++ b/inc/blocks/bfs-course-tax/assets/scss/style.scss @@ -1,3 +1,7 @@ +/** + * Style CSS de bfs-course-tax +*/ + .bfs-course-tax { display: block; @@ -32,4 +36,3 @@ text-align: right; } } - diff --git a/inc/blocks/bfs-course-tax/bfs-course-tax.php b/inc/blocks/bfs-course-tax/bfs-course-tax.php index 933e811..2682b25 100644 --- a/inc/blocks/bfs-course-tax/bfs-course-tax.php +++ b/inc/blocks/bfs-course-tax/bfs-course-tax.php @@ -1,42 +1,43 @@ * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 3.0.0 + * @since 4.0.0 * @package beflex-child * */ -if ( function_exists( 'acf_register_block_type' ) ) { - acf_register_block_type( - array( - 'name' => 'bfs_course_tax', - 'title' => esc_html__( 'Course categories', 'beflex' ), - 'description' => esc_html__( 'Display categories associated to a course', 'beflex' ), - 'category' => 'beflex', - 'mode' => 'preview', - 'icon' => '', - 'keywords' => array( 'beflex', 'sensei', 'bfs', 'block', 'categories', 'taxonomies', 'course' ), - 'render_callback' => 'bfs_course_tax_render_callback', - 'enqueue_assets' => function() { - wp_enqueue_style( 'block-bfs-course-tax-style', get_template_directory_uri() . '/inc/blocks/bfs-course-tax/assets/css/style.min.css' ); -// wp_enqueue_script( 'block-bf-process-script', get_template_directory_uri() . '/inc/blocks/bf-process/assets/js/bf-process.js', array('jquery'), '', true ); - } - ) - ); +if ( ! defined( 'BFS_COURSE_TAX_DIR' ) ) { + define( 'BFS_COURSE_TAX_DIR', dirname(__DIR__, 1) . '/bfs-course-tax' ); +} +if ( ! defined( 'BFS_COURSE_TAX_URL' ) ) { + define( 'BFS_COURSE_TAX_URL', get_stylesheet_directory_uri() . '/inc/blocks/bfs-course-tax' ); } +/** + * Generate block + * + * @return void + */ +function bfs_course_tax_register_acf_blocks() { + wp_register_style( 'block-bfs-course-tax-style', BFS_COURSE_TAX_URL . '/assets/css/style.min.css' ); + wp_register_script( 'block-bfs-course-tax-script', BFS_COURSE_TAX_URL . '/assets/js/bfs-course-tax.js', array('jquery'), '', true ); + register_block_type( BFS_COURSE_TAX_DIR . '/assets/json/' ); +} +add_action( 'init', 'bfs_course_tax_register_acf_blocks', 5 ); /** - * Diaporama Block Callback Function. + * Load Json fields + * + * @param array $paths Json path * - * @param array $block The block settings and attributes. - * @param string $content The block inner HTML (empty). - * @param bool $is_preview True during AJAX preview. - * @param int $post_id The post ID this block is saved to. + * @return array $paths Json path */ -function bfs_course_tax_render_callback( $block, $content = '', $is_preview = false, $post_id = 0 ) { - include get_template_directory() . '/inc/blocks/bfs-course-tax/view.php'; +function bfs_course_tax_load_json( $paths ) { + $paths[] = BFS_COURSE_TAX_DIR . '/assets/json'; + return $paths; } +add_filter( 'acf/settings/load_json', 'bfs_course_tax_load_json' ); + \ No newline at end of file diff --git a/inc/blocks/bfs-course-tax/view.php b/inc/blocks/bfs-course-tax/view.php index 054daf6..29c2211 100644 --- a/inc/blocks/bfs-course-tax/view.php +++ b/inc/blocks/bfs-course-tax/view.php @@ -1,41 +1,48 @@ - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 2.0.0 - * @package beflex-sensei + * Display taxonomies of a Sensei course. * + * @param array $block The block settings and attributes. + * @param string $content The block inner HTML (empty). + * @param bool $is_preview True during backend preview render. + * @param int $post_id The post ID the block is rendering content against. + * This is either the post ID currently being displayed inside a query loop, + * or the post ID of the post hosting this block. + * @param array $context The context provided to the block by the post or its parent block. */ -// That block only works with courses custom post types. +// Support custom "anchor" values. +$anchor = ''; +if ( ! empty( $block['anchor'] ) ) { + $anchor = 'id="' . esc_attr( $block['anchor'] ) . '" '; +} + +// Create class attribute allowing for custom "className" and "align" values. +$class_name = 'bfs-course-tax'; + +if ( ! empty( $block['className'] ) ) { + $class_name .= ' ' . $block['className']; +} +if ( ! empty( $block['align'] ) ) { + $class_name .= ' align' . $block['align']; +} + +// Admin classes if ( is_admin() ) : - esc_html_e( 'Display course categories', 'beflex' ); - return; + $class_name .= ' is-admin'; + esc_html_e( 'Display course taxonomies', 'beflex' ); endif; if ( 'course' != get_post_type( get_the_ID() ) ) : return; endif; -$classes = 'bfs-course-tax'; -if ( !empty( $block['className'] ) ) : - $classes .= sprintf( ' %s', $block['className'] ); -endif; -if ( !empty( $block['align'] ) ) : - $classes .= sprintf( ' align%s', $block['align'] ); -endif; - - $terms_list = get_the_terms( get_the_ID(), 'course-category' ); - if ( ! empty( $terms_list ) ) : ?> -
+
class="">
- diff --git a/inc/blocks/bfs-course-time/assets/css/style.css b/inc/blocks/bfs-course-time/assets/css/style.css index ba885fd..03b05ae 100644 --- a/inc/blocks/bfs-course-time/assets/css/style.css +++ b/inc/blocks/bfs-course-time/assets/css/style.css @@ -1,8 +1,11 @@ +/** + * Style CSS de bfs-course-time +*/ .bfs-course-time { color: rgba(0, 0, 0, 0.6); font-size: 14px; } -.bfs-course-time .bfs-course-lessons__icon { +.bfs-course-time .bfs-course-time__icon { width: 14px; vertical-align: text-top; } diff --git a/inc/blocks/bfs-course-time/assets/css/style.min.css b/inc/blocks/bfs-course-time/assets/css/style.min.css index 321f548..db611cc 100644 --- a/inc/blocks/bfs-course-time/assets/css/style.min.css +++ b/inc/blocks/bfs-course-time/assets/css/style.min.css @@ -1 +1 @@ -.bfs-course-time{color:rgba(0,0,0,.6);font-size:14px}.bfs-course-time .bfs-course-lessons__icon{width:14px;vertical-align:text-top}.bfs-course-time span{vertical-align:text-bottom} \ No newline at end of file +.bfs-course-time{color:rgba(0,0,0,.6);font-size:14px}.bfs-course-time .bfs-course-time__icon{width:14px;vertical-align:text-top}.bfs-course-time span{vertical-align:text-bottom} \ No newline at end of file diff --git a/inc/blocks/bfs-course-time/assets/js/bfs-course-time.js b/inc/blocks/bfs-course-time/assets/js/bfs-course-time.js new file mode 100644 index 0000000..7cc3fcf --- /dev/null +++ b/inc/blocks/bfs-course-time/assets/js/bfs-course-time.js @@ -0,0 +1,27 @@ +(function($){ + /** + * initializeBlock + * + * Adds custom JavaScript to the block HTML. + * + * @param object $block The block jQuery element. + * @param object attributes The block attributes (only available when editing). + * @return void + */ + var initializeBlock = function( $block ) { + } + + // Initialize each block on page load (front end). + $(document).ready(function(){ + $('.bfs-course-time').each(function(){ + initializeBlock( $(this) ); + }); + }); + + // Initialize dynamic block preview (editor). + if( window.acf ) { + window.acf.addAction( 'render_block_preview/type=bfs-course-time', initializeBlock ); + } + +})(jQuery); + \ No newline at end of file diff --git a/inc/blocks/bfs-course-time/assets/json/block.json b/inc/blocks/bfs-course-time/assets/json/block.json new file mode 100644 index 0000000..398f6b9 --- /dev/null +++ b/inc/blocks/bfs-course-time/assets/json/block.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "name": "beflex/course-time", + "title": "BFS Course time", + "description": "Display time length of a course", + "style": [ "block-bfs-course-time-style" ], + "viewScript": [], + "category": "beflex", + "icon": "", + "apiVersion": 2, + "textdomain": "beflex", + "keywords": [ + "beflex", + "bfs", + "sensei", + "time", + "course-time" + ], + "supports": { + }, + "acf": { + "mode": "preview", + "renderTemplate": "../../view.php" + } +} diff --git a/inc/blocks/bfs-course-time/assets/scss/style.scss b/inc/blocks/bfs-course-time/assets/scss/style.scss index 414d588..bcc436d 100644 --- a/inc/blocks/bfs-course-time/assets/scss/style.scss +++ b/inc/blocks/bfs-course-time/assets/scss/style.scss @@ -1,8 +1,11 @@ +/** + * Style CSS de bfs-course-time +*/ .bfs-course-time { color: rgba(0,0,0,0.6); font-size: 14px; - .bfs-course-lessons__icon { + .bfs-course-time__icon { width: 14px; vertical-align: text-top; } @@ -10,4 +13,3 @@ vertical-align: text-bottom; } } - diff --git a/inc/blocks/bfs-course-time/bfs-course-time.php b/inc/blocks/bfs-course-time/bfs-course-time.php index 3f826c3..8047f89 100644 --- a/inc/blocks/bfs-course-time/bfs-course-time.php +++ b/inc/blocks/bfs-course-time/bfs-course-time.php @@ -1,42 +1,43 @@ * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 3.0.0 + * @since 4.0.0 * @package beflex-child * */ -if ( function_exists( 'acf_register_block_type' ) ) { - acf_register_block_type( - array( - 'name' => 'bfs_course_time', - 'title' => esc_html__( 'Course time', 'beflex' ), - 'description' => esc_html__( 'Display time length of a course', 'beflex' ), - 'category' => 'beflex', - 'mode' => 'preview', - 'icon' => '', - 'keywords' => array( 'beflex', 'sensei', 'bfs', 'block', 'time', 'length', 'course' ), - 'render_callback' => 'bfs_course_time_render_callback', - 'enqueue_assets' => function() { - wp_enqueue_style( 'block-bfs-course-time-style', get_template_directory_uri() . '/inc/blocks/bfs-course-time/assets/css/style.min.css' ); -// wp_enqueue_script( 'block-bfs-course-time-script', get_template_directory_uri() . '/inc/blocks/bfs-course-time/assets/js/bf-process.js', array('jquery'), '', true ); - } - ) - ); +if ( ! defined( 'BFS_COURSE_TIME_DIR' ) ) { + define( 'BFS_COURSE_TIME_DIR', dirname(__DIR__, 1) . '/bfs-course-time' ); +} +if ( ! defined( 'BFS_COURSE_TIME_URL' ) ) { + define( 'BFS_COURSE_TIME_URL', get_stylesheet_directory_uri() . '/inc/blocks/bfs-course-time' ); } +/** + * Generate block + * + * @return void + */ +function bfs_course_time_register_acf_blocks() { + wp_register_style( 'block-bfs-course-time-style', BFS_COURSE_TIME_URL . '/assets/css/style.min.css' ); + wp_register_script( 'block-bfs-course-time-script', BFS_COURSE_TIME_URL . '/assets/js/bfs-course-time.js', array('jquery'), '', true ); + register_block_type( BFS_COURSE_TIME_DIR . '/assets/json/' ); +} +add_action( 'init', 'bfs_course_time_register_acf_blocks', 5 ); /** - * Diaporama Block Callback Function. + * Load Json fields + * + * @param array $paths Json path * - * @param array $block The block settings and attributes. - * @param string $content The block inner HTML (empty). - * @param bool $is_preview True during AJAX preview. - * @param int $post_id The post ID this block is saved to. + * @return array $paths Json path */ -function bfs_course_time_render_callback( $block, $content = '', $is_preview = false, $post_id = 0 ) { - include get_template_directory() . '/inc/blocks/bfs-course-time/view.php'; +function bfs_course_time_load_json( $paths ) { + $paths[] = BFS_COURSE_TIME_DIR . '/assets/json'; + return $paths; } +add_filter( 'acf/settings/load_json', 'bfs_course_time_load_json' ); + \ No newline at end of file diff --git a/inc/blocks/bfs-course-time/view.php b/inc/blocks/bfs-course-time/view.php index 472d1fd..f19e144 100644 --- a/inc/blocks/bfs-course-time/view.php +++ b/inc/blocks/bfs-course-time/view.php @@ -1,45 +1,56 @@ - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 2.0.0 - * @package beflex-sensei + * course-time. * + * @param array $block The block settings and attributes. + * @param string $content The block inner HTML (empty). + * @param bool $is_preview True during backend preview render. + * @param int $post_id The post ID the block is rendering content against. + * This is either the post ID currently being displayed inside a query loop, + * or the post ID of the post hosting this block. + * @param array $context The context provided to the block by the post or its parent block. */ -// That block only works with courses custom post types. +// Support custom "anchor" values. +$anchor = ''; +if ( ! empty( $block['anchor'] ) ) { + $anchor = 'id="' . esc_attr( $block['anchor'] ) . '" '; +} + +// Create class attribute allowing for custom "className" and "align" values. +$class_name = 'bfs-course-time'; + +if ( ! empty( $block['className'] ) ) { + $class_name .= ' ' . $block['className']; +} +if ( ! empty( $block['align'] ) ) { + $class_name .= ' align' . $block['align']; +} + +// Admin classes if ( is_admin() ) : + $class_name .= ' is-admin'; esc_html_e( 'Display course time', 'beflex' ); - return; endif; if ( 'course' != get_post_type( get_the_ID() ) ) : return; endif; -$classes = 'bfs-course-time'; -if ( !empty( $block['className'] ) ) : - $classes .= sprintf( ' %s', $block['className'] ); -endif; -if ( !empty( $block['align'] ) ) : - $classes .= sprintf( ' align%s', $block['align'] ); -endif; - $lesson_time = beflex_get_course_length( get_the_ID() ); if ( ! empty( $lesson_time ) ) : ?> -
+
class=""> %2$s %3$s', - esc_url( get_template_directory_uri() . '/inc/blocks/bfs-course-time/assets/images/clock-regular.svg' ), + ' %2$s %3$s', + esc_url( BFS_COURSE_TIME_URL . '/assets/images/clock-regular.svg' ), esc_html( $lesson_time ), esc_html__( 'min', 'beflex' ) ); ?>
- diff --git a/inc/blocks/bfs-login/assets/css/style.css b/inc/blocks/bfs-login/assets/css/style.css index c93f91d..67126ba 100644 --- a/inc/blocks/bfs-login/assets/css/style.css +++ b/inc/blocks/bfs-login/assets/css/style.css @@ -1,3 +1,6 @@ +/** + * Style CSS de bfs-login +*/ .bfs-login { display: -webkit-box; display: -ms-flexbox; diff --git a/inc/blocks/bfs-login/assets/js/bfs-login.js b/inc/blocks/bfs-login/assets/js/bfs-login.js new file mode 100644 index 0000000..9472439 --- /dev/null +++ b/inc/blocks/bfs-login/assets/js/bfs-login.js @@ -0,0 +1,27 @@ +(function($){ + /** + * initializeBlock + * + * Adds custom JavaScript to the block HTML. + * + * @param object $block The block jQuery element. + * @param object attributes The block attributes (only available when editing). + * @return void + */ + var initializeBlock = function( $block ) { + } + + // Initialize each block on page load (front end). + $(document).ready(function(){ + $('.bfs-login').each(function(){ + initializeBlock( $(this) ); + }); + }); + + // Initialize dynamic block preview (editor). + if( window.acf ) { + window.acf.addAction( 'render_block_preview/type=bfs-login', initializeBlock ); + } + +})(jQuery); + \ No newline at end of file diff --git a/inc/blocks/bfs-login/assets/json/block.json b/inc/blocks/bfs-login/assets/json/block.json new file mode 100644 index 0000000..699e017 --- /dev/null +++ b/inc/blocks/bfs-login/assets/json/block.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "name": "beflex/login", + "title": "BFS Login/logout", + "description": "Display login and profile link", + "style": [ "block-bfs-login-style" ], + "viewScript": [], + "category": "beflex", + "icon": "", + "apiVersion": 2, + "textdomain": "beflex", + "keywords": [ + "beflex", + "login" + ], + "supports": { + }, + "acf": { + "mode": "preview", + "renderTemplate": "../../view.php" + } +} diff --git a/inc/blocks/bfs-login/assets/scss/style.scss b/inc/blocks/bfs-login/assets/scss/style.scss index f1ae6fa..a3c7ad4 100644 --- a/inc/blocks/bfs-login/assets/scss/style.scss +++ b/inc/blocks/bfs-login/assets/scss/style.scss @@ -1,3 +1,6 @@ +/** + * Style CSS de bfs-login +*/ .bfs-login { display: flex; flex-wrap: wrap; @@ -39,3 +42,4 @@ } } } + diff --git a/inc/blocks/bfs-login/bfs-login.php b/inc/blocks/bfs-login/bfs-login.php index d8bf4e5..e20bf2f 100644 --- a/inc/blocks/bfs-login/bfs-login.php +++ b/inc/blocks/bfs-login/bfs-login.php @@ -1,42 +1,43 @@ * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 3.0.0 + * @since 4.0.0 * @package beflex-child * */ -if ( function_exists( 'acf_register_block_type' ) ) { - acf_register_block_type( - array( - 'name' => 'bfs_login', - 'title' => esc_html__( 'Sensei login navigation', 'beflex' ), - 'description' => esc_html__( 'Display login and profile link', 'beflex' ), - 'category' => 'beflex', - 'mode' => 'preview', - 'icon' => '', - 'keywords' => array( 'beflex', 'sensei', 'bfs', 'block', 'time', 'length', 'course' ), - 'render_callback' => 'bfs_login_render_callback', - 'enqueue_assets' => function() { - wp_enqueue_style( 'block-bfs-login-style', get_template_directory_uri() . '/inc/blocks/bfs-login/assets/css/style.min.css' ); -// wp_enqueue_script( 'block-bfs-login-script', get_template_directory_uri() . '/inc/blocks/bfs-login/assets/js/bf-login.js', array('jquery'), '', true ); - } - ) - ); +if ( ! defined( 'BFS_LOGIN_DIR' ) ) { + define( 'BFS_LOGIN_DIR', dirname(__DIR__, 1) . '/bfs-login' ); +} +if ( ! defined( 'BFS_LOGIN_URL' ) ) { + define( 'BFS_LOGIN_URL', get_stylesheet_directory_uri() . '/inc/blocks/bfs-login' ); } +/** + * Generate block + * + * @return void + */ +function bfs_login_register_acf_blocks() { + wp_register_style( 'block-bfs-login-style', BFS_LOGIN_URL . '/assets/css/style.min.css' ); + wp_register_script( 'block-bfs-login-script', BFS_LOGIN_URL . '/assets/js/bfs-login.js', array('jquery'), '', true ); + register_block_type( BFS_LOGIN_DIR . '/assets/json/' ); +} +add_action( 'init', 'bfs_login_register_acf_blocks', 5 ); /** - * Login Block Callback Function. + * Load Json fields + * + * @param array $paths Json path * - * @param array $block The block settings and attributes. - * @param string $content The block inner HTML (empty). - * @param bool $is_preview True during AJAX preview. - * @param int $post_id The post ID this block is saved to. + * @return array $paths Json path */ -function bfs_login_render_callback( $block, $content = '', $is_preview = false, $post_id = 0 ) { - include get_template_directory() . '/inc/blocks/bfs-login/view.php'; +function bfs_login_load_json( $paths ) { + $paths[] = BFS_LOGIN_DIR . '/assets/json'; + return $paths; } +add_filter( 'acf/settings/load_json', 'bfs_login_load_json' ); + \ No newline at end of file diff --git a/inc/blocks/bfs-login/view.php b/inc/blocks/bfs-login/view.php index 6b2274d..0873aa1 100644 --- a/inc/blocks/bfs-login/view.php +++ b/inc/blocks/bfs-login/view.php @@ -1,18 +1,42 @@ - * @link https://developer.wordpress.org/themes/basics/theme-functions/ - * @since 2.0.0 - * @package beflex-sensei + * login. * + * @param array $block The block settings and attributes. + * @param string $content The block inner HTML (empty). + * @param bool $is_preview True during backend preview render. + * @param int $post_id The post ID the block is rendering content against. + * This is either the post ID currently being displayed inside a query loop, + * or the post ID of the post hosting this block. + * @param array $context The context provided to the block by the post or its parent block. */ +// Support custom "anchor" values. +$anchor = ''; +if ( ! empty( $block['anchor'] ) ) { + $anchor = 'id="' . esc_attr( $block['anchor'] ) . '" '; +} + +// Create class attribute allowing for custom "className" and "align" values. +$class_name = 'bfs-login'; + +if ( ! empty( $block['className'] ) ) { + $class_name .= ' ' . $block['className']; +} +if ( ! empty( $block['align'] ) ) { + $class_name .= ' align' . $block['align']; +} + +// Admin classes +if ( is_admin() ) : + $class_name .= ' is-admin'; + esc_html_e( 'Display Sensei login navigation', 'beflex' ); +endif; + if ( is_user_logged_in() ) : $profile_url = Sensei()->learner_profiles->get_permalink( get_current_user_id() ); ?> -