PluginProbe
Document Embedder – let visitors read files without downloading / 1.8.6
Document Embedder – let visitors read files without downloading v1.8.6
2.3.1 2.3.0 2.2.1 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.3 1.7.4 1.7.6 1.7.9 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 All 30 releases
document-emberdder / admin / framework / fields / link / link.php

link.php in Document Embedder – let visitors read files without downloading 1.8.6, at admin/framework/fields/link/link.php

83 lines 2.8 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( 'CSF_Field_link' ) ) {
11 class CSF_Field_link extends 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', 'csf' ),
21 'edit_title' => esc_html__( 'Edit Link', 'csf' ),
22 'remove_title' => esc_html__( 'Remove Link', 'csf' ),
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 $this->field_before();
38
39 echo '<textarea readonly="readonly" class="csf--link hidden"></textarea>';
40
41 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>';
42
43 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[url]' ) ) .'" value="'. esc_attr( $value['url'] ) .'"'. $this->field_attributes( array( 'class' => 'csf--url' ) ) .' />';
44 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[text]' ) ) .'" value="'. esc_attr( $value['text'] ) .'" class="csf--text" />';
45 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[target]' ) ) .'" value="'. esc_attr( $value['target'] ) .'" class="csf--target" />';
46
47 echo '<a href="#" class="button button-primary csf--add'. esc_attr( $hidden ) .'">'. $args['add_title'] .'</a> ';
48 echo '<a href="#" class="button csf--edit'. esc_attr( $maybe_hidden ) .'">'. $args['edit_title'] .'</a> ';
49 echo '<a href="#" class="button csf-warning-primary csf--remove'. esc_attr( $maybe_hidden ) .'">'. $args['remove_title'] .'</a>';
50
51 echo $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