You are on page 1of 5

<?

php
/**
* Hestia functions and definitions
*
* @package Hestia
* @since Hestia 1.0
*/

define( 'HESTIA_VERSION', '1.1.85' );


define( 'HESTIA_VENDOR_VERSION', '1.0.1' );
define( 'HESTIA_PHP_INCLUDE', trailingslashit( get_template_directory() ) .
'inc/' );
define( 'HESTIA_CORE_DIR', HESTIA_PHP_INCLUDE . 'core/' );

wp_enqueue_script( 'contact', get_template_directory_uri() . '/contact.js', array (


'jquery' ), 1.0, true);

// Load hooks
require_once( HESTIA_PHP_INCLUDE . 'hooks/hooks.php' );

// Load Helper Globally Scoped Functions


require_once( HESTIA_PHP_INCLUDE . 'helpers/sanitize-functions.php' );
require_once( HESTIA_PHP_INCLUDE . 'helpers/layout-functions.php' );

if ( class_exists( 'WooCommerce' ) ) {
require_once( HESTIA_PHP_INCLUDE .
'compatibility/woocommerce/functions.php' );
}

if ( function_exists( 'max_mega_menu_is_enabled' ) ) {
require_once( HESTIA_PHP_INCLUDE . 'compatibility/max-mega-
menu/functions.php' );
}
/**
* Adds notice for PHP < 5.3.29 hosts.
*/
function hestia_no_support_5_3() {
$message = __( 'Hey, we\'ve noticed that you\'re running an outdated version
of PHP which is no longer supported. Make sure your site is fast and secure, by
upgrading PHP to the latest version.', 'hestia' );

printf( '<div class="error"><p>%1$s</p></div>', esc_html( $message ) );


}

if ( version_compare( PHP_VERSION, '5.3.29' ) < 0 ) {


/**
* Add notice for PHP upgrade.
*/
add_filter( 'template_include', '__return_null', 99 );
switch_theme( WP_DEFAULT_THEME );
unset( $_GET['activated'] );
add_action( 'admin_notices', 'hestia_no_support_5_3' );

return;
}

/**
* Begins execution of the theme core.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 1.0.0
*/
function hestia_run() {
new Hestia_Core();

$vendor_file = trailingslashit( get_template_directory() ) .


'vendor/autoload.php';
if ( is_readable( $vendor_file ) ) {
require_once $vendor_file;
}
add_filter( 'themeisle_sdk_products', 'hestia_load_sdk' );
}

/**
* Loads products array.
*
* @param array $products All products.
*
* @return array Products array.
*/
function hestia_load_sdk( $products ) {
$products[] = get_template_directory() . '/style.css';

return $products;
}

require_once( HESTIA_CORE_DIR . 'class-hestia-autoloader.php' );


Hestia_Autoloader::set_path( HESTIA_PHP_INCLUDE );
Hestia_Autoloader::define_excluded_files(
array(
'node_modules',
'hooks',
'helpers',
)
);
Hestia_Autoloader::define_namespaces( array( 'Hestia' ) );

/**
* Invocation of the Autoloader::loader method.
*
* @since 1.0.0
*/
spl_autoload_register( 'Hestia_Autoloader::loader' );

/**
* The start of the app.
*
* @since 1.0.0
*/
hestia_run();

/**
* Upgrade link to BeaverBuilder
*/
function hestia_bb_upgrade_link() {
return 'https://www.wpbeaverbuilder.com/?fla=101&campaign=hestia';
}

add_filter( 'fl_builder_upgrade_url', 'hestia_bb_upgrade_link' );

if ( ! defined( 'ELEMENTOR_PARTNER_ID' ) ) {
define( 'ELEMENTOR_PARTNER_ID', 2112 );
}

/**
* Append theme name to the upgrade link
* If the active theme is child theme of Hestia
*
* @param string $link - Current link.
*
* @return string $link - New upgrade link.
* @package hestia
* @since 1.1.75
*/
function hestia_upgrade_link( $link ) {

$theme_name = wp_get_theme()->get_stylesheet();

$hestia_child_themes = array(
'orfeo',
'fagri',
'tiny-hestia',
'christmas-hestia',
);

if ( $theme_name === 'hestia' ) {


return $link;
}

if ( ! in_array( $theme_name, $hestia_child_themes ) ) {


return $link;
}

$link = add_query_arg(
array(
'theme' => $theme_name,
), $link
);

return $link;
}

add_filter( 'hestia_upgrade_link_from_child_theme_filter', 'hestia_upgrade_link' );

/**
* Check if $no_seconds have passed since theme was activated.
* Used to perform certain actions, like displaying upsells or add a new
recommended action in About Hestia page.
*
* @param integer $no_seconds number of seconds.
*
* @return bool
* @since 1.1.45
* @access public
*/
function hestia_check_passed_time( $no_seconds ) {
$activation_time = get_option( 'hestia_time_activated' );
if ( ! empty( $activation_time ) ) {
$current_time = time();
$time_difference = (int) $no_seconds;
if ( $current_time >= $activation_time + $time_difference ) {
return true;
} else {
return false;
}
}

return true;
}

/**
* Legacy code function.
*/
function hestia_setup_theme() {
return;
}

add_action('woocommerce_after_shop_loop_item_title',
'woocommerce_after_shop_loop_item_title_short_description', 5);

/** Add the Dealer Locator banner before the "Related Products" bit. **/

add_action( 'woocommerce_after_single_product_summary',
'custom_single_product_banner', 12 );
function custom_single_product_banner() {

$output = '<div class="dealer_locator_container">


<div class="dealer_locator_main">
<h3 class="dealer_locator_title">
Find Yours wherever you are.
</h3>
<div class="dealer_locator_txt">
<p>Vestibulum pretium sagittis ex, ac dictum ante rhoncus eu.
Phasellus tempus auctor varius. Vestibulum consequat, lectus nec hendrerit rutrum,
velit risus maximus dolor, molestie gravida dui sapien sit amet neque.</p>
</div>
<div class="dealer_locator_button">
<a class="button_text"
href="http://localhost/test/contact_test/">
<span>Find a Retailer</span>
</a>
</div>
</div>
</div>';
echo $output;
};

add_filter( 'woocommerce_get_image_size_thumbnail', function( $size ) {


return array(
'width' => 400,
'height' => 400,
'crop' => 0,
);
});

add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {


return array(
'width' => 180,
'height' => 180,
'crop' => 0,
);
});

You might also like