PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 6.3.3
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v6.3.3
7.2.1 7.2 7.1.2 7.1.1 7.1 7.0.4 7.0.6 7.0.7 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 6.3.1 trunk 5.7.3 5.7.5 5.8.1 5.8.2 5.8.3 5.8.4 5.8.6 6.0.4 6.0.5 All 36 releases
mlsimport / includes / class-mlsimport-loader.php

class-mlsimport-loader.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 6.3.3, at includes/class-mlsimport-loader.php

131 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6
7 /**
8 * Register all actions and filters for the plugin
9 *
10 * @link http://mlsimport.com/
11 * @since 1.0.0
12 *
13 * @package Mlsimport
14 * @subpackage Mlsimport/includes
15 */
16
17 /**
18 * Register all actions and filters for the plugin.
19 *
20 * Maintain a list of all hooks that are registered throughout
21 * the plugin, and register them with the WordPress API. Call the
22 * run function to execute the list of actions and filters.
23 *
24 * @package Mlsimport
25 * @subpackage Mlsimport/includes
26 * @author MlsImport <office@mlsimport.com>
27 */
28 class Mlsimport_Loader {
29
30
31 /**
32 * The array of actions registered with WordPress.
33 *
34 * @since 1.0.0
35 * @access protected
36 * @var array $actions The actions registered with WordPress to fire when the plugin loads.
37 */
38 protected $actions;
39
40 /**
41 * The array of filters registered with WordPress.
42 *
43 * @since 1.0.0
44 * @access protected
45 * @var array $filters The filters registered with WordPress to fire when the plugin loads.
46 */
47 protected $filters;
48
49 /**
50 * Initialize the collections used to maintain the actions and filters.
51 *
52 * @since 1.0.0
53 */
54 public function __construct() {
55
56 $this->actions = array();
57 $this->filters = array();
58 }
59
60 /**
61 * Add a new action to the collection to be registered with WordPress.
62 *
63 * @since 1.0.0
64 * @param string $hook The name of the WordPress action that is being registered.
65 * @param object $component A reference to the instance of the object on which the action is defined.
66 * @param string $callback The name of the function definition on the $component.
67 * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
68 * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
69 */
70 public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
71 $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
72 }
73
74 /**
75 * Add a new filter to the collection to be registered with WordPress.
76 *
77 * @since 1.0.0
78 * @param string $hook The name of the WordPress filter that is being registered.
79 * @param object $component A reference to the instance of the object on which the filter is defined.
80 * @param string $callback The name of the function definition on the $component.
81 * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
82 * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
83 */
84 public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
85 $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
86 }
87
88 /**
89 * A utility function that is used to register the actions and hooks into a single
90 * collection.
91 *
92 * @since 1.0.0
93 * @access private
94 * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
95 * @param string $hook The name of the WordPress filter that is being registered.
96 * @param object $component A reference to the instance of the object on which the filter is defined.
97 * @param string $callback The name of the function definition on the $component.
98 * @param int $priority The priority at which the function should be fired.
99 * @param int $accepted_args The number of arguments that should be passed to the $callback.
100 * @return array The collection of actions and filters registered with WordPress.
101 */
102 private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
103
104 $hooks[] = array(
105 'hook' => $hook,
106 'component' => $component,
107 'callback' => $callback,
108 'priority' => $priority,
109 'accepted_args' => $accepted_args,
110 );
111
112 return $hooks;
113 }
114
115 /**
116 * Register the filters and actions with WordPress.
117 *
118 * @since 1.0.0
119 */
120 public function run() {
121
122 foreach ( $this->filters as $hook ) {
123 add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
124 }
125
126 foreach ( $this->actions as $hook ) {
127 add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
128 }
129 }
130 }
131