| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Tag Groups Pro |
| 5 |
* |
| 6 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 7 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 8 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 9 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 10 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 11 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 12 |
* THE SOFTWARE. |
| 13 |
* @package Tag Groups Pro |
| 14 |
* |
| 15 |
* @author Christoph Amthor |
| 16 |
* @copyright 2019 Christoph Amthor (@ Chatty Mango, chattymango.com) |
| 17 |
* @license see official vendor website |
| 18 |
* |
| 19 |
* @since 1.19.0 |
| 20 |
*/ |
| 21 |
|
| 22 |
/** |
| 23 |
* Aliases for backwards compatibility and convenience |
| 24 |
* |
| 25 |
*/ |
| 26 |
if (!function_exists('tag_groups_cloud') && class_exists('TagGroups_Shortcode_Tabs')) { |
| 27 |
/** |
| 28 |
* |
| 29 |
* Wrapper for the static method tag_groups_cloud |
| 30 |
* |
| 31 |
* @param array $atts |
| 32 |
* @param bool $return_array |
| 33 |
* @return string |
| 34 |
*/ |
| 35 |
function tag_groups_cloud($atts = array(), $return_array = false) |
| 36 |
{ |
| 37 |
return ( new TagGroups_Shortcode_Tabs() )->tag_groups_cloud($atts, $return_array); |
| 38 |
} |
| 39 |
|
| 40 |
} |
| 41 |
if (!function_exists('tag_groups_accordion') && class_exists('TagGroups_Shortcode_Accordion')) { |
| 42 |
/** |
| 43 |
* |
| 44 |
* Wrapper for the static method tag_groups_accordion |
| 45 |
* |
| 46 |
* @param array $atts |
| 47 |
* @return string |
| 48 |
*/ |
| 49 |
function tag_groups_accordion($atts = array()) |
| 50 |
{ |
| 51 |
return ( new TagGroups_Shortcode_Accordion() )->tag_groups_accordion($atts); |
| 52 |
} |
| 53 |
|
| 54 |
} |
| 55 |
if (!function_exists('post_in_tag_group')) { |
| 56 |
/** |
| 57 |
* Checks if the post with $post_id has a tag that is in the tag group with $tag_group_id. |
| 58 |
* |
| 59 |
* @param int $post_id |
| 60 |
* @param int $tag_group_id |
| 61 |
* @return boolean |
| 62 |
*/ |
| 63 |
function post_in_tag_group($post_id, $tag_group_id) |
| 64 |
{ |
| 65 |
$tag_group_taxonomies = TagGroups_Taxonomy::get_enabled_taxonomies(); |
| 66 |
$tags = array(); |
| 67 |
foreach ($tag_group_taxonomies as $tag_group_taxonomy) { |
| 68 |
$tags_tax = get_the_terms($post_id, $tag_group_taxonomy); |
| 69 |
|
| 70 |
if (is_array($tags_tax)) { |
| 71 |
$tags = array_merge($tags, $tags_tax); |
| 72 |
} elseif (false === $tags_tax) { |
| 73 |
return false; |
| 74 |
} |
| 75 |
} |
| 76 |
if ($tags) { |
| 77 |
foreach ($tags as $tag) { |
| 78 |
$tg_term = new TagGroups_Term($tag); |
| 79 |
if ($tg_term->has_group($tag_group_id)) { |
| 80 |
return true; |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
return false; |
| 85 |
} |
| 86 |
|
| 87 |
} |
| 88 |
|