public static function addPixelFireForHook()

in integration/FacebookWordpressIntegrationBase.php [35:62]


  public static function addPixelFireForHook($pixel_fire_for_hook_params) {
    $hook_name = $pixel_fire_for_hook_params['hook_name'];
    $classname = $pixel_fire_for_hook_params['classname'];
    $inject_function = $pixel_fire_for_hook_params['inject_function'];
    $priority = isset($pixel_fire_for_hook_params['priority'])
    ? $pixel_fire_for_hook_params['priority']
    : 11;

    $user_function = array(
      // get derived class in base class
      $classname,
      $inject_function);
    $reflection = new ReflectionMethod($classname, $inject_function);
    $argc = $reflection->getNumberOfParameters();
    $argv = $reflection->getParameters();

    $callback = function () use ($user_function, $argv) {
      $hook_wp_footer = function () use ($user_function, $argv) {
        \call_user_func_array($user_function, $argv);
      };
      add_action(
        'wp_footer',
        $hook_wp_footer,
        11);
    };

    add_action($hook_name, $callback, $priority, $argc);
  }