PHP 8.2.31
Preview: system-status.js Size: 5.38 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/assets/js/admin/system-status.js

/* global jQuery, woocommerce_admin_system_status, wcSetClipboard, wcClearClipboard */
jQuery( function ( $ ) {
	/**
	 * Users country and state fields
	 */
	var wcSystemStatus = {
		init: function () {
			$( document.body )
				.on(
					'click',
					'a.help_tip, a.woocommerce-help-tip, woocommerce-product-type-tip',
					this.preventTipTipClick
				)
				.on( 'click', 'a.debug-report', this.generateReport )
				.on( 'click', '#copy-for-support', this.copyReport )
				.on( 'click', '#copy-for-github', this.copyGithubReport )
				.on( 'aftercopy', '#copy-for-support, #copy-for-github', this.copySuccess )
				.on( 'aftercopyfailure', '#copy-for-support, #copy-for-github', this.copyFail )
				.on( 'click', '#download-for-support', this.downloadReport );
		},

		/**
		 * Prevent anchor behavior when click on TipTip.
		 *
		 * @return {Bool}
		 */
		preventTipTipClick: function() {
			return false;
		},

		/**
		 * Generate system status report.
		 *
		 * @return {Bool}
		 */
		generateReport: function() {
			var report = '';

			$( '.wc_status_table thead, .wc_status_table tbody' ).each( function() {
				if ( $( this ).is( 'thead' ) ) {
					var label = $( this ).find( 'th:eq(0)' ).data( 'exportLabel' ) || $( this ).text();
					report = report + '\n### ' + label.trim() + ' ###\n\n';
				} else {
					$( 'tr', $( this ) ).each( function() {
						var label       = $( this ).find( 'td:eq(0)' ).data( 'exportLabel' ) || $( this ).find( 'td:eq(0)' ).text();
						var the_name    = label.trim().replace( /(<([^>]+)>)/ig, '' ); // Remove HTML.

						// Find value
						var $value_html = $( this ).find( 'td:eq(2)' ).clone();
						$value_html.find( '.private' ).remove();
						$value_html.find( '.dashicons-yes' ).replaceWith( '&#10004;' );
						$value_html.find( '.dashicons-no-alt, .dashicons-warning' ).replaceWith( '&#10060;' );

						// Format value
						var the_value   = $value_html.text().trim();
						var value_array = the_value.split( ', ' );

						if ( value_array.length > 1 ) {
							// If value have a list of plugins ','.
							// Split to add new line.
							var temp_line ='';
							$.each( value_array, function( key, line ) {
								temp_line = temp_line + line + '\n';
							});

							the_value = temp_line;
						}

						if ( the_name || the_value ) {
							report = report + '' + the_name + ': ' + the_value + '\n';
						} else {
							report = report + '\n';
						}
					});
				}
			});

			try {
				$( '#debug-report' ).slideDown();
				$( '#debug-report' ).find( 'textarea' ).val( '`' + report + '`' ).trigger( 'focus' ).trigger( 'select' );
				$( this ).fadeOut();
				return false;
			} catch ( e ) {
				/* jshint devel: true */
				console.log( e );
			}

			return false;
		},

		/**
		 * Copy for report.
		 *
		 * @param {Object} evt Copy event.
		 */
		copyReport: function( evt ) {
			wcClearClipboard();
			wcSetClipboard( $( '#debug-report' ).find( 'textarea' ).val(), $( this ) );
			evt.preventDefault();
		},
		/**
		 * Apply redactions
		 */
		applyRedactions( report ) {
			var redactions = [
				{
					regex: /(WordPress address \(URL\):)[^\n]*/,
					replacement: "$1 [Redacted]"
				},
				{
					regex: /(Site address \(URL\):)[^\n]*/,
					replacement: "$1 [Redacted]"
				},
				{
					regex: /(### Database ###\n)([\s\S]*?)(\n### Post Type Counts ###)/,
					replacement: "$1\n[REDACTED]\n$3"
				}
			];

			redactions.forEach( function( redaction ) {
				report = report.replace( redaction.regex, redaction.replacement );
			});
			return report;
		},
		/**
		 * Copy for GitHub report.
		 *
		 * @param {Object} event Copy event.
		 */
		copyGithubReport: function( event ) {
			wcClearClipboard();
			var reportValue = $( '#debug-report' ).find( 'textarea' ).val();
			var redactedReport = wcSystemStatus.applyRedactions( reportValue );

			var reportForGithub = '<details><summary>System Status Report</summary>\n\n``' + redactedReport + '``\n</details>';

			wcSetClipboard( reportForGithub, $( this ) );
			event.preventDefault();
		},

		/**
		 * Display a "Copied!" tip when success copying
		 */
		copySuccess: function( event ) {
			$( event.target ).tipTip({
				'attribute':  'data-tip',
				'activation': 'focus',
				'fadeIn':     50,
				'fadeOut':    50,
				'delay':      0
			}).trigger( 'focus' );
		},

		/**
		 * Displays the copy error message when failure copying.
		 */
		copyFail: function() {
			$( '.copy-error' ).removeClass( 'hidden' );
			$( '#debug-report' ).find( 'textarea' ).trigger( 'focus' ).trigger( 'select' );
		},

		downloadReport: function() {
			var ssr_text = new Blob( [ $( '#debug-report' ).find( 'textarea' ).val() ], { type: 'text/plain' } );

			var domain = window.location.hostname;
			var datetime = new Date().toISOString().slice( 0, 19 ).replace( /:/g, '-' );

			var a = document.createElement( 'a' );
			a.download = 'SystemStatusReport_' + domain + '_' + datetime + '.txt';
			a.href = window.URL.createObjectURL( ssr_text );
			a.textContent = 'Download ready';
			a.style='display:none';
			a.click();
			a.remove();
		}
	};

	wcSystemStatus.init();

	$( '.wc_status_table' ).on( 'click', '.run-tool .button', function( evt ) {
		evt.stopImmediatePropagation();
		return window.confirm( woocommerce_admin_system_status.run_tool_confirmation );
	});

	$( '#log-viewer-select' ).on( 'click', 'h2 a.page-title-action', function( evt ) {
		evt.stopImmediatePropagation();
		return window.confirm( woocommerce_admin_system_status.delete_log_confirmation );
	});
});

Directory Contents

Dirs: 0 × Files: 70

Name Size Perms Modified Actions
3.89 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
2.23 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
4.35 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
2.77 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
16.84 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
6.66 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
2.99 KB lrw-r--r-- 2025-04-01 15:51:36
Edit Download
1.61 KB lrw-r--r-- 2025-04-01 15:51:36
Edit Download
54.51 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
33.12 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
42.26 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
22.55 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
37.39 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
19.50 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
4.95 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
3.02 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
2.34 KB lrw-r--r-- 2018-05-23 19:30:10
Edit Download
1.25 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
1.16 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
730 B lrw-r--r-- 2023-12-27 00:45:02
Edit Download
696 B lrw-r--r-- 2025-07-29 12:34:58
Edit Download
298 B lrw-r--r-- 2025-07-29 12:34:58
Edit Download
2.60 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
1.66 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
7.06 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
4.58 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
5.39 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
2.70 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
12.04 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
6.08 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
11.95 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
6.25 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
5.38 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.08 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
4.62 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
2.52 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.78 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
1.87 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
4.06 KB lrw-r--r-- 2024-09-23 20:44:04
Edit Download
1.59 KB lrw-r--r-- 2024-09-23 20:44:04
Edit Download
869 B lrw-r--r-- 2021-05-18 21:00:20
Edit Download
336 B lrw-r--r-- 2021-05-18 21:00:20
Edit Download
1.61 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
1.13 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
13.58 KB lrw-r--r-- 2023-08-16 00:05:04
Edit Download
7.71 KB lrw-r--r-- 2023-08-16 00:05:04
Edit Download
1.98 KB lrw-r--r-- 2022-10-19 00:34:38
Edit Download
1.17 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
3.79 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
2.09 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
2.92 KB lrw-r--r-- 2023-05-24 03:17:54
Edit Download
1.70 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
1.43 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
638 B lrw-r--r-- 2026-02-23 17:58:34
Edit Download
10.05 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
6.35 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
6.57 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
3.57 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
7.04 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.90 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
35.43 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
17.10 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
9.23 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
4.85 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
1.33 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
574 B lrw-r--r-- 2026-02-23 17:58:34
Edit Download
1.78 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
1.05 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
22.32 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
11.93 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).