NF_MergeTags_Other

Class NF_MergeTags_Other.

Defined (1)

The class is defined in the following location(s).

/includes/MergeTags/Other.php  
  1. final class NF_MergeTags_Other extends NF_Abstracts_MergeTags 
  2. protected $id = 'other'; 
  3.  
  4. public function __construct() 
  5. parent::__construct(); 
  6. $this->title = __( 'Other', 'ninja-forms' ); 
  7. $this->merge_tags = Ninja_Forms()->config( 'MergeTagsOther' ); 
  8.  
  9. add_action( 'init', array( $this, 'init' ) ); 
  10.  
  11. public function init() 
  12. if( is_admin() ) { 
  13. if( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) return; 
  14. $url_query = parse_url( wp_get_referer(), PHP_URL_QUERY ); 
  15. parse_str( $url_query, $variables ); 
  16. } else { 
  17. $variables = $_GET; 
  18.  
  19. if( ! is_array( $variables ) ) return; 
  20.  
  21. foreach( $variables as $key => $value ) { 
  22. $value = wp_kses_post( $value ); 
  23. $this->set_merge_tags( $key, $value ); 
  24.  
  25. public function __call($name, $arguments) 
  26. return $this->merge_tags[ $name ][ 'value' ]; 
  27.  
  28. public function set_merge_tags( $key, $value ) 
  29. $callback = ( is_numeric( $key ) ) ? 'querystring_' . $key : $key; 
  30.  
  31. $this->merge_tags[ $callback ] = array( 
  32. 'id' => $key,  
  33. 'tag' => "{querystring:" . $key . "}",  
  34. 'callback' => $callback,  
  35. 'value' => $value 
  36. ); 
  37.  
  38. $this->merge_tags[ $callback . '_deprecated' ] = array( 
  39. 'id' => $key,  
  40. 'tag' => "{" . $key . "}",  
  41. 'callback' => $callback,  
  42. 'value' => $value 
  43. ); 
  44.  
  45. protected function system_date() 
  46. $format = Ninja_Forms()->get_setting( 'date_format' ); 
  47. if ( empty( $format ) ) { 
  48. $format = 'Y/m/d'; 
  49. return date( $format, time() ); 
  50.  
  51. protected function user_ip() 
  52. $ip = '127.0.0.1'; 
  53. if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { 
  54. //check ip from share internet 
  55. $ip = $_SERVER['HTTP_CLIENT_IP']; 
  56. } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { 
  57. //to check ip is pass from proxy 
  58. $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; 
  59. } elseif( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { 
  60. $ip = $_SERVER['REMOTE_ADDR']; 
  61.  
  62. return apply_filters( 'ninja_forms-get_ip', apply_filters( 'nf_get_ip', $ip ) ); 
  63.  
  64.  
  65. } // END CLASS NF_MergeTags_Other