Created
April 24, 2018 14:59
-
-
Save ScarletPonytail/f5ccbd90e736b3129978ae257b36f3c8 to your computer and use it in GitHub Desktop.
Wordpress - Wrap image with a link to the button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
================================================================ | |
Opening | |
================================================================ | |
<?php // Check if the buttons should show | |
if ( 'yes' === $settings->cb_blk_one_show_btns ) : | |
// Run a foreach loop over every button from global options | |
if ( count( $settings->cb_blk_one_btns ) === 1 ) : | |
foreach ( $settings->cb_blk_one_btns as $key => $val ) : | |
printf( '<a href="%1$s" class="ctawrapa %2$s" target="%3$s" %4$s>', | |
( strpos( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype, 'open-country-popup' ) !== false ) ? esc_attr( '#country-popup' ) : esc_url( $settings->cb_blk_one_btns[ $key ]->sc_global_btnurl ), // %1$s : href | |
( ( strpos( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype, 'open-country-popup' ) !== false ) ? esc_attr( 'country-popup' ) : '' ), // %2$s : Add country-popup class for JS listener | |
( ( strpos( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype, 'open-country-popup' ) === false ) ? esc_url( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype ) : '' ), // %3$s : If not country popup as target (_self, _blank) | |
( ( strpos( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype, 'open-country-popup' ) !== false ) ? 'data-location="' . esc_attr( '' . str_replace('open-country-popup-', '', $settings->cb_blk_one_btns[ $key ]->sc_global_urltype) ) . '"' : '' ) // %4$s : Set country popup style so be used in JS (personal, business, islamic...) | |
); | |
endforeach; | |
endif; | |
endif; ?> | |
================================================================ | |
Closing | |
================================================================ | |
<?php | |
if ( 'yes' === $settings->cb_blk_one_show_btns ) : // Check if the buttons should show | |
if ( count( $settings->cb_blk_one_btns ) === 1 ) : ?> | |
</a> | |
<?php endif; | |
endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment