PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.1
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.1
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / admin / ta-framework / fields / link / link.php

link.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.1, at admin/ta-framework/fields/link/link.php

82 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * Field: link
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DRK_LITE_Field_link' ) ) {
11 class DRK_LITE_Field_link extends DRK_LITE_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(
20 $this->field,
21 array(
22 'add_title' => esc_html__( 'Add Link', 'darkify' ),
23 'edit_title' => esc_html__( 'Edit Link', 'darkify' ),
24 'remove_title' => esc_html__( 'Remove Link', 'darkify' ),
25 )
26 );
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 wp_kses_post( $this->field_before() );
41
42 echo '<textarea readonly="readonly" class="drk_lite--link hidden"></textarea>';
43
44 echo '<div class="' . esc_attr( $maybe_hidden ) . '"><div class="drk_lite--result">' . sprintf( '{url:"%s", text:"%s", target:"%s"}', esc_url($value['url']), esc_html($value['text']), esc_attr($value['target']) ) . '</div></div>';
45
46 echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[url]' ) ) . '" value="' . esc_attr( $value['url'] ) . '"' . wp_kses_post($this->field_attributes( array( 'class' => 'drk_lite--url' ) )) . ' />';
47 echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[text]' ) ) . '" value="' . esc_attr( $value['text'] ) . '" class="drk_lite--text" />';
48 echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[target]' ) ) . '" value="' . esc_attr( $value['target'] ) . '" class="drk_lite--target" />';
49
50 echo '<a href="#" class="button button-primary drk_lite--add' . esc_attr( $hidden ) . '">' . esc_html($args['add_title']) . '</a> ';
51 echo '<a href="#" class="button drk_lite--edit' . esc_attr( $maybe_hidden ) . '">' . esc_html($args['edit_title']) . '</a> ';
52 echo '<a href="#" class="button drk_lite-warning-primary drk_lite--remove' . esc_attr( $maybe_hidden ) . '">' . esc_html( $args['remove_title'] ) . '</a>';
53
54 echo wp_kses_post( $this->field_after() );
55 }
56
57 public function enqueue() {
58
59 if ( ! wp_script_is( 'wplink' ) ) {
60 wp_enqueue_script( 'wplink' );
61 }
62
63 if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
64 wp_enqueue_script( 'jquery-ui-autocomplete' );
65 }
66
67 add_action( 'admin_print_footer_scripts', array( $this, 'add_wp_link_dialog' ) );
68 }
69
70 public function add_wp_link_dialog() {
71
72 if ( ! class_exists( '_WP_Editors' ) ) {
73 require_once ABSPATH . WPINC . '/class-wp-editor.php';
74 }
75
76 wp_print_styles( 'editor-buttons' );
77
78 _WP_Editors::wp_link_dialog();
79 }
80 }
81 }
82