Forums

[resolved] [Plugin: HookPress] Fatal error: Call to undefined function: array_intersect_key() (5 posts)

  1. danhixon
    Member
    Posted 3 years ago #

    Hookpress looks great! (esp. since I don't like php) - I just can't get it to work.

    Fatal error: Call to undefined function: array_intersect_key() in /nfs/c02/h05/mnt/15692/domains/blog.spokt.com/html/wp-content/plugins/hookpress/includes.php on line 173

    I set up this hook and tried to publish:

    hook URL fields
    ON action: publish_post http://spokt.com/blog_update post_url [delete]

    I'd appreciate any help, thanks!

  2. Ah, so array_intersect_key requires PHP 5.1... I guess you aren't using 5.1?

    I probably could get away without that function, or recreating it... maybe in a future release.

  3. danhixon
    Member
    Posted 3 years ago #

    Apparently not: 4.4.8

    I'll see what it would take to upgrade.

    Thanks for the quick reply!

  4. danhixon
    Member
    Posted 3 years ago #

    I added this to the include.php file:

    if (!function_exists('array_intersect_key'))
    {
      function array_intersect_key($isec, $keys)
      {
        $argc = func_num_args();
        if ($argc > 2)
        {
          for ($i = 1; !empty($isec) && $i < $argc; $i++)
          {
            $arr = func_get_arg($i);
            foreach (array_keys($isec) as $key)
            {
              if (!isset($arr[$key]))
              {
                unset($isec[$key]);
              }
            }
          }
          return $isec;
        }
        else
        {
          $res = array();
          foreach (array_keys($isec) as $key)
          {
            if (isset($keys[$key]))
            {
              $res[$key] = $isec[$key];
            }
          }
          return $res;
        }
      }
    }
  5. Cool. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags