600, 'display' => 'Каждые 10 минут' ); $raspisanie['one_minutes'] = array( 'interval' => 60, 'display' => 'Каждую минут' ); $raspisanie['five_minutes'] = array( 'interval' => 300, 'display' => 'Каждые 5 минут' ); $raspisanie['there_minutes'] = array( 'interval' => 180, 'display' => 'Каждые 3 минут' ); $raspisanie['there_hours'] = array( 'interval' => 10800, 'display' => 'Каждые 3 часа' ); $raspisanie['hours'] = array( 'interval' => 3600, 'display' => 'Каждый час' ); return $raspisanie; } //hourly if( !wp_next_scheduled('action_generateXML') ) wp_schedule_event( time(), 'hours', 'action_generateXML'); add_action( 'action_generateXML', 'generateXML', 10); function generateXML() { global $wpdb, $post; $max_second=(int)ini_get('max_execution_time'); ini_set("memory_limit", '3000M'); $start = time(); $tmp_path=ABSPATH.'wp-content/uploads/temp_xml'; $tmp_feeds=$tmp_path.'/all_feeds/'; $tmp_file=$tmp_path.'/xml.tmp'; $feeds_path=ABSPATH.'/feed/'; require_once(get_template_directory().'/includes/classes/feed.php'); $feed=new Feed($tmp_file); $start_size=$feed->getSize(); sleep(1); if($start_size!=$feed->getSize()) { echo 'Процесс уже идет!'; die(); } $max_size=250000000; $step=150000; $term_str=''; // $terms=get_terms( ['taxonomy'=>'product_cat','child_of'=>19,'hide_empty'=>false]); // $terms[]=get_term(19); $terms=get_terms( ['taxonomy'=>'product_cat','hide_empty'=>false]); $term_ids=array(); foreach ($terms as $term) { $term_ids[]=$term->term_id; $term_str .="'".$term->term_id."',"; } $term_str=trim($term_str,','); if($feed->getSize()==0) { $feed->new_string(''); $feed->new_string(''); $feed->new_string(''); $feed->new_string(''); $feed->tags('name', get_bloginfo('name')); $feed->tags('company', get_bloginfo('name')); $feed->tags('url', home_url()); $feed->tags('phone', 'Россия: '.get_field('phone','options')); $feed->tags('platform', 'Yandex.YML'); $feed->tags('version', '1.7.3'); $feed->new_string(''); $feed->new_string(''); $feed->new_string(''); $feed->new_string(''); foreach($terms as $term) { $parent_id=$term->parent ? 'parentId="'.$term->parent.'"' : 'parentId="0"'; $feed->new_string(''.trim($term->name).''); } $feed->new_string(''); $feed->new_string(''); } unset($terms); $query_str="SELECT ID FROM $wpdb->posts p left join $wpdb->term_relationships tr ON (p.ID = tr.object_id) where p.ID > %d and p.post_type = 'product' and p.post_status = 'publish' "; if($term_str) { $query_str .=" and tr.term_taxonomy_id IN (".$term_str.") "; } $query_str .=" group by p.ID ORDER BY p.ID limit %d "; $current_product=get_option('xml_current_product') ? get_option('xml_current_product') : 0; $query_str=$wpdb->prepare($query_str, $current_product,$step ); foreach ($wpdb->get_col($query_str) as $ID) { $post=get_post($ID); setup_postdata($post); $feed->new_string(''); $feed->tags('url', get_the_permalink()); $feed->tags('price', round(get_post_meta( $ID, '_price', true ))); $feed->tags('currencyId', 'RUB'); foreach (array_reverse(wp_get_object_terms( array($ID), 'product_cat', array('fields'=>'ids') )) as $term_id) { if(in_array($term_id,$term_ids)) { $feed->tags('categoryId', $term_id); break; } } $feed->tags('delivery', 'true'); $feed->tags('name', Feed::prepareField(get_the_title())); $desc=get_the_content(); if($desc) { $feed->tags('description', Feed::cdata($desc)); } //$feed->tags('vendor', Feed::prepareField($array['BRAND'])); foreach (return_post_meta_and_name ($ID) as $name=>$value) { $feed->tags('param', Feed::prepareField($value), array('type'=>'name', 'text'=>Feed::prepareField($name))); } $feed->tags('picture', get_the_post_thumbnail_url( $ID, 'full' )); $feed->new_string(''); $end_work_time= 600 - (time() - $start); // update_option( 'end_work_time', $end_work_time,false); if($end_work_time < 7) { update_option( 'xml_current_product', $ID,false); die(); } if($feed->getSize() > $max_size) { $feed->new_string(''); $feed->new_string(''); $feed->new_string(''); $k=1; $new_feed=$tmp_feeds.'yml_'.$k.'.xml'; while(file_exists($new_feed)) { $k++; $new_feed=$tmp_feeds.'yml_'.$k.'.xml'; } unset($feed); rename($tmp_file, $new_feed); //$wpdb update_option( 'xml_current_product', $ID,false); die(); } // array_map('unlink',glob(ABSPATH.'/feed/*')); //glob($tmp_feeds.'*'); //file_exists } $feed->new_string(''); $feed->new_string(''); $feed->new_string(''); $k=1; $new_feed=$tmp_feeds.'yml_'.$k.'.xml'; while(file_exists($new_feed)) { $k++; $new_feed=$tmp_feeds.'yml_'.$k.'.xml'; } unset($feed); rename($tmp_file, $new_feed); array_map('unlink',glob($feeds_path.'*')); $links=new Feed($feeds_path.'link.txt'); foreach (glob($tmp_feeds.'*') as $item) { $name_file=basename($item); rename($item, $feeds_path.$name_file); $links->new_string(home_url().'/feed/'.$name_file); } unset($links); delete_option('xml_current_product'); } ?> null, 'labels' => array( 'name' => 'Услуги', // основное название для типа записи 'singular_name' => 'Услуга', // название для одной записи этого типа 'add_new' => 'Добавить услугу', // для добавления новой записи 'add_new_item' => 'Добавление услуги', // заголовка у вновь создаваемой записи в админ-панели. 'edit_item' => 'Редактирование услуги', // для редактирования типа записи 'new_item' => 'Новая услуга', // текст новой записи 'view_item' => 'Смотреть услугу', // для просмотра записи этого типа. 'search_items' => 'Искать услугу', // для поиска по этим типам записи 'not_found' => 'Не найдено', // если в результате поиска ничего не было найдено 'not_found_in_trash' => 'Не найдено в корзине', // если не было найдено в корзине 'parent_item_colon' => '', // для родителей (у древовидных типов) 'menu_name' => 'Услуги', // название меню ), 'description' => '', 'public' => true, // 'publicly_queryable' => null, // зависит от public // 'exclude_from_search' => null, // зависит от public // 'show_ui' => null, // зависит от public 'show_in_menu' => true, // показывать ли в меню адмнки // 'show_in_admin_bar' => null, // зависит от show_in_menu 'show_in_rest' => null, // добавить в REST API. C WP 4.7 'rest_base' => null, // $post_type. C WP 4.7 'menu_position' => null, 'menu_icon' => null, //'capability_type' => 'post', //'capabilities' => 'post', // массив дополнительных прав для этого типа записи //'map_meta_cap' => null, // Ставим true чтобы включить дефолтный обработчик специальных прав 'hierarchical' => true, 'supports' => ['title', 'editor', 'thumbnail','page-attributes'], // 'title','editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions','page-attributes','post-formats' // 'taxonomies' => ['types'], 'has_archive' => true, 'rewrite' => true, 'query_var' => true, )); register_post_type('proizvodstvo', array( 'label' => null, 'labels' => array( 'name' => 'Производство', // основное название для типа записи 'singular_name' => 'Производство', // название для одной записи этого типа 'add_new' => 'Добавить Производство', // для добавления новой записи 'add_new_item' => 'Добавление Производства', // заголовка у вновь создаваемой записи в админ-панели. 'edit_item' => 'Редактирование Производства', // для редактирования типа записи 'new_item' => 'Новое Производство', // текст новой записи 'view_item' => 'Смотреть Производство', // для просмотра записи этого типа. 'search_items' => 'Искать Производство', // для поиска по этим типам записи 'not_found' => 'Не найдено', // если в результате поиска ничего не было найдено 'not_found_in_trash' => 'Не найдено в корзине', // если не было найдено в корзине 'parent_item_colon' => '', // для родителей (у древовидных типов) 'menu_name' => 'Производство', // название меню ), 'description' => '', 'public' => true, // 'publicly_queryable' => null, // зависит от public // 'exclude_from_search' => null, // зависит от public // 'show_ui' => null, // зависит от public 'show_in_menu' => true, // показывать ли в меню адмнки // 'show_in_admin_bar' => null, // зависит от show_in_menu 'show_in_rest' => null, // добавить в REST API. C WP 4.7 'rest_base' => null, // $post_type. C WP 4.7 'menu_position' => null, 'menu_icon' => null, //'capability_type' => 'post', //'capabilities' => 'post', // массив дополнительных прав для этого типа записи //'map_meta_cap' => null, // Ставим true чтобы включить дефолтный обработчик специальных прав 'hierarchical' => true, 'supports' => ['title', 'editor', 'thumbnail','page-attributes'], // 'title','editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions','page-attributes','post-formats' // 'taxonomies' => ['types'], 'has_archive' => true, 'rewrite' => true, 'query_var' => true, )); register_post_type('cities', array( 'label' => null, 'labels' => array( 'name' => 'Города', // основное название для типа записи 'singular_name' => 'Город', // название для одной записи этого типа 'add_new' => 'Добавить Город', // для добавления новой записи 'add_new_item' => 'Добавление Города', // заголовка у вновь создаваемой записи в админ-панели. 'edit_item' => 'Редактирование Города', // для редактирования типа записи 'new_item' => 'Новый Город', // текст новой записи 'view_item' => 'Смотреть Город', // для просмотра записи этого типа. 'search_items' => 'Искать Город', // для поиска по этим типам записи 'not_found' => 'Не найдено', // если в результате поиска ничего не было найдено 'not_found_in_trash' => 'Не найдено в корзине', // если не было найдено в корзине 'parent_item_colon' => '', // для родителей (у древовидных типов) 'menu_name' => 'Города', // название меню ), 'description' => '', 'public' => true, 'publicly_queryable' => false, // зависит от public 'exclude_from_search' => false, // зависит от public // 'show_ui' => null, // зависит от public 'show_in_menu' => true, // показывать ли в меню адмнки // 'show_in_admin_bar' => null, // зависит от show_in_menu 'show_in_rest' => null, // добавить в REST API. C WP 4.7 'rest_base' => null, // $post_type. C WP 4.7 'menu_position' => null, 'menu_icon' => null, //'capability_type' => 'post', //'capabilities' => 'post', // массив дополнительных прав для этого типа записи //'map_meta_cap' => null, // Ставим true чтобы включить дефолтный обработчик специальных прав 'hierarchical' => false, 'supports' => ['title'], // 'title','editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions','page-attributes','post-formats' // 'taxonomies' => ['types'], 'has_archive' => false, 'rewrite' => false, 'query_var' => false, )); } ?> 'Настройки сайта', 'menu_title' => 'Настройки сайта', 'menu_slug' => 'theme-general-settings', 'capability' => 'edit_posts', 'redirect' => false )); } if( 'disable_gutenberg' ){ add_filter( 'use_block_editor_for_post_type', '__return_false', 100 ); remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); add_action( 'admin_init', function(){ remove_action( 'admin_notices', [ 'WP_Privacy_Policy_Content', 'notice' ] ); add_action( 'edit_form_after_title', [ 'WP_Privacy_Policy_Content', 'notice' ] ); } ); } add_filter( 'body_class',function ( $classes ) { // добавим класс 'class-name' в массив классов $classes $classes[] = 'flex'; $classes[] = 'column'; return $classes; } ); add_filter('wp_title','clear_title', 10,3); function clear_title ($title, $sep, $seplocation) { $parts=explode($sep,$title); return array_pop($parts); } add_filter('post_thumbnail_id','set_default_img'); function set_default_img($thumbnail_id) { if(!$thumbnail_id) { $thumbnail_id=get_field('default_img','options'); } return $thumbnail_id; } add_filter('wp_get_attachment_image_src',function ($image){ $image[1]=''; $image[2]=''; return $image; }); add_theme_support( 'html5', array( 'script', 'style' ) ); ?> __( 'Front Menu', 'Главное меню' ), 'footer' => __( 'Footer Menu', 'Меню в подвале меню' ), ) ); add_filter( 'nav_menu_css_class', 'add_my_class_to_nav_menu', 10, 3 ); function add_my_class_to_nav_menu( $classes, $item,$args ){ if($args->theme_location=='front') { $classes[] = 'menu__item'; if(in_array('menu-item-has-children',$classes)) { $classes[] = 'menu__item--has_childs'; } if(in_array('current-menu-item',$classes)) { $classes[] = 'active'; } } if($args->theme_location=='footer') { $classes[] = 'sgrid_12'; $classes[] = 'md_sgrid_6'; } return $classes; } add_filter( 'nav_menu_link_attributes','add_class_parent_link_menu', 10,4 ); function add_class_parent_link_menu ($atts, $item, $args, $depth ) { if($args->theme_location=='front') { if(is_array($item->classes)) { $atts['class']='menu__link'; } } return $atts; } add_filter( 'nav_menu_submenu_css_class','add_class_submenu', 10,3 ); function add_class_submenu($classes, $args, $depth) { if($args->theme_location=='front') { $classes[]='menu__submenu'; } return $classes; } ?> [ 'product_cat' ], 'hide_empty' => false, 'parent' => $parent_id, ]; if(is_shop()) { $args['exclude']=15; } $TERMS=get_terms($args); if($TERMS) { if ($new_template = locate_template(array('woocommerce/categories_page.php'))) { $template = $new_template; } } } } return $template; } add_filter( 'template_include', 'template_uslugi_proizvodstvo', 11); function template_uslugi_proizvodstvo ($template) { if(!is_admin()) { if ((is_post_type_archive('proizvodstvo') || is_post_type_archive('uslugi'))) { if ($new_template = locate_template(array('archive-uslugi-proizvodstvo.php'))) { $template = $new_template; } } if ((is_singular('proizvodstvo') || is_singular('uslugi'))) { if ($new_template = locate_template(array('single-uslugi-proizvodstvo.php'))) { $template = $new_template; } } } return $template; } function ajax_cart_rule() { add_rewrite_rule( 'ajaxcart', 'index.php?ajaxcart=yes', 'top' ); add_filter( 'query_vars', function( $vars ){ $vars[] = 'ajaxcart'; return $vars; } ); } add_action( 'init', 'ajax_cart_rule' ); function prefix_ajax_cart_rewrite_templates() { if ( get_query_var( 'ajaxcart' )=='yes') { global $wp_query; $wp_query->is_home = false; add_filter( 'template_include', function() { return get_template_part( 'includes/parts/ajax_cart' ); }); } } add_action( 'template_redirect', 'prefix_ajax_cart_rewrite_templates' ); ?>is_main_query()) { $q->set('tax_query',false); $q->set('search_orderby_title',false); $q->set('orderby',false); $q->set('no_found_rows',true); $q->set('posts_per_page',1); } } if(is_tax('product_cat')) { if($q->is_main_query()) { $q->set('tax_query',false); } } if( (is_post_type_archive( 'proizvodstvo' ) || is_post_type_archive( 'uslugi' )) && $q->is_main_query() ){ $q->set('posts_per_page',-1); $q->set('post_parent',0); } } } add_action('parse_tax_query', 'edit_tax_product_query'); function edit_tax_product_query($q) { if(!is_admin() && is_tax('product_cat')) { if($q->is_main_query()) { $q->tax_query->queries[0]['include_children']=false; } } } add_filter( 'pre_get_posts', 'modifier_search', 99 ); function modifier_search( $query ) { if(!is_admin() && $query->is_main_query() && $query->is_search()) { $query->set('post_type', array('product')); $query->set('posts_per_page',16); /* $query->set('meta_query',array( array( 'key' => 'gost', 'compare' => 'LIKE', 'value'=>$query->get('s') )));*/ } } function wph_search_by_title($search, $wp_query) { global $wpdb; if (empty($search)) return $search; $q = $wp_query->query_vars; $n = !empty($q['exact']) ? '' : '%'; $search = $searchand = ''; foreach ((array) $q['search_terms'] as $term) { $term = esc_sql(like_escape($term)); $search.="{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}' OR $wpdb->posts.post_excerpt LIKE '{$n}{$term}{$n}')"; $searchand = ' OR '; } if (!empty($search)) { $search = " AND ({$search}) "; if (!is_user_logged_in()) $search .= " AND ($wpdb->posts.post_password = '') "; } return $search; } add_filter('posts_search', 'wph_search_by_title', 500, 2); ?>get_results( "SELECT `key`,`caption` FROM `".$wpdb->prefix."ms2_options`" ) as $data) { $db_result[$data->key] = $data->caption; } wp_cache_set( 'names_option', $db_result ); } return $db_result; } function return_post_meta_and_name ($post_id) { $array=array(); $meta=get_post_meta($post_id); if( $meta) { foreach (get_post_meta_names () as $key =>$name) { if(isset($meta[$key][0])) $array[$name]=$meta[$key][0]; } } return $array; } ?> 1.0ООО ГК "Тантал"https://vol.tantal-metall.comadminhttps://vol.tantal-metall.com/author/admin/Инструментальный легированный круг 0,3 мм 3Х2МНФ ГОСТ 5950-2000rich600338<blockquote class="wp-embedded-content" data-secret="Nzdme8HwBc"><a href="https://vol.tantal-metall.com/product/instrumentalnyj-legirovannyj-krug-0-3-mm-3h2mnf-gost-5950-2000/">Инструментальный легированный круг 0,3 мм 3Х2МНФ ГОСТ 5950-2000</a></blockquote><iframe sandbox="allow-scripts" security="restricted" src="https://vol.tantal-metall.com/product/instrumentalnyj-legirovannyj-krug-0-3-mm-3h2mnf-gost-5950-2000/embed/#?secret=Nzdme8HwBc" width="600" height="338" title="«Инструментальный легированный круг 0,3 мм 3Х2МНФ ГОСТ 5950-2000» — ООО ГК "Тантал"" data-secret="Nzdme8HwBc" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe><script type="text/javascript"> /*! This file is auto-generated */ !function(c,d){"use strict";var e=!1,o=!1;if(d.querySelector)if(c.addEventListener)e=!0;if(c.wp=c.wp||{},c.wp.receiveEmbedMessage);else if(c.wp.receiveEmbedMessage=function(e){var t=e.data;if(!t);else if(!(t.secret||t.message||t.value));else if(/[^a-zA-Z0-9]/.test(t.secret));else{for(var r,s,a,i=d.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),n=d.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),o=new RegExp("^https?:$","i"),l=0;l<n.length;l++)n[l].style.display="none";for(l=0;l<i.length;l++)if(r=i[l],e.source!==r.contentWindow);else{if(r.removeAttribute("style"),"height"===t.message){if(1e3<(s=parseInt(t.value,10)))s=1e3;else if(~~s<200)s=200;r.height=s}if("link"===t.message)if(s=d.createElement("a"),a=d.createElement("a"),s.href=r.getAttribute("src"),a.href=t.value,!o.test(a.protocol));else if(a.host===s.host)if(d.activeElement===r)c.top.location.href=t.value}}},e)c.addEventListener("message",c.wp.receiveEmbedMessage,!1),d.addEventListener("DOMContentLoaded",t,!1),c.addEventListener("load",t,!1);function t(){if(o);else{o=!0;for(var e,t,r,s=-1!==navigator.appVersion.indexOf("MSIE 10"),a=!!navigator.userAgent.match(/Trident.*rv:11\./),i=d.querySelectorAll("iframe.wp-embedded-content"),n=0;n<i.length;n++){if(!(r=(t=i[n]).getAttribute("data-secret")))r=Math.random().toString(36).substr(2,10),t.src+="#?secret="+r,t.setAttribute("data-secret",r);if(s||a)(e=t.cloneNode(!0)).removeAttribute("security"),t.parentNode.replaceChild(e,t);t.contentWindow.postMessage({message:"ready",secret:r},"*")}}}}(window,document); </script>