| 1 |
<?php |
| 2 |
/* |
| 3 |
* Followig class handling all inputs control and their |
| 4 |
* dependencies. Do not make changes in code |
| 5 |
* Create on: 9 November, 2013 |
| 6 |
*/ |
| 7 |
|
| 8 |
class WPComment_Inputs{ |
| 9 |
|
| 10 |
/* |
| 11 |
* this var is pouplated with current plugin meta |
| 12 |
*/ |
| 13 |
var $plugin_meta; |
| 14 |
|
| 15 |
|
| 16 |
/* |
| 17 |
* this var contains the scripts info |
| 18 |
* requested by input |
| 19 |
*/ |
| 20 |
var $input_scripts = array(); |
| 21 |
|
| 22 |
/** |
| 23 |
* the static object instace |
| 24 |
*/ |
| 25 |
private static $ins = null; |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* __construct function. |
| 30 |
* |
| 31 |
* @access public |
| 32 |
* @param |
| 33 |
*/ |
| 34 |
public function __construct() {} |
| 35 |
|
| 36 |
public static function get_instance() |
| 37 |
{ |
| 38 |
// create a new object if it doesn't exist. |
| 39 |
is_null(self::$ins) && self::$ins = new self; |
| 40 |
return self::$ins; |
| 41 |
} |
| 42 |
|
| 43 |
/* |
| 44 |
* returning relevant input object |
| 45 |
*/ |
| 46 |
function get_input($type){ |
| 47 |
|
| 48 |
$class_name = 'NM_' . ucfirst($type) . '_WPC'; |
| 49 |
$file_name = 'input.' . $type . '.php'; |
| 50 |
|
| 51 |
if (! class_exists ( $class_name )) { |
| 52 |
|
| 53 |
/** |
| 54 |
* adding filter: nm_input_class-filename |
| 55 |
* @since 6.7 |
| 56 |
* @since 7.6: changing path for eventcalendar addon |
| 57 |
**/ |
| 58 |
|
| 59 |
$_inputs = ''; |
| 60 |
switch( $type ) { |
| 61 |
|
| 62 |
default: |
| 63 |
$_inputs = apply_filters('nm_input_class-'.$type, WPCOMMENT_PATH . "/classes/inputs/{$file_name}", $type); |
| 64 |
break; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
if (file_exists ( $_inputs )){ |
| 69 |
|
| 70 |
include ($_inputs); |
| 71 |
if (class_exists ( $class_name )) |
| 72 |
return new $class_name(); |
| 73 |
else |
| 74 |
return null; |
| 75 |
|
| 76 |
} |
| 77 |
} else { |
| 78 |
return new $class_name(); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* special inputs |
| 84 |
*/ |
| 85 |
function get_addon($type){ |
| 86 |
|
| 87 |
$addon_directory = 'nm-facebook-import-addon'; |
| 88 |
|
| 89 |
$facebook_class_file = WP_CONTENT_DIR . '/plugins/'.$addon_directory.'/index.php'; |
| 90 |
if (file_exists( $facebook_class_file )){ |
| 91 |
|
| 92 |
include_once $facebook_class_file; |
| 93 |
$class_name = 'NM_' . ucfirst($type) . '_WPC'; |
| 94 |
if (class_exists ( $class_name )) |
| 95 |
return new $class_name(); |
| 96 |
else |
| 97 |
return NULL; |
| 98 |
|
| 99 |
} |
| 100 |
} |
| 101 |
/* |
| 102 |
* loading scripts needed by input control |
| 103 |
*/ |
| 104 |
function load_input_scripts(){ |
| 105 |
|
| 106 |
if($this -> input_scripts['shipped']){ |
| 107 |
foreach($this -> input_scripts['shipped'] as $handler){ |
| 108 |
wp_enqueue_script($handler); |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
//front end scripts |
| 113 |
if($this -> input_scripts['custom']){ |
| 114 |
foreach($this -> input_scripts['custom'] as $scripts => $script){ |
| 115 |
|
| 116 |
//checking if it is style |
| 117 |
//nm_personalizedproduct_pa($script); |
| 118 |
if( $script['type'] == 'js'){ |
| 119 |
wp_enqueue_script('wpcomment-'.$script['script_name'], $this->plugin_meta['url'].$script['script_source'], $script['depends'], '3.0', $script['in_footer']); |
| 120 |
}else{ |
| 121 |
wp_enqueue_style('wpcomment-'.$script['script_name'], $this->plugin_meta['url'].$script['script_source']); |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
/* |
| 129 |
* check if browser is ie |
| 130 |
*/ |
| 131 |
function if_browser_is_ie() |
| 132 |
{ |
| 133 |
//print_r($_SERVER['HTTP_USER_AGENT']); |
| 134 |
|
| 135 |
if(!(isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))){ |
| 136 |
return false; |
| 137 |
}else{ |
| 138 |
return true; |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
} |
| 143 |
|
| 144 |
function WPComment_Inputs(){ |
| 145 |
return WPComment_Inputs::get_instance(); |
| 146 |
} |