| @@ -1,146 +1,110 @@ | ||
| 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 | -} | |
| 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 NM_Inputs_wpcomment { | |
| 9 | + | |
| 10 | + | |
| 11 | + /* | |
| 12 | + * this var is pouplated with current plugin meta | |
| 13 | + */ | |
| 14 | + var $plugin_meta; | |
| 15 | + | |
| 16 | + | |
| 17 | + /* | |
| 18 | + * this var contains the scripts info | |
| 19 | + * requested by input | |
| 20 | + */ | |
| 21 | + var $input_scripts; | |
| 22 | + | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * __construct function. | |
| 26 | + * | |
| 27 | + * @access public | |
| 28 | + * @param | |
| 29 | + */ | |
| 30 | + public function __construct() { | |
| 31 | + | |
| 32 | + $this->plugin_meta = get_plugin_meta_wpcomment(); | |
| 33 | + | |
| 34 | + } | |
| 35 | + | |
| 36 | + /* | |
| 37 | + * returning relevant input object | |
| 38 | + */ | |
| 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; | |
| 47 | + } | |
| 48 | + | |
| 49 | + return new $class_name(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + /* | |
| 53 | + * loading scripts needed by input control | |
| 54 | + */ | |
| 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 ); | |
| 60 | + } | |
| 61 | + } | |
| 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'] ); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 77 | + | |
| 78 | + /* | |
| 79 | + * check if browser is ie | |
| 80 | + */ | |
| 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 ) { | |
| 85 | + return true; | |
| 86 | + } else { | |
| 87 | + return false; | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | + /* | |
| 92 | + * get current page url with query string | |
| 93 | + */ | |
| 94 | + function current_page_url() { | |
| 95 | + $page_url = 'http'; | |
| 96 | + if ( isset( $_SERVER['HTTPS'] ) ) { | |
| 97 | + if ( $_SERVER['HTTPS'] == 'on' ) { | |
| 98 | + $page_url .= 's';} | |
| 99 | + } | |
| 100 | + $page_url .= '://'; | |
| 101 | + if ( $_SERVER['SERVER_PORT'] != '80' ) { | |
| 102 | + $page_url .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; | |
| 103 | + } else { | |
| 104 | + $page_url .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; | |
| 105 | + } | |
| 106 | + return $page_url; | |
| 107 | + } | |
| 108 | + | |
| 109 | + | |
| 110 | +} | |