PluginProbe
Tag Groups is the Advanced Way to Display Your Taxonomy Terms / trunk
Tag Groups is the Advanced Way to Display Your Taxonomy Terms vtrunk
2.2.2 2.2.1 2.2.0 trunk 1.40.0 1.40.2 1.41.0 1.42.1 1.43.0 1.43.1 1.43.10 1.43.10.1 1.43.2 1.43.3 1.43.4 1.43.5 1.43.6 1.43.7 1.43.9 1.44.0 1.44.1 1.44.3 1.44.3.1 2.0.0 2.0.1 All 36 releases
tag-groups / include / helpers / class.utilities.php

class.utilities.php in Tag Groups is the Advanced Way to Display Your Taxonomy Terms trunk, at include/helpers/class.utilities.php

83 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package Tag Groups
5 *
6 * @author Christoph Amthor
7 * @copyright 2018 Christoph Amthor (@ Chatty Mango, chattymango.com)
8 * @license GPL-3.0+
9 */
10
11 // phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps, Squiz.Scope.MethodScope.Missing, PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12 if (! class_exists('TagGroups_Utilities')) {
13 /**
14 *
15 */
16 class TagGroups_Utilities
17 {
18 /**
19 * Returns the first element of an array without changing the original array
20 *
21 * @param array $array
22 * @return mixed
23 */
24 public static function get_first_element($array = array())
25 {
26
27 if (! is_array($array)) {
28 TagGroups_Error::log('[Tag Groups] Parameter supplied to get_first_element() must be an array.');
29 return;
30 }
31
32 return reset($array);
33 }
34
35 public static function is_free_plan()
36 {
37
38 return !self::is_premium_plan();
39 }
40
41 public static function is_premium_plan()
42 {
43
44 return defined('TAG_GROUPS_LOADED_BY_PRO') && TAG_GROUPS_LOADED_BY_PRO
45 || defined('TAG_GROUPS_PRO_FILE')
46 || defined('TAG_GROUPS_PRO_VERSION');
47 }
48
49 /**
50 * Turns a string into a valid JS function name, preserving as much as possible uniqueness
51 *
52 * @since 1.26.1
53 *
54 * @param string $raw
55 * @return string
56 */
57 static function create_js_fn_name($raw)
58 {
59
60 return str_replace('-', '', sanitize_html_class($raw));
61 }
62
63
64 /**
65 * Execute wp_die() or die(), depending whether we are running tests
66 * That way we prevent that other plugins add own output after AJAX responses
67 *
68 * @return void
69 */
70 static function die()
71 {
72
73 if (defined('CM_UNIT_TESTING')) {
74 wp_die();
75 } else {
76 die();
77 }
78 }
79 }
80
81
82 }
83