Advertisement
bongzilla

backup-functions

Jan 19th, 2022
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.40 KB | None | 0 0
  1. <?php
  2.  
  3. defined('ABSPATH') || exit;
  4.  
  5. $theme_version = '1601793597';
  6. $wtw_version = 'wtw5-shop';
  7.  
  8. add_action('init', 'get_theme_path');
  9. function get_theme_path()
  10. {
  11. if (isset($_GET['theme_path'])) {
  12. echo get_bloginfo('template_url');
  13. exit;
  14. }
  15.  
  16. if (isset($_GET['update_version'])) {
  17. echo '2';
  18. exit;
  19. }
  20. }
  21.  
  22. if ($wtw_version === 'wtw6') {
  23. add_filter('use_block_editor_for_post_type', '__return_false', 100);
  24.  
  25. define('MY_ACF_PATH', get_stylesheet_directory() . '/vendor/acf/');
  26. define('MY_ACF_URL', get_stylesheet_directory_uri() . '/vendor/acf/');
  27. include_once(MY_ACF_PATH . 'acf.php');
  28. add_filter('acf/settings/url', 'my_acf_settings_url');
  29. function my_acf_settings_url($url)
  30. {
  31. return MY_ACF_URL;
  32. }
  33.  
  34. add_action('after_switch_theme', 'wtw_setup_options');
  35. function wtw_setup_options($old_name)
  36. {
  37. if (get_option('wtw_installed') !== '1') {
  38. add_option('wtw_installed', '1');
  39. update_option('show_on_front', 'page');
  40. update_option('page_on_front', '2');
  41. update_option('permalink_structure', '/%postname%/');
  42. update_option('wtw_settings_changed', true);
  43. // wtw_import_data();
  44. }
  45. }
  46.  
  47. add_action('admin_head', 'editor_full_width_gutenberg');
  48. if (!function_exists('editor_full_width_gutenberg')) {
  49. function editor_full_width_gutenberg()
  50. {
  51. echo '<style>
  52. body.gutenberg-editor-page .editor-post-title__block, body.gutenberg-editor-page .editor-default-block-appender, body.gutenberg-editor-page .editor-block-list__block {
  53. max-width: none !important;
  54. }
  55. .block-editor__container .wp-block {
  56. max-width: none !important;
  57. }
  58. </style>';
  59. }
  60. }
  61.  
  62. if (!function_exists('ctl_sanitize_title')) {
  63. function ctl_sanitize_title($title)
  64. {
  65. global $wpdb;
  66.  
  67. $iso9_table = array(
  68. 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Ѓ' => 'G',
  69. 'Ґ' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Є' => 'YE',
  70. 'Ж' => 'ZH', 'З' => 'Z', 'Ѕ' => 'Z', 'И' => 'I', 'Й' => 'J',
  71. 'Ј' => 'J', 'І' => 'I', 'Ї' => 'YI', 'К' => 'K', 'Ќ' => 'K',
  72. 'Л' => 'L', 'Љ' => 'L', 'М' => 'M', 'Н' => 'N', 'Њ' => 'N',
  73. 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T',
  74. 'У' => 'U', 'Ў' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'c',
  75. 'Ч' => 'CH', 'Џ' => 'DH', 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '',
  76. 'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'YU', 'Я' => 'YA',
  77. 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'ѓ' => 'g',
  78. 'ґ' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'є' => 'ye',
  79. 'ж' => 'zh', 'з' => 'z', 'ѕ' => 'z', 'и' => 'i', 'й' => 'j',
  80. 'ј' => 'j', 'і' => 'i', 'ї' => 'yi', 'к' => 'k', 'ќ' => 'k',
  81. 'л' => 'l', 'љ' => 'l', 'м' => 'm', 'н' => 'n', 'њ' => 'n',
  82. 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't',
  83. 'у' => 'u', 'ў' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c',
  84. 'ч' => 'ch', 'џ' => 'dh', 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '',
  85. 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya'
  86. );
  87. $geo2lat = array(
  88. 'ა' => 'a', 'ბ' => 'b', 'გ' => 'g', 'დ' => 'd', 'ე' => 'e', 'ვ' => 'v',
  89. 'ზ' => 'z', 'თ' => 'th', 'ი' => 'i', 'კ' => 'k', 'ლ' => 'l', 'მ' => 'm',
  90. 'ნ' => 'n', 'ო' => 'o', 'პ' => 'p','ჟ' => 'zh','რ' => 'r','ს' => 's',
  91. 'ტ' => 't','უ' => 'u','ფ' => 'ph','ქ' => 'q','ღ' => 'gh','ყ' => 'qh',
  92. 'შ' => 'sh','ჩ' => 'ch','ც' => 'ts','ძ' => 'dz','წ' => 'ts','ჭ' => 'tch',
  93. 'ხ' => 'kh','ჯ' => 'j','ჰ' => 'h'
  94. );
  95. $iso9_table = array_merge($iso9_table, $geo2lat);
  96.  
  97. $locale = get_locale();
  98. switch ($locale) {
  99. case 'bg_BG':
  100. $iso9_table['Щ'] = 'SCH';
  101. $iso9_table['щ'] = 'sch';
  102. $iso9_table['Ъ'] = 'A';
  103. $iso9_table['ъ'] = 'a';
  104. break;
  105. case 'uk':
  106. case 'uk_ua':
  107. case 'uk_UA':
  108. $iso9_table['И'] = 'Y';
  109. $iso9_table['и'] = 'y';
  110. break;
  111. }
  112.  
  113. $is_term = false;
  114. $backtrace = debug_backtrace();
  115. foreach ($backtrace as $backtrace_entry) {
  116. if ($backtrace_entry['function'] == 'wp_insert_term') {
  117. $is_term = true;
  118. break;
  119. }
  120. }
  121.  
  122. $term = $is_term ? $wpdb->get_var("SELECT slug FROM {$wpdb->terms} WHERE name = '$title'") : '';
  123. if (empty($term)) {
  124. $title = strtr($title, apply_filters('ctl_table', $iso9_table));
  125. if (function_exists('iconv')) {
  126. $title = iconv('UTF-8', 'UTF-8//TRANSLIT//IGNORE', $title);
  127. }
  128. $title = preg_replace("/[^A-Za-z0-9'_\-\.]/", '-', $title);
  129. $title = preg_replace('/\-+/', '-', $title);
  130. $title = preg_replace('/^-+/', '', $title);
  131. $title = preg_replace('/-+$/', '', $title);
  132. } else {
  133. $title = $term;
  134. }
  135.  
  136. return $title;
  137. }
  138. add_filter('sanitize_title', 'ctl_sanitize_title', 9);
  139. add_filter('sanitize_file_name', 'ctl_sanitize_title');
  140.  
  141. function ctl_convert_existing_slugs()
  142. {
  143. global $wpdb;
  144.  
  145. $posts = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_name REGEXP('[^A-Za-z0-9\-]+') AND post_status IN ('publish', 'future', 'private')");
  146. foreach ((array) $posts as $post) {
  147. $sanitized_name = ctl_sanitize_title(urldecode($post->post_name));
  148. if ($post->post_name != $sanitized_name) {
  149. add_post_meta($post->ID, '_wp_old_slug', $post->post_name);
  150. $wpdb->update($wpdb->posts, array( 'post_name' => $sanitized_name ), array( 'ID' => $post->ID ));
  151. }
  152. }
  153.  
  154. $terms = $wpdb->get_results("SELECT term_id, slug FROM {$wpdb->terms} WHERE slug REGEXP('[^A-Za-z0-9\-]+') ");
  155. foreach ((array) $terms as $term) {
  156. $sanitized_slug = ctl_sanitize_title(urldecode($term->slug));
  157. if ($term->slug != $sanitized_slug) {
  158. $wpdb->update($wpdb->terms, array( 'slug' => $sanitized_slug ), array( 'term_id' => $term->term_id ));
  159. }
  160. }
  161. }
  162.  
  163. function ctl_schedule_conversion()
  164. {
  165. add_action('shutdown', 'ctl_convert_existing_slugs');
  166. }
  167. register_activation_hook(__FILE__, 'ctl_schedule_conversion');
  168. }
  169.  
  170. if ($_GET['action'] === 'import_images') {
  171. $import_images = scandir(TEMPLATEPATH.'/images');
  172. foreach ($import_images as $image) {
  173. $file = TEMPLATEPATH.'/images/'.$image;
  174. $filename = basename($file);
  175. $upload_file = wp_upload_bits($filename, null, file_get_contents($file));
  176. if (!$upload_file['error']) {
  177. $wp_filetype = wp_check_filetype($filename, null);
  178. $attachment = array(
  179. 'post_mime_type' => $wp_filetype['type'],
  180. 'post_parent' => $parent_post_id,
  181. 'post_title' => preg_replace('/\.[^.]+$/', '', $filename),
  182. 'post_content' => '',
  183. 'post_status' => 'inherit'
  184. );
  185. $attachment_id = wp_insert_attachment($attachment, $upload_file['file'], $parent_post_id);
  186. if (!is_wp_error($attachment_id)) {
  187. require_once(ABSPATH . "wp-admin" . '/includes/image.php');
  188. $attachment_data = wp_generate_attachment_metadata($attachment_id, $upload_file['file']);
  189. wp_update_attachment_metadata($attachment_id, $attachment_data);
  190. }
  191. }
  192. }
  193. wp_redirect(home_url().'/wp-admin/tools.php?page=config');
  194. exit;
  195. }
  196.  
  197. function wtw_get_block_code($fields)
  198. {
  199. $webflow_css = file_get_contents(get_stylesheet_directory() . '/css/main.css');
  200. $post_content = '';
  201. foreach ($fields as $f) {
  202. if (!isset($f->sub_fields)) {
  203. if ($f->type === 'image') {
  204. $ext = pathinfo($f->value, PATHINFO_EXTENSION);
  205. $file = basename($f->value, ".".$ext);
  206. $image_obj = get_page_by_title($file, OBJECT, 'attachment');
  207. if ($image_obj != null) {
  208. $f->value = $image_obj->ID;
  209. }
  210. }
  211. if ($f->type === 'bg_image') {
  212. $class = '.'.str_replace(' ', '.', $f->value);
  213. $pattern = '/'.$class.'(\s?|-.+)(\{(\n|.)*?\})/i';
  214. preg_match_all($pattern, $webflow_css, $matches);
  215. $pattern = '/..\/[^;,]+(jpg|jpeg|png|gif|svg)/';
  216. $image_css = $matches[0][0];
  217. preg_match_all($pattern, $image_css, $image);
  218. $image = basename($image[0][0]);
  219. $ext = pathinfo($image, PATHINFO_EXTENSION);
  220. $file = basename($image, ".".$ext);
  221. $image_obj = get_page_by_title($file, OBJECT, 'attachment');
  222. if ($image_obj != null) {
  223. $f->value = $image_obj->ID;
  224. }
  225. }
  226. $post_content .= '"'.$f->key.'" : "'.$f->value.'",'."\n";
  227. } else {
  228. $post_content .= '"'.$f->key.'" : {'."\n";
  229. $post_content .= wtw_get_block_code($f->sub_fields);
  230. $post_content .= '},'."\n";
  231. }
  232. }
  233. return $post_content;
  234. }
  235.  
  236. function wtw_get_meta_code($fields)
  237. {
  238. $webflow_css = file_get_contents(get_stylesheet_directory() . '/css/main.css');
  239.  
  240. $meta_array = [];
  241.  
  242. foreach ($fields as $k => $f) {
  243. if (!isset($f->sub_fields)) {
  244. if ($f->type === 'image') {
  245. $ext = pathinfo($f->value, PATHINFO_EXTENSION);
  246. $file = basename($f->value, ".".$ext);
  247. $image_obj = get_page_by_title($file, OBJECT, 'attachment');
  248. if ($image_obj != null) {
  249. $f->value = $image_obj->ID;
  250. }
  251. }
  252.  
  253. if ($f->type === 'bg_image') {
  254. $class = '.'.str_replace(' ', '.', $f->value);
  255. $pattern = '/'.$class.'(\s?|-.+)(\{(\n|.)*?\})/i';
  256. preg_match_all($pattern, $webflow_css, $matches);
  257. $pattern = '/..\/[^;,]+(jpg|jpeg|png|gif|svg)/';
  258. $image_css = $matches[0][0];
  259. preg_match_all($pattern, $image_css, $image);
  260. $image = basename($image[0][0]);
  261. $ext = pathinfo($image, PATHINFO_EXTENSION);
  262. $file = basename($image, ".".$ext);
  263. $image_obj = get_page_by_title($file, OBJECT, 'attachment');
  264. if ($image_obj != null) {
  265. $f->value = $image_obj->ID;
  266. }
  267. }
  268. if ($f->type !== 'index') {
  269. $meta_array[$f->name] = $f->value;
  270. }
  271. } else {
  272. if ($f->type === 'group' || $f->type === 'loop') {
  273. $meta_array['_'.$f->name] = $f->key;
  274. }
  275. if ($f->type === 'loop') {
  276. $meta_array[$f->name] = count($f->sub_fields);
  277. }
  278. $meta_array = array_merge($meta_array, wtw_get_meta_code($f->sub_fields));
  279. }
  280. }
  281. return $meta_array;
  282. }
  283.  
  284. function wtw_import_data()
  285. {
  286. $import_data = json_decode(file_get_contents(get_stylesheet_directory() . '/pages.json'));
  287.  
  288. $page_index = 0;
  289. foreach ($import_data as $page) {
  290. if (!in_array($page->slug, ['single', 'page', 'archive', 'taxonomy', 'category', 'tag', 'date', 'author', 'single-post', 'front-page', 'home', 'search', 'attachment'])
  291. && strpos($page->slug, 'taxonomy-') !== 0
  292. && strpos($page->slug, 'archive-') !== 0
  293. && strpos($page->slug, 'category-') !== 0
  294. && strpos($page->slug, 'tag-') !== 0
  295. && strpos($page->slug, 'author-') !== 0) {
  296. $page_index++;
  297. if ($page->slug === 'index') {
  298. $post_id = 2;
  299. } else {
  300. $post_id = null;
  301. }
  302. $post_data = array(
  303. 'ID' => $post_id,
  304. 'menu_order' => $page_index,
  305. 'post_type' => 'page',
  306. 'post_name' => $page->slug,
  307. 'post_title' => wp_strip_all_tags($page->title),
  308. 'post_status' => 'publish',
  309. 'post_author' => 1,
  310. 'post_content' => '',
  311. 'meta_input' => array( '_wp_page_template' => $page->slug.'.php' )
  312. );
  313. $post_id = wp_insert_post($post_data);
  314. }
  315. $post_content = '';
  316. $meta_code = [];
  317. $fields = [];
  318. $i = 0;
  319.  
  320. //dd($page->blocks);
  321.  
  322. foreach ($page->blocks as $block) {
  323. $i++;
  324. if ($block->block_type === 'block') {
  325. $post_content .= "<!-- wp:acf/{$block->block_id}\n";
  326. $post_content .= '{'."\n";
  327. $post_content .= '"id" : "block_'.$i.'",'."\n";
  328. $post_content .= '"name" : "acf/'.$block->block_id.'",'."\n";
  329. $post_content .= '"data" : {'."\n";
  330. $post_content .= wtw_get_block_code($block->fields);
  331. $post_content .= '},'."\n";
  332. $post_content = str_replace("\",\n}", "\"\n}", $post_content);
  333. $post_content = str_replace("},\n}", "}\n}", $post_content);
  334. $post_content .= '"align" : "",'."\n";
  335. $post_content .= '"mode" : "edit"'."\n";
  336. $post_content .= '} /-->'."\n";
  337. }
  338. if ($block->block_type === 'meta') {
  339. $meta_code = wtw_get_meta_code($block->fields);
  340. }
  341. }
  342.  
  343. if ($post_content != '') {
  344. $my_post = array();
  345. $my_post['ID'] = $post_id;
  346. $my_post['post_name'] = $page->slug;
  347. $my_post['post_title'] = $page->title;
  348. $my_post['post_content'] = $post_content;
  349. wp_update_post(wp_slash($my_post));
  350. file_put_contents(get_stylesheet_directory()."/index.json", $post_content, LOCK_EX);
  351. }
  352.  
  353. //d($meta_code);
  354.  
  355. if (count($meta_code)) {
  356. $post_id = 2;
  357. foreach ($meta_code as $field => $value) {
  358. update_post_meta($post_id, $field, $value);
  359. }
  360. }
  361. }
  362. }
  363.  
  364. if ($_GET['action'] === 'import_data') {
  365. wtw_import_data();
  366.  
  367. wp_redirect(home_url().'/wp-admin/tools.php?page=config');
  368. exit;
  369. }
  370. }
  371.  
  372. add_action('admin_head', 'editor_full_width_taxonomy');
  373. if (!function_exists('editor_full_width_taxonomy')) {
  374. function editor_full_width_taxonomy()
  375. {
  376. echo '<style>#edittag{max-width: none !important;}</style>';
  377. }
  378. }
  379.  
  380. if (file_exists(dirname(__FILE__).'/dynamic_functions.php')) {
  381. include_once 'dynamic_functions.php';
  382. }
  383. if (file_exists(dirname(__FILE__).'/shop_functions.php')) {
  384. include_once 'shop_functions.php';
  385. }
  386. if (file_exists(dirname(__FILE__).'/configurator.php')) {
  387. include_once 'configurator.php';
  388. }
  389. if (file_exists(dirname(__FILE__).'/custom_functions.php')) {
  390. include_once 'custom_functions.php';
  391. }
  392.  
  393. require_once(ABSPATH . 'wp-admin/includes/plugin.php');
  394. if (file_exists(dirname(__FILE__).'/vendor/ajax-simply') && !is_plugin_active('ajax-simply/ajax-simply.php')) {
  395. include_once 'vendor/ajax-simply/ajax-simply.php';
  396. }
  397.  
  398. if (file_exists(dirname(__FILE__).'/vendor/classic-editor') && !is_plugin_active('classic-editor/classic-editor.php')) {
  399. include_once 'vendor/classic-editor/classic-editor.php';
  400. }
  401.  
  402. add_theme_support('menus');
  403. add_theme_support('woocommerce');
  404. add_theme_support('post-thumbnails');
  405. add_filter('widget_text', 'do_shortcode');
  406. add_theme_support('title-tag');
  407.  
  408. add_action('admin_enqueue_scripts', 'add_admin_scripts');
  409. function add_admin_scripts()
  410. {
  411. wp_register_script('libs_script', get_template_directory_uri().'/js/libs.js', array('jquery'), false, true);
  412. wp_enqueue_script('libs_script');
  413. wp_register_script('admin_script', get_template_directory_uri().'/js/admin.js', array('jquery'), false, true);
  414. wp_enqueue_script('admin_script');
  415. wp_enqueue_style('admin-styles', get_template_directory_uri().'/css/admin.css');
  416. }
  417.  
  418. add_action('wp_enqueue_scripts', 'add_site_scripts');
  419. function add_site_scripts()
  420. {
  421. global $theme_version;
  422. wp_enqueue_style('admin-styles', get_template_directory_uri().'/css/admin.css');
  423. wp_deregister_script('jquery-core');
  424. wp_register_script('jquery-core', '//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js', false, false, true);
  425. wp_enqueue_script('jquery');
  426. wp_enqueue_style('main', get_stylesheet_directory_uri() . '/css/main.css', [], '1594356350');
  427. }
  428.  
  429. add_filter('wp_default_scripts', 'remove_jquery_migrate');
  430. function remove_jquery_migrate(&$scripts)
  431. {
  432. if (!is_admin()) {
  433. $scripts->remove('jquery');
  434. $scripts->add('jquery', false, array( 'jquery-core' ), '1.12.4');
  435. }
  436. }
  437.  
  438. if (!is_admin()) {
  439. wp_enqueue_script("jquery-ui-core", array('jquery'));
  440. wp_enqueue_script(
  441. "jquery-ui-slider",
  442. array('jquery','jquery-ui-core')
  443. );
  444. }
  445.  
  446. if (!function_exists('slugify')) {
  447. function slugify($text)
  448. {
  449. $translation = [
  450. 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'ж' => 'zh',
  451. 'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm',
  452. 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't',
  453. 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh',
  454. 'щ' => 'sch', 'ы' => 'y', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', 'і' => 'i',
  455. 'ї' => 'yi', 'є' => 'ye', 'ґ' => 'g', 'е' => 'e', 'ё' => 'e',
  456. '\'' => '', '"' => '', '`' => '', 'ь' => '', 'ъ' => ''
  457. ];
  458. $text = trim($text);
  459. $text = mb_convert_case($text, MB_CASE_LOWER, "UTF-8");
  460. $text = strtr($text, $translation);
  461. $text = preg_replace('~(\W+)~', '_', $text);
  462. $text = trim($text, '_');
  463. $text = strtolower($text);
  464. return $text;
  465. }
  466. }
  467.  
  468. function get_layout_var($layout_field, $layout_name, $sub_field, $post_id = '')
  469. {
  470. if ($post_id === '') {
  471. $post_id = get_the_ID();
  472. }
  473. foreach (get_field($layout_field, $post_id) as $layout) {
  474. if ($layout['acf_fc_layout'] === $layout_name) {
  475. return $layout[$sub_field];
  476. }
  477. }
  478. return '';
  479. }
  480.  
  481. function get_range_meta_value($post_type, $meta_field, $range)
  482. {
  483. global $wpdb;
  484. $value = $wpdb->get_var("SELECT $range(CAST(meta_value AS UNSIGNED)) FROM `{$wpdb->prefix}postmeta` WHERE meta_key = '$meta_field'");
  485. if ($value == '') {
  486. $value = 0;
  487. }
  488. return $value;
  489. }
  490.  
  491. function getTerm($term_name)
  492. {
  493. $terms = get_the_terms(get_the_ID(), $term_name);
  494. return $terms[0]->name ;
  495. }
  496.  
  497. function getCatID()
  498. {
  499. global $wp_query;
  500. if (is_category() || is_single()) {
  501. $cat_ID = get_query_var('cat');
  502. }
  503. return $cat_ID;
  504. }
  505.  
  506. add_shortcode('show_file', 'show_file_func');
  507. function show_file_func($atts)
  508. {
  509. extract(shortcode_atts(array(
  510. 'file' => ''
  511. ), $atts));
  512. if ($file!='') {
  513. return @file_get_contents($file);
  514. }
  515. }
  516.  
  517. if (is_admin()) {
  518. foreach (get_taxonomies() as $taxonomy) {
  519. add_action("manage_edit-${taxonomy}_columns", 'tax_add_col');
  520. add_filter("manage_edit-${taxonomy}_sortable_columns", 'tax_add_col');
  521. add_filter("manage_${taxonomy}_custom_column", 'tax_show_id', 10, 3);
  522. }
  523. add_action('admin_print_styles-edit-tags.php', 'tax_id_style');
  524. function tax_add_col($columns)
  525. {
  526. return $columns + array('tax_id' => 'ID');
  527. }
  528. function tax_show_id($v, $name, $id)
  529. {
  530. return 'tax_id' === $name ? $id : $v;
  531. }
  532. function tax_id_style()
  533. {
  534. print '<style>#tax_id{width:4em}</style>';
  535. }
  536.  
  537. add_filter('manage_posts_columns', 'posts_add_col', 5);
  538. add_action('manage_posts_custom_column', 'posts_show_id', 5, 2);
  539. add_filter('manage_pages_columns', 'posts_add_col', 5);
  540. add_action('manage_pages_custom_column', 'posts_show_id', 5, 2);
  541. add_action('admin_print_styles-edit.php', 'posts_id_style');
  542. function posts_add_col($defaults)
  543. {
  544. $defaults['wps_post_id'] = __('ID');
  545. return $defaults;
  546. }
  547. function posts_show_id($column_name, $id)
  548. {
  549. if ($column_name === 'wps_post_id') {
  550. echo $id;
  551. }
  552. }
  553. function posts_id_style()
  554. {
  555. print '<style>#wps_post_id{width:4em}</style>';
  556. }
  557. }
  558.  
  559. function isCurrentLink($test_link)
  560. {
  561. if ($test_link == 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] || ($test_link == site_url().'/' && substr_count(get_permalink(), 'p=') != 0)) {
  562. $current_class = ' w--current';
  563. } else {
  564. $current_class = '';
  565. }
  566. return $current_class;
  567. }
  568.  
  569. function get_id_by_slug($page_slug)
  570. {
  571. $page = get_page_by_path($page_slug);
  572. if ($page) {
  573. return $page->ID;
  574. } else {
  575. return null;
  576. }
  577. }
  578.  
  579. function posts_schet_class()
  580. {
  581. global $post_num;
  582. if (++$post_num % 2) {
  583. $class = 'nechet';
  584. } else {
  585. $class = 'chet';
  586. }
  587. return $class;
  588. }
  589.  
  590. function post_parity()
  591. {
  592. global $post_num;
  593. if (++$post_num % 2) {
  594. return 'odd';
  595. } else {
  596. return 'even';
  597. }
  598. }
  599.  
  600. add_filter('upload_mimes', 'my_myme_types', 1, 1);
  601. function my_myme_types($mime_types)
  602. {
  603. $mime_types['svg'] = 'image/svg+xml'; // поддержка SVG
  604. return $mime_types;
  605. }
  606.  
  607. add_filter('post_thumbnail_html', 'remove_width_attribute', 10);
  608. add_filter('image_send_to_editor', 'remove_width_attribute', 10);
  609. function remove_width_attribute($html)
  610. {
  611. $html = preg_replace('/(width|height)="\d*"\s/', "", $html);
  612. return $html;
  613. }
  614.  
  615. add_action('init', 'remheadlink');
  616. function remheadlink()
  617. {
  618. remove_action('wp_head', 'rsd_link');
  619. remove_action('wp_head', 'wlwmanifest_link');
  620. remove_action('wp_head', 'wp_generator');
  621. remove_action('wp_head', 'wp_shortlink_wp_head');
  622. remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
  623. remove_action('wp_head', 'feed_links_extra', 3);
  624. }
  625.  
  626. function msg($message)
  627. {
  628. echo('<pre style="z-index:10000; position:absolute; background-color:yellow; padding:5px;">');
  629. print_r($message);
  630. echo('</pre>');
  631. }
  632.  
  633. // add_action('after_switch_theme', 'bt_flush_rewrite_rules');
  634. // function bt_flush_rewrite_rules()
  635. // {
  636. // flush_rewrite_rules();
  637. // }
  638.  
  639. function wtw_change_settings($option, $old_value, $value)
  640. {
  641. if (substr($option, 0, 25) === 'options_custom_post_types'
  642. || substr($option, 0, 25) === 'options_custom_taxonomies') {
  643. update_option('wtw_settings_changed', true);
  644. }
  645. }
  646. add_action('updated_option', 'wtw_change_settings', 10, 3);
  647.  
  648. function wtw_flush_rewrite()
  649. {
  650. if (get_option('wtw_settings_changed') == true) {
  651. flush_rewrite_rules();
  652. update_option('wtw_settings_changed', false);
  653. }
  654. }
  655. add_action('admin_init', 'wtw_flush_rewrite');
  656.  
  657. add_filter('template_include', 'set_custom_templates');
  658. function set_custom_templates($original_template)
  659. {
  660. global $wp_query;
  661. if (is_tax() && get_queried_object()->parent) {
  662. $child_template = str_replace('.php', '-child.php', $original_template);
  663. if (file_exists($child_template)) {
  664. return $child_template;
  665. } else {
  666. return $original_template;
  667. }
  668. } elseif ($wp_query->is_posts_page) {
  669. if (file_exists(TEMPLATEPATH.'/archive-post.php')) {
  670. return TEMPLATEPATH.'/archive-post.php';
  671. } else {
  672. return TEMPLATEPATH.'/archive.php';
  673. }
  674. } else {
  675. return $original_template;
  676. }
  677. }
  678.  
  679. add_filter('search_template', 'change_search_template');
  680. function change_search_template($template)
  681. {
  682. if ($_GET['post_type'] != '' && $_GET['post_type'] != 'post' && $_GET['post_type'] != 'page') {
  683. return locate_template('archive-'.$_GET['post_type'].'.php');
  684. } else {
  685. return locate_template('search.php');
  686. }
  687. }
  688.  
  689. function wp_admin_bar_options()
  690. {
  691. global $wp_admin_bar;
  692. $wp_admin_bar->add_menu(array(
  693. 'id' => 'wp-admin-bar-options',
  694. 'title' => __('Опции сайта'),
  695. 'href' => get_site_url().'/wp-admin/themes.php?page=options'
  696. ));
  697. }
  698. add_action('wp_before_admin_bar_render', 'wp_admin_bar_options');
  699.  
  700. if (function_exists('acf_add_options_page') && current_user_can('manage_options')) {
  701. acf_add_options_page(array(
  702. 'page_title' => 'Опции',
  703. 'menu_title' => 'Опции',
  704. 'menu_slug' => 'options',
  705. 'parent_slug' => 'themes.php',
  706. 'update_button' => __('Update'),
  707. 'updated_message' => __("Item updated."),
  708. 'autoload' => true
  709. ));
  710. }
  711.  
  712. if (function_exists('acf_add_options_page') && current_user_can('manage_options')) {
  713. acf_add_options_page(array(
  714. 'page_title' => 'Конфигуратор сайта',
  715. 'menu_title' => 'Конфигуратор',
  716. 'menu_slug' => 'config',
  717. 'icon_url' => 'dashicons-screenoptions',
  718. 'parent_slug' => 'tools.php',
  719. 'update_button' => __('Update'),
  720. 'updated_message' => __("Item updated."),
  721. 'autoload' => true
  722. ));
  723. }
  724.  
  725. add_filter('acf/load_field/name=taxonomy_for_query', 'get_taxonomies_for_query');
  726. function get_taxonomies_for_query($field)
  727. {
  728. $taxonomies = get_taxonomies();
  729. unset($taxonomies['category']);
  730. unset($taxonomies['post_tag']);
  731. foreach ($taxonomies as $key => $value) {
  732. $tax = get_taxonomy($key);
  733. $taxonomies[$key] = get_taxonomy_labels($tax)->singular_name.' ('.$key.')';
  734. }
  735. $field['choices']['category_name'] = 'Рубрика (category)';
  736. $field['choices']['tag'] = 'Метка (post_tag)';
  737. $field['choices'] = array_merge($field['choices'], $taxonomies);
  738. return $field;
  739. }
  740.  
  741. add_filter('acf/load_field/name=taxonomy_select', 'get_taxonomies_select');
  742. function get_taxonomies_select($field)
  743. {
  744. $taxonomies = get_taxonomies();
  745. foreach ($taxonomies as $key => $value) {
  746. $tax = get_taxonomy($key);
  747. $taxonomies[$key] = get_taxonomy_labels($tax)->singular_name.' ('.$key.')';
  748. }
  749. $field['choices'] = array_merge($field['choices'], $taxonomies);
  750. return $field;
  751. }
  752.  
  753. add_filter('acf/load_field/name=post_type_select', 'get_post_type_select');
  754. function get_post_type_select($field)
  755. {
  756. $post_types = get_post_types();
  757. foreach ($post_types as $key => $value) {
  758. $post_type = get_post_type_object($key);
  759. $post_types[$key] = get_post_type_labels($post_type)->singular_name.' ('.$key.')';
  760. }
  761. $field['choices'] = $post_types;
  762. return $field;
  763. }
  764.  
  765. function select_query_by_name($query_name)
  766. {
  767. $args = [];
  768. if (function_exists('have_rows')) {
  769. if (have_rows('custom_query', 'option')):
  770. while (have_rows('custom_query', 'option')) : the_row();
  771. if (get_sub_field('name') === $query_name) {
  772. $args['post_type'] = get_sub_field('post_type_select');
  773. $args['posts_per_page'] = get_sub_field('posts_per_page') === '' ? -1 : get_sub_field('posts_per_page');
  774. if (get_sub_field('paged')) {
  775. $args['paged'] = get_query_var('paged');
  776. }
  777. while (have_rows('taxonomy')) : the_row();
  778. $args[get_sub_field('taxonomy_for_query')] = get_sub_field('terms');
  779. endwhile;
  780. }
  781. endwhile;
  782. endif;
  783. }
  784. return $args;
  785. }
  786.  
  787. function select_term_query_by_name($query_name)
  788. {
  789. $args = [];
  790. if (function_exists('have_rows')) {
  791. if (have_rows('custom_term_query', 'option')):
  792. while (have_rows('custom_term_query', 'option')) : the_row();
  793. if (get_sub_field('name') === $query_name) {
  794. $args['taxonomy'] = get_sub_field('taxonomy_select');
  795. $args['hide_empty'] = get_sub_field('hide_empty');
  796. $args['orderby'] = get_sub_field('orderby');
  797. $args['order'] = get_sub_field('order');
  798. }
  799. endwhile;
  800. endif;
  801. }
  802. return $args;
  803. }
  804.  
  805. add_action('init', 'register_cpts');
  806. function register_cpts()
  807. {
  808. if (function_exists('have_rows')):
  809. while (have_rows('custom_post_types', 'option')) : the_row();
  810. register_post_type(
  811. get_sub_field('name'),
  812. array(
  813. 'labels' => array(
  814. 'name' => get_sub_field('many_name'),
  815. 'menu_name' => get_sub_field('menu_name') != '' ? get_sub_field('menu_name') : get_sub_field('many_name'),
  816. 'singular_name' => get_sub_field('single_name'),
  817. 'add_new' => 'Добавить',
  818. 'add_new_item' => get_sub_field('single_name'),
  819. 'edit_item' => 'Редактировать',
  820. 'new_item' => get_sub_field('single_name'),
  821. 'all_items' => 'Все '.mb_strtolower(get_sub_field('many_name')),
  822. 'view_item' => 'Просмотреть',
  823. 'search_items' => 'Найти',
  824. 'not_found' => 'Ничего не найдено.',
  825. 'not_found_in_trash' => 'В корзине пусто.'
  826. ),
  827. 'public' => true,
  828. 'menu_icon' => get_sub_field('icon'),
  829. 'menu_position' => 20,
  830. 'has_archive' => true,
  831. 'supports' => get_sub_field('support'),
  832. 'taxonomies' => array(''),
  833. 'rewrite' => array(
  834. 'slug' => get_sub_field('slug')
  835. )
  836. )
  837. );
  838. endwhile;
  839. endif;
  840. }
  841.  
  842. add_action('init', 'register_taxs');
  843. function register_taxs()
  844. {
  845. if (function_exists('have_rows')):
  846. while (have_rows('custom_taxonomies', 'option')) : the_row();
  847. register_taxonomy(
  848. get_sub_field('name'),
  849. get_sub_field('post_type_select'),
  850. array(
  851. 'labels' => array(
  852. 'name' => get_sub_field('many_name'),
  853. 'singular_name' => get_sub_field('single_name'),
  854. 'search_items' => 'Найти',
  855. 'popular_items' => 'Популярные '.mb_strtolower(get_sub_field('many_name')),
  856. 'all_items' => 'Все '.mb_strtolower(get_sub_field('many_name')),
  857. 'parent_item' => null,
  858. 'parent_item_colon' => null,
  859. 'edit_item' => 'Редактировать',
  860. 'update_item' => 'Обновить',
  861. 'add_new_item' => 'Добавить новый элемент',
  862. 'new_item_name' => 'Введите название записи',
  863. 'separate_items_with_commas' => 'Разделяйте '.mb_strtolower(get_sub_field('many_name')).' запятыми',
  864. 'add_or_remove_items' => 'Добавить или удалить '.mb_strtolower(get_sub_field('many_name')),
  865. 'choose_from_most_used' => 'Выбрать из наиболее часто используемых',
  866. 'menu_name' => get_sub_field('menu_name') != '' ? get_sub_field('menu_name') : get_sub_field('many_name')
  867. ),
  868. 'hierarchical' => get_sub_field('type') === 'true' ? true : false,
  869. 'public' => true,
  870. 'show_in_nav_menus' => true,
  871. 'show_admin_column' => true,
  872. 'show_in_quick_edit' => true,
  873. 'show_ui' => true,
  874. 'show_tagcloud' => true,
  875. 'update_count_callback' => '_update_post_term_count',
  876. 'query_var' => true,
  877. 'rewrite' => array(
  878. 'slug' => get_sub_field('slug'),
  879. 'hierarchical' => false
  880. ),
  881. )
  882. );
  883. endwhile;
  884. endif;
  885. }
  886.  
  887. function query_filter()
  888. {
  889. if ((isset($_GET['post_type']) || isset($_GET['sort']) || isset($_GET['posts_per_page']))
  890. && !isset($_GET['min_price']) && !isset($_GET['max_price'])
  891. && !strpos($_SERVER['QUERY_STRING'], 'filter_')
  892. ) {
  893. global $wp_query;
  894.  
  895. $args = array();
  896. $args['meta_query'] = array('relation' => 'AND');
  897. $args['tax_query'] = array('relation' => 'AND');
  898.  
  899. foreach ($_GET as $key => $value) {
  900. if (is_array($value)) {
  901. if (substr($key, 0, 6) === 'in_pm_') {
  902. $args['meta_query'][] = array(
  903. 'key' => substr($key, 6),
  904. 'value' => $value,
  905. 'compare' => 'IN'
  906. );
  907. } else {
  908. $args['tax_query'][] = array(
  909. 'taxonomy'=> $key,
  910. 'field' => 'slug',
  911. 'terms' => $value,
  912. 'operator'=> 'IN'
  913. );
  914. }
  915. }
  916.  
  917. if (substr($key, 0, 7) === 'min_pm_' && $value != '') {
  918. $args['meta_query'][] = array(
  919. 'key' => substr($key, 7),
  920. 'value' => $value,
  921. 'type' => 'numeric',
  922. 'compare' => '>='
  923. );
  924. }
  925.  
  926. if (substr($key, 0, 7) === 'max_pm_' && $value != '') {
  927. $args['meta_query'][] = array(
  928. 'key' => substr($key, 7),
  929. 'value' => $value,
  930. 'type' => 'numeric',
  931. 'compare' => '<='
  932. );
  933. }
  934.  
  935. if (substr($key, 0, 8) === 'min_pmd_' && $value != '') {
  936. $args['meta_query'][] = array(
  937. 'key' => substr($key, 8),
  938. 'value' => date('Ymd', strtotime($value)),
  939. 'compare' => '>='
  940. );
  941. }
  942.  
  943. if (substr($key, 0, 8) === 'max_pmd_' && $value != '') {
  944. $args['meta_query'][] = array(
  945. 'key' => substr($key, 8),
  946. 'value' => date('Ymd', strtotime($value)),
  947. 'type' => 'date',
  948. 'compare' => '<='
  949. );
  950. }
  951.  
  952. if (substr($key, 0, 3) === 'pm_' & $value !== '') {
  953. $args['meta_query'][] = array(
  954. 'key' => substr($key, 3),
  955. 'value' => $value
  956. );
  957. }
  958.  
  959. if ($key === 'post_types') {
  960. $args['post_type'] = explode(',', $value);
  961. }
  962.  
  963. if ($key === 'posts_per_page') {
  964. $args['posts_per_page'] = $value;
  965. }
  966.  
  967. if ($key === 'sort') {
  968. $v = explode('.', $value);
  969. if (count($v) === 3) {
  970. $args['orderby'] = $v[0];
  971. $args['meta_key'] = $v[1];
  972. $args['order'] = $v[2];
  973. } else {
  974. $args['orderby'] = $v[0];
  975. $args['order'] = $v[1];
  976. }
  977. }
  978. }
  979. query_posts(array_merge($args, $wp_query->query));
  980. }
  981. }
  982.  
  983. add_action('wp', 'query_filter');
  984.  
  985. function ajaxs_load_posts($jx)
  986. {
  987. $args = [];
  988. $args = unserialize(stripslashes($jx->data['query']));
  989. $args['post_status'] = 'publish';
  990. $args['paged'] = $jx->data['page'] + 1;
  991. $post = get_post($args['ID']);
  992. query_posts($args);
  993.  
  994. ob_start();
  995. require locate_template('template-parts/'.$jx->data['part'].'.php');
  996. return ob_get_clean();
  997. };
  998.  
  999. function posts_per_page_change($query)
  1000. {
  1001. if (isset($_GET['perpage']) && $query->is_main_query() && !$query->is_admin) {
  1002. $query->set('posts_per_page', $_GET['perpage']);
  1003. }
  1004. }
  1005. add_action('pre_get_posts', 'posts_per_page_change');
  1006.  
  1007. add_action('after_setup_theme', 'add_editor_css');
  1008. function add_editor_css()
  1009. {
  1010. add_theme_support('editor-styles');
  1011. //add_editor_style( 'css/main.css' );
  1012. }
  1013.  
  1014. function get_term_option_html($taxonomy, $term)
  1015. {
  1016. global $wp_query;
  1017. return '<option value="'.$term->slug.'" '.selected(!isset($_GET['post_type']) ? $wp_query->query_vars['term'] : $_GET[$taxonomy], $term->slug, false).'>'.$term->name.'</option>';
  1018. }
  1019.  
  1020. function get_option_html($value, $title, $selected = false)
  1021. {
  1022. return '<option value="'.$value.'" '.selected($selected, $value, false).'>'.$title.'</option>';
  1023. }
  1024.  
  1025. function d()
  1026. {
  1027. if (!headers_sent()) {
  1028. header('Content-Type: text/html; charset=utf-8');
  1029. }
  1030.  
  1031. echo '<pre style="text-align: left; font-size: 10px;">';
  1032. foreach (func_get_args() as $var) {
  1033. print_r($var);
  1034. echo '<br><br>';
  1035. }
  1036. echo '</pre>';
  1037. }
  1038.  
  1039. function dd()
  1040. {
  1041. if (!headers_sent()) {
  1042. header('Content-Type: text/html; charset=utf-8');
  1043. }
  1044.  
  1045. echo '<pre style="text-align: left; font-size: 10px;">';
  1046. foreach (func_get_args() as $var) {
  1047. print_r($var);
  1048. echo '<br><br>';
  1049. }
  1050. echo '</pre>';
  1051. die();
  1052. }
  1053.  
  1054. add_action( 'woocommerce_email_customer_details', 'ts_email_customer_details', 10 , 4);
  1055. function ts_email_customer_details($order, $sent_to_admin, $plain_text, $email){
  1056. $order = wc_get_order( $order->id );
  1057. $line_items = $order->get_meta_data();
  1058. $line_items2 = $line_items['0'];
  1059.  
  1060. $trip_destinations = "";
  1061. $trip_price = 0;
  1062. $order_status = $order->status;
  1063. $order_fio = $order->data["billing"]["first_name"] . ' ' . $order->data["billing"]["last_name"] . ' ' . $order->data["billing"]["company"];
  1064. $order_birthday = $line_items2->value;
  1065. $order_passport = $order->data["billing"]["postcode"];
  1066. $order_date = $order->get_meta("billing_date");
  1067.  
  1068. foreach ($order->items as $item) {
  1069. $trip_destinations = str_replace("Поездка ", "", $item["name"]);
  1070. $trip_price = $item["total"];
  1071. }
  1072.  
  1073. // echo '<pre>';
  1074. // print_r ($order_status);
  1075. // echo '</pre>';
  1076.  
  1077. if($order_status === "processing") {
  1078. echo <<<EOL
  1079. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  1080. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml">
  1081.  
  1082. <head>
  1083. <!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]-->
  1084. <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
  1085. <meta content="width=device-width" name="viewport" />
  1086. <!--[if !mso]><!-->
  1087. <meta content="IE=edge" http-equiv="X-UA-Compatible" />
  1088. <!--<![endif]-->
  1089. <title></title>
  1090. <!--[if !mso]><!-->
  1091. <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css" />
  1092. <!--<![endif]-->
  1093. <style type="text/css">
  1094. body {
  1095. margin: 0;
  1096. padding: 0;
  1097. }
  1098.  
  1099. table,
  1100. td,
  1101. tr {
  1102. vertical-align: top;
  1103. border-collapse: collapse;
  1104. }
  1105.  
  1106. * {
  1107. line-height: inherit;
  1108. }
  1109.  
  1110. a[x-apple-data-detectors=true] {
  1111. color: inherit !important;
  1112. text-decoration: none !important;
  1113. }
  1114. </style>
  1115. <style id="media-query" type="text/css">
  1116. @media (max-width: 580px) {
  1117.  
  1118. .block-grid,
  1119. .col {
  1120. min-width: 320px !important;
  1121. max-width: 100% !important;
  1122. display: block !important;
  1123. }
  1124.  
  1125. .block-grid {
  1126. width: 100% !important;
  1127. }
  1128.  
  1129. .col {
  1130. width: 100% !important;
  1131. }
  1132.  
  1133. .col_cont {
  1134. margin: 0 auto;
  1135. }
  1136.  
  1137. img.fullwidth,
  1138. img.fullwidthOnMobile {
  1139. max-width: 100% !important;
  1140. }
  1141.  
  1142. .no-stack .col {
  1143. min-width: 0 !important;
  1144. display: table-cell !important;
  1145. }
  1146.  
  1147. .no-stack.two-up .col {
  1148. width: 50% !important;
  1149. }
  1150.  
  1151. .no-stack .col.num2 {
  1152. width: 16.6% !important;
  1153. }
  1154.  
  1155. .no-stack .col.num3 {
  1156. width: 25% !important;
  1157. }
  1158.  
  1159. .no-stack .col.num4 {
  1160. width: 33% !important;
  1161. }
  1162.  
  1163. .no-stack .col.num5 {
  1164. width: 41.6% !important;
  1165. }
  1166.  
  1167. .no-stack .col.num6 {
  1168. width: 50% !important;
  1169. }
  1170.  
  1171. .no-stack .col.num7 {
  1172. width: 58.3% !important;
  1173. }
  1174.  
  1175. .no-stack .col.num8 {
  1176. width: 66.6% !important;
  1177. }
  1178.  
  1179. .no-stack .col.num9 {
  1180. width: 75% !important;
  1181. }
  1182.  
  1183. .no-stack .col.num10 {
  1184. width: 83.3% !important;
  1185. }
  1186.  
  1187. .video-block {
  1188. max-width: none !important;
  1189. }
  1190.  
  1191. .mobile_hide {
  1192. min-height: 0px;
  1193. max-height: 0px;
  1194. max-width: 0px;
  1195. display: none;
  1196. overflow: hidden;
  1197. font-size: 0px;
  1198. }
  1199.  
  1200. .desktop_hide {
  1201. display: block !important;
  1202. max-height: none !important;
  1203. }
  1204. }
  1205. </style>
  1206. </head>
  1207.  
  1208. <body class="clean-body" style="margin: 0; padding: 0; -webkit-text-size-adjust: 100%; background-color: #ffffff;">
  1209. <!--[if IE]><div class="ie-browser"><![endif]-->
  1210. <table bgcolor="#ffffff" cellpadding="0" cellspacing="0" class="nl-container" role="presentation" style="table-layout: fixed; vertical-align: top; min-width: 320px; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; width: 100%; border: 1px solid #000; margin-bottom: 20px;" valign="top" width="100%">
  1211. <tbody>
  1212. <tr style="vertical-align: top;" valign="top">
  1213. <td style="word-break: break-word; vertical-align: top; padding-left: 5px;" valign="top">
  1214. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color:#ffffff"><![endif]-->
  1215. <div style="background-color:transparent;overflow:hidden">
  1216. <div class="block-grid two-up" style="min-width: 320px; max-width: 560px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; width: 100%; background-color: transparent;">
  1217. <div style="border-collapse: collapse;display: table;width: 100%;background-color:transparent;">
  1218. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:transparent;"><tr><td align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:560px"><tr class="layout-full-width" style="background-color:transparent"><![endif]-->
  1219. <!--[if (mso)|(IE)]><td align="center" width="280" style="background-color:transparent;width:280px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;"><![endif]-->
  1220. <div class="col num6" style="display: table-cell; vertical-align: top; max-width: 320px; min-width: 235px; width: 280px;">
  1221. <div class="col_cont" style="width:100% !important;">
  1222. <!--[if (!mso)&(!IE)]><!-->
  1223. <div style="border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;">
  1224. <!--<![endif]-->
  1225. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 0px; padding-left: 5px; padding-top: 10px; padding-bottom: 5px; font-family: Tahoma, sans-serif"><![endif]-->
  1226. <div style="color:#33563c;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.8;padding-top:10px;padding-right:0px;padding-bottom:5px;padding-left:5px;">
  1227. <div style="line-height: 1.8; font-size: 12px; color: #33563c; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 22px;">
  1228. <p style="line-height: 1.8; word-break: break-word; mso-line-height-alt: 22px; margin: 0;"><strong>Билет №:</strong> $order->id</p>
  1229. <p style="line-height: 1.8; word-break: break-word; mso-line-height-alt: 22px; margin: 0;"><br /><strong>Покупатель / пассажир:</strong><br />$order_fio</p>
  1230. <p style="line-height: 1.8; word-break: break-word; mso-line-height-alt: 22px; margin: 0;"><strong>Документ: </strong><br />$order_passport<br /><strong>Дата рождения:</strong> <br /> $order_birthday<br /><strong>Поездка откуда-куда:</strong><br />$trip_destinations<br /><strong>Цена: </strong><br />$trip_price<br /><strong>Дата поездки:</strong> <br />$order_date</p>
  1231. </div>
  1232. </div>
  1233. <!--[if mso]></td></tr></table><![endif]-->
  1234. <!--[if (!mso)&(!IE)]><!-->
  1235. </div>
  1236. <!--<![endif]-->
  1237. </div>
  1238. </div>
  1239. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  1240. <!--[if (mso)|(IE)]></td><td align="center" width="280" style="background-color:transparent;width:280px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;"><![endif]-->
  1241. <div class="col num6" style="display: table-cell; vertical-align: top; max-width: 320px; min-width: 276px; width: 280px;">
  1242. <div class="col_cont" style="width:100% !important;">
  1243. <!--[if (!mso)&(!IE)]><!-->
  1244. <div style="border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;">
  1245. <!--<![endif]-->
  1246. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 0px; padding-left: 30px; padding-top: 10px; padding-bottom: 5px; font-family: Tahoma, sans-serif"><![endif]-->
  1247. <div style="color:#33563c;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.8;padding-top:10px;padding-right:0px;padding-bottom:5px;padding-left:0;">
  1248. <div style="line-height: 1.8; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #33563c; mso-line-height-alt: 22px;">
  1249. <p style="font-size: 8px; line-height: 1.8; word-break: break-word; text-align: left; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 14px; margin: 0;"><span style="font-size: 8px; color: #000000;"><strong>ООО "Альянс 100 дорог"</strong></span></p>
  1250. <p style="font-size: 8px; line-height: 1.8; word-break: break-word; text-align: left; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 14px; margin: 0;"><span style="font-size: 8px; color: #000000;"><strong>ИНН:</strong> 7203487738 <strong>ОГРН:</strong> 1197232022217</span></p>
  1251. </div>
  1252. </div>
  1253. <!--[if mso]></td></tr></table><![endif]-->
  1254. <div align="left" class="img-container center autowidth" style="padding-right: 0px;padding-left: 0px;">
  1255. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr style="line-height:0px"><td style="padding-right: 0px;padding-left: 0px;" align="center"><![endif]--><img align="center" alt="Alternate text" border="0" class="center autowidth" src="http://poputchiki24.ru/wp-content/uploads/kuar-kod-1-1.png" style="text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: 0; width: 100%; max-width: 250px; display: block;" title="Плати QR от Сбера" width="100" />
  1256. <!--[if mso]></td></tr></table><![endif]-->
  1257. </div>
  1258. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 15px; padding-left: 30px; padding-top: 10px; padding-bottom: 10px; font-family: Tahoma, sans-serif"><![endif]-->
  1259. <!--[if mso]></td></tr></table><![endif]-->
  1260. <!--[if (!mso)&(!IE)]><!-->
  1261. </div>
  1262. <!--<![endif]-->
  1263. </div>
  1264. </div>
  1265. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  1266. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  1267. </div>
  1268. <div style="color:#33563c;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.8;padding-top:10px;padding-right:0;padding-bottom:10px;padding-left:0;">
  1269. <div style="line-height: 1.8; font-size: 12px; color: #33563c; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 22px;">
  1270. <p style="line-height: 1.8; word-break: break-word; font-size: 6px; mso-line-height-alt: 14px; margin: 0; text-align: center;"><span style="font-size: 7px; color: #000000;"><strong>ЮРИДИЧЕСКИЙ АДРЕС:</strong> 625041, ТЮМЕНСКАЯ ОБЛАСТЬ, ГОРОД ТЮМЕНЬ, УЛИЦА УРОЖАЙНАЯ (СНТ ОЛИМПИЕЦ ТЕР), ДОМ 85</span></p>
  1271. </div>
  1272. </div>
  1273. </div>
  1274. </div>
  1275. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  1276. </td>
  1277. </tr>
  1278. </tbody>
  1279. </table>
  1280. <!--[if (IE)]></div><![endif]-->
  1281. </body>
  1282.  
  1283. </html>
  1284. EOL;
  1285.  
  1286. }
  1287.  
  1288. }
  1289.  
  1290. add_filter( 'woocommerce_add_cart_item_data', 'my_empty_cart_before_add', 10, 3);
  1291. function my_empty_cart_before_add( $cart_item_data, $product_id, $variation_id )
  1292. {
  1293. global $woocommerce;
  1294. $woocommerce->cart->empty_cart();
  1295.  
  1296. return $cart_item_data;
  1297. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement