Last active
November 14, 2017 12:16
-
-
Save saqibameen/458bc993ef1bc4f5ebb104387702faef to your computer and use it in GitHub Desktop.
WP: Plugin function to return image in specified size (if any), default otherwise.
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
<?php | |
/** | |
* Get Logo. | |
* | |
* Returns logo of WPCouple.com in specified width (if any). | |
* | |
* @param array $atts Array of attributes. | |
* @return mixed | |
*/ | |
function wpc_get_logo( $atts ) { | |
// Get argument values. | |
$arguments = shortcode_atts( array( 'size' => null ), $atts ); | |
// Size is set. | |
if ( ! empty( $arguments['size'] ) ) { | |
// Set source & size of image in img tag. | |
$logo = '<img width="' . $arguments['size'] . 'px" src="' . plugins_url( 'images/wp-couple-logo.png', __FILE__ ) . '">'; | |
} else { // Size is not set. | |
// Set source of image tag. | |
$logo = '<img src="' . plugins_url( 'images/wp-couple-logo.png', __FILE__ ) . '">'; | |
} | |
// Return logo. | |
return $logo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment