HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-172-31-4-197 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wordpress/wp-content/plugins/wp-whatsapp-chat/lib/models/class-button.php
<?php
namespace QuadLayers\QLWAPP\Models;

use QuadLayers\QLWAPP\Entities\Button as Button_Entity;

use QuadLayers\WP_Orm\Builder\SingleRepositoryBuilder;

class Button {

	protected static $instance;
	protected $repository;

	public function __construct() {
		add_filter( 'sanitize_option_qlwapp_button', 'wp_unslash' );
		$builder = ( new SingleRepositoryBuilder() )
		->setTable( 'qlwapp_button' )
		->setEntity( Button_Entity::class );

		$this->repository = $builder->getRepository();
	}

	public function get_table() {
		return $this->repository->getTable();
	}

	public function get() {
		$entity = $this->repository->find();
		$result = null;

		if ( $entity ) {
			$result = $entity->getProperties();
		} else {
			$admin  = new Button_Entity();
			$result = $admin->getProperties();
		}

		if ( ! is_admin() ) {
			$result['text']    = qlwapp_replacements_vars( $result['text'] );
			$result['message'] = qlwapp_replacements_vars( $result['message'] );
		}

		return $result;
	}

	public function delete_all() {
		return $this->repository->delete();
	}

	public function save( $data ) {
		$entity = $this->repository->create( $this->sanitize( $data ) );

		if ( $entity ) {
			return true;
		}
	}

	public function sanitize( $settings ) {
		if ( isset( $settings['layout'] ) ) {
			$settings['layout'] = sanitize_html_class( $settings['layout'] );
		}
		if ( isset( $settings['position'] ) ) {
			$settings['position'] = sanitize_html_class( $settings['position'] );
		}
		if ( isset( $settings['text'] ) ) {
			$settings['text'] = sanitize_text_field( $settings['text'] );
		}
		if ( isset( $settings['message'] ) ) {
			// Preserve line breaks while sanitizing the message
			$settings['message'] = wp_kses( $settings['message'], array() );
			$settings['message'] = wp_unslash( $settings['message'] );
		}
		if ( isset( $settings['icon'] ) ) {
			// Check if it's a URL (for custom images) or a CSS class (for font icons)
			if ( filter_var( $settings['icon'], FILTER_VALIDATE_URL ) ||
				( strpos( $settings['icon'], 'http' ) === 0 ) ||
				( strpos( $settings['icon'], '.' ) !== false && preg_match( '/\.(jpg|jpeg|png|gif|svg|webp)$/i', $settings['icon'] ) ) ) {
				// It's an image URL, sanitize as URL
				$settings['icon'] = sanitize_url( $settings['icon'] );
			} else {
				// It's a CSS class, sanitize as HTML class
				$settings['icon'] = sanitize_html_class( $settings['icon'] );
			}
		}
		if ( isset( $settings['phone'] ) ) {
			$settings['phone'] = qlwapp_format_phone( $settings['phone'] );
		}
		if ( isset( $settings['group'] ) ) {
			$settings['group'] = sanitize_url( $settings['group'] );
		}
		if ( isset( $settings['whatsapp_link_type'] ) ) {
			$settings['whatsapp_link_type'] = in_array( $settings['whatsapp_link_type'], array( 'api', 'web' ) ) ? $settings['whatsapp_link_type'] : 'web';
		}

		return $settings;
	}

	public static function instance() {
		if ( ! isset( self::$instance ) ) {
			self::$instance = new self();
		}
		return self::$instance;
	}
}