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

Sticky tutor settings nav, work on tutor menu and added filter to option saved message. #552

Merged
merged 6 commits into from
Sep 12, 2023
Merged
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
11 changes: 5 additions & 6 deletions assets/react/admin-dashboard/segments/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,18 @@ document.addEventListener('DOMContentLoaded', function () {
button.attr('disabled', true);
},
success: function (resp) {
const { data = {}, success } = resp || {};
const { message = __('Something Went Wrong!', 'tutor') } = data;
const { data = {}, success, message = __('Settings Saved', 'tutor') } = resp || {};

if (success) {
// Disableing save btn after saved successfully
if (document.getElementById('save_tutor_option')) {
document.getElementById('save_tutor_option').disabled = true;
}
tutor_toast('Success!', __('Settings Saved', 'tutor'), 'success');
return;
tutor_toast( __('Success!','tutor'), message , 'success');
window.dispatchEvent(new CustomEvent('tutor_option_saved', {detail: data}));
}else{
tutor_toast( __('Warning!','tutor'), message, 'warning');
}

tutor_toast('Error!', message, 'error');
},
complete: function () {
button.removeClass('is-loading');
Expand Down
14 changes: 14 additions & 0 deletions assets/react/admin-dashboard/tutor-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,18 @@ jQuery(document).ready(function($) {
let tableHeight = jQuery('.tutor-table-responsive .tutor-table').height()
jQuery('.tutor-table-responsive').css('min-height', tableHeight + 110)
}

/**
* Set get pro link
* @since 2.2.5
*/
const getProMenu = document.querySelector('span.tutor-get-pro-text')
if (getProMenu?.parentElement?.nodeName === 'A') {
const el = getProMenu.parentElement;
const link = 'https://www.themeum.com/product/tutor-lms/pricing?utm_source=tutor_plugin_get_pro_page&utm_medium=wordpress_dashboard&utm_campaign=go_premium';

el.setAttribute('href', link)
el.setAttribute('target', '_blank')
}

});
4 changes: 4 additions & 0 deletions assets/scss/admin-dashboard/_tutor-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,10 @@ a:has(> span.tutor-get-pro-text ) {
}
}

span.tutor-addons-text{
color: orange;
}

.updating-icon:before {
font-family: 'tutor';
margin-right: 5px;
Expand Down
2 changes: 2 additions & 0 deletions assets/scss/admin-dashboard/v2/components/_nav-tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
.tutor-nav {
// admin option tabs
&.tutor-option-tabs {
position: sticky;
top: 120px;
.tutor-nav-link {
color: var(--tutor-color-secondary);
border: 1px solid transparent;
Expand Down
4 changes: 2 additions & 2 deletions classes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function register_menu() {
add_submenu_page( 'tutor', __( 'Withdraw Requests', 'tutor' ), __( 'Withdraw Requests', 'tutor' ), 'manage_tutor', Withdraw_Requests_List::WITHDRAW_REQUEST_LIST_PAGE, array( $this, 'withdraw_requests' ) );
}

add_submenu_page( 'tutor', __( 'Add-ons', 'tutor' ), __( 'Add-ons', 'tutor' ), 'manage_tutor', 'tutor-addons', array( $this, 'enable_disable_addons' ) );
add_submenu_page( 'tutor', __( 'Add-ons', 'tutor' ), sprintf( '<span class="tutor-addons-text">%s</span>', __( 'Add-ons', 'tutor' ) ), 'manage_tutor', 'tutor-addons', array( $this, 'enable_disable_addons' ) );

do_action( 'tutor_admin_register' );

Expand All @@ -138,7 +138,7 @@ public function register_menu() {
do_action( 'tutor_after_settings_menu' );

if ( ! $has_pro ) {
add_submenu_page( 'tutor', __( 'Upgrade to Pro', 'tutor' ), __( '<span class="tutor-get-pro-text">Upgrade to Pro</span>', 'tutor' ), 'manage_options', 'tutor-get-pro', array( $this, 'tutor_get_pro' ) );
add_submenu_page( 'tutor', __( 'Upgrade to Pro', 'tutor' ), sprintf( '<span class="tutor-get-pro-text">%s</span>', __( 'Upgrade to Pro', 'tutor' ) ), 'manage_options', 'tutor-get-pro', array( $this, 'tutor_get_pro' ) );
}
}

Expand Down
11 changes: 10 additions & 1 deletion classes/Options_V2.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,16 @@ public function tutor_option_save() {

do_action( 'tutor_option_save_after' );

wp_send_json_success( $option );
$data = apply_filters(
'tutor_option_saved_data',
array(
'success' => true,
'message' => __( 'Settings Saved', 'tutor' ),
'options' => $option,
)
);

wp_send_json( $data );
}

/**
Expand Down
Loading