Version Description
- bugfixes
Download this release
Release Info
Developer | carlos_a_sanz |
Plugin | Qtranslate Slug |
Version | 1.1.5 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.1.5
- README.txt +7 -6
- qtranslate-slug.php +65 -31
- termmeta-core.php +72 -51
README.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Carlos Sanz García
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SYC46KSLRC4Q8
|
4 |
Tags: qtranslate, slug, multilanguage
|
5 |
Requires at least: 3.3
|
6 |
-
Tested up to: 3.
|
7 |
-
Version: 1.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -21,11 +21,9 @@ Adds support for permalink translations and fix some QTranslate deficiencies sin
|
|
21 |
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
22 |
* Qtranslate 2.5.8
|
23 |
|
24 |
-
= New in version 1.1 =
|
25 |
|
26 |
-
*
|
27 |
-
* fixed some parse url bugs
|
28 |
-
* fixed slug bases validation
|
29 |
|
30 |
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by sepparetly on each site.**
|
31 |
|
@@ -80,6 +78,9 @@ That's because language selector metabox is hidden, if you are in admin *nav men
|
|
80 |
|
81 |
== Changelog ==
|
82 |
|
|
|
|
|
|
|
83 |
= 1.1 =
|
84 |
* added multisite support
|
85 |
* fixed some parse url bugs
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SYC46KSLRC4Q8
|
4 |
Tags: qtranslate, slug, multilanguage
|
5 |
Requires at least: 3.3
|
6 |
+
Tested up to: 3.5.1
|
7 |
+
Version: 1.1.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
21 |
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
22 |
* Qtranslate 2.5.8
|
23 |
|
24 |
+
= New in version 1.1.5 =
|
25 |
|
26 |
+
* bugfixes
|
|
|
|
|
27 |
|
28 |
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by sepparetly on each site.**
|
29 |
|
78 |
|
79 |
== Changelog ==
|
80 |
|
81 |
+
= 1.1.5 =
|
82 |
+
* bugfixes
|
83 |
+
|
84 |
= 1.1 =
|
85 |
* added multisite support
|
86 |
* fixed some parse url bugs
|
qtranslate-slug.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: qTranslate slug
|
4 |
Plugin URI: http://not-only-code.github.com/qtranslate-slug/
|
5 |
Description: Allows to define a slug for each language and some qTranslate bug fixes
|
6 |
-
Version: 1.1
|
7 |
Author: Carlos Sanz Garcia
|
8 |
Author URI: http://github.com/not-only-code
|
9 |
*/
|
@@ -30,6 +30,8 @@ function _debug( $message ) {
|
|
30 |
endif;
|
31 |
////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
|
|
|
|
33 |
|
34 |
/**
|
35 |
* QtranslateSlugWidget class
|
@@ -367,7 +369,6 @@ class QtranslateSlug {
|
|
367 |
echo "<p><strong>Qtranslate Slug:</strong></p>" . PHP_EOL;
|
368 |
echo "<p>" . __('This plugin requires at least <strong>Wordpress 3.3</strong> and <strong>Qtranslate(2.5.8 or newer)</strong>', 'qts') . "</p>" . PHP_EOL;
|
369 |
echo "</div>" . PHP_EOL;
|
370 |
-
|
371 |
}
|
372 |
|
373 |
|
@@ -615,10 +616,13 @@ class QtranslateSlug {
|
|
615 |
|
616 |
if ( empty($this->permalink_structure) || $q_config['url_mode'] == 1 )
|
617 |
$base_args['lang'] = $this->get_lang();
|
618 |
-
|
619 |
// rebulid query with all args
|
620 |
$url = add_query_arg($base_args, $url);
|
621 |
-
|
|
|
|
|
|
|
622 |
return $url;
|
623 |
}
|
624 |
|
@@ -756,7 +760,7 @@ class QtranslateSlug {
|
|
756 |
}
|
757 |
}
|
758 |
|
759 |
-
return $wp->public_query_vars;
|
760 |
}
|
761 |
|
762 |
|
@@ -1293,16 +1297,18 @@ class QtranslateSlug {
|
|
1293 |
public function _get_page_link( $link, $id ) {
|
1294 |
global $post, $wp_rewrite, $q_config;
|
1295 |
|
|
|
|
|
1296 |
if ( !$id )
|
1297 |
$id = (int) $post->ID;
|
1298 |
else
|
1299 |
-
$
|
1300 |
|
1301 |
-
$draft_or_pending = in_array( $
|
1302 |
|
1303 |
$link = $wp_rewrite->get_page_permastruct();
|
1304 |
|
1305 |
-
if ( !empty($link) && ( isset($
|
1306 |
|
1307 |
$link = str_replace('%pagename%', $this->get_page_uri($id), $link);
|
1308 |
|
@@ -1842,27 +1848,38 @@ class QtranslateSlug {
|
|
1842 |
public function unique_term_slug($slug, $term, $lang) {
|
1843 |
global $wpdb;
|
1844 |
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1866 |
}
|
1867 |
|
1868 |
|
@@ -2229,10 +2246,12 @@ add_action('plugins_loaded', array($qtranslate_slug, 'init') );
|
|
2229 |
|
2230 |
/**
|
2231 |
* Language Selector Code for templating
|
2232 |
-
*
|
|
|
|
|
2233 |
* @since 1.0
|
2234 |
*/
|
2235 |
-
function qts_language_menu($type = "text", $args = array()) {
|
2236 |
global $qtranslate_slug;
|
2237 |
|
2238 |
$qtranslate_slug->language_menu($type, $args);
|
@@ -2240,6 +2259,21 @@ function qts_language_menu($type = "text", $args = array()) {
|
|
2240 |
|
2241 |
|
2242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2243 |
/**
|
2244 |
* Add a "Settings" link to the plugins.php page for Qtranslate Slug
|
2245 |
*
|
3 |
Plugin Name: qTranslate slug
|
4 |
Plugin URI: http://not-only-code.github.com/qtranslate-slug/
|
5 |
Description: Allows to define a slug for each language and some qTranslate bug fixes
|
6 |
+
Version: 1.1.5
|
7 |
Author: Carlos Sanz Garcia
|
8 |
Author URI: http://github.com/not-only-code
|
9 |
*/
|
30 |
endif;
|
31 |
////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
33 |
+
// testing push from cloned repo
|
34 |
+
|
35 |
|
36 |
/**
|
37 |
* QtranslateSlugWidget class
|
369 |
echo "<p><strong>Qtranslate Slug:</strong></p>" . PHP_EOL;
|
370 |
echo "<p>" . __('This plugin requires at least <strong>Wordpress 3.3</strong> and <strong>Qtranslate(2.5.8 or newer)</strong>', 'qts') . "</p>" . PHP_EOL;
|
371 |
echo "</div>" . PHP_EOL;
|
|
|
372 |
}
|
373 |
|
374 |
|
616 |
|
617 |
if ( empty($this->permalink_structure) || $q_config['url_mode'] == 1 )
|
618 |
$base_args['lang'] = $this->get_lang();
|
619 |
+
|
620 |
// rebulid query with all args
|
621 |
$url = add_query_arg($base_args, $url);
|
622 |
+
|
623 |
+
$url = str_replace('/?', '?', $url); // hack: improve this code
|
624 |
+
$url = str_replace('?', '/?', $url); // hack: improve this code
|
625 |
+
|
626 |
return $url;
|
627 |
}
|
628 |
|
760 |
}
|
761 |
}
|
762 |
|
763 |
+
return count(array_diff($query_vars, $wp->public_query_vars)) > 0 ? $query_vars : $wp->public_query_vars;
|
764 |
}
|
765 |
|
766 |
|
1297 |
public function _get_page_link( $link, $id ) {
|
1298 |
global $post, $wp_rewrite, $q_config;
|
1299 |
|
1300 |
+
$current_post = $post;
|
1301 |
+
|
1302 |
if ( !$id )
|
1303 |
$id = (int) $post->ID;
|
1304 |
else
|
1305 |
+
$current_post = &get_post($id);
|
1306 |
|
1307 |
+
$draft_or_pending = in_array( $current_post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
|
1308 |
|
1309 |
$link = $wp_rewrite->get_page_permastruct();
|
1310 |
|
1311 |
+
if ( !empty($link) && ( isset($current_post->post_status) && !$draft_or_pending ) ) {
|
1312 |
|
1313 |
$link = str_replace('%pagename%', $this->get_page_uri($id), $link);
|
1314 |
|
1848 |
public function unique_term_slug($slug, $term, $lang) {
|
1849 |
global $wpdb;
|
1850 |
|
1851 |
+
$meta_key_name = $this->get_meta_key($lang);
|
1852 |
+
$query = $wpdb->prepare("SELECT term_id FROM $wpdb->termmeta WHERE meta_key = '%s' AND meta_value = '%s' AND term_id != %d ",
|
1853 |
+
$meta_key_name,
|
1854 |
+
$slug,
|
1855 |
+
$term->term_id);
|
1856 |
+
$exists_slug = $wpdb->get_results($query);
|
1857 |
+
|
1858 |
+
if ( empty($exists_slug) )
|
1859 |
+
return $slug;
|
1860 |
+
|
1861 |
+
// If we didn't get a unique slug, try appending a number to make it unique.
|
1862 |
+
$query = $wpdb->prepare(
|
1863 |
+
"SELECT meta_value FROM $wpdb->termmeta WHERE meta_key = '%s' AND meta_value = '%s' AND term_id != %d",
|
1864 |
+
$meta_key_name,
|
1865 |
+
$slug,
|
1866 |
+
$term->term_id);
|
1867 |
+
|
1868 |
+
if ( $wpdb->get_var( $query ) ) {
|
1869 |
+
$num = 2;
|
1870 |
+
do {
|
1871 |
+
$alt_slug = $slug . "-$num";
|
1872 |
+
$num++;
|
1873 |
+
$slug_check = $wpdb->get_var(
|
1874 |
+
$wpdb->prepare(
|
1875 |
+
"SELECT meta_value FROM $wpdb->termmeta WHERE meta_key = '%s' AND meta_value = '%s'",
|
1876 |
+
$meta_key_name,
|
1877 |
+
$alt_slug) );
|
1878 |
+
} while ( $slug_check );
|
1879 |
+
$slug = $alt_slug;
|
1880 |
+
}
|
1881 |
+
|
1882 |
+
return $slug;
|
1883 |
}
|
1884 |
|
1885 |
|
2246 |
|
2247 |
/**
|
2248 |
* Language Selector Code for templating
|
2249 |
+
*
|
2250 |
+
* @package Qtranslate Slug
|
2251 |
+
* @subpackage Core
|
2252 |
* @since 1.0
|
2253 |
*/
|
2254 |
+
function qts_language_menu ($type = "text", $args = array()) {
|
2255 |
global $qtranslate_slug;
|
2256 |
|
2257 |
$qtranslate_slug->language_menu($type, $args);
|
2259 |
|
2260 |
|
2261 |
|
2262 |
+
/**
|
2263 |
+
* Adds support for old plugin function
|
2264 |
+
*
|
2265 |
+
* @package Qtranslate Slug
|
2266 |
+
* @subpackage Core
|
2267 |
+
* @since 1.1.5
|
2268 |
+
*/
|
2269 |
+
function qTranslateSlug_getSelfUrl ($lang = false) {
|
2270 |
+
global $qtranslate_slug;
|
2271 |
+
|
2272 |
+
return $qtranslate_slug->get_current_url($lang);
|
2273 |
+
}
|
2274 |
+
|
2275 |
+
|
2276 |
+
|
2277 |
/**
|
2278 |
* Add a "Settings" link to the plugins.php page for Qtranslate Slug
|
2279 |
*
|
termmeta-core.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
/**
|
3 |
* Install Term meta table - setup table, store db version for future updates
|
4 |
*/
|
|
|
5 |
function install_term_meta_table() {
|
6 |
global $wpdb;
|
7 |
|
@@ -19,6 +20,7 @@ function install_term_meta_table() {
|
|
19 |
PRIMARY KEY id (`meta_id`)) $collate;";
|
20 |
$wpdb->query($sql);
|
21 |
}
|
|
|
22 |
|
23 |
|
24 |
|
@@ -28,6 +30,8 @@ function simple_post_meta_define_table() {
|
|
28 |
}
|
29 |
add_action( 'init', 'simple_post_meta_define_table' );
|
30 |
|
|
|
|
|
31 |
/**
|
32 |
* Updates metadata cache for list of term IDs.
|
33 |
*
|
@@ -38,9 +42,11 @@ add_action( 'init', 'simple_post_meta_define_table' );
|
|
38 |
* @param array $term_ids List of post IDs.
|
39 |
* @return bool|array Returns false if there is nothing to update or an array of metadata.
|
40 |
*/
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
|
46 |
|
@@ -53,9 +59,11 @@ function update_termmeta_cache($term_ids) {
|
|
53 |
* @param bool $unique Optional, default is false. Whether the same key should not be added.
|
54 |
* @return bool False for failure. True for success.
|
55 |
*/
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
59 |
|
60 |
|
61 |
|
@@ -71,9 +79,11 @@ function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
|
|
71 |
* @param mixed $meta_value Optional. Metadata value.
|
72 |
* @return bool False for failure. True for success.
|
73 |
*/
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
77 |
|
78 |
|
79 |
|
@@ -86,9 +96,11 @@ function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
|
|
86 |
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single
|
87 |
* is true.
|
88 |
*/
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
92 |
|
93 |
|
94 |
|
@@ -106,10 +118,11 @@ function get_term_meta( $term_id, $key, $single = false ) {
|
|
106 |
* @param mixed $prev_value Optional. Previous value to check before removing.
|
107 |
* @return bool False on failure, true if success.
|
108 |
*/
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
}
|
|
|
113 |
|
114 |
|
115 |
|
@@ -119,24 +132,26 @@ function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' )
|
|
119 |
* @param string $term_meta_key Key to search for when deleting.
|
120 |
* @return bool Whether the term meta key was deleted from the database
|
121 |
*/
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
return false;
|
125 |
-
|
126 |
-
global $wpdb;
|
127 |
-
$term_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT term_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key));
|
128 |
-
if ( $term_ids ) {
|
129 |
-
$termmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key ) );
|
130 |
-
$in = implode( ',', array_fill(1, count($termmetaids), '%d'));
|
131 |
-
do_action( 'delete_termmeta', $termmetaids );
|
132 |
-
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->termmeta WHERE meta_id IN($in)", $termmetaids ));
|
133 |
-
do_action( 'deleted_termmeta', $termmetaids );
|
134 |
-
foreach ( $term_ids as $term_id )
|
135 |
-
wp_cache_delete($term_id, 'term_meta');
|
136 |
-
return true;
|
137 |
}
|
138 |
-
|
139 |
-
}
|
140 |
|
141 |
|
142 |
|
@@ -150,14 +165,16 @@ function delete_term_meta_by_key($term_meta_key) {
|
|
150 |
* @param int $term_id term ID
|
151 |
* @return array
|
152 |
*/
|
153 |
-
|
154 |
-
$term_id
|
|
|
155 |
|
156 |
-
|
157 |
-
|
158 |
|
159 |
-
|
160 |
-
}
|
|
|
161 |
|
162 |
|
163 |
|
@@ -169,15 +186,17 @@ function get_term_custom( $term_id ) {
|
|
169 |
* @param int $term_id term ID
|
170 |
* @return array|null Either array of the keys, or null if keys could not be retrieved.
|
171 |
*/
|
172 |
-
|
173 |
-
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
}
|
|
|
181 |
|
182 |
|
183 |
|
@@ -191,11 +210,13 @@ function get_term_custom_keys( $term_id ) {
|
|
191 |
* @param int $term_id Term ID
|
192 |
* @return array Meta field values.
|
193 |
*/
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
197 |
|
198 |
-
|
199 |
|
200 |
-
|
201 |
-
}
|
|
2 |
/**
|
3 |
* Install Term meta table - setup table, store db version for future updates
|
4 |
*/
|
5 |
+
if ( !function_exists('install_term_meta_table') ):
|
6 |
function install_term_meta_table() {
|
7 |
global $wpdb;
|
8 |
|
20 |
PRIMARY KEY id (`meta_id`)) $collate;";
|
21 |
$wpdb->query($sql);
|
22 |
}
|
23 |
+
endif;
|
24 |
|
25 |
|
26 |
|
30 |
}
|
31 |
add_action( 'init', 'simple_post_meta_define_table' );
|
32 |
|
33 |
+
|
34 |
+
|
35 |
/**
|
36 |
* Updates metadata cache for list of term IDs.
|
37 |
*
|
42 |
* @param array $term_ids List of post IDs.
|
43 |
* @return bool|array Returns false if there is nothing to update or an array of metadata.
|
44 |
*/
|
45 |
+
if ( !function_exists('update_termmeta_cache') ):
|
46 |
+
function update_termmeta_cache($term_ids) {
|
47 |
+
return update_meta_cache('term', $term_ids);
|
48 |
+
}
|
49 |
+
endif;
|
50 |
|
51 |
|
52 |
|
59 |
* @param bool $unique Optional, default is false. Whether the same key should not be added.
|
60 |
* @return bool False for failure. True for success.
|
61 |
*/
|
62 |
+
if ( !function_exists('add_term_meta') ):
|
63 |
+
function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
|
64 |
+
return add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
|
65 |
+
}
|
66 |
+
endif;
|
67 |
|
68 |
|
69 |
|
79 |
* @param mixed $meta_value Optional. Metadata value.
|
80 |
* @return bool False for failure. True for success.
|
81 |
*/
|
82 |
+
if ( !function_exists('delete_term_meta') ):
|
83 |
+
function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
|
84 |
+
return delete_metadata('term', $term_id, $meta_key, $meta_value);
|
85 |
+
}
|
86 |
+
endif;
|
87 |
|
88 |
|
89 |
|
96 |
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single
|
97 |
* is true.
|
98 |
*/
|
99 |
+
if ( !function_exists('get_term_meta') ):
|
100 |
+
function get_term_meta( $term_id, $key, $single = false ) {
|
101 |
+
return get_metadata('term', $term_id, $key, $single);
|
102 |
+
}
|
103 |
+
endif;
|
104 |
|
105 |
|
106 |
|
118 |
* @param mixed $prev_value Optional. Previous value to check before removing.
|
119 |
* @return bool False on failure, true if success.
|
120 |
*/
|
121 |
+
if ( !function_exists('update_term_meta') ):
|
122 |
+
function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) {
|
123 |
+
return update_metadata('term', $term_id, $meta_key, $meta_value, $prev_value);
|
124 |
+
}
|
125 |
+
endif;
|
126 |
|
127 |
|
128 |
|
132 |
* @param string $term_meta_key Key to search for when deleting.
|
133 |
* @return bool Whether the term meta key was deleted from the database
|
134 |
*/
|
135 |
+
if ( !function_exists('delete_term_meta_by_key') ):
|
136 |
+
function delete_term_meta_by_key($term_meta_key) {
|
137 |
+
if ( !$term_meta_key )
|
138 |
+
return false;
|
139 |
+
|
140 |
+
global $wpdb;
|
141 |
+
$term_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT term_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key));
|
142 |
+
if ( $term_ids ) {
|
143 |
+
$termmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key ) );
|
144 |
+
$in = implode( ',', array_fill(1, count($termmetaids), '%d'));
|
145 |
+
do_action( 'delete_termmeta', $termmetaids );
|
146 |
+
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->termmeta WHERE meta_id IN($in)", $termmetaids ));
|
147 |
+
do_action( 'deleted_termmeta', $termmetaids );
|
148 |
+
foreach ( $term_ids as $term_id )
|
149 |
+
wp_cache_delete($term_id, 'term_meta');
|
150 |
+
return true;
|
151 |
+
}
|
152 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
+
endif;
|
|
|
155 |
|
156 |
|
157 |
|
165 |
* @param int $term_id term ID
|
166 |
* @return array
|
167 |
*/
|
168 |
+
if ( !function_exists('add_term_meta') ):
|
169 |
+
function get_term_custom( $term_id ) {
|
170 |
+
$term_id = (int) $term_id;
|
171 |
|
172 |
+
if ( ! wp_cache_get($term_id, 'term_meta') )
|
173 |
+
update_termmeta_cache($term_id);
|
174 |
|
175 |
+
return wp_cache_get($term_id, 'term_meta');
|
176 |
+
}
|
177 |
+
endif;
|
178 |
|
179 |
|
180 |
|
186 |
* @param int $term_id term ID
|
187 |
* @return array|null Either array of the keys, or null if keys could not be retrieved.
|
188 |
*/
|
189 |
+
if ( !function_exists('get_term_custom_keys') ):
|
190 |
+
function get_term_custom_keys( $term_id ) {
|
191 |
+
$custom = get_term_custom( $term_id );
|
192 |
|
193 |
+
if ( !is_array($custom) )
|
194 |
+
return;
|
195 |
|
196 |
+
if ( $keys = array_keys($custom) )
|
197 |
+
return $keys;
|
198 |
+
}
|
199 |
+
endif;
|
200 |
|
201 |
|
202 |
|
210 |
* @param int $term_id Term ID
|
211 |
* @return array Meta field values.
|
212 |
*/
|
213 |
+
if ( !function_exists('get_term_custom_values') ):
|
214 |
+
function get_term_custom_values( $key = '', $term_id ) {
|
215 |
+
if ( !$key )
|
216 |
+
return null;
|
217 |
|
218 |
+
$custom = get_term_custom($term_id);
|
219 |
|
220 |
+
return isset($custom[$key]) ? $custom[$key] : null;
|
221 |
+
}
|
222 |
+
endif;
|