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