PluginProbe
FileBird – WordPress Media Library Folders & File Manager / 4.3.1
FileBird – WordPress Media Library Folders & File Manager v4.3.1
6.5.8 6.5.7 6.5.5 6.5.4 trunk 4.3.1 5.1.6 5.3 5.3.2 5.4.3 5.4.4 5.4.5 5.5 5.5.3 5.5.5 5.5.8 5.5.8.1 5.6 5.6.1 5.6.2 5.6.3 5.6.4 6.2.3 6.2.5 6.3 All 36 releases
filebird / includes / Controller / CompatiblePolylang.php

CompatiblePolylang.php in FileBird – WordPress Media Library Folders & File Manager 4.3.1, at includes/Controller/CompatiblePolylang.php

77 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace FileBird\Controller;
3
4 use FileBird\Model\Folder as FolderModel;
5
6 defined('ABSPATH') || exit;
7
8 class CompatiblePolylang extends Controller {
9 protected static $instance = null;
10
11 private $active;
12 private $total;
13 private $table_filebird_polylang;
14 public $delete_process_id;
15 private $lang;
16
17 public function __construct() {
18 global $wpdb, $polylang;
19
20 $this->total = 0;
21 $this->delete_process_id = null;
22
23 $this->active = function_exists("pll_get_post_translations");
24 if ($this->active) {
25 if ($polylang->options['media_support'] == 1)
26 {
27 $this->lang = PLL()->model->get_language( get_user_meta( get_current_user_id(), 'pll_filter_content', true ) );
28 add_action('pll_translate_media', array($this, 'duplicateAttachmentToFolder'), 10, 3);
29 //add_filter( 'pll_filter_query_excluded_query_vars', array($this, 'excludedQueryVars'), 10, 3);
30 // add_filter('fbv_in_not_in_select_query', array($this, 'inNotInSelectQuery'), 10, 4);
31 // add_filter('fbv_in_not_in_where_query', array($this, 'inNotInWhereQuery'), 10, 2);
32 add_filter('fbv_count_args', array($this, 'countArgs'));
33 }
34 }
35 }
36
37 public function duplicateAttachmentToFolder($post_id, $tr_id, $lang_slug) {
38 $folders_of_source = FolderModel::getFoldersOfPost($post_id);
39 FolderModel::setFoldersForPosts($tr_id, $folders_of_source);
40 }
41 public function excludedQueryVars($excludes, $query, $lang) {
42 if(isset($query->query['fbv_count']) && $query->query_vars['post_type'] == 'attachment' ) {
43 $excludes = array_values(array_diff($excludes, array('post__in', 'post__not_in')));
44 }
45 return $excludes;
46 }
47 public function inNotInSelectQuery($query, $fbv, $fbv_table, $fbv_relation_table) {
48 global $wpdb;
49 if($fbv !== 0 && is_object($this->lang)) {
50 $query = "SELECT `attachment_id` FROM " .
51 $fbv_relation_table .
52 " JOIN ".$wpdb->prefix."term_relationships ON " .
53 $fbv_relation_table . ".attachment_id = ".$wpdb->prefix."term_relationships.object_id ";
54 }
55 return $query;
56 }
57 public function inNotInWhereQuery($where, $fbv) {
58 if($fbv !== 0 && is_object($this->lang)) {
59 $where[] = 'term_taxonomy_id = ' . $this->lang->term_taxonomy_id;
60 }
61 return $where;
62 }
63 public function countArgs($args) {
64 if(is_object($this->lang)) {
65 $args['lang'] = $this->lang->slug;
66 }
67
68 return $args;
69 }
70 public static function getInstance() {
71 if (null == self::$instance) {
72 self::$instance = new self;
73 }
74 return self::$instance;
75 }
76 }
77