| 1 |
<?php |
| 2 |
|
| 3 |
use FluentBoards\App\App; |
| 4 |
|
| 5 |
// $app is available |
| 6 |
|
| 7 |
if (!function_exists('fluentBoards')) { |
| 8 |
function fluentBoards($module = null) |
| 9 |
{ |
| 10 |
return App::getInstance($module); |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
if (!function_exists('FluentBoardsApi')) { |
| 15 |
function FluentBoardsApi($key = null) |
| 16 |
{ |
| 17 |
$api = fluentBoards('api'); |
| 18 |
return is_null($key) ? $api : $api->{$key}; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
if (!function_exists('fluent_boards_user_avatar')) { |
| 23 |
function fluent_boards_user_avatar($email, $name = '') |
| 24 |
{ |
| 25 |
$hash = md5(strtolower(trim($email))); |
| 26 |
/** |
| 27 |
* Gravatar URL by Email |
| 28 |
* |
| 29 |
* @return string $gravatar url of the gravatar image |
| 30 |
*/ |
| 31 |
$fallback = ''; |
| 32 |
if ($name) { |
| 33 |
$fallback = '&d=https%3A%2F%2Fui-avatars.com%2Fapi%2F' . urlencode($name) . '/128'; |
| 34 |
} |
| 35 |
|
| 36 |
return apply_filters('fluent_boards/get_avatar', |
| 37 |
"https://www.gravatar.com/avatar/{$hash}?s=128" . $fallback, |
| 38 |
$email |
| 39 |
); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
if (!function_exists('fluent_boards_mix')) { |
| 44 |
function fluent_boards_mix($path, $manifestDirectory = '') |
| 45 |
{ |
| 46 |
return fluentBoards('url.assets') . ltrim($path, '/'); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
if (!function_exists('FluentBoardsAssetUrl')) { |
| 51 |
function FluentBoardsAssetUrl($path = null) |
| 52 |
{ |
| 53 |
$assetUrl = fluentBoards('url.assets'); |
| 54 |
|
| 55 |
return $path ? ($assetUrl . $path) : $assetUrl; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
if (!function_exists('fluent_boards_page_url')) { |
| 60 |
function fluent_boards_page_url(): ?string |
| 61 |
{ |
| 62 |
return apply_filters('fluent_boards/app_url', admin_url('admin.php?page=fluent-boards#/')); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
function fluent_boards_get_pref_settings($cached = true) |
| 67 |
{ |
| 68 |
static $pref = null; |
| 69 |
|
| 70 |
if ($cached && $pref) { |
| 71 |
return $pref; |
| 72 |
} |
| 73 |
|
| 74 |
$settings = [ |
| 75 |
'timeTracking' => [ |
| 76 |
'enabled' => 'no', |
| 77 |
'all_boards' => 'yes', |
| 78 |
'selected_boards' => [] |
| 79 |
], |
| 80 |
'frontend' => [ |
| 81 |
'enabled' => 'no', |
| 82 |
'slug' => 'projects', |
| 83 |
'render_type' => 'standalone', |
| 84 |
'page_id' => '' |
| 85 |
], |
| 86 |
'menu_settings' => [ |
| 87 |
'in_fluent_crm' => 'no', |
| 88 |
'menu_position' => 3 |
| 89 |
] |
| 90 |
]; |
| 91 |
|
| 92 |
$storedSettings = get_option('fluent_boards_modules', []); |
| 93 |
if ($storedSettings && is_array($storedSettings)) { |
| 94 |
$settings = wp_parse_args($storedSettings, $settings); |
| 95 |
} |
| 96 |
|
| 97 |
$pref = $settings; |
| 98 |
|
| 99 |
return $settings; |
| 100 |
} |
| 101 |
|
| 102 |
if (!function_exists('fluent_boards_site_logo')) { |
| 103 |
function fluent_boards_site_logo() |
| 104 |
{ |
| 105 |
$logo_url = ''; |
| 106 |
if (function_exists('get_custom_logo') && has_custom_logo()) { |
| 107 |
$custom_logo_id = get_theme_mod('custom_logo'); |
| 108 |
$logo = wp_get_attachment_image_src($custom_logo_id, 'full'); |
| 109 |
if ($logo) { |
| 110 |
$logo_url = $logo[0]; |
| 111 |
} |
| 112 |
} |
| 113 |
return apply_filters('fluent_boards/site_logo', $logo_url); |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
function fluent_boards_get_option($key, $default = null) |
| 118 |
{ |
| 119 |
$exit = \FluentBoards\App\Models\Meta::where('object_type', 'option') |
| 120 |
->where('key', $key) |
| 121 |
->first(); |
| 122 |
|
| 123 |
if ($exit) { |
| 124 |
return $exit->value; |
| 125 |
} |
| 126 |
|
| 127 |
return $default; |
| 128 |
} |
| 129 |
|
| 130 |
function fluent_boards_update_option($key, $value) |
| 131 |
{ |
| 132 |
$exit = \FluentBoards\App\Models\Meta::where('object_type', 'option') |
| 133 |
->where('key', $key) |
| 134 |
->first(); |
| 135 |
|
| 136 |
if ($exit) { |
| 137 |
$exit->value = $value; |
| 138 |
$exit->save(); |
| 139 |
} else { |
| 140 |
$exit = \FluentBoards\App\Models\Meta::create([ |
| 141 |
'object_type' => 'option', |
| 142 |
'key' => $key, |
| 143 |
'value' => $value |
| 144 |
]); |
| 145 |
} |
| 146 |
|
| 147 |
return $exit; |
| 148 |
} |
| 149 |
|
| 150 |
|
| 151 |
function fluentBoardsDb() |
| 152 |
{ |
| 153 |
return fluentBoards('db'); |
| 154 |
} |