<?php

function hyper_news_intro_text( $default_text ) {
	$default_text .= sprintf(
		'<div class="notice notice-info hyper-news-demo-data"><p class="demo-file-content">%1$s <a href="%2$s" target="_blank">%3$s</a></p></div>',
		esc_html__( 'Demo content files for Hyper News Theme.', 'hyper-news' ),
		esc_url( 'https://docs.ascendoor.com/docs/hyper-news/getting-started/import-demo-content/' ),
		esc_html__( 'Click here to download demo files.', 'hyper-news' )
	);
	return $default_text;
}
add_filter( 'pt-ocdi/plugin_intro_text', 'hyper_news_intro_text' );

/**
 * OCDI after import.
 */
function hyper_news_after_import_setup() {
	// Assign menus to their locations.
	$hyper_news_primary_menu = get_term_by( 'name', 'Primary Menu', 'nav_menu' );
	$hyper_news_social_menu  = get_term_by( 'name', 'Social Menu', 'nav_menu' );

	set_theme_mod(
		'nav_menu_locations',
		array(
			'primary' => $hyper_news_primary_menu->term_id,
			'social'  => $hyper_news_social_menu->term_id,
		)
	);

	// Assign front page and posts page (blog page).
	$hyper_news_front_page_id = get_page_by_title( 'Home' );
	$hyper_news_blog_page_id  = get_page_by_title( 'Blog' );

	update_option( 'show_on_front', 'page' );
	update_option( 'page_on_front', $hyper_news_front_page_id->ID );
	update_option( 'page_for_posts', $hyper_news_blog_page_id->ID );

}
add_action( 'ocdi/after_import', 'hyper_news_after_import_setup' );
