Skip to content

Commit

Permalink
Option to set the default target
Browse files Browse the repository at this point in the history
  • Loading branch information
JoryHogeveen committed Dec 2, 2016
1 parent 965bdf2 commit 5a07ddd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion classes/fields/link.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public function options() {
'default' => 0,
'type' => 'boolean',
'dependency' => true
),
self::$type . '_default_target' => array(
'label' => __( 'Open in a new window by default?', 'pods' ),
'default' => 0,
'type' => 'boolean',
'dependency' => false
)
)
),
Expand Down Expand Up @@ -203,7 +209,7 @@ public function display( $value = null, $name = null, $options = null, $pod = nu

$atts = '';

if ( ! empty( $value['target'] ) ) {
if ( ! empty( $value['target'] ) || ( ! isset( $value['target'] ) && 1 == pods_var( self::$type . '_default_target', $options ) ) ) {
// Possible support for other targets in future
$atts .= ' target="' . esc_attr( $value['target'] ) . '"';
}
Expand Down
2 changes: 1 addition & 1 deletion ui/fields/link.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$target_attributes[ 'value' ] = '_blank';
$target_attributes[ 'tabindex' ] = 2;
$target_attributes[ 'style' ] = 'display: inline-block;';
if (isset($value['target']) && $value['target'] == '_blank') {
if (isset($value['target']) && $value['target'] == '_blank' || ( ! isset( $value['target'] ) && ! empty( $options['link_default_target'] ) ) ) {
$target_attributes[ 'checked' ] = 'checked';
}
$target_name = $name.'[target]';
Expand Down

0 comments on commit 5a07ddd

Please sign in to comment.