# wp-comment-fields/5.2/classes/input.class.php

Comments Extra Fields For Post,Pages and CPT, version 5.2. 146 lines.

- Page: https://pluginprobe.com/plugins/wp-comment-fields/5.2/code/classes/input.class.php
- Raw: https://pluginprobe.com/plugins/wp-comment-fields/5.2/raw/classes/input.class.php
- Modified: 2022-12-22T06:48:38+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/wp-comment-fields/5.2/code/classes/input.class.php#L10-L20`.

```php
<?php
/*
 * Followig class handling all inputs control and their 
 * dependencies. Do not make changes in code
 * Create on: 9 November, 2013 
 */

class WPComment_Inputs{

	/*
	 * this var is pouplated with current plugin meta 
	 */
	var $plugin_meta;
	
	
	/*
	 * this var contains the scripts info 
	 * requested by input
	 */
	var $input_scripts = array();
	
	/**
	 * the static object instace
	 */
	private static $ins = null;
	
	
	/**
	 * __construct function.
	 *
	 * @access public
	 * @param 
	 */
	public function __construct() {}
	
	public static function get_instance()
	{
		// create a new object if it doesn't exist.
		is_null(self::$ins) && self::$ins = new self;
		return self::$ins;
	}
	
	/*
	 * returning relevant input object
	 */
	function get_input($type){
		
		$class_name 	= 'NM_' . ucfirst($type) . '_WPC';
		$file_name		= 'input.' . $type . '.php';
				
		if (! class_exists ( $class_name )) {
			
			/**
			 * adding filter: nm_input_class-filename
			 * @since 6.7
			 * @since 7.6: changing path for eventcalendar addon
			 **/
			 
			 $_inputs = '';
			 switch( $type ) {
			 	
			 	default:
			 		$_inputs = apply_filters('nm_input_class-'.$type, WPCOMMENT_PATH . "/classes/inputs/{$file_name}", $type); 	
			 	break;
			 }
			 
			 
			if (file_exists ( $_inputs )){
				
				include ($_inputs);
				if (class_exists ( $class_name ))
					return new $class_name();
				else
					return null;
				
			}
		} else {
			return new $class_name();
		}
	}
	
	/**
	 * special inputs
	 */
	 function get_addon($type){
	 	
		$addon_directory = 'nm-facebook-import-addon';
	
		$facebook_class_file = WP_CONTENT_DIR . '/plugins/'.$addon_directory.'/index.php';
		if (file_exists( $facebook_class_file )){
			
			include_once $facebook_class_file;
			$class_name 	= 'NM_' . ucfirst($type) . '_WPC';
			if (class_exists ( $class_name ))
				return new $class_name();
			else
				return NULL;
			
		}
	 }
	/*
	 * loading scripts needed by input control
	 */
	function load_input_scripts(){
		
		if($this -> input_scripts['shipped']){
			foreach($this -> input_scripts['shipped'] as $handler){
				wp_enqueue_script($handler);
			}
		}
		
		//front end scripts
		if($this -> input_scripts['custom']){
			foreach($this -> input_scripts['custom'] as $scripts => $script){
				
				//checking if it is style
				//nm_personalizedproduct_pa($script);	
				if( $script['type'] == 'js'){
					wp_enqueue_script('wpcomment-'.$script['script_name'], $this->plugin_meta['url'].$script['script_source'], $script['depends'], '3.0', $script['in_footer']);
				}else{
					wp_enqueue_style('wpcomment-'.$script['script_name'], $this->plugin_meta['url'].$script['script_source']);
				}
			}
		}
	}
	
	
	/*
	 * check if browser is ie
	 */
	function if_browser_is_ie()
	{
		//print_r($_SERVER['HTTP_USER_AGENT']);
		
		if(!(isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))){
			return false;
		}else{
			return true;
		}
	}
	
}

function WPComment_Inputs(){
	return WPComment_Inputs::get_instance();
}
```
