PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.40
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.40
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / app / Functions / helpers.php

helpers.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.40, at app/Functions/helpers.php

207 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 'recurring_task' => [
91 'enabled' => 'no',
92 'all_boards' => 'yes',
93 'selected_boards' => []
94 ],
95 ];
96
97 $storedSettings = get_option('fluent_boards_modules', []);
98 if ($storedSettings && is_array($storedSettings)) {
99 $settings = wp_parse_args($storedSettings, $settings);
100 }
101
102 $pref = $settings;
103
104 return $settings;
105 }
106
107 if (!function_exists('fluent_boards_site_logo')) {
108 function fluent_boards_site_logo()
109 {
110 $logo_url = '';
111 if (function_exists('get_custom_logo') && has_custom_logo()) {
112 $custom_logo_id = get_theme_mod('custom_logo');
113 $logo = wp_get_attachment_image_src($custom_logo_id, 'full');
114 if ($logo) {
115 $logo_url = $logo[0];
116 }
117 }
118 return apply_filters('fluent_boards/site_logo', $logo_url);
119 }
120 }
121
122 function fluent_boards_get_option($key, $default = null)
123 {
124 $exit = \FluentBoards\App\Models\Meta::where('object_type', 'option')
125 ->where('key', $key)
126 ->first();
127
128 if ($exit) {
129 return $exit->value;
130 }
131
132 return $default;
133 }
134
135 function fluent_boards_update_option($key, $value)
136 {
137 $exit = \FluentBoards\App\Models\Meta::where('object_type', 'option')
138 ->where('key', $key)
139 ->first();
140
141 if ($exit) {
142 $exit->value = $value;
143 $exit->save();
144 } else {
145 $exit = \FluentBoards\App\Models\Meta::create([
146 'object_type' => 'option',
147 'key' => $key,
148 'value' => $value
149 ]);
150 }
151
152 return $exit;
153 }
154
155
156 function fluentBoardsDb()
157 {
158 return fluentBoards('db');
159 }
160
161
162 function fbsGetFeaturesConfig()
163 {
164 $features = fluent_boards_get_option('_fbs_features', []);
165
166 $defaults = [
167 'cloud_storage' => 'no',
168 // more advanced features/config can be added here
169 ];
170
171 if (defined('FLUENT_BOARDS_CLOUD_STORAGE') && FLUENT_BOARDS_CLOUD_STORAGE) {
172 $features['cloud_storage'] = 'yes';
173 }
174
175 return wp_parse_args($features, $defaults);
176 }
177
178 function fbsGetOption($key, $default = null)
179 {
180 return fluent_boards_get_option($key, $default);
181 }
182
183 function fbsUpdateOption($key, $value)
184 {
185 return fluent_boards_update_option($key, $value);
186 }
187
188 function fluentboardsCsvMimes()
189 {
190 /**
191 * Board Import CSV Mimes
192 *
193 * @return array array of CSV mimes
194 */
195 return apply_filters('fluenboards_csv_mimes', [
196 'text/csv',
197 'text/plain',
198 'application/csv',
199 'text/comma-separated-values',
200 'application/excel',
201 'application/vnd.ms-excel',
202 'application/vnd.msexcel',
203 'text/anytext',
204 'application/octet-stream',
205 'application/txt'
206 ]);
207 }