芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/socialdigivlms.com/wp-content/themes/tutorstarter/inc/Helpers.php
'TutorMate', 'slug' => 'tutormate', 'required' => false, ), ); // Array of configuration settings. $config = array( 'id' => 'tutorstarter', 'default_path' => '', 'menu' => 'tgmpa-install-plugins', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => false, 'message' => '', ); tgmpa( $plugins, $config ); } if ( ! function_exists( 'control_active_callback' ) ) { /** * Control active callback */ function control_active_callback() { // Get the appropriate theme mod. $header_type = get_theme_mod( 'header_type_select' ); if ( 'header_four' !== $header_type ) { return true; } else { return false; } } } if ( ! function_exists( 'control_active_cart_callback' ) ) { /** * Control active cart callback */ function control_active_cart_callback() { // Get the appropriate theme mod. $header_type = get_theme_mod( 'header_type_select' ); if ( class_exists( 'WooCommerce' ) && 'header_default' === $header_type ) { return true; } elseif ( class_exists( 'WooCommerce' ) && 'header_right' === $header_type ) { return true; } elseif ( class_exists( 'WooCommerce' ) && 'header_fullwidth' === $header_type ) { return true; } else { return false; } } } if ( ! function_exists( 'control_active_cart_trans_callback' ) ) { /** * Control active cart transparent callback */ function control_active_cart_trans_callback() { // Get the appropriate theme mod. $header_type = get_theme_mod( 'header_type_select' ); if ( class_exists( 'WooCommerce' ) && 'header_transparent' === $header_type ) { return true; } else { return false; } } } if ( ! function_exists( 'control_active_callback_meta' ) ) { /** * Control active callback for post meta */ function control_active_callback_meta() { // Get the appropriate theme mod. $is_active_meta = get_theme_mod( 'blog_meta_toggle' ); if ( $is_active_meta ) { return true; } return false; } } if ( ! function_exists( 'control_active_callback_grid' ) ) { /** * Control active callback for layout grid */ function control_active_callback_grid() { // Get the appropriate theme mod. $is_active_grid = get_theme_mod( 'blog_layout_select' ); if ( 'grid_view' === $is_active_grid ) { return true; } return false; } } if ( ! function_exists( 'control_active_callback_std_menu' ) ) { /** * Control active callback for std menu color */ function control_active_callback_std_menu() { // Get the appropriate theme mod. $header_type = get_theme_mod( 'header_type_select' ); if ( 'header_default' === $header_type ) { return true; } elseif ( 'header_right' === $header_type ) { return true; } elseif ( 'header_fullwidth' === $header_type ) { return true; } elseif ( 'header_fullwidth_center' === $header_type ) { return true; } else { return false; } } } if ( ! function_exists( 'control_active_callback_transparent' ) ) { /** * Control active callback for transparent header */ function control_active_callback_transparent() { // Get the appropriate theme mod. $header_type = get_theme_mod( 'header_type_select' ); if ( 'header_transparent' === $header_type ) { return true; } else { return false; } } } if ( ! function_exists( 'control_active_callback_sticky_header' ) ) { /** * Control active callback for sticky header bg */ function control_active_callback_sticky_header() { // Get the appropriate theme mod. $header_type = get_theme_mod( 'header_type_select' ); $header_sticky_on = get_theme_mod( 'header_sticky_toggle' ); if ( true === $header_sticky_on && 'header_transparent' === $header_type ) { return true; } else { return false; } } } if ( ! function_exists( 'control_active_callback_non_trans' ) ) { /** * Control active callback for non-transparent header */ function control_active_callback_non_trans() { // Get the appropriate theme mod. $header_type = get_theme_mod( 'header_type_select' ); if ( 'header_default' == $header_type ) { return true; } elseif ( 'header_right' === $header_type ) { return true; } elseif ( 'header_fullwidth' === $header_type ) { return true; } elseif ( 'header_fullwidth_center' === $header_type ) { return true; } else { return false; } } } if ( ! function_exists( 'tutorstarter_sanitize_color' ) ) { /** * Sanitize colors. * * @param array $value The color. * * @return array */ function tutorstarter_sanitize_color( $value ) { return $value; } } if ( ! function_exists( 'control_active_callback_footer_layout' ) ) { /** * Control active callback for footer layouts except five */ function control_active_callback_footer_layout() { // Get the appropriate theme mod. $selected_footer = get_theme_mod( 'footer_type_select' ); if ( 'footer_five' === $selected_footer || 'footer_six' === $selected_footer ) { return false; } return true; } } if ( ! function_exists( 'control_active_callback_footer_logo_trans' ) ) { /** * Control active callback for footer transparent logo */ function control_active_callback_footer_logo_trans() { // Get the appropriate theme mod. $selected_footer = get_theme_mod( 'footer_type_select' ); if ( 'footer_five' === $selected_footer || 'footer_six' === $selected_footer ) { return true; } return false; } } if ( ! function_exists( 'sanitize_range_value' ) ) { /** * Sanitize values for range inputs. * * @param string $input Control input. * * @return float */ function sanitize_range_value( $input ) { $range_value = json_decode( $input, true ); $range_value['desktop'] = is_numeric( $range_value['desktop'] ) ? floatval( $range_value['desktop'] ) : ''; $range_value['tablet'] = is_numeric( $range_value['tablet'] ) ? floatval( $range_value['tablet'] ) : ''; $range_value['mobile'] = is_numeric( $range_value['mobile'] ) ? floatval( $range_value['mobile'] ) : ''; return wp_json_encode( $range_value ); } } if ( ! function_exists( 'sanitize_select_radio' ) ) { /** * Control sanitize select and radio callback */ function sanitize_select_radio( $input, $setting ) { $input = sanitize_key( $input ); $choices = $setting->manager->get_control( $setting->id )->choices; return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } } if ( ! function_exists( 'sanitize_select_range_value' ) ) { /** * Sanitize values for select and range inputs. * * @param string|int $input Control input. * * @return string|int */ function sanitize_select_range_value( $input ) { return $input; } } if ( ! function_exists( 'sanitize_fonts' ) ) { /** * Control sanitize fonts callback */ function sanitize_fonts( $input ) { return $input; } } if ( ! function_exists( 'allowed_html' ) ) { /** * Permitted htl tags list * * @return array array of allowed html tags. */ function allowed_html() { $allowed_html = array( 'a' => array( 'href' => array(), 'title' => array(), ), 'strong' => array(), '©' => array(), ); return $allowed_html; } } if ( ! function_exists( 'tutorstarter_post_pagination' ) ) { /** * Custom pagination */ function tutorstarter_post_pagination() { global $wp_query; $paged = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $paged, '%#%', esc_url( get_pagenum_link( $paged ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var( 'paged' ) ), 'mid_size' => 2, 'prev_text' => __( '<', 'tutorstarter' ), 'next_text' => __( '>', 'tutorstarter' ), 'total' => $wp_query->max_num_pages, ) ); } } /** * Tutor starter ajax signup */ add_action( 'wp_ajax_nopriv_ajaxregister', 'tutor_theme_ajax_register_new_user' ); function tutor_theme_ajax_register_new_user() { if ( ! check_ajax_referer( 'tutor-starter-signup-nonce', 'signupNonce' ) ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Cheating huh?', 'tutorstarter' ), ) ); die(); } $username = isset( $_POST['username'] ) ? sanitize_text_field( $_POST['username'] ) : ''; $email = isset( $_POST['email'] ) ? sanitize_email( $_POST['email'] ) : ''; $password = isset( $_POST['password'] ) ? sanitize_text_field( $_POST['password'] ) : ''; $confirm_password = isset( $_POST['confirm_password'] ) ? sanitize_text_field( $_POST['confirm_password'] ) : ''; if ( ! $username ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Please provide a username.', 'tutorstarter' ), ) ); die(); } elseif ( ! $email ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'A valid email is required.', 'tutorstarter' ), ) ); die(); } elseif ( ! $password ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Please provide a strong password.', 'tutorstarter' ), ) ); die(); } elseif ( ! $confirm_password ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Please confirm the password.', 'tutorstarter' ), ) ); die(); } elseif ( username_exists( $username ) ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Username already exists.', 'tutorstarter' ), ) ); die(); } elseif ( ! is_email( $email ) ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Email address is not valid.', 'tutorstarter' ), ) ); die(); } elseif ( email_exists( $email ) ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'This Email already exists.', 'tutorstarter' ), ) ); die(); } elseif ( strlen( $password ) <= 6 ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Password must be 7 characters or more.', 'tutorstarter' ), ) ); die(); } elseif ( strcmp( $password, $confirm_password ) !== 0 ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Password does not match.', 'tutorstarter' ), ) ); die(); } else { $user_input = array( 'user_login' => $username, 'display_name' => $username, 'user_email' => $email, 'user_pass' => $password, ); $user_id = wp_insert_user( $user_input ); if ( ! is_wp_error( $user_id ) ) { $login_data = array(); $login_data['user_login'] = $username; $login_data['user_password'] = $password; $login_data['remember'] = false; $user_verify = wp_signon( $login_data, false ); if ( is_wp_error( $user_verify ) ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Something went wrong! Please try again later.', 'tutorstarter' ), ) ); die(); } else { echo json_encode( array( 'loggedin' => true, 'message' => __( 'Registration successful, redirecting...', 'tutorstarter' ), ) ); die(); } } else { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Incorrect username or password.', 'tutorstarter' ), ) ); die(); } } } /** * Tutor starter ajax signin */ add_action( 'wp_ajax_nopriv_ajaxlogin', 'tutor_theme_ajax_login' ); function tutor_theme_ajax_login() { if ( ! check_ajax_referer( 'tutor-starter-signin-nonce', 'signinNonce' ) ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Cheating huh?', 'tutorstarter' ), ) ); die(); } $email = isset( $_POST['email'] ) ? sanitize_email( $_POST['email'] ) : ''; $password = isset( $_POST['password'] ) ? sanitize_text_field( $_POST['password'] ) : ''; if ( ! $email ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Email is not valid.', 'tutorstarter' ), ) ); die(); } elseif ( ! $password ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Password field is empty.', 'tutorstarter' ), ) ); die(); } else { $login_data = array(); $login_data['user_login'] = $email; $login_data['user_password'] = $password; $login_data['remember'] = false; $user_verify = wp_signon( $login_data, false ); if ( is_wp_error( $user_verify ) ) { echo json_encode( array( 'loggedin' => false, 'message' => __( 'Invalid login details', 'tutorstarter' ), ) ); die(); } else { echo json_encode( array( 'loggedin' => true, 'message' => __( 'Signin successful, redirecting...', 'tutorstarter' ), ) ); die(); } } } /** * Tutor starter header cart */ if ( ! function_exists( 'tutor_starter_header_cart' ) ) { /** * Display the header cart. */ function tutor_starter_header_cart() { ?>
cart->get_cart_contents_count() ) { ?> (cart->get_cart_contents_count() ); ?>)
(cart->get_cart_contents_count() ); ?>)
'; return $button; } } /** * Header switcher */ function tutorstarter_header_switcher() { $page_meta = get_post_meta( get_the_ID(), '_tutorstarter_page_metadata', true ); $trans_header_toggle = ( ! empty( $page_meta['header_trans_toggle'] ) ? $page_meta['header_trans_toggle'] : false ); $selected_header = get_theme_mod( 'header_type_select', 'header_default' ); $active_header_class = 'navbar-center'; if ( ! empty( $trans_header_toggle ) && true === $trans_header_toggle ) { $active_header_class = 'navbar-left'; } else { switch ( $selected_header ) { case 'header_default': $active_header_class = 'navbar-center'; break; case 'header_transparent': $active_header_class = 'navbar-left'; break; case 'header_right': $active_header_class = 'navbar-right'; break; case 'header_fullwidth': $active_header_class = 'navbar-right full-width'; break; case 'header_fullwidth_center': $active_header_class = 'navbar-center full-width'; break; } } return $active_header_class; } /** * Site logo parser */ if ( ! function_exists( 'tutorstarter_site_logo' ) ) { function tutorstarter_site_logo() { $logo = get_theme_mod( 'custom_logo' ); $logo_img = ! empty( $logo ) ? wp_get_attachment_image_url( $logo, 'full' ) : false; $logo_retina = get_theme_mod( 'retina_logo' ); $retina_imgset = 'srcset="' . esc_url( $logo_retina ) . ' 1x, ' . esc_url( $logo_retina ) . ' 2x"'; if ( $logo_img ) : ?>
alt="" />
alt="" />
alt="">
alt="">