PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / codestar-framework / fields / link / link.php

link.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/codestar-framework/fields/link/link.php

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