File: /home/.Trash/valcnct/public_html/wp-content/themes/enfold-child/functions.php
<?php
/*
* Add your own functions here. You can also copy some of the theme functions into this file.
* Wordpress will use those functions instead of the original functions then.
*/
add_filter( 'ppp_nonce_life', 'my_nonce_life' );
function my_nonce_life() {
return 60 * 60 * 24 * 7; // 5 days
}
/******************************************************/
/* creativeengineeringstudio.com | Custom PHP Code */
/******************************************************/
/* removes the "Reset Theme Options" button */
add_action('admin_head', 'remove_reset_button');
function remove_reset_button() {
echo '<style>
.avia_footer_reset{ display: none !important; }
</style>';
}
/* remove all the tooltips that appear when you hover over an image */
function add_custom_tooltip(){
?>
<script>
jQuery(window).load(function(){
jQuery('a').removeAttr('title');
jQuery('img').removeAttr('title');
});
</script>
<?php
}
add_action('wp_footer', 'add_custom_tooltip');
/* use a widget area in the header
add_action( 'ava_after_main_menu', 'enfold_customization_header_widget_area' );
function enfold_customization_header_widget_area() {
dynamic_sidebar( 'header' );
}
*/
/* use the social share section on pages and not just posts -
If you want to add it below the single product page featured image, you can use this but it will disable the sidebar:
remove_action( 'woocommerce_before_single_product_summary', 'avia_close_image_div', 20);
add_action( 'woocommerce_before_single_product_summary', 'avia_product_share', 20);
function avia_product_share() {
//share links on single post
avia_social_share_links();
echo "</div>";
}
*/
/* use the social share section on pages and not just posts -
Use this one if you simply want to add it below the single product page content:
add_action('woocommerce_after_single_product_summary', 'avia_add_social_toolbar', 10);
function avia_add_social_toolbar()
{
$content = avia_social_share_links(array(), false, '', false);
$content .= '<div class="hr"></div>';
echo $content;
}
*/
/* change the logo url on some pages
add_filter('avf_logo','av_change_logo_url');
function av_change_logo_url($url)
{
if( is_front_page() )
{
$url = "http://creativeengineeringstudio.com/dev/core/wp-content/uploads/2016/01/logo-placeholder-340x156.jpg";
}
if( is_page('contact') )
{
$url = "http://creativeengineeringstudio.com/dev/core/wp-content/uploads/2018/03/logo-placeholder-white-new_red.png";
}
return $url;
}
*/
/* use the Layout Builder with any post type */
add_filter('avf_builder_boxes', 'add_builder_to_posttype');
function add_builder_to_posttype($metabox)
{
foreach($metabox as &$meta)
{
if($meta['id'] == 'avia_builder' || $meta['id'] == 'layout')
{
$meta['page'][] = 'post'; /*instead add the name of the custom post type here*/
}
}
return $metabox;
}
/* replace the default “Blog – Latest News” title
add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
function fix_single_post_title($args,$id)
{
if ( $args['title'] == 'Blog - Latest News' )
{
$args['title'] = get_the_title($id);
$args['link'] = get_permalink($id);
$args['heading'] = 'h1';
}
return $args;
}
*/
/* enable Avia Layout Builder Debug */
//set builder mode to debug
add_action('avia_builder_mode', "builder_set_debug");
function builder_set_debug()
{
return "debug";
}
/* add subtext to logo
add_filter('avf_logo_subtext', 'kriesi_logo_addition');
function kriesi_logo_addition($sub) {
$sub .= 'Company Name';
return $sub;
}
*/
/* add a currency to Gravity Forms (Rands)
add_filter("gform_currencies", "update_currency");
function update_currency($currencies) {
$currencies['EUR'] = array(
"name" => __("Rand", "gravityforms"),
"symbol_left" => "R",
"symbol_right" => '',
"symbol_padding" => " ",
"thousand_separator" => ',',
"decimal_separator" => '.',
"decimals" => 2);
return $currencies;
}
*/
/* integrate Relevanssi Search
add_filter('avf_ajax_search_function', 'avia_init_relevanssi', 10, 4);
function avia_init_relevanssi($function_name, $search_query, $search_parameters, $defaults)
{
$function_name = 'avia_relevanssi_search';
return $function_name;
}
function avia_relevanssi_search($search_query, $search_parameters, $defaults)
{
global $query;
$tempquery = $query;
if(empty($tempquery)) $tempquery = new WP_Query();
$tempquery->query_vars = $search_parameters;
relevanssi_do_query($tempquery);
$posts = $tempquery->posts;
return $posts;
}
*/
/* add a different logo to a specific page
add_filter('avf_logo','av_change_logo');
function av_change_logo($logo)
{
if(is_page( 'slug-of-page' ) )
{
$logo = "http://www.kriesi.at/wp-content/themes/kriesi/images/logo.png";
}
return $logo;
}
*/
/* Gravity Forms - Custom CAPTCHA */
function validate_captcha_entry( $result, $value, $form, $field ) {
$valid_captcha_entry = array(
'VAL' => 'CAPTCHA',
);
// Allow user entry to include lower-case letters.
$capitalized_value = strtoupper( $value );
// Check if the entered entry is valid.
if ( ! array_key_exists( $capitalized_value, $valid_captcha_entry ) ) {
$result['is_valid'] = false;
$result['message'] = 'That answer appears to be invalid. Please try again.';
}
return $result;
}
add_filter( 'gform_field_validation_3_10', 'validate_captcha_entry', 10, 4 );
// Register new icon as a theme icon - YouTube + Instagram + Google Plus
function avia_add_custom_icon($icons) {
$icons['youtube-2'] = array( 'font' =>'fontello', 'icon' => 'uf16a');
$icons['instagram-2'] = array( 'font' =>'fontello', 'icon' => 'uf16d');
$icons['gplus'] = array( 'font' =>'fontello', 'icon' => 'uf0d5');
return $icons;
}
add_filter('avf_default_icons','avia_add_custom_icon', 10, 1);
// Add new icon as an option for social icons - YouTube + Instagram + Google Plus
function avia_add_custom_social_icon($icons) {
$icons['youtube-2'] = 'youtube-2';
$icons['instagram-2'] = 'instagram-2';
$icons['gplus'] = 'gplus';
return $icons;
}
add_filter('avf_social_icons_options','avia_add_custom_social_icon', 10, 1);
// Vanilla pop-up box
function add_custom_script(){
?>
<script type="text/javascript">
jQuery(window).ready(function($){
jQuery('.open-popup-link').magnificPopup({
type:'inline',
midClick: true
});
});
</script>
<?php
}
add_action('wp_footer', 'add_custom_script');
/* Custom GForms Spinner */
add_filter( 'gform_ajax_spinner_url', 'spinner_url', 10, 2 );
function spinner_url( $image_src, $form ) {
return "/dev/valcucine/wp-content/uploads/2018/09/Dual_Ring-1s-15px-thick.gif";
}
/* Google Structured Data Tool Test - ImageObject Fix */
add_filter('avf_markup_helper_attributes', 'avf_markup_helper_attributes_modified', 10, 2);
function avf_markup_helper_attributes_modified($attributes, $args) {
if($args['context'] == 'image') {
$attributes['itemprop'] = 'image';
}
return $attributes;
}
// Load WP jquery.js in footer
function starter_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', includes_url( '/js/jquery/jquery.js' ), false, NULL, true );
wp_enqueue_script( 'jquery' );
wp_enqueue_style( 'starter-style', get_stylesheet_uri() );
wp_enqueue_script( 'includes', get_template_directory_uri() . '/js/min/includes.min.js', '', '', true );
}
add_action( 'wp_enqueue_scripts', 'starter_scripts' );