Commit 7439a84a authored by Simonas's avatar Simonas

Data migrated

parent bd85b470
......@@ -16,10 +16,10 @@
- check if dev.biuro.lt, dev.biuro.lv, dev.biuro.ee works
### DB backup
- `C:\web\dev.biuro> docker exec -i mysql mysqldump -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress > docker/mariadb/db_005.sql`
- `C:\web\dev.biuro> docker exec -i mysql mysqldump -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress > docker/mariadb/db_002.sql`
### DB restore
- `C:\web\dev.biuro> docker exec -i mysql mysql -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress < docker/mariadb/db_004.sql`
- `C:\web\dev.biuro> docker exec -i mysql mysql -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress < docker/mariadb/db_001.sql`
## Development
- `C:\web\dev.biuro\wordpress>yarn (or npm install)`
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
// spl_autoload_register( function ( $class ) {
// $classname_pieces = explode( '_', strtolower( $class ) );
// $class_file = get_template_directory() . "/lib/" . implode( '-', $classname_pieces ) . ".php";
// if ( file_exists( $class_file ) ) {
// include_once $class_file;
// } else {
// $class_file = get_template_directory() . "/lib/" . array_pop( $classname_pieces ) . "s/" . implode( '-', $classname_pieces ) . ".php";
// if ( file_exists( $class_file ) ) {
// include_once $class_file;
// }
// }
// } );
// $Theme_Support = new Theme_Support();
// $Theme_Support->init();
// $Theme_Enqueue = new Theme_Enqueue();
// $Theme_Enqueue->init();
// $Theme_Endpoints = new Theme_Endpoints();
// $Theme_Endpoints->init();
function debug($arr) {
echo '<pre>';
print_r( $arr );
echo '</pre>';
}
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
// function posts_link_attributes_1() {
// return 'class="c-pagination c-pagination--prev"';
// }
// function posts_link_attributes_2() {
// return 'class="c-pagination c-pagination--next"';
// }
// add_filter('next_posts_link_attributes', 'posts_link_attributes_1');
// add_filter('previous_posts_link_attributes', 'posts_link_attributes_2');
// add_filter('next_post_link', 'post_link_attributes');
// add_filter('previous_post_link', 'post_link_attributes');
// function post_link_attributes($output) {
// $injection = 'class="styled-button"';
// return str_replace('<a href=', '<a '.$injection.' href=', $output);
// }
/**
* Enables the Excerpt meta box in Page edit screen.
*/
// function wpcodex_add_excerpt_support_for_pages() {
// add_post_type_support( 'page', 'excerpt' );
// }
// add_action( 'init', 'wpcodex_add_excerpt_support_for_pages' );
function getImages($postID) {
$res = array();
$images = get_children( array (
'numberposts' => -1,
'order' => 'ASC',
'post_mime_type' => 'image',
'post_parent' => $postID,
'post_status' => null,
'post_type' => 'attachment'
));
foreach ( $images as $ID => $image ) {
$res[] = array(
// 'holder' => (string) parse_url(wp_get_attachment_image_src( $ID, 'placeholder' )[0])['path'],
// 'img' => (string) parse_url(wp_get_attachment_image_src( $ID, 'thumbnail' )[0])['path'],
// 'img2x' => (string) parse_url(wp_get_attachment_image_src( $ID, 'thumbnail@2x' )[0])['path'],
// 'medium' => (string) parse_url(wp_get_attachment_image_src( $ID, 'medium' )[0])['path'],
// 'medium2x' => (string) parse_url(wp_get_attachment_image_src( $ID, 'medium@2x' )[0])['path'],
// 'large' => (string) parse_url(wp_get_attachment_image_src( $ID, 'large' )[0])['path'],
// 'large2x' => (string) parse_url(wp_get_attachment_image_src( $ID, 'large@2x' )[0])['path'],
'holder' => wp_get_attachment_image_src( $ID, 'placeholder' )[0],
'img' => wp_get_attachment_image_src( $ID, 'thumbnail' )[0],
'img2x' => wp_get_attachment_image_src( $ID, 'thumbnail@2x' )[0],
'medium' => wp_get_attachment_image_src( $ID, 'medium' )[0],
'medium2x' => wp_get_attachment_image_src( $ID, 'medium@2x' )[0],
'large' => wp_get_attachment_image_src( $ID, 'large' )[0],
'large2x' => wp_get_attachment_image_src( $ID, 'large@2x' )[0],
'text' => (string) get_post_meta($ID, '_wp_attachment_image_alt', true)
);
}
return $res;
}
function getMenus( ) {
$menus = wp_get_nav_menus();
$res = array();
foreach ( $menus as $menu ) :
$res[ $menu->slug ] = getSubMenus($menu->term_id);
endforeach;
return $res;
}
// function getMenus( ) {
// $locations = get_nav_menu_locations();
// $registered_menus = get_registered_nav_menus();
// $menus = array();
// if ( $locations && $registered_menus ) :
// foreach ( $registered_menus as $slug => $menu ) :
// if ( ! isset( $locations[ $slug ] ) ) {
// continue;
// }
// $menus[ $slug ]['ID'] = $locations[ $slug ];
// // $menus[ $slug ]['lang'] = $default_lang;
// $menus[ $slug ]['pages'] = getSubMenus($locations[ $slug ]);
// // $rest_menus[ $slug ]['pages'] = array();
// // $rest_menus[ $slug ]['label'] = $label;
// // $rest_menus[ $slug ]['meta']['links']['collection'] = $rest_url;
// // $rest_menus[ $slug ]['meta']['links']['self'] = $rest_url . $slug;
// endforeach;
// endif;
// return $menus;
// }
function getSubMenus ( $ID ) {
$menu_items = wp_get_nav_menu_items( $ID );
$rev_items = array_reverse( $menu_items );
$rev_menu = array();
$cache = array();
foreach ( $rev_items as $item ) :
$formatted = array(
'order' => (int) $item->menu_order,
'title' => $item->title,
'path' => (string) parse_url($item->url)['path'],
'objectID' => abs( $item->object_id ),
'pages' => array(),
// 'parent' => abs( $item->menu_item_parent ),
// 'url' => $item->url,
// 'attr' => $item->attr_title,
// 'target' => $item->target,
// 'classes' => implode( ' ', $item->classes ),
// 'xfn' => $item->xfn,
// 'description' => $item->description,
// 'object' => $item->object,
// 'type' => $item->type,
// 'type_label' => $item->type_label,
);
if ( array_key_exists( $item->ID, $cache ) ) {
$formatted['pages'] = array_reverse( $cache[ $item->ID ] );
}
$formatted = apply_filters( 'rest_menus_format_menu_item', $formatted );
if ( $item->menu_item_parent != 0 ) {
if ( array_key_exists( $item->menu_item_parent, $cache ) ) {
array_push( $cache[ $item->menu_item_parent ], $formatted );
} else {
$cache[ $item->menu_item_parent ] = array( $formatted, );
}
} else {
array_push( $rev_menu, $formatted );
}
endforeach;
return array_reverse( $rev_menu );
}
function getPages ( $data ) {
$res = array();
$props = array(
'posts_per_page' => -1,
'offset' => 0,
'category' => '',
'category_name' => '',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'page',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'author_name' => '',
'post_status' => 'publish',
'suppress_filters' => true
);
$pages = get_posts($props);
// pll_home_url($slug);
foreach ( $pages as $page ) :
$arr = (array) $page;
$pageID = $arr['ID'];
$title = get_post_meta( $arr['ID'], '_yoast_wpseo_title', true );
if (!$title):
$title = $arr['post_title'];
endif;
$cat = get_the_category( $pageID );
$lang = pll_get_post_language( $pageID );
$path = (string) parse_url(get_page_link( $pageID ))['path'];
$res[ $path ] = (array) [];
$res[ $path ]['ID'] = $pageID;
$res[ $path ]['title'] = $title;
$res[ $path ]['description'] = get_post_meta( $pageID, '_yoast_wpseo_metadesc', true );
$res[ $path ]['content'] = apply_filters('the_content', $arr['post_content']);
$res[ $path ]['categoryID'] = $cat[0] -> cat_ID;
$res[ $path ]['paths'] = getLanguages( $pageID );
$res[ $path ]['images'] = getImages( $pageID );
// $res[ $path ]['lang'] = $lang
$res[ $path ]['homeURL'] = (string) parse_url( pll_home_url( $lang ) )['path'];
// $res[ $path ]['page'] = is_page( $pageID );
endforeach;
// 'yoast_wpseo_focuskw' => get_post_meta($post->ID, '_yoast_wpseo_focuskw', true),
// 'yoast_wpseo_title' => get_post_meta($post->ID, '_yoast_wpseo_title', true),
// 'yoast_wpseo_metadesc' => get_post_meta($post->ID, '_yoast_wpseo_metadesc', true),
// 'yoast_wpseo_linkdex' => get_post_meta($post->ID, '_yoast_wpseo_linkdex', true),
// 'yoast_wpseo_metakeywords' => get_post_meta($post->ID, '_yoast_wpseo_metakeywords', true),
// 'yoast_wpseo_meta-robots-noindex' => get_post_meta($post->ID, '_yoast_wpseo_meta-robots-noindex', true),
// 'yoast_wpseo_meta-robots-nofollow' => get_post_meta($post->ID, '_yoast_wpseo_meta-robots-nofollow', true),
// 'yoast_wpseo_meta-robots-adv' => get_post_meta($post->ID, '_yoast_wpseo_meta-robots-adv', true),
// 'yoast_wpseo_canonical' => get_post_meta($post->ID, '_yoast_wpseo_canonical', true),
// 'yoast_wpseo_redirect' => get_post_meta($post->ID, '_yoast_wpseo_redirect', true),
// 'yoast_wpseo_opengraph-title' => get_post_meta($post->ID, '_yoast_wpseo_opengraph-title', true),
// 'yoast_wpseo_opengraph-description' => get_post_meta($post->ID, '_yoast_wpseo_opengraph-description', true),
// 'yoast_wpseo_opengraph-image' => get_post_meta($post->ID, '_yoast_wpseo_opengraph-image', true),
// 'yoast_wpseo_twitter-title' => get_post_meta($post->ID, '_yoast_wpseo_twitter-title', true),
// 'yoast_wpseo_twitter-description' => get_post_meta($post->ID, '_yoast_wpseo_twitter-description', true),
// 'yoast_wpseo_twitter-image' => get_post_meta($post->ID, '_yoast_wpseo_twitter-image', true)
// "ID": 14,
// "post_author": "3",
// "post_date": "2014-07-21 19:54:07",
// "post_date_gmt": "2014-07-21 17:54:07",
// "post_content": "<h1>Location</h1>\r\nADDRESS: Gediminas ave. 26 Vilnius, lithuania\r\nPHONE: <strong>+370 5 2031228</strong>\r\nEMAIL: <a href=\"mailto:info@town.lt\">info@town.lt</a>\r\n\r\nMonday - Thursday: 11:30-22:00\r\nFriday: 11:30 - 23:30\r\nSaturday: 12:30 - 23:30\r\nSundays: closed\r\n\r\n<a href=\"http://www.facebook.com/thetowncontemporarygrillbar\" target=\"_blank\" rel=\"noopener\">FOLLOW US ON FACEBOOK</a>\r\n\r\n&nbsp;",
// "post_title": "Contacts",
// "post_excerpt": "",
// "post_status": "publish",
// "comment_status": "open",
// "ping_status": "closed",
// "post_password": "",
// "post_name": "contacts",
// "to_ping": "",
// "pinged": "",
// "post_modified": "2018-01-28 18:02:26",
// "post_modified_gmt": "2018-01-28 16:02:26",
// "post_content_filtered": "",
// "post_parent": 0,
// "guid": "http://town.loc.al/?page_id=14",
// "menu_order": 0,
// "post_type": "page",
// "post_mime_type": "",
// "comment_count": "0",
// "filter": "raw"
// debug($res);
// print_r($res);
return $res;
}
function getLanguages ( $ID ) {
$res = array();
$languages = pll_the_languages(array(
'raw' => 1,
'post_id' => $ID
));
foreach ( $languages as $language ) :
$arr = (array) $language;
$res[] = array(
'slug' => $arr['slug'],
'name' => $arr['name'],
'order' => (int) $arr['order'],
'path' => (string) parse_url($arr['url'])['path']
);
endforeach;
return $res;
}
function getPosts ( ) {
$res = array();
$props = array(
'posts_per_page' => -1,
'offset' => 0,
'category' => '',
'category_name' => '',
'orderby' => 'date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'author_name' => '',
'post_status' => 'publish',
'suppress_filters' => true
);
$posts = get_posts($props);
foreach ( $posts as $post ) :
$arr = (array) $post;
$postID = (int) $arr['ID'];
$cat = get_the_category( $postID );
$res[] = array(
'categoryID' => $cat[0] -> cat_ID,
'content' => apply_filters('the_content', $arr['post_content']),
'order' => (int) $arr['menu_order'],
'type' => (string) get_post_format( $postID )
);
endforeach;
return $res;
}
function getForms ( ) {
$res = array();
// $args = array('post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1);
$props = array(
'posts_per_page' => -1,
'offset' => 0,
'category' => '',
'category_name' => '',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'wpcf7_contact_form',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'author_name' => '',
'post_status' => 'publish',
'suppress_filters' => true
);
$forms = get_posts($props);
// debug($forms);
foreach ( $forms as $form ) :
$arr = (array) $form;
$formID = $arr['ID'];
$res[ $formID ]['ID'] = $formID;
$res[ $formID ]['content'] = apply_filters('the_content', $arr['post_content']);
endforeach;
// debug(get_posts($args));
// $res[0] = '00000';
// $res[1] = '00001';
// $res[2] = '00002';
return $res;
}
// function getArray ( ) {
// $res = array();
// $res[0] = '00000';
// $res[1] = '00001';
// $res[2] = '00002';
// return $res;
// }
// add_action( 'rest_api_init', function () {
// register_rest_route( 'our-wp-api/v1', '/pages', array(
// 'methods' => WP_REST_Server::READABLE,
// 'callback' => 'getPages',
// ));
// register_rest_route( 'our-wp-api/v1', '/menus', array(
// array(
// 'methods' => WP_REST_Server::READABLE,
// 'callback' => 'getMenus'
// )
// ));
// register_rest_route( 'our-wp-api/v1', '/posts', array(
// array(
// 'methods' => WP_REST_Server::READABLE,
// 'callback' => 'getPosts'
// )
// ));
// register_rest_route( 'our-wp-api/v1', '/forms', array(
// array(
// 'methods' => WP_REST_Server::READABLE,
// 'callback' => 'getForms'
// )
// ));
// });
/*-----------------------------------------------------------------------------------*/
/* Enable more buttons in admin
/*-----------------------------------------------------------------------------------*/
function enable_more_buttons($buttons) {
$buttons[] = 'hr';
// $buttons[] = 'sub';
// $buttons[] = 'sup';
// $buttons[] = 'fontselect';
// $buttons[] = 'fontsizeselect';
// $buttons[] = 'cleanup';
// $buttons[] = 'styleselect';
return $buttons;
}
add_filter("mce_buttons_2", "enable_more_buttons");
function biuro_theme_setup() {
add_theme_support( 'post-formats', array(
'aside',
// 'image',
// 'video',
// 'quote',
// 'link',
// 'gallery',
// 'audio',
) );
// Make sure featured images are enabled
add_theme_support( 'post-thumbnails' );
update_option( 'thumbnail_crop', 1 );
add_image_size( 'placeholder', 26, 14, true );
update_option( 'thumbnail_size_w', 320 );
update_option( 'thumbnail_size_h', 175 );
update_option( 'thumbnail_crop', 1 );
add_image_size( 'thumbnail@2x', 640, 350, true );
update_option( 'medium_size_w', 480 );
update_option( 'medium_size_h', 262 );
update_option( 'medium_crop', 1 );
add_image_size( 'medium@2x', 960, 524, true );
update_option( 'large_size_w', 715 );
update_option( 'large_size_h', 390 );
update_option( 'large_crop', 1 );
add_image_size( 'large@2x', 1430, 780, true );
// removing medium_large thumbnail
add_filter( 'intermediate_image_sizes', function( $sizes ) {
return array_filter( $sizes, function( $val ) {
return 'medium_large' !== $val; // Filter out 'medium_large'
});
});
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
}
// add_filter( 'pre_option_thumbnail_crop', '__return_zero' );
add_action( 'after_setup_theme', 'biuro_theme_setup' );
// function wpse_setup_theme() {
// add_theme_support( 'post-thumbnails' );
// add_image_size( 'small-thumb', 60, 60, true );
// }
// add_action( 'after_setup_theme', 'wpse_setup_theme' );
// // Standard Size Thumbnail
// if(false === get_option("thumbnail_crop")) {
// add_option("thumbnail_crop", "1");
// } else {
// update_option("thumbnail_crop", "1");
// }
// // Medium Size Thumbnail
// if(false === get_option("medium_crop")) {
// add_option("medium_crop", "1");
// } else {
// update_option("medium_crop", "1");
// }
// // Large Size Thumbnail
// if(false === get_option("large_crop")) {
// add_option("large_crop", "1");
// } else {
// update_option("large_crop", "1");
// }
// add_image_size( 'size-placeholder', 40, 22, true );
// add_image_size( 'size-small', 320, 175, true );
// add_image_size( 'size-small-2x', 640, 350, true );
// add_image_size( 'size-medium', 480, 262, true );
// add_image_size( 'size-medium-2x', 960, 524, true );
// add_image_size( 'size-large', 715, 390, true );
// add_image_size( 'size-large-2x', 1430, 780, true );
// function biuro_theme_custom_sizes( $sizes ) {
// return array_merge( $sizes, array(
// 'your-custom-size' => __( 'Your Custom Size Name' ),
// ) );
// }
// add_filter( 'image_size_names_choose', 'biuro_theme_custom_sizes' );
// add_theme_support( 'post-thumbnails' );
function filter_site_upload_size_limit( $size ) {
// Set the upload size limit to 60 MB for users lacking the 'manage_options' capability.
// if ( ! current_user_can( 'manage_options' ) ) {
// 60 MB.
$size = 10 * 1024 * 1024;
// }
return $size;
}
add_filter( 'upload_size_limit', 'filter_site_upload_size_limit', 20 );
// 1
// 2
// 3
// add_image_size( 'sidebar-thumb', 120, 120, true ); // Hard Crop Mode
// add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop Mode
// add_image_size( 'singlepost-thumb', 590, 9999 ); // Unlimited Height Mode
// This code creates three new image sizes with different sizes. Feel free to tweak the code to meet your own requirements.
// You can display an image size in anywhere in your theme using this code.
// function add_custom_sizes() {
// add_image_size( 'portfolio-thumb', 243, 163, true );
// add_image_size( 'portfolio-image', 1074, 725, true );
// add_image_size( 'available-homes', 500, 279, true );
// add_image_size( 'idea-thumb', 146, 141, true );
// }
// add_action('after_setup_theme','add_custom_sizes');
// add_image_size( 'placeholder-size', 40, 22, true );
// add_image_size( 'mid_size', 600 );
// add_image_size( 'lrg_size', 1200 );
// add_image_size( 'sup_size', 2400 );
function our_scripts() {
// get the theme directory style.css and link to it in the header
// wp_enqueue_style( 'town-style', get_template_directory_uri() . '/css/main.css', '10000', 'all' );
// add fitvid
// wp_enqueue_script( 'naked-fitvid', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), NAKED_VERSION, true );
// add theme scripts
// wp_enqueue_script( 'naked', get_template_directory_uri() . '/js/theme.min.js', array(), NAKED_VERSION, true );
// add flexslider scripts
// wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), NAKED_VERSION, true );
}
add_action( 'wp_enqueue_scripts', 'our_scripts' ); // Register this fxn and allow Wordpress to call it automatcally in the header
function my_deregister_scripts(){
wp_dequeue_script( 'wp-embed' );
}
add_action( 'wp_footer', 'my_deregister_scripts' );
function add_posts_order() {
add_post_type_support('post', 'page-attributes');
}
add_action( 'admin_init', 'add_posts_order' );
/**
* Disable the emoji's
*/
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_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
add_filter( 'emoji_svg_url', '__return_false' );
}
add_action( 'init', 'disable_emojis' );
/**
* Filter function used to remove the tinymce emoji plugin.
*
* @param array $plugins
* @return array Difference betwen the two arrays
*/
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
/**
* Remove emoji CDN hostname from DNS prefetching hints.
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed for.
* @return array Difference betwen the two arrays.
*/
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
if ( 'dns-prefetch' == $relation_type ) {
/** This filter is documented in wp-includes/formatting.php */
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
$urls = array_diff( $urls, array( $emoji_svg_url ) );
}
return $urls;
}
// add_filter( 'emoji_svg_url', '__return_false' );
function init_biuro_theme() {
// Add categories for pages
register_taxonomy_for_object_type( 'category', 'page' );
// Remove Custom fields from posts
// remove_meta_box('postcustom','post','normal');
// remove_meta_box( $id, $page, $context );
// Remove tags support from posts
unregister_taxonomy_for_object_type('post_tag', 'post');
// Register menus
register_nav_menus(
array(
'main-menu' => 'Main menu',
'region-menu' => 'Region menu',
// 'footer-menu' => 'Footer menu'
)
);
// unregister_nav_menu('town_nav');
// unregister_nav_menu('vilnius_nav');
// unregister_nav_menu('kaunas_nav');
// unregister_nav_menu('steak_nav');
// unregister_nav_menu('footer_nav');
// unregister_nav_menu('steakhouse-menu');
// unregister_nav_menu('vilnius-menu');
}
add_action('init', 'init_biuro_theme');
function setPagesLT () {
return setPages ( 'biuro.lt', '2018/10/' );
}
function setPagesLV () {
return setPages ( 'biuro.lv', 'sites/2/2018/10/' );
}
function setPagesEE () {
return setPages ( 'biuro.ee', 'sites/3/2018/10/' );
}
function setPages ( $domain, $path ) {
global $wpdb;
$data = $wpdb->get_results("SELECT
ID as ID,
Title as post_title,
Content as post_content,
Sort as menu_order,
URLSegment as post_name,
Created as post_date,
LastEdited as post_modified,
MetaTitle as _yoast_wpseo_title,
MetaDescription as _yoast_wpseo_metadesc,
MetaKeywords as _yoast_wpseo_focuskw,
Locale as locale,
ParentID as parentID,
CASE WHEN (ParentID > 0) THEN (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID) ELSE '' END AS URLSegmentParent,
CASE WHEN (ParentID > 0) THEN CONCAT('/', (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID), '/', URLSegment, '/') ELSE CONCAT('/', URLSegment, '/') END AS URLSegmentFull,
MenuTitle as menu FROM SiteTree_Live a ORDER BY parentID");
$res = array();
$arr = array();
foreach ($data as $row) {
$res[$row->ID] = $row;
}
foreach ($res as $key => $row) {
$search = array(
'direktorija/boxru4',
'sitetree_link%20id',
'http://' . $domain . '/assets',
'http://www.' . $domain . '/assets',
'href="http://biuro.lt',
'href="http://www.biuro.lt',
'src="http://biuro.lt',
'src="http://www.biuro.lt',
'assets/New-pictures/New-pictures/_resampled',
'assets/New-pictures/New-pictures/',
'assets/New-pictures/_resampled/',
'assets/New-pictures/',
'assets/_resampled/',
'assets/Nauja-direktorija/Nauja-direktorija/',
'assets/Nauja-direktorija/',
'assets/Files/_resampled/',
'assets/Files/',
'assets/Uploads/Nauji-paveiksleliai/',
'assets/Uploads/blocks/',
'assets/Uploads/',
'assets/',
'mysite/img/',
'/New-pictures/',
'/_resampled/',
'/Lottery/',
);
$replace = array(
'direktorija/boxru6',
'sitetree_link id',
'assets',
'assets',
'href="https://dev.biuro.lt',
'href="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'/',
'/',
'/',
);
$content = str_replace($search, $replace, $row->post_content);
preg_match_all('/\[sitetree_link id=(\d+)\]/mi', $content, $matches);
if (count($matches[0]) > 0) {
foreach ($matches[0] as $in => $r) {
// $res[$row->ID] = $row;
$content = str_replace($matches[0][$in], $res[$matches[1][$in]]->URLSegmentFull, $content);
}
}
$parentID = 0;
if ($row->parentID > 0) {
$parentPage = get_page_by_path($row->URLSegmentParent);
$parentID = $parentPage->ID;
}
# code...
$postID = wp_insert_post(array(
'post_title' => $row->post_title,
'post_content' => $content,
'menu_order' => $row->menu_order,
'post_name' => $row->post_name,
'post_date' => $row->post_date,
'post_modified' => $row->post_modified,
'post_author' => 1,
'post_type' => 'page',
'post_status' => 'publish',
'post_parent' => $parentID,
));
if ($postID > 0) {
add_post_meta($postID, '_yoast_wpseo_title', $row->_yoast_wpseo_title);
add_post_meta($postID, '_yoast_wpseo_metadesc', $row->_yoast_wpseo_metadesc);
add_post_meta($postID, '_yoast_wpseo_focuskw', $row->_yoast_wpseo_focuskw);
$code = 'lt';
switch ($row->locale) {
case 'lt_LT':
$code = 'lt';
break;
case 'en_US':
$code = 'en';
break;
case 'ru_RU':
$code = 'ru';
break;
case 'de_DE':
$code = 'de';
break;
case 'lv_LV':
$code = 'lv';
break;
case 'et_EE':
$code = 'et';
break;
}
PLL()->model->post->set_language($postID, $code);
}
}
return $arr;
}
// add_action( 'rest_api_init', function () {
// // https://dev.biuro.lt/wp-json/biuro/v1/pagesLT
// // https://dev.biuro.lv/wp-json/biuro/v1/pagesLV
// // https://dev.biuro.ee/wp-json/biuro/v1/pagesEE
// register_rest_route( 'biuro/v1', '/pagesLT', array(
// 'methods' => WP_REST_Server::READABLE,
// 'callback' => 'setPagesLT',
// ));
// register_rest_route( 'biuro/v1', '/pagesLV', array(
// 'methods' => WP_REST_Server::READABLE,
// 'callback' => 'setPagesLV',
// ));
// register_rest_route( 'biuro/v1', '/pagesEE', array(
// 'methods' => WP_REST_Server::READABLE,
// 'callback' => 'setPagesEE',
// ));
// });
\ No newline at end of file
......@@ -741,201 +741,3 @@ function init_biuro_theme() {
// unregister_nav_menu('vilnius-menu');
}
add_action('init', 'init_biuro_theme');
function setPagesLT () {
return setPages ( 'biuro.lt', '2018/10/' );
}
function setPagesLV () {
return setPages ( 'biuro.lv', 'sites/2/2018/10/' );
}
function setPagesEE () {
return setPages ( 'biuro.ee', 'sites/3/2018/10/' );
}
function setPages ( $domain, $path ) {
global $wpdb;
$data = $wpdb->get_results("SELECT
ID as ID,
Title as post_title,
Content as post_content,
Sort as menu_order,
URLSegment as post_name,
Created as post_date,
LastEdited as post_modified,
MetaTitle as _yoast_wpseo_title,
MetaDescription as _yoast_wpseo_metadesc,
MetaKeywords as _yoast_wpseo_focuskw,
Locale as locale,
ParentID as parentID,
CASE WHEN (ParentID > 0) THEN (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID) ELSE '' END AS URLSegmentParent,
CASE WHEN (ParentID > 0) THEN CONCAT('/', (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID), '/', URLSegment, '/') ELSE CONCAT('/', URLSegment, '/') END AS URLSegmentFull,
MenuTitle as menu FROM SiteTree_Live a ORDER BY parentID");
$res = array();
$arr = array();
foreach ($data as $row) {
$res[$row->ID] = $row;
}
foreach ($res as $key => $row) {
$search = array(
'direktorija/boxru4',
'sitetree_link%20id',
'http://' . $domain . '/assets',
'http://www.' . $domain . '/assets',
'href="http://biuro.lt',
'href="http://www.biuro.lt',
'src="http://biuro.lt',
'src="http://www.biuro.lt',
'assets/New-pictures/New-pictures/_resampled',
'assets/New-pictures/New-pictures/',
'assets/New-pictures/_resampled/',
'assets/New-pictures/',
'assets/_resampled/',
'assets/Nauja-direktorija/Nauja-direktorija/',
'assets/Nauja-direktorija/',
'assets/Files/_resampled/',
'assets/Files/',
'assets/Uploads/Nauji-paveiksleliai/',
'assets/Uploads/blocks/',
'assets/Uploads/',
'assets/',
'mysite/img/',
'/New-pictures/',
'/_resampled/',
);
$replace = array(
'direktorija/boxru6',
'sitetree_link id',
'assets',
'assets',
'href="https://dev.biuro.lt',
'href="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'/',
'/',
);
$content = str_replace($search, $replace, $row->post_content);
preg_match_all('/\[sitetree_link id=(\d+)\]/mi', $content, $matches);
if (count($matches[0]) > 0) {
foreach ($matches[0] as $in => $r) {
// $res[$row->ID] = $row;
$content = str_replace($matches[0][$in], $res[$matches[1][$in]]->URLSegmentFull, $content);
}
}
$parentID = 0;
if ($row->parentID > 0) {
$parentPage = get_page_by_path($row->URLSegmentParent);
$parentID = $parentPage->ID;
}
# code...
$postID = wp_insert_post(array(
'post_title' => $row->post_title,
'post_content' => $content,
'menu_order' => $row->menu_order,
'post_name' => $row->post_name,
'post_date' => $row->post_date,
'post_modified' => $row->post_modified,
'post_author' => 1,
'post_type' => 'page',
'post_status' => 'publish',
'post_parent' => $parentID,
));
if ($postID > 0) {
add_post_meta($postID, '_yoast_wpseo_title', $row->_yoast_wpseo_title);
add_post_meta($postID, '_yoast_wpseo_metadesc', $row->_yoast_wpseo_metadesc);
add_post_meta($postID, '_yoast_wpseo_focuskw', $row->_yoast_wpseo_focuskw);
$code = 'lt';
switch ($row->locale) {
case 'lt_LT':
$code = 'lt';
break;
case 'en_US':
$code = 'en';
break;
case 'ru_RU':
$code = 'ru';
break;
case 'de_DE':
$code = 'de';
break;
case 'lv_LV':
$code = 'lv';
break;
case 'et_EE':
$code = 'et';
break;
}
PLL()->model->post->set_language($postID, $code);
}
}
return $arr;
}
add_action( 'rest_api_init', function () {
// https://dev.biuro.lt/wp-json/biuro/v1/pagesLT
// https://dev.biuro.lv/wp-json/biuro/v1/pagesLV
// https://dev.biuro.ee/wp-json/biuro/v1/pagesEE
register_rest_route( 'biuro/v1', '/pagesLT', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLT',
));
register_rest_route( 'biuro/v1', '/pagesLV', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLV',
));
register_rest_route( 'biuro/v1', '/pagesEE', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesEE',
));
});
\ No newline at end of file
......@@ -145,6 +145,17 @@
<div id="sidebar">
<?php
$translations = pll_the_languages(array('raw'=>1));
echo '<ul style="float: left; list-style: none; margin: 0; padding: 0;">';
foreach ($translations as $code => $lang) :
echo '<li><a href="' . $lang['url'] . '">' . $lang['name'] . '</a></li>';
endforeach;
echo '</ul>';
?>
<ul id="menu">
<li>
<a href="#">VISI</a>
......
......@@ -741,201 +741,3 @@ function init_biuro_theme() {
// unregister_nav_menu('vilnius-menu');
}
add_action('init', 'init_biuro_theme');
function setPagesLT () {
return setPages ( 'biuro.lt', '2018/10/' );
}
function setPagesLV () {
return setPages ( 'biuro.lv', 'sites/2/2018/10/' );
}
function setPagesEE () {
return setPages ( 'biuro.ee', 'sites/3/2018/10/' );
}
function setPages ( $domain, $path ) {
global $wpdb;
$data = $wpdb->get_results("SELECT
ID as ID,
Title as post_title,
Content as post_content,
Sort as menu_order,
URLSegment as post_name,
Created as post_date,
LastEdited as post_modified,
MetaTitle as _yoast_wpseo_title,
MetaDescription as _yoast_wpseo_metadesc,
MetaKeywords as _yoast_wpseo_focuskw,
Locale as locale,
ParentID as parentID,
CASE WHEN (ParentID > 0) THEN (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID) ELSE '' END AS URLSegmentParent,
CASE WHEN (ParentID > 0) THEN CONCAT('/', (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID), '/', URLSegment, '/') ELSE CONCAT('/', URLSegment, '/') END AS URLSegmentFull,
MenuTitle as menu FROM SiteTree_Live a ORDER BY parentID");
$res = array();
$arr = array();
foreach ($data as $row) {
$res[$row->ID] = $row;
}
foreach ($res as $key => $row) {
$search = array(
'direktorija/boxru4',
'sitetree_link%20id',
'http://' . $domain . '/assets',
'http://www.' . $domain . '/assets',
'href="http://biuro.lt',
'href="http://www.biuro.lt',
'src="http://biuro.lt',
'src="http://www.biuro.lt',
'assets/New-pictures/New-pictures/_resampled',
'assets/New-pictures/New-pictures/',
'assets/New-pictures/_resampled/',
'assets/New-pictures/',
'assets/_resampled/',
'assets/Nauja-direktorija/Nauja-direktorija/',
'assets/Nauja-direktorija/',
'assets/Files/_resampled/',
'assets/Files/',
'assets/Uploads/Nauji-paveiksleliai/',
'assets/Uploads/blocks/',
'assets/Uploads/',
'assets/',
'mysite/img/',
'/New-pictures/',
'/_resampled/',
);
$replace = array(
'direktorija/boxru6',
'sitetree_link id',
'assets',
'assets',
'href="https://dev.biuro.lt',
'href="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'/',
'/',
);
$content = str_replace($search, $replace, $row->post_content);
preg_match_all('/\[sitetree_link id=(\d+)\]/mi', $content, $matches);
if (count($matches[0]) > 0) {
foreach ($matches[0] as $in => $r) {
// $res[$row->ID] = $row;
$content = str_replace($matches[0][$in], $res[$matches[1][$in]]->URLSegmentFull, $content);
}
}
$parentID = 0;
if ($row->parentID > 0) {
$parentPage = get_page_by_path($row->URLSegmentParent);
$parentID = $parentPage->ID;
}
# code...
$postID = wp_insert_post(array(
'post_title' => $row->post_title,
'post_content' => $content,
'menu_order' => $row->menu_order,
'post_name' => $row->post_name,
'post_date' => $row->post_date,
'post_modified' => $row->post_modified,
'post_author' => 1,
'post_type' => 'page',
'post_status' => 'publish',
'post_parent' => $parentID,
));
if ($postID > 0) {
add_post_meta($postID, '_yoast_wpseo_title', $row->_yoast_wpseo_title);
add_post_meta($postID, '_yoast_wpseo_metadesc', $row->_yoast_wpseo_metadesc);
add_post_meta($postID, '_yoast_wpseo_focuskw', $row->_yoast_wpseo_focuskw);
$code = 'lt';
switch ($row->locale) {
case 'lt_LT':
$code = 'lt';
break;
case 'en_US':
$code = 'en';
break;
case 'ru_RU':
$code = 'ru';
break;
case 'de_DE':
$code = 'de';
break;
case 'lv_LV':
$code = 'lv';
break;
case 'et_EE':
$code = 'et';
break;
}
PLL()->model->post->set_language($postID, $code);
}
}
return $arr;
}
add_action( 'rest_api_init', function () {
// https://dev.biuro.lt/wp-json/biuro/v1/pagesLT
// https://dev.biuro.lv/wp-json/biuro/v1/pagesLV
// https://dev.biuro.ee/wp-json/biuro/v1/pagesEE
register_rest_route( 'biuro/v1', '/pagesLT', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLT',
));
register_rest_route( 'biuro/v1', '/pagesLV', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLV',
));
register_rest_route( 'biuro/v1', '/pagesEE', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesEE',
));
});
\ No newline at end of file
......@@ -145,6 +145,17 @@
<div id="sidebar">
<?php
$translations = pll_the_languages(array('raw'=>1));
echo '<ul style="float: left; list-style: none; margin: 0; padding: 0;">';
foreach ($translations as $code => $lang) :
echo '<li><a href="' . $lang['url'] . '">' . $lang['name'] . '</a></li>';
endforeach;
echo '</ul>';
?>
<ul id="menu">
<li>
<a href="#">VISI</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment