Created
July 10, 2017 09:00
-
-
Save Gkiokan/a5239547e722bb53d4d1d6a9cbf255c6 to your computer and use it in GitHub Desktop.
WP Helpers
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
<?php | |
/* | |
Project: WP Helpers for ... | |
Author: Gkiokan Sali | |
Date: 10.07.2017 | |
*/ | |
class Helpers { | |
/* | |
Get the Thumbnail Image | |
*/ | |
public static function get_image($id=null, $size='full', $key=0){ | |
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($id), $size); | |
return isset($thumb[$key]) ? $thumb[$key] : ''; | |
} | |
/* | |
Get the VC Image | |
*/ | |
public static function get_vc_image($id=null, $size='full', $key=0){ | |
$thumb = wp_get_attachment_image_src( $id, $size); | |
return isset($thumb[$key]) ? $thumb[$key] : ''; | |
} | |
/* | |
Easy Getter | |
*/ | |
public static function get($item=null, $default='', $atts=null){ | |
if(is_array($atts)) | |
return | |
// If the Item is set and not empty return the value | |
!empty($atts[$item]) && isset($atts[$item]) ? | |
// Check if the value is an array or not | |
( is_array($atts[$item]) ? $atts[$item] : esc_attr($atts[$item]) ) | |
// Anything else will return the default value | |
: $default; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment