post_date_gmt; _e( 'Copyright © ' , 'bmci' );; if ( substr( $first_date, 0, 4 ) == date( 'Y' ) ) { echo date( 'Y' ); } else { echo substr( $first_date, 0, 4 ) . "-" . date( 'Y' ); } echo ' ' . get_bloginfo( 'name' ) . ' '; _e( 'All rights reserved.' , 'bmci' );; } /** * Olam Theme Functions - Register meta fields. * Registering meta fields to download post type. **/ function olam_register_download_metafields() { $prefix = 'bmci'; /** * Sample metabox to demonstrate each field type included */ $cmb_demo = new_cmb2_box( array( 'id' => $prefix . 'metabox', 'title' => esc_html__( 'Download Options', 'bmci' ), 'object_types' => array( 'download') ) ); $cmb_demo->add_field( array( 'name' => esc_html__( 'Preview URL', 'bmci' ), 'desc' => esc_html__( 'The URL for the Live Preview button that shows on single download page under featured image / preview media', 'bmci' ), 'id' => 'preview_url', 'type' => 'text', )); $cmb_demo->add_field( array( 'name' => esc_html__( 'Subheading', 'bmci' ), 'desc' => esc_html__( 'Subheading for the item displayed under title', 'bmci' ), 'id' => 'subheading', 'type' => 'text', ) ); $cmb_demo->add_field( array( 'name' => esc_html__( 'Downloads Thumbnail', 'bmci' ), 'desc' => esc_html__( 'Alternate thumbnail image instead of featured image to show in listing sections (slider thumb style)', 'bmci' ), 'id' => 'download_item_thumbnail', 'type' => 'file', 'options' =>array( 'url' =>false, ) ) ); $cmb_demo->add_field( array( 'name' => esc_html__( 'Square Images', 'bmci' ), 'desc' => esc_html__( 'Download item square image to show in different sections (shop, category, archives and shortcodes instead of featured image.)', 'bmci' ), 'id' => 'download_item_square_img', 'type' => 'file', 'options' =>array( 'url' =>false, ) ) ); $cmb_demo->add_field( array( 'name' => esc_html__( 'Audio URL', 'bmci' ), 'desc' => esc_html__( 'Upload the audio file preview file for the audio player', 'bmci' ), 'id' => 'download_item_audio_id', 'type' => 'file', 'options' =>array( 'url' =>false, ) ) ); // $cmb_demo->add_field( array( // 'name' => esc_html__( 'Video URL', 'bmci' ), // 'desc' => esc_html__( 'Upload the video file to display in video player', 'bmci' ), // 'id' => 'download_item_video_id', // 'type' => 'file', // 'options' =>array( // 'url' =>false, // ) // ) // ); $cmb_demo->add_field( array( 'name' => esc_html__( 'Video URL', 'bmci' ), 'desc' => esc_html__( 'Add the video url to display in video player preview (ideally Youtube, Vimeo or self hosted video URL)', 'bmci' ), 'id' => 'download_item_video_id', 'type' => 'text', ) ); } if ( ! isset( $content_width ) ) $content_width = 1180; //Add Custom Widgets $widgets_dir = WP_CONTENT_DIR . "/themes/".get_option('template')."/includes/widgets/"; if (@is_dir($widgets_dir)) { $widgets_dh = opendir($widgets_dir); while (($widgets_file = readdir($widgets_dh)) !== false) { if(strpos($widgets_file,'.php') && $widgets_file != "widget-blank.php") { include_once($widgets_dir . $widgets_file); } } closedir($widgets_dh); } /** * Olam Theme Functions - Add Editor Styles. * Adding styles to WP editor. **/ function olam_add_editor_styles() { add_editor_style( 'css/editor-style.css' ); } add_action( 'admin_init', 'olam_add_editor_styles' ); /** * Olam Theme Functions - Theme Setup. * Olam theme setup. * Loading text domain **/ if( ! function_exists( 'olam_theme_setup' ) ){ function olam_theme_setup(){ load_theme_textdomain('bmci', get_template_directory() . '/languages'); add_theme_support( 'bmci' ); } } add_action('after_setup_theme', 'olam_theme_setup'); /** * Olam Theme Functions - Registering Sidebars. * Registering the required sidebars. **/ if( ! function_exists( 'olam_register_sidebars' ) ){ function olam_register_sidebars(){ if (function_exists('register_sidebar')) { register_sidebar(array( 'name' => esc_html__('Single Download Sidebar','bmci'), 'id' => 'olam-single-download', 'description' => esc_html__('Single Download Page Sidebar','bmci'), 'before_widget' => '', 'before_title' => '' )); register_sidebar( array( 'name' => esc_html__('Download Category Sidebar','bmci'), 'id' => 'olam-download-category-sidebar', 'description' => esc_html__('Download Category Sidebar','bmci'), 'before_widget' => '', 'before_title' => '' ) ); register_sidebar( array( 'name' => esc_html__('Author Downloads Sidebar','bmci'), 'id' => 'olam-author-sidebar', 'description' => esc_html__('Sidebar used in author downloads page','bmci'), 'before_title' => '', 'before_widget' => '', ) ); register_sidebar( array( 'name' => esc_html__('Blog Page Sidebar','bmci'), 'id' => 'olam-blog-page-sidebar', 'description' => esc_html__('Blog Page Sidebar','bmci'), 'before_widget' => '', 'before_title' => '' ) ); register_sidebar( array( 'name' => esc_html__('Page Sidebar','bmci'), 'id' => 'olam-page-sidebar', 'description' => esc_html__('Page Sidebar','bmci'), 'before_widget' => '', 'before_title' => '' ) ); register_sidebar( array( 'name' => esc_html__('Footer 1','bmci'), 'id' => 'olam-footer-area-1', 'description' => esc_html__('Footer Area 1','bmci'), 'before_widget' => '', ) ); register_sidebar( array( 'name' => esc_html__('Footer 2','bmci'), 'id' => 'olam-footer-area-2', 'description' => esc_html__('Footer Area 2','bmci'), 'before_widget' => '', 'before_title' => '
', 'after_title' => '
' ) ); if ( class_exists( 'WooCommerce' ) ) { register_sidebar(array( 'name' => esc_html__('Woocommerce Sidebar','bmci'), 'id' => 'olam-woocommerce-sidebar', 'description' => esc_html__('Woocommerce Sidebar','bmci'), 'before_widget' => '', 'before_title' => '' )); } } } } add_action( 'widgets_init', 'olam_register_sidebars'); /** * Olam Theme Functions - Check EDD exists. * Checking if EDD is installed. **/ function olam_check_edd_exists() { if( class_exists( 'Easy_Digital_Downloads' ) ) { return true; } return false; } /** * Olam Theme Functions - Register Menud. * Registering Menus. **/ if( ! function_exists( 'olam_register_menus' ) ){ function olam_register_menus() { register_nav_menus( array( 'header-top-menu' => esc_html__('Header Menu','bmci'), ) ); } } add_action('init', 'olam_register_menus'); /** * Olam Theme Functions - Register styles and scripts. * Loading theme scripts and styles. **/ if( ! function_exists( 'olam_register_styles_scripts' ) ){ function olam_register_styles_scripts(){ $protocol = is_ssl() ? 'https' : 'http'; $loadedFonts=olam_load_googlefont_styles(); wp_enqueue_style('normalize', get_template_directory_uri() . '/css/normalize.min.css',array(),'3.0.2'); wp_enqueue_style('olam-bootstrap', get_template_directory_uri() . '/css/bootstrap.css',array(),'1.0'); wp_enqueue_style('olam-style', get_template_directory_uri() . '/css/style.css',array(),'1.0'); wp_enqueue_style('owl-carousel', get_template_directory_uri() . '/css/owl.carousel.css',array(),'2.0'); if ( class_exists( 'WooCommerce' ) ) { wp_enqueue_style('woocommerce-style', get_template_directory_uri() . '/css/woocommerce-style.css'); wp_enqueue_style('bmci', get_template_directory_uri() . '/css/woocommerce.css'); } wp_enqueue_style('olam-color', get_template_directory_uri().'/css/color.css.php',array(),'1.0'); if( get_theme_mod('olam_dark_style') == 1 ) { wp_enqueue_style('dark-style', get_template_directory_uri() . '/css/dark-style.css'); } if(isset($loadedFonts) && (strlen($loadedFonts) >0 ) ) { wp_enqueue_style('olam-google-fonts',"{$protocol}://fonts.googleapis.com/css?family=".$loadedFonts); } wp_enqueue_script('modernizr', get_template_directory_uri().'/js/vendor/modernizr-2.8.3-respond-1.4.2.min.js',array('jquery'),'2.8.3'); wp_enqueue_script('jquery-easypiechart', get_template_directory_uri().'/js/jquery.easypiechart.min.js',array('jquery'),'2.1.5', true); wp_enqueue_script('olam-bootstrap-js', get_template_directory_uri().'/js/bootstrap.min.js',array('jquery'),'1.0', true); wp_enqueue_script('sly', get_template_directory_uri().'/js/sly.min.js',array(),'1.5.1', true); wp_enqueue_script('owl-carousel', get_template_directory_uri().'/js/owl.carousel.min.js',array('jquery'),'2.0', true); //wp_enqueue_script('pretty-photo', get_template_directory_uri().'/js/jquery.prettyPhoto.js',array('jquery'),'3.1.6', true); wp_enqueue_script('appear', get_template_directory_uri().'/js/appear.js',array(),'1.0', true); wp_enqueue_script('easing', get_template_directory_uri().'/js/easing.js',array('jquery'),'1.3', true); wp_enqueue_script('jquery-parallax', get_template_directory_uri().'/js/jquery.parallax-1.1.3.js',array('jquery'),'1.1.3', true); if(isset($data['theme_retina']) && $data['theme_retina']==1){ wp_enqueue_script('retina', get_template_directory_uri().'/js/retina.min.js',array(),'1.0',true); } wp_enqueue_script('olam-main', get_template_directory_uri().'/js/olam-main.js',array('jquery'),'1.0', true); if ( is_singular(array('post')) && comments_open() ){ wp_enqueue_script('comment-reply'); } $ajax_url =(function_exists('edd_get_ajax_url'))?edd_get_ajax_url():admin_url( 'admin-ajax.php' ); wp_localize_script( 'olam-main', 'olam_main_ajax', array( 'ajaxurl' => $ajax_url, 'nonce' => wp_create_nonce('olam_main'), 'piecolor'=>get_theme_mod('olam_theme_pri_color'), ) ); // Body specs $bodyspecscolor=get_theme_mod('olam_bodycolor'); $bodyspecsfont=get_theme_mod('olam_bodyfont'); $bodyspecssize=get_theme_mod('olam_bodysize'); $bodySpecs_color=(isset($bodyspecscolor))?$bodyspecscolor:null; $bodySpecs_font=(isset($bodyspecsfont))?$bodyspecsfont:null; $bodySpecs_size=(isset($bodyspecssize))?$bodyspecssize:null; $color = get_theme_mod( 'my-custom-color' ); //E.g. #FF0000 $inner_page_heading = olam_get_page_option(get_the_ID(),"olam_disable_inner_page_heading"); $custom_css = " body { font-family : {$bodySpecs_font}, Arial, Helvetica; color : {$bodySpecs_color}; font-size : {$bodySpecs_size}px; } "; if($inner_page_heading){ $custom_css.= " .inner-page-heading{ display:none; } "; } wp_add_inline_style( 'olam-color', $custom_css ); } } add_action('wp_enqueue_scripts', 'olam_register_styles_scripts'); /** * olam lightbox Function * PRETTY PHOTO * Prettyphoto (not Fancybox) will continue to be registered but not enqueued, since woocommerse update 2.7 */ if(class_exists('WooCommerce')){ add_action( 'wp_enqueue_scripts', 'olam_lightbox' ); function olam_lightbox() { global $woocommerce; $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; { wp_enqueue_script( 'prettyPhoto', esc_url( $woocommerce->plugin_url() ) . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true ); wp_enqueue_script( 'prettyPhoto-init', esc_url( $woocommerce->plugin_url() ) . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true ); wp_enqueue_style( 'woocommerce_prettyPhoto_css', esc_url( $woocommerce->plugin_url() ) . '/assets/css/prettyPhoto.css' ); } } } /** * Olam Theme Function - Load admin styles * Loading admin styles. **/ if( ! function_exists( 'olam_load_custom_wp_admin_style' ) ){ function olam_load_custom_wp_admin_style() { wp_enqueue_style( 'olam-admin-styles', get_template_directory_uri() . '/css/admin-styles.css'); } } add_action( 'admin_enqueue_scripts', 'olam_load_custom_wp_admin_style' ); /** * Olam Theme Function - Old IE Fixes * Fixes for old IE versions. **/ if( ! function_exists( 'olam_old_ie_fixes' ) ){ function olam_old_ie_fixes() { global $is_IE; if ( $is_IE ) { echo ''; } } } add_action( 'wp_head', 'olam_old_ie_fixes' ); /** * Olam Function - Pagination. * * This function sets the pagination for post pages. */ if( ! function_exists( 'olam_pagination' ) ){ function olam_pagination($pages = '', $range = 4, $ordinary=null) { // The Custom Pagination if(!isset($ordinary)){ $showitems = ($range * 2) + 1; global $paged; if (empty($paged)) $paged = 1; if ($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if (!$pages) { $pages = 1; } } if (1 != $pages) { echo "
"; }} else{ // The default wp pagination. if( get_next_posts_link() || get_previous_posts_link() ) { echo '
'; } } } } /** * Olam Function - ajax url. * * This function sets the ajaxurl. */ if( ! function_exists( 'olam_ajaxurl' ) ){ function olam_ajaxurl() { ?> -1, 'author' => $id, 'post_type'=>'download' ) ); while ($query->have_posts()) { $query->the_post(); $tags = wp_get_object_terms( get_the_ID(), 'download_tag'); foreach ($tags as $key => $val) { if ($val->term_id > 0) { if (!array_key_exists($val->term_id, $user_tags)) { $user_tags[$val->term_id] = $val; } } } } return $user_tags; } } /** * Olam Function - Get page options. * * This function gets the page meta options. */ if( ! function_exists( 'olam_get_page_option' ) ){ function olam_get_page_option($pageID,$pageOption){ $allOptions= get_post_meta($pageID,'fw_options'); $pageOptionData=(isset($allOptions[0][$pageOption]))?$allOptions[0][$pageOption]:false; return $pageOptionData; } } /** * Olam Function - EDD Sale Count. * * This function gets the edd sale count. */ if( ! function_exists( 'olam_get_edd_sale_count' ) ){ function olam_get_edd_sale_count($postID){ return get_post_meta( $postID, '_edd_download_sales', true ); } } /** * Olam Function - Get Comments. * * This function gets downloads comment count. */ if( ! function_exists( 'olam_get_comment_count' ) ){ function olam_get_comment_count($postID){ $itemComments=get_comments( array ( // post ID 'post_id' => $postID, // return just the total number 'count' => TRUE ) ); return $itemComments; } } /** * Olam Function - Authorization init. * * Initializing the authorisation. */ if( ! function_exists( 'olam_authorisation_init' ) ){ function olam_authorisation_init(){ if (function_exists('edd_get_option')) { $loginRedirectPageID=edd_get_option( 'login_redirect_page', '' ); $loginRedirect=get_permalink( $loginRedirectPageID ); } else { $loginRedirect=home_url(); } wp_enqueue_script('olam-register-login', get_template_directory_uri().'/js/olam-register-login.js', array('jquery')); wp_localize_script( 'olam-register-login', 'ajax_auth_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'redirecturl' => isset($loginRedirect) ? $loginRedirect : home_url(), 'loadingmessage' => esc_html__('Sending user info, please wait...','bmci') )); add_action( 'wp_ajax_olam_ajaxlogin', 'olam_ajaxlogin' ); add_action( 'wp_ajax_nopriv_olam_ajaxlogin', 'olam_ajaxlogin' ); add_action( 'wp_ajax_nopriv_olam_ajaxregister','olam_ajax_register' ); add_action( 'wp_ajax_olam_ajaxregister', 'olam_ajax_register' ); } } add_action('init', 'olam_authorisation_init'); /** * Olam Function - Ajax Login. * * Ajax popup login actions. */ if( ! function_exists( 'olam_ajaxlogin' ) ){ function olam_ajaxlogin(){ // First check the nonce, if it fails the function will break check_ajax_referer( 'ajax-login-nonce', 'security' ); // Nonce is checked, get the POST data and sign user on // Call auth_user_login olam_auth_user_login($_POST['username'], $_POST['password'], 'Login'); die(); } } /** * Olam Function - Ajax Register. * * Ajax popup register actions. */ if( ! function_exists( 'olam_ajax_register' ) ){ function olam_ajax_register(){ global $options; $options = get_option('olam_register_login'); // First check the nonce, if it fails the function will break check_ajax_referer( 'ajax-register-nonce', 'security' ); // Nonce is checked, get the POST data and sign user on $info = array(); $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['username']) ; $info['user_pass'] = sanitize_text_field($_POST['password']); $info['user_email'] = sanitize_email( $_POST['email']); // Register the user if(!is_email($info['user_email']) ){ echo json_encode(array('loggedin'=>false, 'message'=>esc_html__("Please enter a valid email address","olam"))); die(); } if(sanitize_text_field($_POST['password2'])!=$info['user_pass']){ echo json_encode(array('loggedin'=>false, 'message'=>esc_html__("Please enter same password in both fields","olam"))); die(); } if(!isset($info['user_pass'])|| !(strlen($info['user_pass']) >0 ) ){ echo json_encode(array('loggedin'=>false, 'message'=>esc_html__("Password fields cannot be blank","olam"))); die(); } $user_register = wp_insert_user( $info ); if ( is_wp_error($user_register) ){ $error = $user_register->get_error_codes() ; if(in_array('empty_user_login', $error)) echo json_encode(array('loggedin'=>false, 'message'=>$user_register->get_error_message('empty_user_login'))); elseif(in_array('existing_user_login',$error)) echo json_encode(array('loggedin'=>false, 'message'=>esc_html__('This username is already registered.','bmci'))); elseif(in_array('existing_user_email',$error)) echo json_encode(array('loggedin'=>false, 'message'=>esc_html__('This email address is already registered.','bmci'))); } else { olam_auth_user_login($info['nickname'], $info['user_pass'], 'Registration'); } die(); } } /** * Olam Function - Auth user login. * * Authenticating the popup login user. */ if( ! function_exists( 'olam_auth_user_login' ) ){ function olam_auth_user_login($user_login, $password, $login) { $info = array(); $info['user_login'] = $user_login; $info['user_password'] = $password; $info['remember'] = true; add_action( 'set_logged_in_cookie', 'olam_loggedin_cookie' ); function olam_loggedin_cookie( $logged_in_cookie ){ $_COOKIE[LOGGED_IN_COOKIE] = $logged_in_cookie; } $user_signon = wp_signon( $info, is_ssl() ? true : false); if ( is_wp_error($user_signon) ){ echo json_encode(array('loggedin'=>false, 'message'=>esc_html__('Wrong username or password.','bmci'))); } else { global $current_user; wp_set_current_user($user_signon->ID); if($login=="Login"){ echo json_encode(array('loggedin'=>true, 'message'=>esc_html__('Login successful, redirecting...','bmci'))); } else{ echo json_encode(array('loggedin'=>true, 'message'=>esc_html__('Registration successful, redirecting...','bmci'))); } } die(); } } /** * Olam Function - Printing the current user name. * * Displays the currently logged in user name. */ if( ! function_exists( 'olam_print_current_user_name' ) ){ function olam_print_current_user_name(){ $current_user = wp_get_current_user(); echo esc_html($current_user->user_login); } } add_action( 'wp_ajax_olam_main_ajax', 'olam_main_ajax' ); add_action( 'wp_ajax_nopriv_olam_main_ajax','olam_main_ajax'); /** * Olam Function - Main Ajax,mini cart. * * Mini cart main ajax action. */ if( ! function_exists( 'olam_main_ajax' ) ){ function olam_main_ajax(){ if(isset($_GET['cart_count']) && ($_GET['cart_count']==1) ){ echo edd_get_cart_quantity(); } else{ olam_print_mini_cart(); } die(); } } /** * Olam Function - Remove Item Url * Returns the URL to remove an item from the cart (Used in Mini cart) * * parameters => int - $cart_key - Cart item key * int - $cart_key_id- Cart item Post ID * return value => string - $remove_url - URL to remove the cart item */ if( ! function_exists( 'olam_remove_item_url' ) ){ function olam_remove_item_url( $cart_key, $cart_key_id ) { if ( defined( 'DOING_AJAX' ) ) { $current_page = edd_get_current_page_url(); } else { $current_page = edd_get_current_page_url(); } $remove_url = edd_add_cache_busting( add_query_arg( array( 'cart_item' => $cart_key, 'edd_action' => 'remove' ), $current_page ) ); return apply_filters( 'edd_remove_item_url', $remove_url ); } } /** * Olam Function - Print Mini Cart * * Displays the header minicart widget */ if( ! function_exists( 'olam_print_mini_cart' ) ){ function olam_print_mini_cart(){ if(!olam_check_edd_exists()){ return; } ?>
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='
' . esc_html__( 'Your cart is empty.', 'bmci' ) . '
'.esc_html__('Please add a product','bmci').'
'; return $message; } } /** * Olam Function - Custom excerpt length * * Modifying the excerpt length */ if( ! function_exists( 'olam_custom_excerpt_length' ) ) { function olam_custom_excerpt_length( $length ) { return 150; } } add_filter( 'excerpt_length', 'olam_custom_excerpt_length', 999 ); //Disable WordPress sanitization to allow more than just $allowedtags from /wp-includes/kses.php remove_filter('pre_user_description', 'wp_filter_kses'); //Add sanitization for WordPress posts add_filter( 'pre_user_description', 'wp_filter_post_kses'); /** * Olam Function - Replace Site Url * * Replacing the theme options siteurl with actual protocols. */ function olam_replace_site_url($url){ $data = ""; if (is_string($url)) { $data = str_replace( array( '[site_url]', '[site_url_secure]', ), array( home_url('', 'http'), home_url('', 'https'), ), $url ); } return $data; } /** * Olam Function - Price Filter * * Removing the id(to fix duplicate id issue) from price displayed. */ add_filter("edd_download_price_after_html","olam_edd_price_filter",10, 3); function olam_edd_price_filter($pricehtml,$id,$price){ $newpricehtml=''.$price.''; return $newpricehtml; } /** * Olam Function - Check for comments/pingbacks * * Removing the id(to fix duplicate id issue) from price displayed. */ function olam_post_has( $type, $post_id ) { $comments = get_comments('status=approve&type=' . $type . '&post_id=' . $post_id ); $comments = separate_comments( $comments ); return 0 < count( $comments[ $type ] ); } /** * Olam Function - Validate gravatar * * Validating gravatar from email. */ function olam_validate_gravatar($email) { //print_r($email); die; // Craft a potential url and test its headers $hash = md5(strtolower(trim($email))); $uri = 'https://www.gravatar.com/avatar/' . $hash . '?d=404'; $headers = @get_headers($uri); if (!preg_match("|200|", $headers[0])) { $has_valid_avatar = FALSE; } else { $has_valid_avatar = TRUE; } return $has_valid_avatar; } /** * Olam Function - Get terms dropdown * * Adding the download category filter. */ function olam_get_terms_dropdown() { $values = array( 'show_option_all' => esc_html__('All','bmci'), 'orderby' => 'name', 'order' => 'ASC', 'echo' => 1, 'hide_empty' => 1, 'show_count' => 1, 'selected' => $kat = get_query_var( 'download_cat' ), 'name' => 'download_cat', 'hierarchical' => 1, 'id' => '', 'value_field' => 'name', 'class' => 'download_cat_filter', 'taxonomy' => 'download_category' ); $categories = wp_dropdown_categories($values); } /** * Olam Function - posts_where Filter edit for search (custom post type = download) * */ function olam_search_where($where){ global $wpdb; if( is_search() ){ $where .= "OR (t.name LIKE '%".get_search_query()."%' AND {$wpdb->posts}.post_status = 'publish' )"; return $where; } } function olam_search_join($join){ global $wpdb; if( is_search()){ $join .= "LEFT JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id"; return $join; } } function olam_search_groupby($groupby){ global $wpdb; // we need to group on post ID $groupby_id = "{$wpdb->posts}.ID"; if(!is_search() || strpos($groupby, $groupby_id) !== false) return $groupby; // groupby was empty, use ours if(!strlen(trim($groupby))) return $groupby_id; // wasn't empty, append ours return $groupby.", ".$groupby_id; } // add_filter('posts_where','olam_search_where'); //add_filter('posts_join', 'olam_search_join'); //add_filter('posts_groupby', 'olam_search_groupby'); /** * Do not include php tag */ add_filter( 'posts_join', 'olam_custom_posts_join', 10, 2 ); /** * Callback for WordPress 'posts_join' filter.' * * @global $wpdb * @see https://codex.wordpress.org/Class_Reference/wpdb * * @link https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join * * @param string $join The sql JOIN clause. * @param WP_Query $wp_query The current WP_Query instance. * @return string $join The sql JOIN clause. */ function olam_custom_posts_join( $join, $query ) { global $wpdb; //* if main query and search... if ( is_main_query() && is_search() ) { //* join term_relationships, term_taxonomy, and terms into the current SQL where clause $join .= " LEFT JOIN ( {$wpdb->term_relationships} INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id INNER JOIN {$wpdb->terms} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id ) ON {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id "; } return $join; } /** * Do not include php tags */ add_filter( 'posts_where', 'olam_custom_posts_where', 10, 2 ); /** * Callback for WordPress 'posts_where' filter. * * Modify the where clause to include searches against a WordPress taxonomy. * * @see https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where * * @param string $where The where clause. * @param WP_Query $query The current WP_Query. * @return string The where clause. */ function olam_custom_posts_where( $where, $query ) { global $wpdb; if ( is_main_query() && is_search() ) { //* get additional where clause for the user $user_where = olam_get_user_posts_where(); $where .= " OR ( {$wpdb->term_taxonomy}.taxonomy IN( 'category', 'post_tag' ) AND {$wpdb->terms}.name LIKE '%" . esc_sql( get_query_var( 's' ) ) . "%' {$user_where} )"; } return $where; } /** * Get a where clause dependent on the current user's status. * * @global $wpdb * @see https://codex.wordpress.org/Class_Reference/wpdb * * @uses get_current_user_id() * @see http://codex.wordpress.org/Function_Reference/get_current_user_id * * @return string The user where clause. */ function olam_get_user_posts_where() { global $wpdb; $user_id = get_current_user_id(); $sql = ''; $status = array( "'publish'" ); if ( 0 !== $user_id ) { $status[] = "'private'"; $sql .= " AND {$wpdb->posts}.post_author = " . absint( $user_id ); } $sql .= " AND {$wpdb->posts}.post_status IN( " . implode( ',', $status ) . " ) "; return $sql; } /** * Do not include php tags */ add_filter( 'posts_groupby', 'olam_custom_posts_groupby', 10, 2 ); /** * Callback for WordPress 'posts_groupby' filter. * * Set the GROUP BY clause to post IDs. * * @global $wpdb * @see https://codex.wordpress.org/Class_Reference/wpdb * * @param string $groupby The GROUPBY caluse. * @param WP_Query $query The current WP_Query object. * @return string The GROUPBY clause. */ function olam_custom_posts_groupby( $groupby, $query ) { global $wpdb; //* if is main query and a search... if ( is_main_query() && is_search() ) { $groupby = "{$wpdb->posts}.ID"; } return $groupby; } // =========== Theme Demo data installation /** * @param FW_Ext_Backups_Demo[] $demos * @return FW_Ext_Backups_Demo[] */ function olam_filter_theme_fw_ext_backups_demos($demos) { $demos_array = array( 'olam_demo_1_2' => array( 'title' => esc_html__('demo1,2-Main', 'bmci'), 'screenshot' => 'https://themes.layero.com/olamwp/demo-data/demo12-main/screenshot.png', 'preview_link' => 'https://themes.layero.com/olamwp/', ), 'olam_demo_3' => array( 'title' => esc_html__('demo3-Services', 'bmci'), 'screenshot' => 'https://themes.layero.com/olamwp/demo-data/demo3-services/screenshot.png', 'preview_link' => 'https://themes.layero.com/olamwp3/', ), 'olam_demo_4' => array( 'title' => esc_html__('demo4-Booking', 'bmci'), 'screenshot' => 'https://themes.layero.com/olamwp/demo-data/demo4-booking/screenshot.png', 'preview_link' => 'https://themes.layero.com/olamwp4/', ), ); $download_url = 'https://themes.layero.com/olamwp/demo-data/index.php'; foreach ($demos_array as $id => $data) { $demo = new FW_Ext_Backups_Demo($id, 'piecemeal', array( 'url' => $download_url, 'file_id' => $id, )); $demo->set_title($data['title']); $demo->set_screenshot($data['screenshot']); $demo->set_preview_link($data['preview_link']); $demos[ $demo->get_id() ] = $demo; unset($demo); } return $demos; } add_filter('fw:ext:backups-demo:demos', 'olam_filter_theme_fw_ext_backups_demos'); // Function to remove version numbers function sdt_remove_ver_css_js( $src ) { if ( strpos( $src, 'ver=' ) ) $src = remove_query_arg( 'ver', $src ); return $src; } // display custom admin notice function st_custom_admin_notice() { $st_th_info = wp_get_theme(); $currentversion = str_replace('.','',(esc_html( $st_th_info->get('Version') ))); $isitdismissed = 'st_notice_dismissed'.$currentversion; if ( !get_user_meta( get_current_user_id() , $isitdismissed ) ) { ?>

get('Name') );?> - get('Version') ); ?> Dismiss this message

get('Version') ))); $dismissurl = 'st-notice-dismissed'.$currentversion; $isitdismissed = 'st_notice_dismissed'.$currentversion; $user_id = get_current_user_id(); if ( isset( $_GET[$dismissurl] ) ) add_user_meta( $user_id, $isitdismissed, 'true', true ); } add_action( 'admin_init', 'st_notice_dismissed' ); // Hide Brizy page builder upsell admin notice and WC template notices add_action('admin_head', 'hide_brizy_admin_notice'); function hide_brizy_admin_notice() { echo ''; }