| @@ -1,112 +1,110 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | - * Followig class handling all inputs control and their | |
| 3 | + * Followig class handling all inputs control and their | |
| 4 | 4 | * dependencies. Do not make changes in code |
| 5 | - * Create on: 9 November, 2013 | |
| 5 | + * Create on: 9 November, 2013 | |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -class NM_Inputs_wpcomment{ | |
| 9 | - | |
| 8 | +class NM_Inputs_wpcomment { | |
| 10 | 9 | |
| 10 | + | |
| 11 | 11 | /* |
| 12 | - * this var is pouplated with current plugin meta | |
| 12 | + * this var is pouplated with current plugin meta | |
| 13 | 13 | */ |
| 14 | 14 | var $plugin_meta; |
| 15 | - | |
| 16 | - | |
| 15 | + | |
| 16 | + | |
| 17 | 17 | /* |
| 18 | - * this var contains the scripts info | |
| 18 | + * this var contains the scripts info | |
| 19 | 19 | * requested by input |
| 20 | 20 | */ |
| 21 | 21 | var $input_scripts; |
| 22 | - | |
| 23 | - | |
| 22 | + | |
| 23 | + | |
| 24 | 24 | /** |
| 25 | 25 | * __construct function. |
| 26 | 26 | * |
| 27 | 27 | * @access public |
| 28 | - * @param | |
| 28 | + * @param | |
| 29 | 29 | */ |
| 30 | 30 | public function __construct() { |
| 31 | - | |
| 32 | - $this -> plugin_meta = get_plugin_meta_wpcomment(); | |
| 31 | + | |
| 32 | + $this->plugin_meta = get_plugin_meta_wpcomment(); | |
| 33 | + | |
| 33 | 34 | } |
| 34 | - | |
| 35 | + | |
| 35 | 36 | /* |
| 36 | 37 | * returning relevant input object |
| 37 | 38 | */ |
| 38 | - function get_input($type){ | |
| 39 | - | |
| 40 | - $class_name = 'NM_' . ucfirst($type); | |
| 41 | - $file_name = 'input.' . $type . '.php'; | |
| 42 | - | |
| 43 | - if (! class_exists ( $class_name )) { | |
| 44 | - $_inputs = $this -> plugin_meta ['path'] . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'inputs' . DIRECTORY_SEPARATOR . $file_name; | |
| 45 | - if (file_exists ( $_inputs )) | |
| 46 | - include_once ($_inputs); | |
| 47 | - else | |
| 48 | - die ( 'Reen, Reen, BUMPs! not found ' . $_inputs ); | |
| 39 | + public function get_input( $type ) { | |
| 40 | + | |
| 41 | + // global $plugin_meta; | |
| 42 | + $class_name = 'NM_' . ucfirst( $type ); | |
| 43 | + $file_name = 'input.' . $type . '.php'; | |
| 44 | + | |
| 45 | + if ( ! class_exists( $class_name ) ) { | |
| 46 | + require_once wpcf_get_path() . '/classes/inputs/' . $file_name; | |
| 49 | 47 | } |
| 50 | - | |
| 48 | + | |
| 51 | 49 | return new $class_name(); |
| 52 | 50 | } |
| 53 | - | |
| 51 | + | |
| 54 | 52 | /* |
| 55 | 53 | * loading scripts needed by input control |
| 56 | 54 | */ |
| 57 | - function load_input_scripts(){ | |
| 58 | - | |
| 59 | - if($this -> input_scripts['shipped']){ | |
| 60 | - foreach($this -> input_scripts['shipped'] as $handler){ | |
| 61 | - wp_enqueue_script($handler); | |
| 55 | + function load_input_scripts() { | |
| 56 | + | |
| 57 | + if ( $this->input_scripts['shipped'] ) { | |
| 58 | + foreach ( $this->input_scripts['shipped'] as $handler ) { | |
| 59 | + wp_enqueue_script( $handler ); | |
| 62 | 60 | } |
| 63 | 61 | } |
| 64 | - | |
| 65 | - //front end scripts | |
| 66 | - if( isset( $this -> input_scripts['custom'] ) && $this -> input_scripts['custom']){ | |
| 67 | - foreach( $this -> input_scripts['custom'] as $scripts => $script ){ | |
| 68 | - | |
| 69 | - //checking if it is style | |
| 70 | - if( $script['type'] == 'js'){ | |
| 71 | - wp_enqueue_script($this->plugin_meta['shortname'].'-'.$script['script_name'], $this->plugin_meta['url'].$script['script_source'], $script['depends'], '3.0', $script['in_footer']); | |
| 72 | - }else{ | |
| 73 | - wp_enqueue_style($this->plugin_meta['shortname'].'-'.$script['script_name'], $this->plugin_meta['url'].$script['script_source']); | |
| 62 | + | |
| 63 | + // front end scripts | |
| 64 | + if ( isset( $this->input_scripts['custom'] ) && $this->input_scripts['custom'] ) { | |
| 65 | + foreach ( $this->input_scripts['custom'] as $scripts => $script ) { | |
| 66 | + | |
| 67 | + // checking if it is style | |
| 68 | + if ( $script['type'] == 'js' ) { | |
| 69 | + wp_enqueue_script( $this->plugin_meta['shortname'] . '-' . $script['script_name'], $this->plugin_meta['url'] . $script['script_source'], $script['depends'], '3.0', $script['in_footer'] ); | |
| 70 | + } else { | |
| 71 | + wp_enqueue_style( $this->plugin_meta['shortname'] . '-' . $script['script_name'], $this->plugin_meta['url'] . $script['script_source'] ); | |
| 74 | 72 | } |
| 75 | 73 | } |
| 76 | 74 | } |
| 77 | 75 | } |
| 78 | - | |
| 79 | - | |
| 76 | + | |
| 77 | + | |
| 80 | 78 | /* |
| 81 | 79 | * check if browser is ie |
| 82 | 80 | */ |
| 83 | - function if_browser_is_ie() | |
| 84 | - { | |
| 85 | - //print_r($_SERVER['HTTP_USER_AGENT']); | |
| 86 | - | |
| 87 | - if (isset($_SERVER['HTTP_USER_AGENT']) && | |
| 88 | - (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') == false) || strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') == false) | |
| 81 | + function if_browser_is_ie() { | |
| 82 | + // print_r($_SERVER['HTTP_USER_AGENT']); | |
| 83 | + if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && | |
| 84 | + ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Chrome' ) == false ) || strpos( $_SERVER['HTTP_USER_AGENT'], 'Safari' ) == false ) { | |
| 89 | 85 | return true; |
| 90 | - else | |
| 86 | + } else { | |
| 91 | 87 | return false; |
| 88 | + } | |
| 92 | 89 | } |
| 93 | - | |
| 90 | + | |
| 94 | 91 | /* |
| 95 | 92 | * get current page url with query string |
| 96 | 93 | */ |
| 97 | 94 | function current_page_url() { |
| 98 | 95 | $page_url = 'http'; |
| 99 | - if( isset($_SERVER["HTTPS"]) ) { | |
| 100 | - if ($_SERVER["HTTPS"] == "on") {$page_url .= "s";} | |
| 96 | + if ( isset( $_SERVER['HTTPS'] ) ) { | |
| 97 | + if ( $_SERVER['HTTPS'] == 'on' ) { | |
| 98 | + $page_url .= 's';} | |
| 101 | 99 | } |
| 102 | - $page_url .= "://"; | |
| 103 | - if ($_SERVER["SERVER_PORT"] != "80") { | |
| 104 | - $page_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; | |
| 100 | + $page_url .= '://'; | |
| 101 | + if ( $_SERVER['SERVER_PORT'] != '80' ) { | |
| 102 | + $page_url .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; | |
| 105 | 103 | } else { |
| 106 | - $page_url .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; | |
| 104 | + $page_url .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; | |
| 107 | 105 | } |
| 108 | 106 | return $page_url; |
| 109 | 107 | } |
| 110 | - | |
| 111 | - | |
| 112 | -} | |
| 108 | + | |
| 109 | + | |
| 110 | +} | |