PluginProbe ʕ •ᴥ•ʔ
External Links – nofollow, noopener & new window / trunk
External Links – nofollow, noopener & new window vtrunk
0.31 0.32 0.33 0.34 0.35 1.01 1.02 1.03 1.10 1.20 1.21 1.30 1.31 1.40 1.41 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.60 1.61 1.62 1.70 1.80 1.81 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 2.3 2.32 2.35 2.40 2.42 2.43 2.45 2.46 2.47 2.48 2.50 2.51 2.55 2.56 2.57 2.58 2.59 2.60 2.61 2.62 2.63 2.64 2.65 trunk 0.10 0.11 0.12 0.20 0.21 0.30
wp-external-links / includes / admin / settings-fields / class-wpel-external-link-fields.php
wp-external-links / includes / admin / settings-fields Last commit date
class-wpel-admin-fields.php 1 year ago class-wpel-exceptions-fields.php 1 year ago class-wpel-excluded-link-fields.php 3 years ago class-wpel-exit-confirmation-fields.php 1 year ago class-wpel-external-link-fields.php 3 years ago class-wpel-internal-link-fields.php 3 years ago class-wpel-link-fields-base.php 1 year ago
class-wpel-external-link-fields.php
104 lines
1 <?php
2 /**
3 * Class WPEL_External_Link_Fields
4 *
5 * @package WPEL
6 * @category WordPress Plugin
7 * @version 2.3
8 * @link https://www.webfactoryltd.com/
9 * @license Dual licensed under the MIT and GPLv2+ licenses
10 */
11 final class WPEL_External_Link_Fields extends WPEL_Link_Fields_Base
12 {
13
14 /**
15 * Initialize
16 */
17 protected function init()
18 {
19 $option_name = 'wpel-external-link-settings';
20 $fields = $this->get_general_fields( $option_name );
21
22 // specific field settings
23 $fields[ 'apply_settings' ][ 'label' ] = __( 'Settings for external links:', 'wp-external-links' );
24 $fields[ 'apply_settings' ][ 'default_value' ] = '1';
25 $fields[ 'target' ][ 'label' ] = __( 'Open external links:', 'wp-external-links' );
26
27 //
28 $index_prev = array_search( 'rel_noreferrer', array_keys( $fields ) );
29 $index_insert = $index_prev + 1;
30
31 $additional_fields = array(
32 'rel_external' => array(
33 'label' => '',
34 'class' => 'wpel-no-label wpel-hidden',
35 'default_value' => '1',
36 ),
37 'rel_sponsored' => array(
38 'label' => '',
39 'class' => 'wpel-no-label wpel-hidden',
40 'default_value' => '0',
41 ),
42 'rel_ugc' => array(
43 'label' => '',
44 'class' => 'wpel-no-label wpel-hidden',
45 'default_value' => '0',
46 )
47 );
48
49 $fields = array_merge(
50 array_slice( $fields, 0, $index_insert )
51 , $additional_fields
52 , array_slice( $fields, $index_insert )
53 );
54
55 $this->set_settings( array(
56 'section_id' => 'wpel-external-link-fields',
57 'page_id' => 'wpel-external-link-fields',
58 'option_name' => $option_name,
59 'option_group' => $option_name,
60 'title' => __( 'External Links', 'wp-external-links' ),
61 'fields' => $fields,
62 ) );
63
64 parent::init();
65 }
66
67 /**
68 * Show field methods
69 */
70
71 protected function show_rel_external( array $args )
72 {
73 $this->get_html_fields()->check_with_label(
74 $args[ 'key' ]
75 , __( 'Add <code>"external"</code>', 'wp-external-links' )
76 , '1'
77 , ''
78 );
79 }
80
81 /**
82 * Validate and sanitize user input before saving to database
83 * @param array $new_values
84 * @param array $old_values
85 * @return array
86 */
87 protected function before_update( array $new_values, array $old_values )
88 {
89 $is_valid = true;
90
91 $is_valid = $is_valid && in_array( $new_values[ 'rel_external' ], array( '', '1' ) );
92
93 if ( false === $is_valid ) {
94 // error when user input is not valid conform the UI, probably tried to "hack"
95 $this->add_error( __( 'Something went wrong. One or more values were invalid.', 'wp-external-links' ) );
96 return $old_values;
97 }
98
99 $update_values = parent::before_update( $new_values, $old_values );
100 return $update_values;
101 }
102
103 }
104