<?php
/**
 * Hook loader: collects actions/filters and registers them on run().
 *
 * @package Brainwerk SEO Suite
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

class Seoforge_Loader {
    protected $actions = array();
    protected $filters = array();

    public function add_action( $hook, $component, $callback, $priority = 10, $args = 1 ) {
        $this->actions[] = array(
            'hook'      => $hook,
            'component' => $component,
            'callback'  => $callback,
            'priority'  => $priority,
            'args'      => $args,
        );
    }

    public function add_filter( $hook, $component, $callback, $priority = 10, $args = 1 ) {
        $this->filters[] = array(
            'hook'      => $hook,
            'component' => $component,
            'callback'  => $callback,
            'priority'  => $priority,
            'args'      => $args,
        );
    }

    public function run() {
        foreach ( $this->actions as $a ) {
            add_action( $a['hook'], array( $a['component'], $a['callback'] ), $a['priority'], $a['args'] );
        }
        foreach ( $this->filters as $f ) {
            add_filter( $f['hook'], array( $f['component'], $f['callback'] ), $f['priority'], $f['args'] );
        }
    }
}
