-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from kimcoleman/dev
1.3.8 version ready for release; font awesome shortcode attributes ro…
- Loading branch information
Showing
3 changed files
with
60 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,65 @@ | ||
<?php | ||
function memberlitesc_fa_shortcode($atts, $content = null) { | ||
// $atts ::= array of attributes | ||
// $atts ::= array of attributes | ||
// $content ::= text within enclosing form of shortcode element | ||
// examples: [fa icon="comment" color="primary" type="solid" size="3x"] | ||
|
||
extract(shortcode_atts(array( | ||
'color' => '', | ||
extract(shortcode_atts(array( | ||
'color' => null, | ||
'icon' => '', | ||
'size' => '', | ||
'type' => '', | ||
), $atts)); | ||
$r = '<i class="'; | ||
|
||
$font_awesome_icons_brands = memberlite_shortcodes_get_font_awesome_icons( 'brand' ); | ||
|
||
// Check if the icon is a "brand" icon and set the type attribute. | ||
if ( in_array( $icon, $font_awesome_icons_brands ) ) { | ||
$type = 'brand'; | ||
} | ||
|
||
if ( ! empty( $type ) ) { | ||
if ( $type === 'regular' ) { | ||
$r .= 'far'; | ||
} elseif ( $type === 'solid' ) { | ||
$r .= 'fas'; | ||
} elseif ( $type === 'brand' ) { | ||
$r .= 'fab'; | ||
} | ||
'size' => null, | ||
'type' => null, | ||
'rotate' => null, | ||
'flip' => null, | ||
'animate' => null, | ||
), $atts)); | ||
$r = '<i class="'; | ||
|
||
$font_awesome_icons_brands = memberlite_shortcodes_get_font_awesome_icons( 'brand' ); | ||
|
||
// Check if the icon is a "brand" icon and set the type attribute. | ||
if ( in_array( $icon, $font_awesome_icons_brands ) ) { | ||
$type = 'brand'; | ||
} | ||
|
||
if ( ! empty( $type ) ) { | ||
if ( $type === 'regular' ) { | ||
$classes[] = 'far'; | ||
} elseif ( $type === 'solid' ) { | ||
$classes[] = 'fas'; | ||
} elseif ( $type === 'brand' ) { | ||
$classes[] = 'fab'; | ||
} | ||
} else { | ||
$r .= 'fa'; | ||
} | ||
$classes[] = 'fa'; | ||
} | ||
|
||
$r .= ' fa-' . $icon; | ||
$classes[] = ' fa-' . $icon; | ||
|
||
if(!empty($color)) | ||
{ | ||
$r .= ' ' . $color; | ||
if ( ! empty( $color ) ) { | ||
$classes[] = ' ' . $color; | ||
} | ||
if(!empty($size)) | ||
{ | ||
$r .= ' fa-' . $size; | ||
|
||
if ( ! empty($size ) ) { | ||
$classes[] = ' fa-' . $size; | ||
} | ||
$r .= '"></i>'; | ||
return $r; | ||
|
||
if ( ! empty( $rotate ) ) { | ||
$classes[] = 'fa-rotate-' . $rotate; | ||
} | ||
|
||
if ( ! empty( $flip ) ) { | ||
$classes[] = 'fa-flip-' . $flip; | ||
} | ||
|
||
if ( ! empty( $animate ) ) { | ||
$classes[] = 'fa-' . $animate; | ||
} | ||
|
||
return sprintf( | ||
'<i class="%1$s"></i>', | ||
esc_attr( implode( ' ', $classes ) ) | ||
); | ||
} | ||
remove_shortcode('fa'); //replace shortcode bundled with Memberlite 2.0 and prior or anywhere else | ||
add_shortcode('fa', 'memberlitesc_fa_shortcode'); |