field, array(
'add_title' => esc_html__( 'Add Link', 'sakurairo_csf' ),
'edit_title' => esc_html__( 'Edit Link', 'sakurairo_csf' ),
'remove_title' => esc_html__( 'Remove Link', 'sakurairo_csf' ),
) );
$default_values = array(
'url' => '',
'text' => '',
'target' => '',
);
$value = wp_parse_args( $this->value, $default_values );
$hidden = ( ! empty( $value['url'] ) || ! empty( $value['url'] ) || ! empty( $value['url'] ) ) ? ' hidden' : '';
$maybe_hidden = ( empty( $hidden ) ) ? ' hidden' : '';
echo $this->field_before();
echo '';
echo '
'. sprintf( '{url:"%s", text:"%s", target:"%s"}', $value['url'], $value['text'], $value['target'] ) .'
';
echo 'field_attributes( array( 'class' => 'csf--url' ) ) .' />';
echo '';
echo '';
echo ''. $args['add_title'] .' ';
echo ''. $args['edit_title'] .' ';
echo ''. $args['remove_title'] .'';
echo $this->field_after();
}
public function enqueue() {
if ( ! wp_script_is( 'wplink' ) ) {
wp_enqueue_script( 'wplink' );
}
if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
wp_enqueue_script( 'jquery-ui-autocomplete' );
}
add_action( 'admin_print_footer_scripts', array( $this, 'add_wp_link_dialog' ) );
}
public function add_wp_link_dialog() {
if ( ! class_exists( '_WP_Editors' ) ) {
require_once ABSPATH . WPINC .'/class-wp-editor.php';
}
wp_print_styles( 'editor-buttons' );
_WP_Editors::wp_link_dialog();
}
}
}