//bloginfo('url');
//bloginfo( 'template_url' );
add_theme_support('post-thumbnails');
add_image_size( 'i3500', 3500);
add_image_size( 'i1200', 1200);
add_image_size( 'i600', 600);
include('includes/blocks.php');
add_theme_support('menus');
wp_enqueue_script('jquery');
//disable feeds
function wp_disable_feeds(){
wp_die( __('No feeds available!') );
}
add_action('do_feed', 'wp_disable_feeds', 1);
add_action('do_feed_rdf', 'wp_disable_feeds', 1);
add_action('do_feed_rss', 'wp_disable_feeds', 1);
add_action('do_feed_rss2', 'wp_disable_feeds', 1);
add_action('do_feed_atom', 'wp_disable_feeds', 1);
add_action('do_feed_rss2_comments', 'wp_disable_feeds', 1);
add_action('do_feed_atom_comments', 'wp_disable_feeds', 1);
//remove image resize from wordpress 5.3 and up
add_filter( 'big_image_size_threshold', '__return_false' );
add_filter( 'wp_default_scripts', 'dequeue_jquery_migrate' );
function dequeue_jquery_migrate( &$scripts){
if(!is_admin()){
$scripts->remove( 'jquery');
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' );
}
}
add_filter('acf/fields/relationship/result', 'acf_append_edit_link_to_relationship_results', 10, 4);
function acf_append_edit_link_to_relationship_results($title, $post, $field, $post_id) {
if($post->post_type=='product')
{
$tmpFields=get_fields($post->ID);
$title='

'.$title.' - '.$tmpFields['uci'];
}
return $title;
}
//remove global styles css
function wps_deregister_styles() {
wp_dequeue_style( 'global-styles' );
}
add_action( 'wp_enqueue_scripts', 'wps_deregister_styles', 100 );
//Remove the REST API endpoint.
remove_action('rest_api_init', 'wp_oembed_register_route');
// Turn off oEmbed auto discovery.
add_filter( 'embed_oembed_discover', '__return_false' );
//Don't filter oEmbed results.
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
//Remove oEmbed discovery links.
remove_action('wp_head', 'wp_oembed_add_discovery_links');
//Remove oEmbed JavaScript from the front-end and back-end.
remove_action('wp_head', 'wp_oembed_add_host_js');
//google maps api key for admin area
/*function my_acf_init() {
acf_update_setting('google_api_key', 'AIzaSyAWD7xvIsJ1qHXVARIQgXcki3ThskR0dAo');
}
add_action('acf/init', 'my_acf_init');*/
function printTime($time)
{
if($time<60)
return $time.' min ';
else
{
$hours=floor($time/60);
$mins=$time%60;
$print=$hours.' h ';
if($mins>0)
$print.=' '.$mins.' min';
return $print;
}
}
function doThumb($id,$size){
$tmpUrl=wp_get_attachment_image_src($id,$size);
return $tmpUrl[0];
}
function doBg($id,$sizePhone,$sizeDesktop){
$str='';
if($sizePhone!='')
{
$tmpUrl=wp_get_attachment_image_src($id,$sizePhone);
$str.=' data-bgPhone="'.$tmpUrl[0].'" ';
}
if($sizeDesktop!='')
{
$tmpUrl=wp_get_attachment_image_src($id,$sizeDesktop);
$str.=' data-bgDesktop="'.$tmpUrl[0].'" ';
}
return $str;
}
// optimizations
function disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
}
add_action( 'init', 'disable_emojis' );
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
function remove_jquery_migrate( $scripts ) {
if(!is_admin()&&isset($scripts->registered['jquery'])){
$script = $scripts->registered['jquery'];
if( $script->deps ){ // Check whether the script has any dependencies
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );
function remove_gutenberg_styles() {
wp_dequeue_style( 'wp-block-library' );
}
add_action( 'wp_enqueue_scripts', 'remove_gutenberg_styles', 100 );
function acf_wysiwyg_remove_wpautop() {
remove_filter('acf_the_content', 'wpautop' );
}
add_action('acf/init', 'acf_wysiwyg_remove_wpautop');
function getExcerpt($str,$words=70,$addDots=true)
{
return preg_replace("/^\W*((\w[\w'-]*\b\W*){1,".$words."}).*/ms", '\\1',strip_tags($str)).($addDots==true?'[...]':'');
}
class FLHM_HTML_Compression{
protected $flhm_compress_css = false;
protected $flhm_compress_js = false;
protected $flhm_info_comment = true;
protected $flhm_remove_comments = true;
protected $html;
public function __construct($html)
{
if (!empty($html))
$this->flhm_parseHTML($html);
}
public function __toString()
{
return $this->html;
}
protected function flhm_bottomComment($raw, $compressed)
{
$raw = strlen($raw);
$compressed = strlen($compressed);
$savings = ($raw-$compressed) / $raw * 100;
$savings = round($savings, 2);
return '';
}
protected function flhm_minifyHTML($html)
{
$pattern = '/<(?