| @@ -1,35 +1,31 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function acym_addBreadcrumb($title, $link = '') | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | + | |
| 5 | +// Front-end breadcrumb for Joomla | |
| 6 | +function acym_addBreadcrumb(string $title, string $link = ''): void | |
| 4 | 7 | { |
| 5 | 8 | } |
| 6 | 9 | |
| 7 | -function acym_setPageTitle($title) | |
| 10 | +// Page title modification for Joomla | |
| 11 | +function acym_setPageTitle(string $title): void | |
| 8 | 12 | { |
| 9 | 13 | } |
| 10 | 14 | |
| 11 | -function acym_isLeftMenuNecessary() | |
| 15 | +function acym_isLeftMenuNecessary(): bool | |
| 12 | 16 | { |
| 17 | + // Already one in WP | |
| 13 | 18 | return false; |
| 14 | 19 | } |
| 15 | 20 | |
| 16 | -function acym_getLeftMenu($name) | |
| 21 | +function acym_isPluginActive(string $plugin, string $family = 'system'): bool | |
| 17 | 22 | { |
| 18 | - return ''; | |
| 19 | -} | |
| 20 | - | |
| 21 | -function acym_isPluginActive($plugin, $family = 'system') | |
| 22 | -{ | |
| 23 | 23 | return true; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -function acym_menuOnly($link) | |
| 26 | +function acym_disableCmsEditor(): void | |
| 27 | 27 | { |
| 28 | -} | |
| 29 | - | |
| 30 | -function acym_disableCmsEditor() | |
| 31 | -{ | |
| 32 | 28 | add_filter( |
| 33 | 29 | 'user_can_richedit', |
| 34 | 30 | function ($a) { |
| 35 | 31 | return false; |
| @@ -37,9 +33,9 @@ | ||
| 37 | 33 | 50 |
| 38 | 34 | ); |
| 39 | 35 | } |
| 40 | 36 | |
| 41 | -function acym_isElementorEdition() | |
| 37 | +function acym_isElementorEdition(): bool | |
| 42 | 38 | { |
| 43 | 39 | global $post; |
| 44 | 40 | |
| 45 | 41 | if (empty($post) || !class_exists('\\Elementor\\Plugin')) return false; |
| @@ -44,5 +40,29 @@ | ||
| 44 | 40 | |
| 45 | 41 | if (empty($post) || !class_exists('\\Elementor\\Plugin')) return false; |
| 46 | 42 | |
| 47 | 43 | return \Elementor\Plugin::$instance->db->is_built_with_elementor($post->ID); |
| 44 | +} | |
| 45 | + | |
| 46 | +function acym_scheduleTask(array $options, int $taskId = 0): ?int | |
| 47 | +{ | |
| 48 | + if (wp_next_scheduled($options['name'])) { | |
| 49 | + return 1; | |
| 50 | + } | |
| 51 | + | |
| 52 | + return true === wp_schedule_event(time(), $options['taskFrequency'], $options['name']) ? 1 : 0; | |
| 53 | +} | |
| 54 | + | |
| 55 | +function acym_deleteScheduledTask(array $options): bool | |
| 56 | +{ | |
| 57 | + $timestamp = wp_next_scheduled($options['name']); | |
| 58 | + if ($timestamp) { | |
| 59 | + return true === wp_unschedule_event($timestamp, $options['name']); | |
| 60 | + } | |
| 61 | + | |
| 62 | + return true; | |
| 63 | +} | |
| 64 | + | |
| 65 | +function acym_rand(int $min, int $max): int | |
| 66 | +{ | |
| 67 | + return wp_rand($min, $max); | |
| 48 | 68 | } |