PluginProbe ʕ •ᴥ•ʔ
External Links – nofollow, noopener & new window / 2.32
External Links – nofollow, noopener & new window v2.32
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 7 years ago class-wpel-exceptions-fields.php 7 years ago class-wpel-excluded-link-fields.php 7 years ago class-wpel-external-link-fields.php 7 years ago class-wpel-internal-link-fields.php 7 years ago class-wpel-link-fields-base.php 7 years ago
class-wpel-external-link-fields.php
96 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 );
38
39 $fields = array_merge(
40 array_slice( $fields, 0, $index_insert )
41 , $additional_fields
42 , array_slice( $fields, $index_insert )
43 );
44
45 $this->set_settings( array(
46 'section_id' => 'wpel-external-link-fields',
47 'page_id' => 'wpel-external-link-fields',
48 'option_name' => $option_name,
49 'option_group' => $option_name,
50 'title' => __( 'External Links', 'wp-external-links' ),
51 'fields' => $fields,
52 ) );
53
54 parent::init();
55 }
56
57 /**
58 * Show field methods
59 */
60
61 protected function show_rel_external( array $args )
62 {
63 $this->get_html_fields()->check_with_label(
64 $args[ 'key' ]
65 , __( 'Add <code>"external"</code>', 'wp-external-links' )
66 , '1'
67 , ''
68 );
69 }
70
71 /**
72 * Validate and sanitize user input before saving to databse
73 * @param array $new_values
74 * @param array $old_values
75 * @return array
76 */
77 protected function before_update( array $new_values, array $old_values )
78 {
79 $is_valid = true;
80
81 $is_valid = $is_valid && in_array( $new_values[ 'rel_external' ], array( '', '1' ) );
82
83 if ( false === $is_valid ) {
84 // error when user input is not valid conform the UI, probably tried to "hack"
85 $this->add_error( __( 'Something went wrong. One or more values were invalid.', 'wp-external-links' ) );
86 return $old_values;
87 }
88
89 $update_values = parent::before_update( $new_values, $old_values );
90 return $update_values;
91 }
92
93 }
94
95 /*?>*/
96