id ) { case 'dashboard' : include( 'class-wc-admin-dashboard.php' ); break; case 'users' : case 'user' : case 'profile' : include( 'class-wc-admin-profile.php' ); break; } } /** * Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from accessing admin */ public function prevent_admin_access() { $prevent_access = false; if ( 'yes' == get_option( 'woocommerce_lock_down_admin' ) && ! is_ajax() && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php' ) { $prevent_access = true; } $prevent_access = apply_filters( 'woocommerce_prevent_admin_access', $prevent_access ); if ( $prevent_access ) { wp_safe_redirect( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ); exit; } } /** * Preview email template * @return [type] */ public function preview_emails() { if ( isset( $_GET['preview_woocommerce_mail'] ) ) { if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'preview-mail') ) die( 'Security check' ); global $email_heading; ob_start(); include( 'views/html-email-template-preview.php' ); $mailer = WC()->mailer(); $message = ob_get_clean(); $email_heading = __( 'Order Received', 'woocommerce' ); echo $mailer->wrap_message( $email_heading, $message ); exit; } } } endif; return new WC_Admin();