HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: /home/mmickelson/theflexguy.com/wp-content/themes/vanilla/_tarski/classes/asset.php
<?php
/**
 * class Asset
 * 
 * @package Tarski
 * @since 2.1
 */
class Asset {
	
	/**
	 * Initialisation method which calls all other methods in turn.
	 */
	function init() {
		$assets = new Asset;
		
		$assets->meta();
		$assets->stylesheets();
		$assets->javascript();
		$assets->feeds();
		
		$assets->output();
	}
	
	/**
	 * Generate meta elements pertaining to Tarski and the site.
	 * 
	 * @hook filter tarski_asset_meta
	 * Filters the metadata generated by the Asset wrapper.
	 */
	function meta() {
		$themeversion = theme_version();
		$meta = array("<meta name=\"wp_theme\" content=\"Tarski $themeversion\" />");
		
		global $wp_query;
		$excerpt = trim(strip_tags(wp_specialchars($wp_query->post->post_excerpt)));

		if ( (is_single() || is_page()) && strlen($excerpt) )
			$description = $excerpt;
		else
			$description = get_bloginfo('description');

		if ( strlen($description) )
			$meta[] = "<meta name=\"description\" content=\"$description\" />";
		
		if(get_option('blog_public') != '0')
			$meta[] = '<meta name="robots" content="all" />';
			
		$this->meta = apply_filters('tarski_asset_meta', $meta);
	}
	
	/**
	 * Generate links to the various Tarski stylesheets.
	 * 
	 * @hook filter tarski_style_array
	 * Filter the array of stylesheet attributes from which the stylesheet
	 * links are generated.
	 * 
	 * @hook filter tarski_stylesheets
	 * Filter the raw stylesheet link elements before they're printed to
	 * the document.
	 */
	function stylesheets() {
		$style_array = array(
			'main' => array(
				'url' => get_bloginfo('stylesheet_url'),
			),
			'screen' => array(
				'url' => get_bloginfo('template_directory') . '/library/css/screen.css',
				'media' => 'screen,projection'
			),
			'print' => array(
				'url' => get_bloginfo('template_directory') . '/library/css/print.css',
				'media' => 'print'
			)
		);

		if(get_tarski_option('style')) {
			$style_array['alternate'] = array(
				'url' => get_bloginfo('template_directory') . '/styles/' . get_tarski_option('style')
			);
		}

		$style_array = apply_filters('tarski_style_array', $style_array);

		if(is_array($style_array)) {
			foreach($style_array as $type => $values) {
				if(is_array($values) && $values['url']) {
					if(empty($values['media'])) {
						$values['media'] = 'all';
					}
					$stylesheets[$type] = sprintf(
						'<link rel="stylesheet" href="%1$s" type="text/css" media="%2$s" />',
						$values['url'],
						$values['media']
					);
				}
			}
		}

		$this->stylesheets = apply_filters('tarski_stylesheets', $stylesheets);
	}
	
	/**
	 * Generate script elements linking to Tarski's JavaScript.
	 * 
	 * @hook filter tarski_javascript
	 * Filter script elements before they're printed to the document.
	 */
	function javascript() {
		$scripts = array(
			'tarski-js' => get_bloginfo('template_directory') . '/app/js/tarski.js'
		);

		foreach($scripts as $name => $url) {
			$javascript[$name] = "<script type=\"text/javascript\" src=\"$url\"></script>";
		}

		$this->javascript = apply_filters('tarski_javascript', $javascript);
	}
	
	/**
	 * Generate RSS or Atom feed link elements appropriate to the context.
	 * 
	 * @hook filter tarski_feeds
	 * Filter the RSS or Atam feed link elements before they're printed to the
	 * document.
	 */
	function feeds() {
		global $comments;
		if(is_single() || (is_page() && ($comments || comments_open()))) {
			global $post;
			$title = sprintf(__('Commments feed for %s','tarski'), get_the_title());
			$link = get_post_comments_feed_link($post->ID);
			$source = 'post_comments';
		} elseif(is_archive()) {
			if(is_category()) {
				$title = sprintf( __('Category feed for %s','tarski'), single_cat_title('','',false) );
				$link = get_category_feed_link(get_query_var('cat'));
				$source = 'category';
			} elseif(is_tag()) {
				$title = sprintf( __('Tag feed for %s','tarski'), single_tag_title('','',false));
				$link = get_tag_feed_link(get_query_var('tag_id'));
				$source = 'tag';
			} elseif(is_author()) {
				$title = sprintf( __('Articles feed for %s','tarski'), the_archive_author_displayname());
				$link = get_author_feed_link(get_query_var('author'));
				$source = 'author';
			} elseif(is_date()) {
				if(is_day()) {
					$title = sprintf( __('Daily archive feed for %s','tarski'), get_the_time(get_option('date_format')));
					$link = get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d'));
					$source = 'day';
				} elseif(is_month()) {
					$title = sprintf( __('Monthly archive feed for %s','tarski'), get_the_time('F Y'));
					$link = get_month_link(get_the_time('Y'), get_the_time('m'));
					$source = 'month';
				} elseif(is_year()) {
					$title = sprintf( __('Yearly archive feed for %s','tarski'), get_the_time('Y'));
					$link = get_year_link(get_the_time('Y'));
					$source = 'year';
				}	
				if(get_settings('permalink_structure')) {
					$link .= 'feed/';
				} else {
					$link .= '&amp;feed=' . get_default_feed();
				}
			}
		} elseif(is_search()) {
			$search_query = attribute_escape(get_search_query());
			$feeds['search'] = generate_feed_link( sprintf(__('Search feed for %s','tarski'), $search_query), get_search_feed_link('', $type), feed_link_type($type) );
			$title = sprintf(__('Search comments feed for %s','tarski'), $search_query);
			$link = get_search_comments_feed_link('', $type);
			$source = 'search_comments';
		} else {
			$title = false;
		}

		if($title && $link)
			$feeds[$source] = generate_feed_link($title, $link, feed_link_type(get_default_feed()));

		$feeds['site'] = generate_feed_link( sprintf(__('%s feed','tarski'), get_bloginfo('name')), get_feed_link(), feed_link_type(get_default_feed()) );
		
		$this->feeds = apply_filters('tarski_feeds', $feeds);
	}
	
	/**
	 * Print generated HTML to the document.
	 * 
	 * @hook filter tarski_assets
	 * A more generalised filter for all assets generated by this class and
	 * printed by this method.
	 */
	function output() {
		$assets_collapsed = array();
		
		foreach ( $this as $asset ) {
			$assets_collapsed[] = implode("\n", $asset);
		}
		
		$assets_filtered = apply_filters('tarski_assets', $assets_collapsed);
		echo implode("\n\n", $assets_filtered);
	}
}

?>