| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Imagify\ThirdParty\NGG; |
| 3 | 3 | |
| 4 | -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); | |
| 4 | +use Imagify\Traits\InstanceGetterTrait; | |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * Imagify NextGen Gallery class. |
| 8 | 8 | * |
| @@ -9,9 +9,9 @@ | ||
| 9 | 9 | * @since 1.5 |
| 10 | 10 | * @author Jonathan Buttigieg |
| 11 | 11 | */ |
| 12 | 12 | class Main { |
| 13 | - use \Imagify\Traits\InstanceGetterTrait; | |
| 13 | + use InstanceGetterTrait; | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Class version. |
| 17 | 17 | * |
| @@ -19,19 +19,8 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | const VERSION = '1.1'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * The constructor. | |
| 24 | - * | |
| 25 | - * @since 1.5 | |
| 26 | - * @since 1.6.5 Doesn't launch the hooks anymore. | |
| 27 | - * @since 1.9 Visibility set to public. | |
| 28 | - * @access public | |
| 29 | - * @author Jonathan Buttigieg | |
| 30 | - */ | |
| 31 | - public function __construct() {} | |
| 32 | - | |
| 33 | - /** | |
| 34 | 23 | * Launch the hooks. |
| 35 | 24 | * |
| 36 | 25 | * @since 1.6.5 |
| 37 | 26 | * @access public |
| @@ -44,12 +33,12 @@ | ||
| 44 | 33 | return; |
| 45 | 34 | } |
| 46 | 35 | $done = true; |
| 47 | 36 | |
| 48 | - add_filter( 'imagify_register_context', [ $this, 'register_context' ] ); | |
| 37 | + add_filter( 'imagify_register_context', [ $this, 'register_context' ] ); | |
| 49 | 38 | add_filter( 'imagify_context_class_name', [ $this, 'add_context_class_name' ], 10, 2 ); |
| 50 | 39 | add_filter( 'imagify_process_class_name', [ $this, 'add_process_class_name' ], 10, 2 ); |
| 51 | - add_filter( 'imagify_bulk_class_name', [ $this, 'add_bulk_class_name' ], 10, 2 ); | |
| 40 | + add_filter( 'imagify_bulk_class_name', [ $this, 'add_bulk_class_name' ], 10, 2 ); | |
| 52 | 41 | add_action( 'init', [ $this, 'add_mixin' ] ); |
| 53 | 42 | } |
| 54 | 43 | |
| 55 | 44 | /** |
| @@ -125,8 +114,9 @@ | ||
| 125 | 114 | } |
| 126 | 115 | |
| 127 | 116 | /** |
| 128 | 117 | * Add custom NGG mixin to override its functions. |
| 118 | + * No-op on NGG v4.x where the POPE framework (Mixin / C_Gallery_Storage) is absent. | |
| 129 | 119 | * |
| 130 | 120 | * @since 1.5 |
| 131 | 121 | * @access public |
| 132 | 122 | * @author Jonathan Buttigieg |
| @@ -131,7 +121,13 @@ | ||
| 131 | 121 | * @access public |
| 132 | 122 | * @author Jonathan Buttigieg |
| 133 | 123 | */ |
| 134 | 124 | public function add_mixin() { |
| 125 | + // @codeCoverageIgnoreStart — requires live NGG v3 POPE classes, not available in unit tests. | |
| 126 | + if ( ! imagify_ngg_has_pope_storage() ) { | |
| 127 | + return; | |
| 128 | + } | |
| 129 | + | |
| 135 | 130 | \C_Gallery_Storage::get_instance()->get_wrapped_instance()->add_mixin( '\\Imagify\\ThirdParty\\NGG\\NGGStorage' ); |
| 131 | + // @codeCoverageIgnoreEnd | |
| 136 | 132 | } |
| 137 | 133 | } |