ReduxFrameworkInstances

Redux Framework Instance Container Class Automatically captures and stores all instances of ReduxFramework at instantiation.

Defined (1)

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

/inc/ReduxFramework/ReduxCore/inc/class.redux_instances.php  
  1. class ReduxFrameworkInstances { 
  2.  
  3. /** 
  4. * ReduxFrameworkInstances 
  5. * @var object 
  6. */ 
  7. private static $instance; 
  8.  
  9. /** 
  10. * ReduxFramework instances 
  11. * @var array 
  12. */ 
  13. private static $instances; 
  14.  
  15. /** 
  16. * Get Instance 
  17. * Get ReduxFrameworkInstances instance 
  18. * OR an instance of ReduxFramework by [opt_name] 
  19. * @param string $opt_name the defined opt_name 
  20. * @return object class instance 
  21. */ 
  22. public static function get_instance( $opt_name = false ) { 
  23.  
  24. if ( is_null( self::$instance ) ) { 
  25. self::$instance = new self(); 
  26.  
  27. if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) { 
  28. return self::$instances[ $opt_name ]; 
  29.  
  30. return self::$instance; 
  31.  
  32. /** 
  33. * Get all instantiated ReduxFramework instances (so far) 
  34. * @return [type] [description] 
  35. */ 
  36. public static function get_all_instances() { 
  37. return self::$instances; 
  38.  
  39. private function __construct() { 
  40.  
  41. add_action( 'redux/construct', array( $this, 'capture' ), 5, 1 ); 
  42.  
  43. $hash = md5( trailingslashit( network_site_url() ) . '-redux' ); 
  44. add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'tracking_arg' ) ); 
  45. add_action( 'wp_ajax_' . $hash, array( $this, 'tracking_arg' ) ); 
  46.  
  47. if (!class_exists('Redux_Tracking') || !method_exists('Redux_Tracking', 'trackingObject')) { 
  48. $hash = md5( md5( AUTH_KEY . SECURE_AUTH_KEY . '-redux' ) . '-support' ); 
  49. add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'support_args' ) ); 
  50. add_action( 'wp_ajax_' . $hash, array( $this, 'support_args' ) ); 
  51.  
  52.  
  53.  
  54. function tracking_arg() { 
  55. echo md5( AUTH_KEY . SECURE_AUTH_KEY . '-redux' ); 
  56. die(); 
  57.  
  58. function support_args() { 
  59.  
  60. $this->options = get_option( 'redux-framework-tracking' ); 
  61. $this->options['dev_mode'] = false; 
  62.  
  63. if ( ! isset( $this->options['hash'] ) || ! $this->options['hash'] || empty( $this->options['hash'] ) ) { 
  64. $this->options['hash'] = md5( network_site_url() . '-' . $_SERVER['REMOTE_ADDR'] ); 
  65. update_option( 'redux-framework-tracking', $this->options ); 
  66.  
  67. if ( isset( $_GET['redux_framework_disable_tracking'] ) && ! empty( $_GET['redux_framework_disable_tracking'] ) ) { 
  68. $this->options['allow_tracking'] = false; 
  69. update_option( 'redux-framework-tracking', $this->options ); 
  70.  
  71. if ( isset( $_GET['redux_framework_enable_tracking'] ) && ! empty( $_GET['redux_framework_enable_tracking'] ) ) { 
  72. $this->options['allow_tracking'] = true; 
  73. update_option( 'redux-framework-tracking', $this->options ); 
  74.  
  75. header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
  76. header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); 
  77. header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); 
  78. header( 'Cache-Control: no-store, no-cache, must-revalidate' ); 
  79. header( 'Cache-Control: post-check=0, pre-check=0', false ); 
  80. header( 'Pragma: no-cache' ); 
  81. $instances = ReduxFrameworkInstances::get_all_instances(); 
  82.  
  83. if ( isset( $_REQUEST['i'] ) && ! empty( $_REQUEST['i'] ) ) { 
  84. if ( is_array( $instances ) && ! empty( $instances ) ) { 
  85. foreach ( $instances as $opt_name => $data ) { 
  86. if ( md5( $opt_name . '-debug' ) == $_REQUEST['i'] ) { 
  87. $array = $instances[ $opt_name ]; 
  88. if ($data->args['dev_mode']) { 
  89. $this->options['dev_mode'] = $data->args['dev_mode']; 
  90. if ( isset( $array ) ) { 
  91. if ( isset( $array->extensions ) && is_array( $array->extensions ) && ! empty( $array->extensions ) ) { 
  92. foreach ( $array->extensions as $key => $extension ) { 
  93. if ( isset( $extension->$version ) ) { 
  94. $array->extensions[ $key ] = $extension->$version; 
  95. } else { 
  96. $array->extensions[ $key ] = true; 
  97. if ( isset( $array->import_export ) ) { 
  98. unset( $array->import_export ); 
  99. if ( isset( $array->debug ) ) { 
  100. unset( $array->debug ); 
  101. } else { 
  102. die(); 
  103.  
  104. } else { 
  105. $array = Redux_Helpers::trackingObject(); 
  106. if ( is_array( $instances ) && ! empty( $instances ) ) { 
  107. $array['instances'] = array(); 
  108. foreach ( $instances as $opt_name => $data ) { 
  109. $array['instances'][] = $opt_name; 
  110. $array['key'] = md5( AUTH_KEY . SECURE_AUTH_KEY ); 
  111.  
  112. echo @json_encode( $array, true ); 
  113. die(); 
  114.  
  115. function capture( $ReduxFramework ) { 
  116. $this->store( $ReduxFramework ); 
  117.  
  118. private function store( $ReduxFramework ) { 
  119. if ( $ReduxFramework instanceof ReduxFramework ) { 
  120. $key = $ReduxFramework->args['opt_name']; 
  121. self::$instances[ $key ] = $ReduxFramework;