id ) { case 'dashboard' : include( 'class-wc-admin-dashboard.php' ); break; case 'options-permalink' : include( 'class-wc-admin-permalink-settings.php' ); break; case 'users' : case 'user' : case 'profile' : case 'user-edit' : 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( wc_get_page_id( 'myaccount' ) ) ); exit; } } /** * Preview email template * * @return string */ public function preview_emails() { if ( isset( $_GET['preview_woocommerce_mail'] ) ) { if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'preview-mail') ) { die( 'Security check' ); } // load the mailer class $mailer = WC()->mailer(); // get the preview email subject $email_heading = __( 'HTML Email Template', 'woocommerce' ); // get the preview email content ob_start(); include( 'views/html-email-template-preview.php' ); $message = ob_get_clean(); // create a new email $email = new WC_Email(); // wrap the content with the email template and then add styles $message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ); // print the preview email echo $message; exit; } } /** * Change the admin footer text on WooCommerce admin pages * * @since 2.3 * @param string $footer_text * @return string */ public function admin_footer_text( $footer_text ) { $current_screen = get_current_screen(); // Check to make sure we're on a WooCommerce admin page if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, wc_get_screen_ids() ) ) ) { // Change the footer text $footer_text = sprintf( __( 'If you like WooCommerce please leave us a ★★★★★ rating on WordPress.org. A huge thank you from WooThemes in advance!', 'woocommerce' ), 'https://wordpress.org/support/view/plugin-reviews/woocommerce?filter=5#postform' ); } return $footer_text; } } return new WC_Admin();