PluginProbe
StreamCast – bring live radio to your site with a sleek player / trunk
StreamCast – bring live radio to your site with a sleek player vtrunk
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / inc / class-streamcast-functions.php

class-streamcast-functions.php in StreamCast – bring live radio to your site with a sleek player trunk, at inc/class-streamcast-functions.php

116 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace StreamCast;
3
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 class Functions {
7 public static function get_meta( $id, $key, $default = null ) {
8 $value = get_post_meta( $id, $key, true );
9 return $value ?: $default;
10 }
11
12 /**
13 * The padlock used by every locked-feature list -- the side column's Pro tuner
14 * and the in-form locked bank. Inherits currentColor, so each caller sets the
15 * tone from its own surface.
16 */
17 public static function lock_icon() {
18 return '<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" aria-hidden="true" focusable="false"><rect x="4" y="11" width="16" height="10" rx="1.5"></rect><path d="M8 11V7a4 4 0 0 1 8 0v4"></path></svg>';
19 }
20
21 /**
22 * One destination for every "what does Pro unlock" link on the screen. Two links
23 * carrying the same label must not land in two different places.
24 */
25 public static function pro_url() {
26 if ( function_exists( 'str_fs' ) ) {
27 return str_fs()->get_upgrade_url();
28 }
29
30 return admin_url( 'edit.php?post_type=streamcast&page=streamcast#/pricing' );
31 }
32
33 /**
34 * The shut marquee: how many settings this player type cannot reach, named.
35 *
36 * Three panels across a full-width blue field -- the count as a large amber
37 * numeral, the headline and the setting names as chips, and the call to action.
38 * The amber is the same #FFD166 as the side column's tuner needle, the only warm
39 * colour in the palette, which is what makes the numeral carry at a glance
40 * without introducing a second accent.
41 *
42 * The vertical pinstripe behind it is the tuner dial's tick rhythm reused as
43 * texture, so the panel reads as the same instrument at a different scale.
44 *
45 * Descriptions are not printed -- they ride along as chip tooltips, since the
46 * marquee trades detail for reach.
47 *
48 * @param array $features List of ['name' => string, 'desc' => string].
49 * @return string
50 */
51 public static function shut_marquee( $features ) {
52 if ( empty( $features ) || ! is_array( $features ) ) {
53 return '';
54 }
55
56 $lock = self::lock_icon();
57 $chips = '';
58 $count = 0;
59
60 foreach ( $features as $feature ) {
61 $name = isset( $feature['name'] ) ? $feature['name'] : '';
62
63 if ( '' === $name ) {
64 continue;
65 }
66
67 $desc = isset( $feature['desc'] ) ? $feature['desc'] : '';
68 $title = '' !== $desc ? ' title="' . esc_attr( $desc ) . '"' : '';
69 $chips .= '<span' . $title . '>' . $lock . esc_html( $name ) . '</span>';
70 $count++;
71 }
72
73 if ( 0 === $count ) {
74 return '';
75 }
76
77 return '<div class="streamcast-marquee">'
78 . '<div class="streamcast-marquee__count">'
79 . '<b>' . esc_html( str_pad( (string) $count, 2, '0', STR_PAD_LEFT ) ) . '</b>'
80 . '<span>' . esc_html( _n( 'Setting shut', 'Settings shut', $count, 'streamcast' ) ) . '</span>'
81 . '</div>'
82 . '<div class="streamcast-marquee__body">'
83 . '<div class="streamcast-marquee__hl">'
84 . esc_html(
85 sprintf(
86 /* translators: %d: number of settings unavailable in the free version. */
87 _n(
88 '%d switch on this screen is shut.',
89 '%d switches on this screen are shut.',
90 $count,
91 'streamcast'
92 ),
93 $count
94 )
95 )
96 . '</div>'
97 . '<div class="streamcast-marquee__chips">' . $chips . '</div>'
98 . '</div>'
99 . '<div class="streamcast-marquee__cta">'
100 . '<a href="' . esc_url( self::pro_url() ) . '" target="_blank" rel="noopener">'
101 . esc_html__( 'See what Pro unlocks', 'streamcast' )
102 . '<em>' . esc_html__( '14-day refund', 'streamcast' ) . '</em>'
103 . '</a>'
104 . '</div>'
105 . '</div>';
106 }
107
108 }
109
110 // Global wrapper for convenience and backward compatibility
111 if ( ! function_exists( 'streamcast_get_meta' ) ) {
112 function streamcast_get_meta( $id, $key, $default = null ) {
113 return \StreamCast\Functions::get_meta( $id, $key, $default );
114 }
115 }
116