PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.10
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.10
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / inc / 3rd-party / nextgen-gallery / classes / Main.php

Main.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.10, at inc/3rd-party/nextgen-gallery/classes/Main.php

138 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Imagify\ThirdParty\NGG;
3
4 defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
5
6 /**
7 * Imagify NextGen Gallery class.
8 *
9 * @since 1.5
10 * @author Jonathan Buttigieg
11 */
12 class Main {
13 use \Imagify\Traits\InstanceGetterTrait;
14
15 /**
16 * Class version.
17 *
18 * @var string
19 */
20 const VERSION = '1.1';
21
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 * Launch the hooks.
35 *
36 * @since 1.6.5
37 * @access public
38 * @author Grégory Viguier
39 */
40 public function init() {
41 static $done = false;
42
43 if ( $done ) {
44 return;
45 }
46 $done = true;
47
48 add_filter( 'imagify_register_context', [ $this, 'register_context' ] );
49 add_filter( 'imagify_context_class_name', [ $this, 'add_context_class_name' ], 10, 2 );
50 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 );
52 add_action( 'init', [ $this, 'add_mixin' ] );
53 }
54
55 /**
56 * Register the context used for NGG.
57 *
58 * @since 1.9
59 * @access public
60 * @author Grégory Viguier
61 *
62 * @param array $contexts An array of context names.
63 * @return array
64 */
65 public function register_context( $contexts ) {
66 $contexts[] = 'ngg';
67 return $contexts;
68 }
69
70 /**
71 * Filter the name of the class to use to define a context.
72 *
73 * @since 1.9
74 * @access public
75 * @author Grégory Viguier
76 *
77 * @param int $class_name The class name.
78 * @param string $context The context name.
79 * @return string
80 */
81 public function add_context_class_name( $class_name, $context ) {
82 if ( 'ngg' === $context ) {
83 return '\\Imagify\\ThirdParty\\NGG\\Context\\NGG';
84 }
85
86 return $class_name;
87 }
88
89 /**
90 * Filter the name of the class to use for the optimization.
91 *
92 * @since 1.9
93 * @access public
94 * @author Grégory Viguier
95 *
96 * @param int $class_name The class name.
97 * @param string $context The context name.
98 * @return string
99 */
100 public function add_process_class_name( $class_name, $context ) {
101 if ( 'ngg' === $context ) {
102 return '\\Imagify\\ThirdParty\\NGG\\Optimization\\Process\\NGG';
103 }
104
105 return $class_name;
106 }
107
108 /**
109 * Filter the name of the class to use for the bulk optimization.
110 *
111 * @since 1.9
112 * @access public
113 * @author Grégory Viguier
114 *
115 * @param int $class_name The class name.
116 * @param string $context The context name.
117 * @return string
118 */
119 public function add_bulk_class_name( $class_name, $context ) {
120 if ( 'ngg' === $context ) {
121 return '\\Imagify\\ThirdParty\\NGG\\Bulk\\NGG';
122 }
123
124 return $class_name;
125 }
126
127 /**
128 * Add custom NGG mixin to override its functions.
129 *
130 * @since 1.5
131 * @access public
132 * @author Jonathan Buttigieg
133 */
134 public function add_mixin() {
135 \C_Gallery_Storage::get_instance()->get_wrapped_instance()->add_mixin( '\\Imagify\\ThirdParty\\NGG\\NGGStorage' );
136 }
137 }
138