PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.5.3
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.5.3
3.1.9 3.1.8 3.1.7 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 trunk 1.3.7 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9 2.9.1 2.9.2
folders / includes / class-wpml.php
folders / includes Last commit date
class-affiliate.php 5 years ago class-polylang.php 5 years ago class-review-box.php 5 years ago class-wpml.php 5 years ago folders.class.php 5 years ago form.class.php 5 years ago plugin.updates.php 5 years ago tree.class.php 5 years ago
class-wpml.php
118 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3 class WCP_Folder_WPML {
4 private $is_wpml_active;
5 private $total;
6 private $lang;
7 private $table_icl_translations;
8
9 protected $post_translations;
10 private $sitepress;
11 private $settings;
12
13 public function __construct()
14 {
15 $this->is_wpml_active = false;
16 $this->total = 0;
17 add_action("admin_init", array($this, 'init'));
18 }
19
20 public function init()
21 {
22 global $sitepress, $wpdb;
23 $is_wpml_active = $sitepress !== null && get_class($sitepress) === "SitePress";
24
25 if ($is_wpml_active) {
26 $settings = $sitepress->get_setting('custom_posts_sync_option', array());
27 if ($sitepress->get_current_language() !== 'all') {
28 $this->is_wpml_active = true;
29 $this->settings = $settings;
30 $this->lang = $sitepress->get_current_language();
31 $this->table_icl_translations = $wpdb->prefix . 'icl_translations';
32 }
33 $this->sitepress = $sitepress;
34 $this->post_translations = $sitepress->post_translations();
35 }
36
37 if ($this->is_wpml_active) {
38 add_filter('premio_folder_item_in_taxonomy', array($this, 'items_in_taxonomy'), 10, 2);
39 add_filter('premio_folder_un_categorized_items', array($this, 'un_categorized_items'), 10, 2);
40 add_filter('premio_folder_all_categorized_items', array($this, 'all_categorized_items'), 10, 2);
41 }
42 }
43
44 public function set_total($post_type){
45 if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
46 global $wpdb;
47 $query = "SELECT COUNT(DISTINCT(p.id))
48 FROM {$this->table_icl_translations} AS wpmlt
49 INNER JOIN {$wpdb->posts} AS p ON p.id = wpmlt.element_id
50 WHERE wpmlt.element_type = 'post_{$post_type}'
51 AND wpmlt.language_code = '{$this->lang}'";
52 if($post_type == 'attachment') {
53 $query .= " AND (p.post_status = 'inherit' OR p.post_status = 'private')";
54 } else {
55 $query .= " AND p.post_status != 'trash'";
56 }
57 $this->total = (int)$wpdb->get_var($query);
58 }
59 }
60
61 public function items_in_taxonomy($term_id, $arg = array()) {
62 $post_type = isset($arg['post_type'])?$arg['post_type']:"";
63 $taxonomy = isset($arg['taxonomy'])?$arg['taxonomy']:"";
64 if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
65 global $wpdb;
66 $term_taxonomy_id = get_term_by('id', (int)$term_id, $taxonomy, OBJECT)->term_taxonomy_id;
67 $join = "INNER JOIN {$wpdb->term_relationships} AS term_rela ON term_rela.object_id = wpmlt.element_id";
68 $where = "wpmlt.element_type = 'post_{$post_type}' AND term_rela.term_taxonomy_id = {$term_taxonomy_id} AND wpmlt.language_code = '{$this->lang}'";
69 $query = "SELECT wpmlt.element_id FROM {$this->table_icl_translations} AS wpmlt " . $join . " WHERE " . $where;
70 $all_ids = $wpdb->get_col($query);
71 $counter = 0;
72 if (count($all_ids) > 0) {
73 if($post_type == 'attachment') {
74 $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `ID` IN (" . implode(',', $all_ids) . ") AND (post_status = 'inherit' OR post_status = 'private')";
75 $counter = $wpdb->get_var($query);
76 } else {
77 $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `ID` IN (" . implode(',', $all_ids) . ") AND post_status != 'trash'";
78 $counter = $wpdb->get_var($query);
79 }
80 }
81 return !empty($counter) ? $counter : 0;
82 }
83 return null;
84 }
85
86 public function un_categorized_items($post_type, $taxonomy) {
87
88 if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
89
90 global $wpdb;
91 $query = "SELECT COUNT(DISTINCT(tmp_table.ID))
92 FROM (SELECT * FROM {$this->table_icl_translations} as wpmlt
93 INNER JOIN {$wpdb->posts} as p on p.id = wpmlt.element_id
94 WHERE wpmlt.element_type = 'post_{$post_type}'
95 and wpmlt.language_code = '{$this->lang}') as tmp_table
96 JOIN {$wpdb->term_relationships} as term_relationships on tmp_table.element_id = term_relationships.object_id
97 JOIN {$wpdb->term_taxonomy} as term_taxonomy on term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id
98 WHERE taxonomy = '{$taxonomy}'";
99 $fileInFolder = (int)$wpdb->get_var($query);
100
101 $this->set_total($post_type);
102
103 return $this->total - $fileInFolder;
104 }
105 return null;
106 }
107
108 public function all_categorized_items($post_type) {
109 if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
110 $this->set_total($post_type);
111 return $this->total;
112 }
113 return null;
114 }
115 }
116 if(class_exists('WCP_Folder_WPML')) {
117 $folder_WPML = new WCP_Folder_WPML();
118 }