WordPoints / wordpoints

Points plugin for WordPress
GNU General Public License v2.0
20 stars 15 forks source link

Smarter network mode for points hooks #251

Closed JDGrimes closed 8 years ago

JDGrimes commented 9 years ago

The network mode for the points hooks works fine for the user in normal operation. However, we run into issues when we're trying to do things programmatically, for example in the unit tests.

The main sore points:

The result of no. 2 is that you have to be very careful with what you do with a hook ID number. For example, consider this code:

WordPoints_Points_Hooks::set_network_mode( true );

$network_instances = $comment_hook->get_instances( 'network' );

foreach ( $network_instances as $number => $instance ) {
    $points_types[ $number ] = $comment_hook->points_type( $number );
}

It looks like it should work perfectly. We've even gone so far as to explicitly turn on network mode. However, this will actually be getting the points types of regular hooks. You have to append network_ to the hook ID number in order to get points types of the network hooks.

This is almost a bug.

JDGrimes commented 8 years ago

Our network mode handling is much improved in the new hooks API (#321). I'm not entirely sure that we should consider this fixed though, because as we said, it's almost a bug. However, I don't think that we're going to pursue this here, since all of this code is soon to be deprecated anyway. If we want we can revisit this later.