PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
← All changes | Libs/adminify-framework/fields/link/link.php +51 -54 4.2.163.2.4.1 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Field: link
5 6 *
@@ -4,79 +5,75 @@
4 5 * Field: link
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'ADMINIFY_Field_link' ) ) {
11 - class ADMINIFY_Field_link extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_link extends ADMINIFY_Fields {
12 12
13 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 - parent::__construct( $field, $value, $unique, $where, $parent );
15 - }
13 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 + parent::__construct( $field, $value, $unique, $where, $parent );
15 + }
16 16
17 - public function render() {
17 + public function render() {
18 + $args = wp_parse_args(
19 + $this->field,
20 + [
21 + 'add_title' => esc_html__( 'Add Link', 'adminify' ),
22 + 'edit_title' => esc_html__( 'Edit Link', 'adminify' ),
23 + 'remove_title' => esc_html__( 'Remove Link', 'adminify' ),
24 + ]
25 + );
18 26
19 - $args = wp_parse_args( $this->field, array(
20 - 'add_title' => esc_html__( 'Add Link', 'adminify' ),
21 - 'edit_title' => esc_html__( 'Edit Link', 'adminify' ),
22 - 'remove_title' => esc_html__( 'Remove Link', 'adminify' ),
23 - ) );
27 + $default_values = [
28 + 'url' => '',
29 + 'text' => '',
30 + 'target' => '',
31 + ];
24 32
25 - $default_values = array(
26 - 'url' => '',
27 - 'text' => '',
28 - 'target' => '',
29 - );
33 + $value = wp_parse_args( $this->value, $default_values );
30 34
31 - $value = wp_parse_args( $this->value, $default_values );
35 + $hidden = ( ! empty( $value['url'] ) || ! empty( $value['url'] ) || ! empty( $value['url'] ) ) ? ' hidden' : '';
32 36
33 - $hidden = ( ! empty( $value['url'] ) || ! empty( $value['url'] ) || ! empty( $value['url'] ) ) ? ' hidden' : '';
37 + $maybe_hidden = ( empty( $hidden ) ) ? ' hidden' : '';
34 38
35 - $maybe_hidden = ( empty( $hidden ) ) ? ' hidden' : '';
39 + echo wp_kses_post( $this->field_before() );
36 40
37 - echo wp_kses_post( $this->field_before() );
41 + echo '<textarea readonly="readonly" class="adminify--link hidden"></textarea>';
38 42
39 - echo '<textarea readonly="readonly" class="adminify--link hidden"></textarea>';
43 + echo '<div class="' . esc_attr( $maybe_hidden ) . '"><div class="adminify--result">' . sprintf( '{url:"%s", text:"%s", target:"%s"}', esc_url( $value['url'] ), wp_kses_post( $value['text'] ), esc_attr( $value['target'] ) ) . '</div></div>';
40 44
41 - echo '<div class="'. esc_attr( $maybe_hidden ) .'"><div class="adminify--result">'. esc_html( sprintf( '{url:"%s", text:"%s", target:"%s"}', $value['url'], $value['text'], $value['target'] ) ) .'</div></div>';
45 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[url]' ) ) . '" value="' . esc_attr( $value['url'] ) . '"' . wp_kses_post( $this->field_attributes( [ 'class' => 'adminify--url' ] ) ) . ' />';
46 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[text]' ) ) . '" value="' . esc_attr( $value['text'] ) . '" class="adminify--text" />';
47 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[target]' ) ) . '" value="' . esc_attr( $value['target'] ) . '" class="adminify--target" />';
42 48
43 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[url]' ) ) .'" value="'. esc_attr( $value['url'] ) .'"'. $this->field_attributes( array( 'class' => 'adminify--url' ) ) .' />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- field_attributes() escapes each attribute via esc_attr()
44 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[text]' ) ) .'" value="'. esc_attr( $value['text'] ) .'" class="adminify--text" />';
45 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[target]' ) ) .'" value="'. esc_attr( $value['target'] ) .'" class="adminify--target" />';
49 + echo '<a href="#" class="button button-primary adminify--add' . esc_attr( $hidden ) . '">' . wp_kses_post( $args['add_title'] ) . '</a> ';
50 + echo '<a href="#" class="button adminify--edit' . esc_attr( $maybe_hidden ) . '">' . wp_kses_post( $args['edit_title'] ) . '</a> ';
51 + echo '<a href="#" class="button adminify-warning-primary adminify--remove' . esc_attr( $maybe_hidden ) . '">' . wp_kses_post( $args['remove_title'] ) . '</a>';
46 52
47 - echo '<a href="#" class="button button-primary adminify--add'. esc_attr( $hidden ) .'">'. esc_html( $args['add_title'] ) .'</a> ';
48 - echo '<a href="#" class="button adminify--edit'. esc_attr( $maybe_hidden ) .'">'. esc_html( $args['edit_title'] ) .'</a> ';
49 - echo '<a href="#" class="button adminify-warning-primary adminify--remove'. esc_attr( $maybe_hidden ) .'">'. esc_html( $args['remove_title'] ) .'</a>';
53 + echo wp_kses_post( $this->field_after() );
54 + }
50 55
51 - echo wp_kses_post( $this->field_after() );
56 + public function enqueue() {
57 + if ( ! wp_script_is( 'wplink' ) ) {
58 + wp_enqueue_script( 'wplink' );
59 + }
52 60
53 - }
61 + if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
62 + wp_enqueue_script( 'jquery-ui-autocomplete' );
63 + }
54 64
55 - public function enqueue() {
65 + add_action( 'admin_print_footer_scripts', [ $this, 'add_wp_link_dialog' ] );
66 + }
56 67
57 - if ( ! wp_script_is( 'wplink' ) ) {
58 - wp_enqueue_script( 'wplink' );
59 - }
68 + public function add_wp_link_dialog() {
69 + if ( ! class_exists( '_WP_Editors' ) ) {
70 + require_once ABSPATH . WPINC . '/class-wp-editor.php';
71 + }
60 72
61 - if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
62 - wp_enqueue_script( 'jquery-ui-autocomplete' );
63 - }
73 + wp_print_styles( 'editor-buttons' );
64 74
65 - add_action( 'admin_print_footer_scripts', array( $this, 'add_wp_link_dialog' ) );
75 + _WP_Editors::wp_link_dialog();
76 + }
66 77
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 - }
78 + }
82 79 }