-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvrls-wa-oxygen-pods-gallery.php
48 lines (35 loc) · 1.14 KB
/
vrls-wa-oxygen-pods-gallery.php
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
<?php
/**
* Plugin Name: Oxygen Pods Gallery Workaround
* Plugin URI:
* Description: Makes Oxygen's Gallery ACF Field look for Pods fields instead of ACF's
* Version: 0.1
* Author: Vitor Loureiro
* Author URI: https://vitorloureiro.com
**/
if (!defined('WPINC')) {
die;
}
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
if (is_plugin_active('oxygen/functions.php') AND is_plugin_active('pods/init.php')) {
function change_key($array, $old_key, $new_key)
{
if (!array_key_exists($old_key, $array))
return $array;
$keys = array_keys($array);
$keys[array_search($old_key, $keys)] = $new_key;
return array_combine($keys, $array);
}
function get_field($fieldname)
{
if (!function_exists('pods_field')) {
echo "PODS is not installed correctly or there is a compatibility issue.";
return "";
}
$pods_field_array = pods_field($fieldname);
foreach ($pods_field_array as $key => $field) {
$pods_field_array[$key] = change_key($pods_field_array[$key], "ID", "id");
}
return $pods_field_array;
}
}