How to Update Widget Link Options to Use New Link Group

Dev Tutorials

Since: 1.2.12 Last Updated: Time to Read: 1 minute

The new link-group  input() type was added in Layers 1.2.12 which replaces the former button link and button text fields in widget repeater areas. The following shows how to update your widgets with the new field, using the Content Widget as a point of reference. Note that line numbers may vary in custom widgets.

Locate the following:

Replace with:

Reference

In the widget content section, where output begins around line 250 ( Content Widget    Slider Widget ) you must replace each instance of the following variables with the new version:

Linking Featured Media

Old:

New

  • Condition: if ( $link_array['link'] ){}
  • Output URL and url attribute: <?php echo $link_href_attr; ?>  = href="http://www.yoursite.com/" 
  • Output target: <?php echo $link_target_attr; ?> = target="_blank"  if the New Tab button is toggled in the control UI.

Linking Titles & Text

This now works the same as linking media.

Old

New

  • Condition: if ( $link_array['link'] ){}
  • Output URL and url attribute: <?php echo $link_href_attr; ?>  = href="http://www.yoursite.com/" 
  • Output Target: <?php echo $link_target_attr; ?> = target="_blank"  if the New Tab button is toggled in the control UI.

Creating Buttons

Old

New

  • Condition: if ( $link_array['link'] ){}
  • Output URL and url attribute: <?php echo $link_href_attr; ?>  = href="http://www.yoursite.com/" 
  • class  remains unchanged
  • Output Target: <?php echo $link_target_attr; ?> = target="_blank"  if the New Tab button is toggled in the control UI.
  • Output Button Text: <?php echo $link_array['text']; ?>

 

Old Code:

The Button Link and Button Text fields were previously located near the very end of the Content and Slider Widget and are displayed here for reference in the event your widget follows a custom structure:

New