<?php

/**
 * nextpage functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package nextpage
 */

/**
 * Define Const for theme Dir
 * @since 1.0.0
 * */
define('NEXTPAGE_ROOT_PATH', get_template_directory());
define('NEXTPAGE_ROOT_URL', get_template_directory_uri());
define('NEXTPAGE_CSS', NEXTPAGE_ROOT_URL . '/assets/css');
define('NEXTPAGE_JS', NEXTPAGE_ROOT_URL . '/assets/js');
define('NEXTPAGE_INC', NEXTPAGE_ROOT_PATH . '/inc');
define('NEXTPAGE_THEME_OPTIONS', NEXTPAGE_INC . '/theme-options');
define('NEXTPAGE_THEME_STYLESHEETS', NEXTPAGE_INC . '/theme-stylesheets');
define('NEXTPAGE_THEME_OPTIONS_IMG', NEXTPAGE_ROOT_URL . '/inc/theme-options/img');

/**
 * define theme info
 * @since 1.0.0
 * */
if (is_child_theme()) {
	$nextpage_theme        = wp_get_theme();
	$nextpage_parent_theme = $nextpage_theme->Template;
	$nextpage_theme_info   = wp_get_theme($nextpage_parent_theme);
} else {
	$nextpage_theme_info = wp_get_theme();
}
define('NEXTPAGE_DEV_MODE', false);
$nextpage_version = NEXTPAGE_DEV_MODE ? time() : $nextpage_theme_info->get('Version');
define('NEXTPAGE_NAME', $nextpage_theme_info->get('Name'));
define('NEXTPAGE_VERSION', $nextpage_version);
define('NEXTPAGE_AUTHOR', $nextpage_theme_info->get('Author'));
define('NEXTPAGE_AUTHOR_URI', $nextpage_theme_info->get('AuthorURI'));


/*
 * include theme helper function
 * @since 1.0.0
 * */
if (file_exists(NEXTPAGE_INC . '/template-functions.php') && NEXTPAGE_INC . '/template-tags.php') {
	require_once NEXTPAGE_INC . '/template-functions.php';
	require_once NEXTPAGE_INC . '/template-tags.php';

	function Nextpage_Function($instance)
	{
		$new_instance = false;
		switch ($instance) {
			case ("Functions"):
				$new_instance = class_exists('Nextpage_Functions') ? Nextpage_Functions::getInstance() : false;
				break;
			case ("Tags"):
				$new_instance = class_exists('Nextpage_Tags') ? Nextpage_Tags::getInstance() : false;
				break;
			default:
				$new_instance = false;
				break;
		}

		return $new_instance;
	}
}
/*
* Include codester helper functions
* @since 1.0.0
*/
if (file_exists(NEXTPAGE_INC . '/get-theme-options.php')) {
	require_once NEXTPAGE_INC . '/get-theme-options.php';
}

/*
* Include theme init file
* @since 1.0.0
*/
if (file_exists(NEXTPAGE_INC . '/class-nextpage-init.php')) {
	require_once NEXTPAGE_INC . '/class-nextpage-init.php';
}


function nextpage_move_comment_field_to_bottom($fields)
{
	$comment_field   = $fields['comment'];
	$comment_cookies = $fields['cookies'];
	unset($fields['comment']);
	unset($fields['cookies']);
	$fields['comment'] = $comment_field;
	$fields['cookies'] = $comment_cookies;

	return $fields;
}

add_filter('comment_form_fields', 'nextpage_move_comment_field_to_bottom', 99, 1);


function nextpage_notice__success()
{
?>
	<div class="notice notice-success is-dismissible">
		<p style="background: #000;color:#fff;padding: 10px;"><a style="color:#10ff00;text-decoration: none;" href="https://solverwp.com/downloads/nextpage-wordpress-magazine-wordpress-theme/" target="_blank">Go Pro</a>
		</p>
	</div>
<?php
}
add_action('admin_notices', 'nextpage_notice__success');
