HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/budilia/budilia.nl/wwwroot/wp-content/themes/forestly/functions.php
<?php
// Forestly Theme's Functions file, this is the heart of theme, modification directly is not recommended.
// Forestly Supports Child Themes, it is the way to go.
// Use a child theme for customization (see http://codex.wordpress.org/Theme_Development and
// @package forestly
// (c) 2013 Jens Wagner, Fosforito Media

// Primary content width according to the design and stylesheet.
if ( ! isset( $content_width ) )
	$content_width = 665;

// Forestly supported features and Registering defaults
function fosforit_setup() {
	// Making Forestly ready for translation.
	// Translations can be added to the /languages/ directory. Sample forestly.pot file is included.
	load_theme_textdomain( 'forestly', get_template_directory() . '/languages' );

	// Adds RSS feed links to <head> for posts and comments.
	add_theme_support( 'automatic-feed-links' );

	// Adds support for Navigation menu, Forestly uses wp_nav_menu() in one location.
	register_nav_menu( 'primary', __( 'Main Navigation Menu', 'forestly' ) );
	
	// Forestly supports custom background color and image using default wordpress functions.
	add_theme_support( 'custom-background', array(
		'default-color' => 'e8e8e8',
	) );

	// Add support for post thumbnails - for classic blog layout
	add_theme_support( 'post-thumbnails' );
	set_post_thumbnail_size( 660, 9999 ); // Unlimited height, soft crop
}
add_action( 'after_setup_theme', 'fosforit_setup' );

// Set Excerpt Thumbnail Size
$forestly_thumb_width = 200;
$forestly_thumb_height = 140;

// Add Excerpt Thumbnails
add_image_size('excerpt-thumbnail', $forestly_thumb_width, $forestly_thumb_height, true);

//Get first Post Image if no Featured Image is set
function forestly_get_first_image() {
global $forestly_thumb_width, $forestly_thumb_height;
$files = get_children('post_parent='.get_the_ID().'&post_type=attachment
&post_mime_type=image&order=desc');
  if($files) :
    $keys = array_reverse(array_keys($files));
    $j=0;
    $num = $keys[$j];
    $image=wp_get_attachment_image($num, 'large', true);
    $imagepieces = explode('"', $image);
    $imagepath = $imagepieces[1];
    $main=wp_get_attachment_url($num);
	$the_title=get_the_title();
    print "<img src='$main' alt='$the_title' class='alignleft wp-post-image' width='$forestly_thumb_width' height='$forestly_thumb_height' />";
  endif;
}

// Loads the fosforit Customizer for live customization
require_once( get_template_directory() . '/inc/fosforit-customizer.php' );

// Enqueueing scripts and styles for front-end of Forestly.
function fosforit_scripts_styles() {
	global $wp_styles;

	// Adds JavaScript to pages with the comment form to support
	// sites with threaded comments (when in use).
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
		wp_enqueue_script( 'comment-reply' );

	// Adds Selectnav.js JavaScript for handling the navigation menu and creating a select based navigation for reponsive layout.
	wp_enqueue_script('fosforit-mobile-navigation', get_template_directory_uri() . '/js/selectnav.js', array(), '1.0', true );
   
	// Loads the awesome readable ubuntu font CSS file for Forestly.
	if ( 'off' !== _x( 'on', 'Ubuntu font: on or off', 'forestly' ) ) {
		$subsets = 'latin,latin-ext';
		$protocol = is_ssl() ? 'https' : 'http';
		$query_args = array(
			'family' => 'Ubuntu:400,700',
			'subset' => $subsets,
		);
		wp_enqueue_style( 'fosforit-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null );
	}

	// Loads fosforit's main stylesheet.
	wp_enqueue_style( 'fosforit-style', get_stylesheet_uri() );

	// Loads the Internet Explorer specific stylesheet.
	wp_enqueue_style( 'fosforit-ie', get_template_directory_uri() . '/css/ie.css', array( 'fosforit-style' ), '20130305' );
	$wp_styles->add_data( 'fosforit-ie', 'conditional', 'lt IE 9' );
}
add_action( 'wp_enqueue_scripts', 'fosforit_scripts_styles', 1 );

// Include predefined CSS Color Scheme
function forestly_pre_css() {
	$forestly_pre_css = forestly_pre_design();
	wp_enqueue_style( 'custom-css', $forestly_pre_css );
}
add_action( 'wp_head', 'forestly_pre_css', 20 );

// Function to get Custom CSS Styles
function forestly_custom_css(){
	echo '<style type="text/css">';
	echo of_get_option('custom_css');
	echo '</style>';
}

// Include Custom CSS Styles
function forestly_extra_css() {
	$forestly_extra_css = forestly_custom_css();
	wp_enqueue_style( 'custom-css', $forestly_extra_css );
}
add_action( 'wp_head', 'forestly_extra_css', 21 );

// WP Title Filter, refer http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title
function fosforit_wp_title( $title, $sep ) {
	global $paged, $page;

	if ( is_feed() )
		return $title;

	// Add the site name.
	$title .= get_bloginfo( 'name' );

	// Add the site description for the home/front page.
	$site_description = get_bloginfo( 'description', 'display' );
	if ( $site_description && ( is_home() || is_front_page() ) )
		$title = "$title $sep $site_description";

	// Add a page number if necessary.
	if ( $paged >= 2 || $page >= 2 )
		$title = "$title $sep " . sprintf( __( 'Page %s', 'forestly' ), max( $paged, $page ) );

	return $title;
}
add_filter( 'wp_title', 'fosforit_wp_title', 10, 2 );

// Default Nav Menu fallback to Pages menu, 
// Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link.
function fosforit_page_menu_args( $args ) {
	if ( ! isset( $args['show_home'] ) )
		$args['show_home'] = true;
	return $args;
}
add_filter( 'wp_page_menu_args', 'fosforit_page_menu_args' );

// Registers the main widgetized sidebar area.
function fosforit_widgets_init() {
	register_sidebar( array(
		'name' => __( 'Main Sidebar', 'forestly' ),
		'id' => 'fosforit-sidebar',
		'description' => __( 'This is a Sitewide sidebar which appears on posts and pages', 'forestly' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget' => '</aside>',
		'before_title' => '<p class="widget-title">',
		'after_title' => '</p>',
	) );

	register_sidebar(array(
		'name' => 'Footer Area 1',
		'id'   => 'fosforit-footer-1',
		'description'   => 'First Footer Widget Area.',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<p class="widget-title-footer">',
		'after_title'   => '</p>'
	));
	
	register_sidebar(array(
		'name' => 'Footer Area 2',
		'id'   => 'fosforit-footer-2',
		'description'   => 'Second Footer Widget Area.',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<p class="widget-title-footer">',
		'after_title'   => '</p>'
	));
	
	register_sidebar(array(
		'name' => 'Footer Area 3',
		'id'   => 'fosforit-footer-3',
		'description'   => 'Third Footer Widget Area.',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<p class="widget-title-footer">',
		'after_title'   => '</p>'
	));
	
	register_sidebar(array(
		'name' => 'Footer Area 4',
		'id'   => 'fosforit-footer-4',
		'description'   => 'Fourth Footer Widget Area.',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<p class="widget-title-footer">',
		'after_title'   => '</p>'
	));
}
add_action( 'widgets_init', 'fosforit_widgets_init' );

if ( ! function_exists( 'fosforit_content_nav' ) ) :
	// Displays navigation to next/previous pages when applicable.
	function fosforit_content_nav( $html_id ) {
		global $wp_query;
		$html_id = esc_attr( $html_id );
		if ( $wp_query->max_num_pages > 1 ) : ?>
			<nav id="<?php echo $html_id; ?>" class="navigation" role="navigation">
				<div class="assistive-text"><?php _e( 'Post navigation', 'forestly' ); ?></div>
				<?php if(of_get_option('enable_num_pagination') == '0'){ ?>
				<div class="nav-previous alignleft"><?php next_posts_link( __( '&laquo; Older posts', 'forestly' ) ); ?></div>
				<div class="nav-next alignright"><?php previous_posts_link( __( 'Newer posts &raquo;', 'forestly' ) ); ?></div>
				<?php } else { ?>
				<?php forestly_numeric_posts_nav(); ?>
				<?php } ?>
			</nav><!-- #<?php echo $html_id; ?> .navigation -->
		<?php endif;
	}
endif;

if ( ! function_exists( 'fosforit_comment' ) ) :
	// Template for comments and pingbacks.
	//
	// To override this walker in a child theme without modifying the comments template
	// simply create your own fosforit_comment(), and that function will be used instead.
	//
	// Used as a callback by wp_list_comments() for displaying the comments.
	function fosforit_comment( $comment, $args, $depth ) {
		$GLOBALS['comment'] = $comment;
		switch ( $comment->comment_type ) :
			case 'pingback' :
				// Display pingbacks differently than normal comments. ?>
				<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
				<p><?php _e( 'Pingback:', 'forestly' ); ?> <?php comment_author_link(); ?>
				<?php edit_comment_link( __( 'Edit', 'forestly' ), '<span class="edit-link">', '</span>' ); ?></p>
			<?php break;
			case 'trackback' :
				// Display trackbacks differently than normal comments. ?>
				<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
				<p><?php _e( 'Trackback:', 'forestly' ); ?> <?php comment_author_link(); ?>
				<?php edit_comment_link( __( 'Edit', 'forestly' ), '<span class="edit-link">', '</span>' ); ?></p>
			<?php break;
			default :
				// Proceed with normal comments.
				global $post; ?>
				<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
					<article id="comment-<?php comment_ID(); ?>" class="comment">
						<header class="comment-meta comment-author vcard">
							<?php
								echo get_avatar( $comment, 30 );
								printf( '<cite class="fn">%1$s %2$s</cite>',
									get_comment_author_link(),
									// Adds Post Author to comments posted by the article writer
									( $comment->user_id === $post->post_author ) ? '<span> ' . __( 'Post author', 'forestly' ) . '</span>' : ''
								);
								printf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
									esc_url( get_comment_link( $comment->comment_ID ) ),
									get_comment_time( 'c' ),
									/* translators: 1: date */
									sprintf( __( '%1$s', 'forestly' ), get_comment_date() )
								);
							?>
						</header><!-- .comment-meta -->
						<?php if ( '0' == $comment->comment_approved ) : ?>
							<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'forestly' ); ?></p>
						<?php endif; ?>
						<section class="comment-content comment">
							<?php comment_text(); ?>
						</section><!-- .comment-content -->
						<div class="reply">
							<?php edit_comment_link( '<span class="fa fa-pencil"></span> '.__( 'Edit', 'forestly' ), '', ' &nbsp; ' ); ?>
							<?php comment_reply_link( array_merge( $args, array( 'reply_text' => '<span class="fa fa-reply"></span> '.__( 'Reply', 'forestly' ),
							'after' => '', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
						</div><!-- .reply -->
					</article><!-- #comment-## -->
			<?php break;
		endswitch; // end comment_type check
	}
endif;

if ( ! function_exists( 'fosforit_entry_meta' ) ) :
	// For Meta information for categories, tags, permalink, author, and date.
	// Create your own fosforit_entry_meta() to override in a child theme.
	function fosforit_entry_meta() {
		// Translators: used between list items, there is a space after the comma.
		$categories_list = get_the_category_list( __( ', ', 'forestly' ) );

		// Translators: used between list items, there is a space after the comma.
		$tag_list = get_the_tag_list( '', __( ', ', 'forestly' ) );

		$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
			esc_url( get_permalink() ),
			esc_attr( get_the_time() ),
			esc_attr( get_the_date( 'c' ) ),
			esc_html( get_the_date() )
		);

		$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
			esc_attr( sprintf( __( 'View all posts by %s', 'forestly' ), get_the_author() ) ),
			get_the_author()
		);

		// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
		if ( $tag_list ) {
			$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'forestly' );
		} elseif ( $categories_list ) {
			$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'forestly' );
		} else {
			$utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'forestly' );
		}

		printf(
			$utility_text,
			$categories_list,
			$tag_list,
			$date,
			$author
		);
	}
endif;

// WordPress body class Extender :
// 1. Using a full-width layout without widgets.
// 2. White or empty background color.
// 3. Custom fonts enabled.
// 4. Single or multiple authors.
function fosforit_body_class( $classes ) {
	$background_color = get_background_color();

	if ( is_page_template( 'page-templates/full-width.php' ) )
		$classes[] = 'full-width';

	if ( empty( $background_color ) )
		$classes[] = 'custom-background-empty';
	elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
		$classes[] = 'custom-background-white';

	// Enable custom font class only if the font CSS is queued to load.
	if ( wp_style_is( 'fosforit-fonts', 'queue' ) )
		$classes[] = 'custom-font-enabled';

	if ( ! is_multi_author() )
		$classes[] = 'single-author';

	return $classes;
}
add_filter( 'body_class', 'fosforit_body_class' );

// Adjusts content_width value for full-width and single image attachment
// templates, and when there are no active widgets in the sidebar.
function fosforit_content_width() {
	if ( is_page_template( 'page-templates/full-width.php' )
	|| is_attachment()
	|| ! is_active_sidebar( 'fosforit-sidebar' ) ) {
		global $content_width;
		$content_width = 1040;
	}
}
add_action( 'template_redirect', 'fosforit_content_width' );

// F-O-R-E-S-T-L-Y welcome
if ( is_admin() && isset($_GET['activated'] ) && $pagenow ==	"themes.php" )
	wp_redirect( 'themes.php?page=forestly_theme_options');

// Function to display the Social Media Icons/Links in the Header section
function forestly_get_social_links(){ ?>
	<div class="socialmedia">
		<?php if( of_get_option('social_url_1') != '' ){ ?>
			<a href="<?php echo of_get_option('social_url_1'); ?>" <?php if( of_get_option('social_open_in_new_tab') == '1' ){ echo 'target="_blank"'; } ?>><img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo of_get_option('social_url_1_type'); ?>.png" rel="author" alt="<?php echo of_get_option('social_url_1_type'); ?>"/></a> 
		<?php } ?>
		<?php if( of_get_option('social_url_2') != '' ){ ?>
			<a href="<?php echo of_get_option('social_url_2'); ?>" <?php if( of_get_option('social_open_in_new_tab') == '1' ){ echo 'target="_blank"'; } ?>><img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo of_get_option('social_url_2_type'); ?>.png" rel="author" alt="<?php echo of_get_option('social_url_2_type'); ?>"/></a> 
		<?php } ?>
		<?php if( of_get_option('social_url_3') != '' ){ ?>
			<a href="<?php echo of_get_option('social_url_3'); ?>" <?php if( of_get_option('social_open_in_new_tab') == '1' ){ echo 'target="_blank"'; } ?>><img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo of_get_option('social_url_3_type'); ?>.png" rel="author" alt="<?php echo of_get_option('social_url_3_type'); ?>"/></a>
		<?php } ?>
		<?php if( of_get_option('social_url_4') != '' ){ ?>
			<a href="<?php echo of_get_option('social_url_4'); ?>" <?php if( of_get_option('social_open_in_new_tab') == '1' ){ echo 'target="_blank"'; } ?>><img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo of_get_option('social_url_4_type'); ?>.png" rel="author" alt="<?php echo of_get_option('social_url_4_type'); ?>"/></a>
		<?php } ?>
		<?php if( of_get_option('social_url_5') != '' ){ ?>
			<a href="<?php echo of_get_option('social_url_5'); ?>" <?php if( of_get_option('social_open_in_new_tab') == '1' ){ echo 'target="_blank"'; } ?>><img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo of_get_option('social_url_5_type'); ?>.png" rel="author" alt="<?php echo of_get_option('social_url_5_type'); ?>"/></a>
		<?php } ?>
		<?php if( of_get_option('social_url_6') != '' ){ ?>
			<a href="<?php echo of_get_option('social_url_6'); ?>" <?php if( of_get_option('social_open_in_new_tab') == '1' ){ echo 'target="_blank"'; } ?>><img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo of_get_option('social_url_6_type'); ?>.png" rel="author" alt="<?php echo of_get_option('social_url_6_type'); ?>"/></a>
		<?php } ?>
	</div>
<?php
}

// Theme Options: Load Option Panel
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';

// This is an example of how to add custom scripts to the options panel.
// This one shows/hides the an option when a checkbox is clicked.
function optionsframework_custom_scripts() { ?>
	<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery('#example_showhidden').click(function() {
			jQuery('#section-example_text_hidden').fadeToggle(400);
		});
		if (jQuery('#example_showhidden:checked').val() !== undefined) {
			jQuery('#section-example_text_hidden').show();
		}
	});
	</script>
<?php
}
add_action( 'optionsframework_custom_scripts', 'optionsframework_custom_scripts' );

// Apply stylesheet to the visual editor.
function forestly_add_editor_styles() {
	add_editor_style( get_template_directory_uri().'/css/editor.css' );
}
add_action( 'init', 'forestly_add_editor_styles' );

// Function to output selected predefined Color Scheme CSS in <head>
function forestly_pre_design(){
	$forestly_pre_design = of_get_option('forestly_pre_design');
	// Include all predefined Color Schemes
	require_once( get_template_directory() . '/inc/pre-color-schemes.php' );
}

// FB-Like Button in Options Panel ;)
function optionscheck_display_before() { ?>
	<div id="fb-root"></div>
	<script>(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) return;
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1&appId=490121547693617";
	  fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));</script>

	<div style="border: 1px solid #ddd; margin-top:7px; Padding: 9px 10px 5px 10px; max-width: 820px;">
		<div class="fb-like" 
		data-href="https://www.facebook.com/fosforito.net" 
		data-width="200" 
		data-layout="button_count" 
		data-action="like" 
		data-show-faces="false" 
		data-share="true"></div>
		<?php _e('<i>Your Like will motivate me to make Forestly better!</i>', 'forestly') ?>
	</div>
<?php }
add_action('optionsframework_before','optionscheck_display_before', 100);

// Replaces the excerpt "more" text by a link
function forestly_new_excerpt_more($more) {
       global $post;
	return '... <a class="moretag" href="'. get_permalink($post->ID) . '">'.__('Continue reading &raquo;','forestly').'</a>';
}
add_filter('excerpt_more', 'forestly_new_excerpt_more');

// Numbered Post Navigation
function forestly_numeric_posts_nav() {
	if( is_singular() )
		return;
	global $wp_query;
	/** Stop execution if there's only 1 page */
	if( $wp_query->max_num_pages <= 1 )
		return;
	$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
	$max   = intval( $wp_query->max_num_pages );
	/**	Add current page to the array */
	if ( $paged >= 1 )
		$links[] = $paged;
	/**	Add the pages around the current page to the array */
	if ( $paged >= 3 ) {
		$links[] = $paged - 1;
		$links[] = $paged - 2;
	}
	if ( ( $paged + 2 ) <= $max ) {
		$links[] = $paged + 2;
		$links[] = $paged + 1;
	}
	echo '<div class="forestly_post_nav"><ul>' . "\n";
	/**	Previous Post Link */
	if ( get_previous_posts_link() )
		printf( '<li>%s</li>' . "\n", get_previous_posts_link(__('&laquo; Previous', 'forestly')) );
	/**	Link to first page, plus ellipses if necessary */
	if ( ! in_array( 1, $links ) ) {
		$class = 1 == $paged ? ' class="active"' : '';
		printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
		if ( ! in_array( 2, $links ) )
			echo '<li>...</li>';
	}
	/**	Link to current page, plus 2 pages in either direction if necessary */
	sort( $links );
	foreach ( (array) $links as $link ) {
		$class = $paged == $link ? ' class="active"' : '';
		printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
	}
	/**	Link to last page, plus ellipses if necessary */
	if ( ! in_array( $max, $links ) ) {
		if ( ! in_array( $max - 1, $links ) )
			echo '<li>...</li>' . "\n";
		$class = $paged == $max ? ' class="active"' : '';
		printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
	}
	/**	Next Post Link */
	if ( get_next_posts_link() )
		printf( '<li>%s</li>' . "\n", get_next_posts_link(__('Next &raquo;', 'forestly')) );
	echo '</ul></div>' . "\n";
}

?>