| 1 |
<?php |
| 2 |
/** |
| 3 |
* wpSmartImportView Class Doc Comment |
| 4 |
* |
| 5 |
* @category Class |
| 6 |
* @package wpSmartImportView |
| 7 |
* @author Xylus Themes |
| 8 |
*/ |
| 9 |
if ( !defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly |
| 10 |
if(!class_exists('wpSmartImportView')){ |
| 11 |
class wpSmartImportView { |
| 12 |
|
| 13 |
public static function load_menu_page($filename ) { |
| 14 |
ob_start(); |
| 15 |
include_once wpSmartImport::getVar('admin_view', 'path') . $filename . '.php'; |
| 16 |
$ret = ob_get_contents(); |
| 17 |
ob_end_clean(); |
| 18 |
return $ret; |
| 19 |
} |
| 20 |
|
| 21 |
public static function load($page, $action, $data = array()) { |
| 22 |
ob_start(); |
| 23 |
global $session; |
| 24 |
extract($data); |
| 25 |
$pages = wpSmartImport::getVar('pages'); |
| 26 |
if (!empty($page)) { |
| 27 |
if ($page == $pages[0]) { |
| 28 |
if ($action == '') { |
| 29 |
include_once wpSmartImport::getVar('admin_view', 'path').'import/index.php'; |
| 30 |
} else { |
| 31 |
$file_path = wpSmartImport::getVar('admin_view', 'path').'import/'.$action.'.php'; |
| 32 |
if ( file_exists( $file_path ) ) { |
| 33 |
require_once $file_path; |
| 34 |
} else { |
| 35 |
self::render_not_found_page( esc_html__( 'Action Not Found', 'wp-smart-import' ), sprintf( esc_html__( 'The requested import action "%s" is not valid or does not exist.', 'wp-smart-import' ), $action ) ); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
} elseif ($page == $pages[1]) { |
| 40 |
if ($action == '') { |
| 41 |
include_once wpSmartImport::getVar('admin_view', 'path').'manage/index.php'; |
| 42 |
} else { |
| 43 |
$file_path = wpSmartImport::getVar('admin_view', 'path').'manage/'.$action.'.php'; |
| 44 |
if ( file_exists( $file_path ) ) { |
| 45 |
require_once $file_path; |
| 46 |
} else { |
| 47 |
self::render_not_found_page( esc_html__( 'Action Not Found', 'wp-smart-import' ), sprintf( esc_html__( 'The requested manage action "%s" is not valid or does not exist.', 'wp-smart-import' ), $action ) ); |
| 48 |
} |
| 49 |
} |
| 50 |
} elseif ($page == $pages[2]) { |
| 51 |
if ($action == '') { |
| 52 |
include_once wpSmartImport::getVar('admin_view', 'path').'files/index.php'; |
| 53 |
} else { |
| 54 |
$file_path = wpSmartImport::getVar('admin_view', 'path').'files/'.$action.'.php'; |
| 55 |
if ( file_exists( $file_path ) ) { |
| 56 |
require_once $file_path; |
| 57 |
} else { |
| 58 |
self::render_not_found_page( esc_html__( 'Action Not Found', 'wp-smart-import' ), sprintf( esc_html__( 'The requested file action "%s" is not valid or does not exist.', 'wp-smart-import' ), $action ) ); |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
$ret = ob_get_contents(); |
| 63 |
ob_end_clean(); |
| 64 |
return $ret; |
| 65 |
} |
| 66 |
return ''; |
| 67 |
} |
| 68 |
|
| 69 |
public static function render_not_found_page($title, $message) { |
| 70 |
?> |
| 71 |
<div class="wpsi-error-wrapper" style="padding: 80px 20px; display: flex; justify-content: center; align-items: center; min-height: 400px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;"> |
| 72 |
<div class="wpsi-error-card" style="width: 100%; max-width: 480px; background: #ffffff; border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04); border: 1px solid #e2e8f0; padding: 45px 35px; text-align: center;"> |
| 73 |
<!-- Friendly Icon Container (Soft Blue/Indigo) --> |
| 74 |
<div style="width: 72px; height: 72px; background: #f0f5ff; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 24px auto;"> |
| 75 |
<svg style="width: 32px; height: 32px; color: #3b82f6;" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> |
| 76 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path> |
| 77 |
</svg> |
| 78 |
</div> |
| 79 |
|
| 80 |
<!-- Title & Subtitle --> |
| 81 |
<h2 style="margin: 0 0 10px 0; font-size: 24px; font-weight: 700; color: #1e293b; letter-spacing: -0.5px;"><?php echo esc_html( $title ); ?></h2> |
| 82 |
<p style="margin: 0 0 30px 0; font-size: 15px; line-height: 1.6; color: #64748b; font-weight: 400;"><?php echo esc_html( $message ); ?></p> |
| 83 |
|
| 84 |
<!-- Action Buttons --> |
| 85 |
<div style="display: flex; gap: 12px; justify-content: center;"> |
| 86 |
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wp_smart_import_manage' ) ); ?>" style="text-decoration: none; background: #3b82f6; color: #ffffff; padding: 12px 20px; font-size: 14px; font-weight: 600; border-radius: 8px; box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2); transition: all 0.2s ease; border: none; cursor: pointer; text-align: center; display: inline-block;"> |
| 87 |
<?php esc_html_e( 'Back to Imports', 'wp-smart-import' ); ?> |
| 88 |
</a> |
| 89 |
<a href="javascript:history.back();" style="text-decoration: none; background: #ffffff; color: #475569; padding: 11px 20px; font-size: 14px; font-weight: 600; border-radius: 8px; border: 1px solid #cbd5e1; transition: all 0.2s ease; cursor: pointer; text-align: center; display: inline-block;"> |
| 90 |
<?php esc_html_e( 'Go Back', 'wp-smart-import' ); ?> |
| 91 |
</a> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
</div> |
| 95 |
<?php |
| 96 |
} |
| 97 |
|
| 98 |
public static function check_valid_path() { |
| 99 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 100 |
$action = isset( $_GET['action'] ) ? esc_attr( sanitize_text_field(wp_unslash( $_GET['action'] ) ) ) : ''; |
| 101 |
if ( ! empty( $action ) && ! preg_match( '/^[a-zA-Z0-9_]+$/', $action ) ) { |
| 102 |
$redirect_url = admin_url( 'admin.php?page=wpsi_notfound' ); |
| 103 |
wp_safe_redirect( $redirect_url, 308 ); |
| 104 |
exit; |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
} |
| 109 |
} |