PluginProbe
Stream – Activity Log & Audit Trail / 3.4.2
Stream – Activity Log & Audit Trail v3.4.2
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | classes/class-connectors.php +35 -15 3.0.13.4.2 View file →
@@ -3,8 +3,9 @@
3 3
4 4 class Connectors {
5 5 /**
6 6 * Hold Plugin class
7 + *
7 8 * @var Plugin
8 9 */
9 10 public $plugin;
10 11
@@ -75,8 +76,9 @@
75 76 'buddypress',
76 77 'edd',
77 78 'gravityforms',
78 79 'jetpack',
80 + 'mercator',
79 81 'user-switching',
80 82 'woocommerce',
81 83 'wordpress-seo',
82 84 );
@@ -82,26 +84,35 @@
82 84 );
83 85
84 86 $classes = array();
85 87 foreach ( $connectors as $connector ) {
86 - include_once $this->plugin->locations['dir'] . '/connectors/class-connector-' . $connector .'.php';
88 + include_once $this->plugin->locations['dir'] . '/connectors/class-connector-' . $connector . '.php';
87 89 $class_name = sprintf( '\WP_Stream\Connector_%s', str_replace( '-', '_', $connector ) );
88 90 if ( ! class_exists( $class_name ) ) {
89 91 continue;
90 92 }
91 93 $class = new $class_name( $this->plugin->log );
92 - if ( ! method_exists( $class, 'is_dependency_satisfied' ) ) {
94 +
95 + // Check if the Connector extends WP_Stream\Connector
96 + if ( ! is_subclass_of( $class, 'WP_Stream\Connector' ) ) {
93 97 continue;
94 98 }
99 +
100 + // Check if the Connector is allowed to be registered in the WP Admin
101 + if ( is_admin() && ! $class->register_admin ) {
102 + continue;
103 + }
104 +
105 + // Check if the Connector is allowed to be registered in the WP Frontend
106 + if ( ! is_admin() && ! $class->register_frontend ) {
107 + continue;
108 + }
109 +
95 110 if ( $class->is_dependency_satisfied() ) {
96 - $classes[] = $class;
111 + $classes[ $class->name ] = $class;
97 112 }
98 113 }
99 114
100 - if ( empty( $classes ) ) {
101 - return;
102 - }
103 -
104 115 /**
105 116 * Allows for adding additional connectors via classes that extend Connector.
106 117 *
107 118 * @param array $classes An array of Connector objects.
@@ -107,8 +118,12 @@
107 118 * @param array $classes An array of Connector objects.
108 119 */
109 120 $this->connectors = apply_filters( 'wp_stream_connectors', $classes );
110 121
122 + if ( empty( $this->connectors ) ) {
123 + return;
124 + }
125 +
111 126 foreach ( $this->connectors as $connector ) {
112 127 if ( ! method_exists( $connector, 'get_label' ) ) {
113 128 continue;
114 129 }
@@ -119,37 +134,42 @@
119 134 $excluded_connectors = array();
120 135
121 136 foreach ( $this->connectors as $connector ) {
122 137 if ( ! method_exists( $connector, 'get_label' ) ) {
123 - $this->plugin->admin->notice( sprintf( __( "%s class wasn't loaded because it doesn't implement the get_label method.", 'stream' ), $connector->name, 'Connector' ), true );
138 + // translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
139 + $this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_label method.', 'stream' ), $connector->name, 'Connector' ), true );
124 140 continue;
125 141 }
126 142 if ( ! method_exists( $connector, 'register' ) ) {
127 - $this->plugin->admin->notice( sprintf( __( "%s class wasn't loaded because it doesn't implement the register method.", 'stream' ), $connector->name, 'Connector' ), true );
143 + // translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
144 + $this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the register method.', 'stream' ), $connector->name, 'Connector' ), true );
128 145 continue;
129 146 }
130 147 if ( ! method_exists( $connector, 'get_context_labels' ) ) {
131 - $this->plugin->admin->notice( sprintf( __( "%s class wasn't loaded because it doesn't implement the get_context_labels method.", 'stream' ), $connector->name, 'Connector' ), true );
148 + // translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
149 + $this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_context_labels method.', 'stream' ), $connector->name, 'Connector' ), true );
132 150 continue;
133 151 }
134 152 if ( ! method_exists( $connector, 'get_action_labels' ) ) {
135 - $this->plugin->admin->notice( sprintf( __( "%s class wasn't loaded because it doesn't implement the get_action_labels method.", 'stream' ), $connector->name, 'Connector' ), true );
153 + // translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
154 + $this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_action_labels method.', 'stream' ), $connector->name, 'Connector' ), true );
136 155 continue;
137 156 }
138 157
139 - // Check if the connectors extends the Connector class, if not skip it
158 + // Check if the connectors extends the Connector class, if not skip it.
140 159 if ( ! is_subclass_of( $connector, '\WP_Stream\Connector' ) ) {
141 - $this->plugin->admin->notice( sprintf( __( "%s class wasn't loaded because it doesn't extends the %s class.", 'stream' ), $connector->name, 'Connector' ), true );
160 + // translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
161 + $this->plugin->admin->notice( sprintf( __( '%1$s class wasn\'t loaded because it doesn\'t extends the %2$s class.', 'stream' ), $connector->name, 'Connector' ), true );
142 162 continue;
143 163 }
144 164
145 165 // Store connector label
146 - if ( ! in_array( $connector->name, $this->term_labels['stream_connector'] ) ) {
166 + if ( ! in_array( $connector->name, $this->term_labels['stream_connector'], true ) ) {
147 167 $this->term_labels['stream_connector'][ $connector->name ] = $connector->get_label();
148 168 }
149 169
150 170 $connector_name = $connector->name;
151 - $is_excluded = in_array( $connector_name, $excluded_connectors );
171 + $is_excluded = in_array( $connector_name, $excluded_connectors, true );
152 172
153 173 /**
154 174 * Allows excluded connectors to be overridden and registered.
155 175 *