PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / trunk
Timetics – Appointment Booking Calendar & Scheduling vtrunk
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / core / addon / extension-icon.php

extension-icon.php in Timetics – Appointment Booking Calendar & Scheduling trunk, at core/addon/extension-icon.php

54 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Extension Icon class
4 *
5 * @package Timetics
6 */
7
8 namespace Timetics\Core\Addon;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Class Extension_Icon
14 *
15 * Loads SVG/PNG icons for Arraytics plugins from assets/images/addons/.
16 */
17 class Extension_Icon {
18
19 /**
20 * Get the icon for a given plugin by name.
21 *
22 * Returns raw SVG markup for .svg files, or a URL string for image files.
23 *
24 * @param string $name Plugin/extension slug (e.g. 'eventin').
25 * @return string SVG markup or image URL, empty string if not found.
26 */
27 public static function get( string $name ): string {
28 return self::load( $name );
29 }
30
31 /**
32 * Load icon file from assets/images/addons/.
33 *
34 * @param string $file_name File name without extension.
35 * @return string
36 */
37 private static function load( string $file_name ): string {
38 $extensions = [ 'svg', 'png', 'webp', 'jpg' ];
39 $base_path = TIMETICS_PLUGIN_DIR . 'assets/images/addons/';
40 $base_url = TIMETICS_ASSETS_URL . 'images/addons/';
41
42 foreach ( $extensions as $ext ) {
43 $file = $base_path . $file_name . '.' . $ext;
44 if ( file_exists( $file ) ) {
45 return 'svg' === $ext
46 ? file_get_contents( $file ) // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
47 : $base_url . $file_name . '.' . $ext;
48 }
49 }
50
51 return '';
52 }
53 }
54