Skip to content

Commit

Permalink
Merge pull request #42 from eoxia-amandine/edit_register_form_page
Browse files Browse the repository at this point in the history
edit_register_form_page
  • Loading branch information
eoxia-amandine authored Apr 11, 2024
2 parents 6ce0a3d + c0a975e commit 40bcffb
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 5 deletions.
65 changes: 65 additions & 0 deletions acf-json/group_6617dbb4efcd8.json
Original file line number Diff line number Diff line change
@@ -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
}
14 changes: 14 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
11 changes: 7 additions & 4 deletions inc/blocks/bfs-login/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
</div>
<?php
else :
$my_account_page_id = intval( Sensei()->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 ) ) :
?>
<div class="bfs-login">
<a href="<?php echo esc_url( $my_courses_url ); ?>" class="bf-button bf-button__style-outline bf-button__color-primary">
<a href="<?php echo esc_url( $beflex_registration_url ); ?>" class="bf-button bf-button__style-outline bf-button__color-primary">
<svg xmlns="http://www.w3.org/2000/svg" class="bfs-login__icon bfs-login__login-icon" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M272 304h-96C78.8 304 0 382.8 0 480c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32C448 382.8 369.2 304 272 304zM48.99 464C56.89 400.9 110.8 352 176 352h96c65.16 0 119.1 48.95 127 112H48.99zM224 256c70.69 0 128-57.31 128-128c0-70.69-57.31-128-128-128S96 57.31 96 128C96 198.7 153.3 256 224 256zM224 48c44.11 0 80 35.89 80 80c0 44.11-35.89 80-80 80S144 172.1 144 128C144 83.89 179.9 48 224 48z"/></svg>
<span class="bfs-login__label bfs-login__login-label"><?php esc_html_e( 'Login', 'beflex' ); ?></span>
</a>
Expand Down
13 changes: 13 additions & 0 deletions sensei/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 40bcffb

Please sign in to comment.