| Server IP : 130.225.57.55 / Your IP : 216.73.216.60 Web Server : Apache System : Linux wp-vhost07 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.1.2-1ubuntu2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /srv/www/reco2st.eu/https/wp-content/themes/erc04961/library/helpers/ |
Upload File : |
<?php
/**
* WordPress Link-making Helpers
*
* @author Max G J Panas <http://maxpanas.com>
*/
/**
* Class MOZ_Link
*
*/
class MOZ_Link {
/**
* Get the href from an
* acf internal/external
* link
*
* Note: assumes $data is an array like eg:
* [
* 'type' => 'internal' or 'custom' or 'tel' or 'email'
* 'internal' => url...
* 'custom' => url...
* 'tel' => text...
* 'email' => email...
* ]
*
* @param array $data
*
* @return bool
*/
public static function get_link_href( $data ) {
if ( ! isset( $data[ $data['type'] ] ) || empty( $data[ $data['type'] ] ) ){
return false;
}
$href = $data[$data['type']];
switch ( $data['type'] ) {
case 'tel': return 'tel:' . MOZ_Utils::get_esc_tel( $href );
case 'email': return 'mailto:' . MOZ_Utils::get_esc_email( $href );
default: return $href;
}
}
/**
* Print the href from an
* acf internal/external
* link
*
* Note: assumes $data is an array like eg:
* [
* 'type' => 'internal' or 'custom' or 'tel' or 'email'
* 'internal' => url...
* 'custom' => url...
* 'tel' => text...
* 'email' => email...
* ]
*
* @param array $data
*/
public static function link_href( $data ) {
echo self::get_link_href( $data );
}
/**
* Add target="_blank"
* to the given attribute
* array if the specified
* href is external
*
* @param array $attrs
*
* @return mixed
*/
public static function add_link_target( $attrs ) {
if (
! isset( $attrs['target'] )
&& isset( $attrs['href'] )
&& ! wp_validate_redirect( $attrs['href'], false )
) {
$attrs['target'] = '_blank';
}
return $attrs;
}
/**
* Add rel="nofollow"
* to the given attribute
* array if the specified
* href is external
*
* @param array $attrs
*
* @return mixed
*/
public static function add_link_rel( $attrs ) {
if (
isset( $attrs['href'] )
&& ! empty( $attrs['href'] )
&& ! wp_validate_redirect( $attrs['href'], false )
) {
$attrs['rel'] = 'nofollow';
}
return $attrs;
}
/**
* Get an anchor tag
*
* @param array $data
* @param array $attrs
* @param string $content
*
* @return string
*/
public static function get_link( $data = null, $attrs = array(), $content = '' ) {
if ( ! empty( $data ) && $href = self::get_link_href( $data ) ) {
$attrs['href'] = $href;
}
return MOZ_Html::get_element( 'a', self::add_link_target( $attrs ), $content );
}
/**
* Print an anchor tag
*
* @param null $data
* @param array $attrs
* @param string $content
*/
public static function link( $data = null, $attrs = array(), $content = '' ) {
echo self::get_link( $data, $attrs, $content );
}
}