| 1 |
<?php |
| 2 |
|
| 3 |
namespace FileBird\Support; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || exit; |
| 6 |
|
| 7 |
use FileBird\Model\Folder as FolderModel; |
| 8 |
|
| 9 |
class DocumentGallery { |
| 10 |
public function __construct() { |
| 11 |
add_action( 'init', array( $this, 'init' ) ); |
| 12 |
} |
| 13 |
|
| 14 |
public function init() { |
| 15 |
if ( ! defined( 'DG_VERSION' ) || version_compare( DG_VERSION, '4.3.2', '<=' ) ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
add_action( 'dg_query', array( $this, 'dg_query' ), 10, 4 ); |
| 19 |
} |
| 20 |
|
| 21 |
public function dg_query( &$query, $taxa, &$excluded_keys, &$errs ) { |
| 22 |
if ( ! empty( $taxa['fbv'] ) ) { |
| 23 |
$excluded_keys[] = 'fbv'; |
| 24 |
|
| 25 |
if ( is_null( FolderModel::findById( $taxa['fbv'] ) ) ) { |
| 26 |
$errs[] = __( 'This folder ID does not exist, please check again.', 'filebird' ); |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
$query['fbv'] = $taxa['fbv']; |
| 31 |
$query['suppress_filters'] = false; |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
|