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 / vendor / codestar-framework / fields / link / link.php

link.php in StreamCast – bring live radio to your site with a sleek player trunk, at vendor/codestar-framework/fields/link/link.php

83 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: link
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'STREAMCAST_STREAMCAST_CSF_Field_link' ) ) {
11 class STREAMCAST_STREAMCAST_CSF_Field_link extends STREAMCAST_STREAMCAST_CSF_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $args = wp_parse_args( $this->field, array(
20 'add_title' => esc_html__( 'Add Link', 'streamcast' ),
21 'edit_title' => esc_html__( 'Edit Link', 'streamcast' ),
22 'remove_title' => esc_html__( 'Remove Link', 'streamcast' ),
23 ) );
24
25 $default_values = array(
26 'url' => '',
27 'text' => '',
28 'target' => '',
29 );
30
31 $value = wp_parse_args( $this->value, $default_values );
32
33 $hidden = ( ! empty( $value['url'] ) || ! empty( $value['url'] ) || ! empty( $value['url'] ) ) ? ' hidden' : '';
34
35 $maybe_hidden = ( empty( $hidden ) ) ? ' hidden' : '';
36
37 echo wp_kses_post( $this->field_before() );
38
39 echo '<textarea readonly="readonly" class="streamcast-csf--link hidden"></textarea>';
40
41 echo '<div class="'. esc_attr( $maybe_hidden ) .'"><div class="streamcast-csf--result">'. sprintf( '{url:"%s", text:"%s", target:"%s"}', esc_html( $value['url'] ), esc_html( $value['text'] ), esc_html( $value['target'] ) ) .'</div></div>';
42
43 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[url]' ) ) .'" value="'. esc_attr( $value['url'] ) .'"'. $this->field_attributes( array( 'class' => 'streamcast-csf--url' ) ) .' />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
44 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[text]' ) ) .'" value="'. esc_attr( $value['text'] ) .'" class="streamcast-csf--text" />';
45 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[target]' ) ) .'" value="'. esc_attr( $value['target'] ) .'" class="streamcast-csf--target" />';
46
47 echo '<a href="#" class="button button-primary streamcast-csf--add'. esc_attr( $hidden ) .'">'. wp_kses_post( $args['add_title'] ) .'</a> ';
48 echo '<a href="#" class="button streamcast-csf--edit'. esc_attr( $maybe_hidden ) .'">'. wp_kses_post( $args['edit_title'] ) .'</a> ';
49 echo '<a href="#" class="button streamcast-csf-warning-primary streamcast-csf--remove'. esc_attr( $maybe_hidden ) .'">'. wp_kses_post( $args['remove_title'] ) .'</a>';
50
51 echo wp_kses_post( $this->field_after() );
52
53 }
54
55 public function enqueue() {
56
57 if ( ! wp_script_is( 'wplink' ) ) {
58 wp_enqueue_script( 'wplink' );
59 }
60
61 if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
62 wp_enqueue_script( 'jquery-ui-autocomplete' );
63 }
64
65 add_action( 'admin_print_footer_scripts', array( $this, 'add_wp_link_dialog' ) );
66
67 }
68
69 public function add_wp_link_dialog() {
70
71 if ( ! class_exists( '_WP_Editors' ) ) {
72 require_once ABSPATH . WPINC .'/class-wp-editor.php';
73 }
74
75 wp_print_styles( 'editor-buttons' );
76
77 _WP_Editors::wp_link_dialog();
78
79 }
80
81 }
82 }
83