HEX
Server: LiteSpeed
System: Linux server902.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: deshuvsd (2181)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/deshuvsd/www/wp-content/plugins/surerank/src/functions/variables.js
export const flat = ( variables, type = '' ) => {
	if ( ! variables ) {
		return;
	}

	let newVariables = {};
	if ( type === 'richSelect' ) {
		newVariables = [];
	}

	Object.values( variables ).forEach( ( variable ) => {
		Object.keys( variable ).forEach( ( key ) => {
			switch ( type ) {
				case 'richSelect':
					newVariables.push( {
						value: key,
						label: variable[ key ].label,
						title: '%' + key + '%',
						description: variable[ key ].description,
					} );
					break;
				case 'detailed':
					newVariables[ key ] = variable[ key ];
					break;
				default:
					newVariables[ key ] = variable[ key ].value;
			}
		} );
	} );

	return newVariables;
};