ID, $author->user_nicename ).'?author_downloads=true';
return $full_url;
}
return EDD_FES()->vendors->get_vendor_store_url( $vendor_id );
}
/* Adding Image Upload and other Fields in author page */
add_action( 'show_user_profile', 'olam_extra_profile_fields' );
add_action( 'edit_user_profile', 'olam_extra_profile_fields' );
/**
* Olam Function - Extra Profile Fields.
*
* Adding extra fields to author profile,displayed in author archive for downloads.
*/
if( ! function_exists( 'olam_extra_profile_fields' ) ){
function olam_extra_profile_fields( $user )
{
?>
" id="authorbannerUploadimage"/>
$fontValue) {
$finalFontArray[]=olam_font_weights($fontValue);
}
$implodedGoogleFonts=implode("|", $finalFontArray);
return $implodedGoogleFonts;
}
}
/**
* Olam Function - Font weights.
*
* Loading Font weights for predefined fonts.
*/
if( ! function_exists( 'olam_font_weights' ) ){
function olam_font_weights($tempFont){
$presetFonts=array(
"Open+Sans"=>array(300,400,600,700),
"Roboto" =>array(100,300,400,500,700),
"Roboto Condensed" =>array(300,400,700),
"Roboto Slab" => array(100,300,400,700),
"Lato" => array(100,300,400,700),
"Oswald" => array(300,400,700),
"Raleway" => array(100,300,400,500,700),
"Droid Sans"=> array(400,700),
"Ubuntu" => array(300,400,500,700),
"Montserrat" => array(400,700)
);
if(array_key_exists($tempFont, $presetFonts)){
$tempFont=str_replace(' ','+', $tempFont);
if(is_array($presetFonts[$tempFont])){
$theFinalFont=$tempFont.":".implode(",", $presetFonts[$tempFont]);
}
}
else{
$gFile = INC_PATH . '/googlefonts.php';
$gFonts= include $gFile;
if(array_key_exists($tempFont, $gFonts)){
$tempFsize=array();
foreach ($gFonts[$tempFont]['variants'] as $tempFkey => $tempFvalue) {
$tempFsize[]=$tempFvalue['id'];
}
$finalSizeArray=array_map("olam_array_filter",$tempFsize);
$finalSize=array_filter($finalSizeArray);
$tempFont=str_replace(' ','+', $tempFont);
if(is_array($finalSize)){
$theFinalFont=$tempFont.":".implode(",", $finalSize);
}
}
else{
$tempFont=str_replace(' ','+', $tempFont);
$theFinalFont=$tempFont;
}
}
return $theFinalFont;
}
}
/**
* Olam Function - Array Filter.
*
* Custom array filter for google font size .
*/
if( ! function_exists( 'olam_array_filter' ) ){
function olam_array_filter($item){
$array=array("300","400","700");
if(in_array($item, $array)){
return $item;
}
}
}
/**
* Olam Function - Check System Fonts.
*
* Checking if a particular fonts is a system font .
*/
if( ! function_exists( 'olam_check_system_fonts' ) ){
function olam_check_system_fonts($font){
$systemFonts=array(
"arial",
"verdana",
"trebuchet",
"trebuchet ms",
"georgia",
"times",
"tahoma",
"helvetica"
);
if(!in_array($font, $systemFonts)){
return $font;
}
return null;
}
}
/**
* Olam Function - Get RevSliders
* This function gets the saved revolution sliders.
*/
if( ! function_exists( 'olam_get_rev_sliders' ) ){
function olam_get_rev_sliders (){
if(!class_exists('RevSlider')){
return false;
}
else{
$theslider = new RevSlider();
$arrSliders = $theslider->getArrSliders();
$arrA = array();
$arrT = array();
foreach($arrSliders as $slider){
$arrA[] = $slider->getAlias();
$arrT[] = $slider->getTitle();
}
if($arrA && $arrT){
$result = array_combine($arrA, $arrT);
}
else
{
$result = false;
}
return $result;
}
}
}
/**
* Olam Function - Get Current page url.
*
* Returning current page url .
*/
if( ! function_exists( 'olam_get_current_page_url' ) ){
function olam_get_current_page_url(){
global $wp;
$current_url = home_url( add_query_arg( array(), $wp->request ) );
return $current_url;
}
}
add_action('admin_init','olam_checkRetinaDisplay');
/**
* Olam Function - Check Retina Display.
* This function check whether the retina display is enabled in the theme settings.
*/
if( ! function_exists( 'olam_checkRetinaDisplay' ) ){
function olam_checkRetinaDisplay(){
$olamOptions=of_get_options();
if(isset($olamOptions['theme_retina']) && $olamOptions['theme_retina']==1){
add_filter( 'wp_generate_attachment_metadata', 'olam_retinaAttachmentMeta', 10, 2 );
add_filter( 'delete_attachment', 'olam_deleteRetinaImages' );
}
}
}
/**
* Olam function - Retina images.
*
* This function is attached to the 'wp_generate_attachment_metadata' filter hook.
*/
if( ! function_exists( 'olam_retinaAttachmentMeta' ) ){
function olam_retinaAttachmentMeta( $metadata, $attachment_id ) {
foreach ( $metadata as $key => $value ) {
if ( is_array( $value ) ) {
foreach ( $value as $image => $attr ) {
if ( is_array( $attr ) && (count($attr)>0) ){
olam_createRetinaImages( get_attached_file( $attachment_id ), $attr['width'], $attr['height'], true );
}
}
}
}
return $metadata;
}
}
/**
* Olam Function - Create retina-ready images.
*
* Referenced via olam_retinaAttachmentMeta().
*/
if( ! function_exists( 'olam_createRetinaImages' ) ){
function olam_createRetinaImages( $file, $width, $height, $crop = false ) {
if ( $width || $height ) {
$resized_file = wp_get_image_editor( $file );
if ( ! is_wp_error( $resized_file ) ) {
$filename = $resized_file->generate_filename( $width . 'x' . $height . '@2x' );
$resized_file->resize( $width * 2, $height * 2, $crop );
$resized_file->save( $filename );
$info = $resized_file->get_size();
return array(
'file' => wp_basename( $filename ),
'width' => $info['width'],
'height' => $info['height'],
);
}
}
return false;
}
}
/**
* Olam Function - Delete retina-ready images.
*
* This function is attached to the 'delete_attachment' filter hook.
*/
if( ! function_exists( 'olam_deleteRetinaImages' ) ){
function olam_deleteRetinaImages( $attachment_id ) {
$meta = wp_get_attachment_metadata( $attachment_id );
$upload_dir = wp_upload_dir();
$path = (isset($meta['file']))?pathinfo( $meta['file'] ):null;
if((is_array($meta)) && count($meta)>0){
foreach ( $meta as $key => $value ) {
if ( 'sizes' === $key ) {
foreach ( $value as $sizes => $size ) {
$original_filename = $upload_dir['basedir'] . '/' . $path['dirname'] . '/' . $size['file'];
$retina_filename = substr_replace( $original_filename, '@2x.', strrpos( $original_filename, '.' ), strlen( '.' ) );
if ( file_exists( $retina_filename ) )
unlink( $retina_filename );
}
}
}
}
}
}
/**
* Olam Function - Check if added to cart.
*
* Check if an item exists or is added to cart already.
*/
if( ! function_exists( 'olam_check_if_added_to_cart' ) ){
function olam_check_if_added_to_cart( $itemID ) {
$cartItems=edd_get_cart_contents();
$cartIDs=olam_get_cart_IDs($cartItems);
if(in_array($itemID, $cartIDs)){
return true;
}
return false;
}
}
/**
* Olam Function - Get cart item ids.
*
* Getting the cart item ids.
*/
if( ! function_exists( 'olam_get_cart_IDs' ) ){
function olam_get_cart_IDs( $cartItems ) {
$cartIDs=array();
if(is_array($cartItems)){
foreach ($cartItems as $cartItemkey => $cartItemvalue) {
$cartIDs[]=$cartItemvalue['id'];
}
}
return $cartIDs;
}
}
// =========== TGM_Plugin =============
/**
* This file represents an example of the code that themes would use to register
* the required plugins.
*
* It is expected that theme authors would copy and paste this code into their
* functions.php file, and amend to suit.
*
* @see http://tgmpluginactivation.com/configuration/ for detailed documentation.
*
* @package TGM-Plugin-Activation
* @subpackage Example
* @version 2.6.1
* @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
* @copyright Copyright (c) 2011, Thomas Griffin
* @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
* @link https://github.com/TGMPA/TGM-Plugin-Activation
*/
/**
* Include the TGM_Plugin_Activation class.
*
* Depending on your implementation, you may want to change the include call:
*
* Parent Theme:
* require_once get_template_directory() . '/path/to/class-tgm-plugin-activation.php';
*
* Child Theme:
* require_once get_stylesheet_directory() . '/path/to/class-tgm-plugin-activation.php';
*
* Plugin:
* require_once dirname( __FILE__ ) . '/path/to/class-tgm-plugin-activation.php'; // change "dirname( __FILE__ )" to "get_template_directory()" for Themeforest standards.
*/
require_once get_template_directory() . '/admin/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'olam_register_required_plugins' );
/**
* Register the required plugins for this theme.
*
* In this example, we register five plugins:
* - one included with the TGMPA library
* - two from an external source, one from an arbitrary source, one from a GitHub repository
* - two from the .org repo, where one demonstrates the use of the `is_callable` argument
*
* The variables passed to the `tgmpa()` function should be:
* - an array of plugin arrays;
* - optionally a configuration array.
* If you are not changing anything in the configuration array, you can remove the array and remove the
* variable from the function call: `tgmpa( $plugins );`.
* In that case, the TGMPA default settings will be used.
*
* This function is hooked into `tgmpa_register`, which is fired on the WP `init` action on priority 10.
*/
function olam_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
// Plugins bundled with a theme.
array(
'name' => esc_html__( 'Olam EDD FES', 'bmci' ), // The plugin name.
'slug' => 'olam-edd-fes-meta-fields', // The plugin slug (typically the folder name).
'source' => esc_url( get_template_directory_uri() . '/admin/plugins/olam-edd-fes-meta-fields.zip' ), // The plugin source.
'required' => false, // If false, the plugin is only 'recommended' instead of required.
'version' => '1.1.0',
),
array(
'name' => esc_html__( 'Olam Multiple Images', 'bmci' ),
'slug' => 'olam-multiple-images',
'source' => esc_url( get_template_directory_uri() . '/admin/plugins/olam-multiple-images.zip' ),
'required' => false,
'version' => '1.2',
),
array(
'name' => esc_html__( 'Layero - EDD Related Downloads & Quick Contact', 'bmci' ),
'slug' => 'layero-edd-related-downloads',
'source' => esc_url( get_template_directory_uri() . '/admin/plugins/layero-edd-related-downloads.zip' ),
'required' => true,
'version' => '1.3',
),
// Plugins from the WordPress Plugin Repository.
array(
'name' => esc_html__( 'Unyson', 'bmci' ),
'slug' => 'unyson',
'required' => true,
),
array(
'name' => esc_html__( 'Easy Digital Downloads', 'bmci' ),
'slug' => 'bmci',
'required' => false,
),
);
/*
* Array of configuration settings. Amend each line as needed.
*
* TGMPA will start providing localized text strings soon. If you already have translations of our standard
* strings available, please help us make TGMPA even better by giving us access to these translations or by
* sending in a pull-request with .po file(s) with the translations.
*
* Only uncomment the strings in the config array if you want to customize the strings.
*/
$config = array(
'id' => 'bmci', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
// =========== _/\_ TGM section ends _/\_ =============
/* Adding featured download meta box */
add_action( 'add_meta_boxes', 'olam_meta_box_add' );
if( ! function_exists( 'olam_meta_box_add' ) )
{
function olam_meta_box_add()
{
add_meta_box( 'olam-meta-box-featured', esc_html__('Featured Download','bmci'), 'olam_meta_box_cb', 'download', 'side');
}
}
/**
* Olam Function - Meta box CB.
*
* Adding a new meta box.
*/
if( ! function_exists( 'olam_meta_box_cb' ) )
{
function olam_meta_box_cb( $post )
{
$values = get_post_custom( $post->ID );
$selected = isset( $values['olam_box_select'] ) ? esc_attr( $values['olam_box_select'][0] ) : '';
wp_nonce_field( 'olam_meta_box_nonce_value', 'olam_box_nonce' );
?>
0) ){
echo ''."\n";
}
}
}
add_action('wp_head', 'olam_retina_logo');
// Fixing the edd schema
add_filter( 'edd_add_schema_microdata', '__return_false' );
remove_filter( 'the_title', 'edd_microdata_title');
/**
* Olam Function - Olam Excerpt
*
* More tag to excerpt.
*/
if( ! function_exists( 'olam_new_excerpt_more' ) )
{
function olam_new_excerpt_more($more) {
global $post;
return '... '.esc_html__("read more","olam").' ';
}
}
add_filter('excerpt_more', 'olam_new_excerpt_more');
add_filter('edd_cart_item','olam_edd_cart_item',10, 2);
/**
* Olam Function - Olam Edd Cart Item
*
* Adding image to edd cart.
*/
if( ! function_exists( 'olam_edd_cart_item' ) )
{
function olam_edd_cart_item($item,$id){
$featImage=null;
$theDownloadImage=get_post_meta($id,'download_item_thumbnail_id');
if(is_array($theDownloadImage) && (count($theDownloadImage)>0) ){
$thumbID=$theDownloadImage[0];
$featImage=wp_get_attachment_image_src($thumbID,'olam-product-thumb-small');
$featImage=$featImage[0];
}
else{
$thumbID=get_post_thumbnail_id($id);
$featImage=wp_get_attachment_image_src($thumbID,'olam-product-thumb-small');
$featImage=$featImage[0];
}
if(isset($featImage)){
$item = str_replace( '{item_image_url}', $featImage, $item );
}
return $item;
}
}
add_filter('edd_empty_cart_message','olam_modify_empty_cart_message');
/**
* Olam Function - Edd Empty Cart Message modify
*
* Modifying the empty cart message style
*/
if( ! function_exists( 'olam_modify_empty_cart_message' ) )
{
function olam_modify_empty_cart_message($message){
$message='