Skip to content

Instantly share code, notes, and snippets.

@Gkiokan
Created July 10, 2017 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gkiokan/a5239547e722bb53d4d1d6a9cbf255c6 to your computer and use it in GitHub Desktop.
Save Gkiokan/a5239547e722bb53d4d1d6a9cbf255c6 to your computer and use it in GitHub Desktop.
WP Helpers
<?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