# quickwebp/2.0.0/admin/class-settings.php

QuickWebP – WebP &amp; AVIF Image Optimizer, Compression &amp; SEO for WordPress, version 2.0.0. 114 lines.

- Page: https://pluginprobe.com/plugins/quickwebp/2.0.0/code/admin/class-settings.php
- Raw: https://pluginprobe.com/plugins/quickwebp/2.0.0/raw/admin/class-settings.php
- Modified: 2023-02-10T18:52:10+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/quickwebp/2.0.0/code/admin/class-settings.php#L10-L20`.

```php
<?php
/**
 * The admin-specific functionality of the plugin.
 *
 * @link       http://webdeclic.com
 * @since      1.0.0
 *
 * @package    Quickwebp
 * @subpackage Quickwebp/admin
 */
class Quickwebp_Settings {

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of this plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct( $plugin_name, $version ) {

		$this->plugin_name = $plugin_name;
		$this->version = $version;

	}

	/**
	 * Enqueue scripts and styles
	 * 
	 */
	public function enqueue_scripts_styles( $hook_suffix ) {
		if ( $hook_suffix == 'toplevel_page_quickwebp-settings' || $hook_suffix == 'media_page_quickwebp-settings' ) {

			$admin_main_settings_assets = include( QUICKWEBP_PLUGIN_PATH . 'public/assets/build/admin-main-settings.asset.php' );
			wp_enqueue_style( 'quickwebpoi_admin_main_settings', QUICKWEBP_PLUGIN_URL . 'public/assets/build/admin-main-settings.css', array(), $admin_main_settings_assets['version'], 'all' );
			wp_enqueue_script( 'quickwebpoi_admin_main_settings', QUICKWEBP_PLUGIN_URL . 'public/assets/build/admin-main-settings.js', $admin_main_settings_assets['dependencies'], $admin_main_settings_assets['version'], true );
		}
	}
		
	/**
	 * add_settings_menu
	 *
	 * @return void
	 */
	public function add_settings_menu() {
		add_submenu_page(
			'upload.php',
			__('Quickwebp Settings', QUICKWEBP_TEXT_DOMAIN),
			__('Quickwebp', QUICKWEBP_TEXT_DOMAIN),
			'manage_options',
			'quickwebp-settings',
			array( $this, 'render_settings_page' )
		);
	}
	
	/**
	 * render_settings_page
	 *
	 * @return void
	 */
	public function render_settings_page() {
		require_once QUICKWEBP_PLUGIN_PATH . 'admin/templates/page-settings.php';
	}
	
	/**
	 * render_component
	 *
	 * @param  mixed $data
	 * @return void
	 */
	public function render_component( $data = array() ) {
		$data['type'] 		= $data['type'] ?? 'text';
		$data['name'] 		= $data['name'] ?? '';
		$file_name 			= $data['type'] == 'text' || $data['type'] == 'email' || $data['type'] == 'tel' || $data['type'] == 'number' ? 'text' : $data['type'];
		$path_to_component 	= QUICKWEBP_PLUGIN_PATH . 'admin/components/' . $file_name . '.php';

		if( file_exists( $path_to_component ) ) {
			?>
			<tr>
				<th>
					<label for="<?php echo esc_attr( $data['name'] ?? '' ); ?>"><?php echo esc_html( $data['label'] ?? '' ); ?></label>
				</th>
				<td class="<?php echo esc_attr( $data['name'] ?? '' ); ?>-container">
					<?php include $path_to_component; ?>
					<?php if( isset( $data['description'] ) ) { 
						?>
						<p class="description"><?php echo esc_html( $data['description'] ); ?></p>
						<?php 
					} 
					?>
				</td>
			</tr>
			<?php
		}
	}
}
```
