PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.2.8
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.2.8
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 / formidable-pro / classes / Main.php

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

70 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Imagify\ThirdParty\FormidablePro;
3
4 use Imagify\Traits\InstanceGetterTrait;
5
6 /**
7 * Compat class for Formidable Forms Pro plugin.
8 * Each call to `new WP_Query()` made by Imagify must have a `'is_imagify' => true` argument.
9 *
10 * @since 1.6.13
11 * @author Grégory Viguier
12 */
13 class Main {
14 use InstanceGetterTrait;
15
16 /**
17 * Class version.
18 *
19 * @var string
20 */
21 const VERSION = '1.1';
22
23 /**
24 * Set to true when the current query comes from Imagify.
25 *
26 * @var int
27 */
28 protected $is_imagify;
29
30 /**
31 * Launch the hooks.
32 *
33 * @since 1.6.13
34 * @author Grégory Viguier
35 */
36 public function init() {
37 add_action( 'parse_query', [ $this, 'maybe_remove_media_library_filter' ] );
38 add_action( 'posts_selection', [ $this, 'maybe_put_media_library_filter_back' ] );
39 }
40
41 /**
42 * Fires before the 'pre_get_posts' hook.
43 *
44 * @since 1.6.13
45 * @author Grégory Viguier
46 *
47 * @param object $wp_query The WP_Query instance (passed by reference).
48 */
49 public function maybe_remove_media_library_filter( $wp_query ) {
50 if ( ! empty( $wp_query->query_vars['is_imagify'] ) && class_exists( 'FrmProFileField' ) ) {
51 $this->is_imagify = true;
52 remove_action( 'pre_get_posts', 'FrmProFileField::filter_media_library', 99 );
53 } else {
54 $this->is_imagify = false;
55 }
56 }
57
58 /**
59 * Fires after the 'pre_get_posts' hook.
60 *
61 * @since 1.6.13
62 * @author Grégory Viguier
63 */
64 public function maybe_put_media_library_filter_back() {
65 if ( $this->is_imagify ) {
66 add_action( 'pre_get_posts', 'FrmProFileField::filter_media_library', 99 );
67 }
68 }
69 }
70