HEX
Server: Apache
System: Linux p3plzcpnl489499.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: dwauav0tm6jp (6177017)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/dwauav0tm6jp/public_html/wp-content/themes/photographer-wp/functions.php
<?php

/* custom filters */

/* custom filters */

	function photographer_theme_setup()
	{
		load_theme_textdomain('read', get_template_directory() . '/languages');
		register_nav_menus(array('pixelwars_theme_menu_location_1' => esc_html__('Theme Navigation Menu', 'read')));
		add_editor_style('admin/css/editor-style.css');
		
		add_theme_support('title-tag');
		add_theme_support('automatic-feed-links');
		add_theme_support('html5', array('comment-list', 'comment-form', 'search-form', 'gallery', 'caption'));
		add_theme_support('post-formats', array('image', 'gallery', 'audio', 'video', 'quote', 'link', 'chat', 'status', 'aside'));
		add_theme_support('post-thumbnails', array('post', 'portfolio', 'page'));
		
		add_theme_support('woocommerce');
		add_theme_support('wc-product-gallery-zoom');
		add_theme_support('wc-product-gallery-slider');
		add_theme_support('wc-product-gallery-lightbox');
	}
	
	add_action('after_setup_theme', 'photographer_theme_setup');


/* ============================================================================================================================================= */


	include_once(get_template_directory() . '/admin/enqueue-styles-scripts.php');
	include_once(get_template_directory() . '/admin/enqueue-inline-style.php');
	include_once(get_template_directory() . '/admin/image-sizes.php');


/* ============================================================================================================================================= */


	function pixelwars_custom_login_logo_url($url)
	{
		return esc_url(home_url('/'));
	}
	
	
	function pixelwars_custom_login_logo_title()
	{
		return get_bloginfo('name');
	}
	
	
	function pixelwars_theme_login_logo()
	{
		$logo_login_hide = get_option('logo_login_hide', false);
		$logo_login      = get_option('logo_login', "");
		
		if ($logo_login_hide)
		{
			echo '<style type="text/css"> h1 { display: none; } </style>';
		}
		else
		{
			if ($logo_login != "")
			{
				add_filter('login_headerurl', 'pixelwars_custom_login_logo_url');
				add_filter('login_headertitle', 'pixelwars_custom_login_logo_title');
				
				echo '<style type="text/css"> h1 a { background-image: url( "' . esc_url($logo_login) . '" ) !important; } </style>';
			}
		}
	}
	
	add_action('login_head', 'pixelwars_theme_login_logo');


/* ============================================================================================================================================= */


	function pixelwars_theme_new_post_column_add($columns)
	{
		return array_merge(
			$columns,
			array('pixelwars_post_feat_img' => __('Featured Image', 'read'))
		);
	}
	
	add_filter('manage_posts_columns' , 'pixelwars_theme_new_post_column_add');
	
	
	function pixelwars_theme_new_post_column_show($column, $post_id)
	{
		if ($column == 'pixelwars_post_feat_img')
		{
			the_post_thumbnail(
				'thumbnail',
				array(
					'style' => 'max-height: 40px; max-width: 40px;'
				)
			);
		}
	}
	
	add_action('manage_posts_custom_column', 'pixelwars_theme_new_post_column_show', 10, 2);


/* ============================================================================================================================================= */


	if ( ! function_exists( 'pixelwars_theme_comments' ) ) :
	
		/*
			Template for comments and pingbacks.
			
			To override this walker in a child theme without modifying the comments template
			simply create your own pixelwars_theme_comments(), and that function will be used instead.
			
			Used as a callback by wp_list_comments() for displaying the comments.
		*/
		
		function pixelwars_theme_comments( $comment, $args, $depth )
		{
			$GLOBALS['comment'] = $comment;
			
			
			switch ( $comment->comment_type ) :
			
				case 'pingback' :
				
				case 'trackback' :
				
					// Display trackbacks differently than normal comments.
					?>
						<li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
							<p>
								<?php
									_e( 'Pingback:', 'read' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'read' ), '<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, 150 );
									
									
									printf( '<cite class="fn">%1$s %2$s</cite>',
											get_comment_author_link(),
											// If current post author is also comment author, make it known visually.
											( $comment->user_id === $post->post_author ) ? '<span></span>' : "" );
									
									
									printf( '<span class="comment-date">%3$s</span>',
											esc_url( get_comment_link( $comment->comment_ID ) ),
											get_comment_time( 'c' ),
											/* translators: 1: date, 2: time */
											sprintf( __( '%1$s at %2$s', 'read' ), get_comment_date(), get_comment_time() ) );
								?>
							</header>
							
							
							<?php
								if ( '0' == $comment->comment_approved ) :
									?>
										<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'read' ); ?></p>
									<?php
								endif;
							?>
							
							
							<section class="comment-content comment">
								<?php
									comment_text();
								?>
								
								<?php
									edit_comment_link( __( 'Edit', 'read' ), '<p class="edit-link">', '</p>' );
								?>
							</section>
							
							<div class="reply">
								<?php
									comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'read' ), 'after' => ' <span>&darr;</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) );
								?>
							</div>
						</article>
					<?php
				break;
				
			endswitch;
		}
		
	endif;


/* ============================================================================================================================================= */


	function pixelwars_theme_password_form()
	{
		global $post;
		
		$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
		
		$o = '<form class="password-form" action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"><p>' . __( "This content is password protected. To view it please enter the password below:", 'read' ) . '</p><label for="' . $label . '">' . __( "Password:", 'read' ) . ' </label><input type="password" id="' . $label . '" name="post_password" class="post-password" size="20" maxlength="20" /><input type="submit" name="Submit" class="btn" value="' . esc_attr__( "Submit", 'read' ) . '" /></form>';
		
		return $o;
	}
	
	add_filter( 'the_password_form', 'pixelwars_theme_password_form' );


/* ============================================================================================================================================= */


	function pixelwars_theme_excerpt_password_form( $excerpt )
	{
		if ( post_password_required() )
		{
			$excerpt = get_the_password_form();
		}
		
		return $excerpt;
	}
	
	add_filter( 'the_excerpt', 'pixelwars_theme_excerpt_password_form' );


/* ============================================================================================================================================= */


	function pixelwars__title_format( $title )
	{
		return '%s';
	}
	
	add_filter( 'private_title_format', 'pixelwars__title_format' );
	add_filter( 'protected_title_format', 'pixelwars__title_format' );


/* ============================================================================================================================================= */


	function pixelwars_theme_excerpt_more( $more )
	{
		return '... <span class="more"><a class="more-link" href="'. get_permalink( get_the_ID() ) . '">' . __( 'Read More', 'read' ) . '</a></span>';
	}
	
	add_filter( 'excerpt_more', 'pixelwars_theme_excerpt_more' );


/* ============================================================================================================================================= */


	function pixelwars_theme_excerpt_max_charlength( $charlength )
	{
		$excerpt = get_the_excerpt();
		$charlength++;
		
		if ( mb_strlen( $excerpt ) > $charlength )
		{
			$subex = mb_substr( $excerpt, 0, $charlength - 5 );
			$exwords = explode( ' ', $subex );
			$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
			
			if ( $excut < 0 )
			{
				echo mb_substr( $subex, 0, $excut );
			}
			else
			{
				echo $subex;
			}
			
			echo '...';
		}
		else
		{
			echo $excerpt;
		}
	}


/* ============================================================================================================================================= */


	if ( function_exists( 'register_sidebar' ) )
	{
		register_sidebar( array('name'          => __( 'Blog Sidebar', 'read' ),
								'id'            => 'pixelwars_blog_sidebar',
								'before_widget' => '<aside id="%1$s" class="widget %2$s">',
								'after_widget'  => '</aside>',
								'before_title'  => '<h3 class="widget-title"><span>',
								'after_title'   => '</span></h3>' ) );
		
		
		register_sidebar( array('name'          => __( 'Page Sidebar', 'read' ),
								'id'            => 'pixelwars_page_sidebar',
								'before_widget' => '<aside id="%1$s" class="widget %2$s">',
								'after_widget'  => '</aside>',
								'before_title'  => '<h3 class="widget-title"><span>',
								'after_title'   => '</span></h3>' ) );
		
		
		register_sidebar( array('name'          => __( 'Footer Social Icons', 'read' ),
								'id'            => 'pixelwars_footer_sidebar',
								'description'   => 'Use social media shortcodes with the Text widget in this widget location to add icons to your footer.',
								'before_widget' => "",
								'after_widget'  => "",
								'before_title'  => '<span style="display: none;">',
								'after_title'   => '</span>' ) );
		
		
		register_sidebar( array('name'          => __( 'Author Social Icons', 'read' ),
								'id'            => 'pixelwars_author_social_icons',
								'description'   => 'Use social media shortcodes with the Text widget in this widget location to add icons under the author info.',
								'before_widget' => "",
								'after_widget'  => "",
								'before_title'  => '<span style="display: none;">',
								'after_title'   => '</span>' ) );
		
		
		$sidebars_with_commas = get_option( 'sidebars_with_commas' );
		
		if ( $sidebars_with_commas != "" )
		{
			$sidebars = preg_split("/[\s]*[,][\s]*/", $sidebars_with_commas);
			
			foreach ( $sidebars as $sidebar_name )
			{
				register_sidebar( array('name'          => $sidebar_name,
										'id'            => $sidebar_name,
										'before_widget' => '<aside id="%1$s" class="widget %2$s">',
										'after_widget'  => '</aside>',
										'before_title'  => '<h3 class="widget-title">',
										'after_title'   => '</h3>' ) );
			}
		}
	}


/* ============================================================================================================================================= */


	/*
		This function filters the post content when viewing a post with the "chat" post format.  It formats the 
		content with structured HTML markup to make it easy for theme developers to style chat posts. The 
		advantage of this solution is that it allows for more than two speakers (like most solutions). You can 
		have 100s of speakers in your chat post, each with their own, unique classes for styling.
		
		@author David Chandra
		@link http://www.turtlepod.org
		@author Justin Tadlock
		@link http://justintadlock.com
		@copyright Copyright (c) 2012
		@license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
		@link http://justintadlock.com/archives/2012/08/21/post-formats-chat
		
		@global array $_post_format_chat_ids An array of IDs for the chat rows based on the author.
		@param string $content The content of the post.
		@return string $chat_output The formatted content of the post.
	*/
	
	
	function pixelwars_theme_post_format_chat_content( $content )
	{
		global $_post_format_chat_ids;
		
		
		/* If this is not a 'chat' post, return the content. */
		if ( !has_post_format( 'chat' ) )
		{
			return $content;
		}
		
		
		/* Set the global variable of speaker IDs to a new, empty array for this chat. */
		$_post_format_chat_ids = array();
		
		/* Allow the separator (separator for speaker/text) to be filtered. */
		$separator = apply_filters( 'my_post_format_chat_separator', ':' );
		
		/* Open the chat transcript div and give it a unique ID based on the post ID. */
		$chat_output = "\n\t\t\t" . '<div id="chat-transcript-' . esc_attr( get_the_ID() ) . '" class="chat-transcript">';
		
		/* Split the content to get individual chat rows. */
		$chat_rows = preg_split( "/(\r?\n)+|(<br\s*\/?>\s*)+/", $content );
		
		
		/* Loop through each row and format the output. */
		foreach ( $chat_rows as $chat_row )
		{
			/* If a speaker is found, create a new chat row with speaker and text. */
			if ( strpos( $chat_row, $separator ) )
			{
				/* Split the chat row into author/text. */
				$chat_row_split = explode( $separator, trim( $chat_row ), 2 );
				
				
				/* Get the chat author and strip tags. */
				$chat_author = strip_tags( trim( $chat_row_split[0] ) );
				
				
				/* Get the chat text. */
				$chat_text = trim( $chat_row_split[1] );
				
				
				/* Get the chat row ID (based on chat author) to give a specific class to each row for styling. */
				$speaker_id = pixelwars_theme_post_format_chat_row_id( $chat_author );
				
				
				/* Open the chat row. */
				$chat_output .= "\n\t\t\t\t" . '<div class="chat-row ' . sanitize_html_class( "chat-speaker-{$speaker_id}" ) . '">';
				
				
				/* Add the chat row author. */
				$chat_output .= "\n\t\t\t\t\t" . '<div class="chat-author ' . sanitize_html_class( strtolower( "chat-author-{$chat_author}" ) ) . ' vcard"><cite class="fn">' . apply_filters( 'my_post_format_chat_author', $chat_author, $speaker_id ) . '</cite>' . $separator . '</div>';
				
				
				/* Add the chat row text. */
				$chat_output .= "\n\t\t\t\t\t" . '<div class="chat-text"><p>' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'my_post_format_chat_text', $chat_text, $chat_author, $speaker_id ) ) . '</p></div>';
				
				
				/* Close the chat row. */
				$chat_output .= "\n\t\t\t\t" . '</div><!-- .chat-row -->';
			}
			/*
				If no author is found, assume this is a separate paragraph of text that belongs to the
				previous speaker and label it as such, but let's still create a new row.
			*/
			else
			{
				/* Make sure we have text. */
				if ( !empty( $chat_row ) )
				{
					/* Open the chat row. */
					$chat_output .= "\n\t\t\t\t" . '<div class="chat-row ' . sanitize_html_class( "chat-speaker-{$speaker_id}" ) . '">';
					
					
					/* Don't add a chat row author.  The label for the previous row should suffice. */
					
					
					/* Add the chat row text. */
					$chat_output .= "\n\t\t\t\t\t" . '<div class="chat-text"><p>' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'my_post_format_chat_text', $chat_row, $chat_author, $speaker_id ) ) . '</p></div>';
					
					
					/* Close the chat row. */
					$chat_output .= "\n\t\t\t</div><!-- .chat-row -->";
				}
			}
		}
		
		
		/* Close the chat transcript div. */
		$chat_output .= "\n\t\t\t</div><!-- .chat-transcript -->\n";
		
		
		/* Return the chat content and apply filters for developers. */
		return apply_filters( 'my_post_format_chat_content', $chat_output );
	}
	
	
	/*
		This function returns an ID based on the provided chat author name. It keeps these IDs in a global 
		array and makes sure we have a unique set of IDs.  The purpose of this function is to provide an "ID"
		that will be used in an HTML class for individual chat rows so they can be styled. So, speaker "John" 
		will always have the same class each time he speaks. And, speaker "Mary" will have a different class 
		from "John" but will have the same class each time she speaks.
		
		@author David Chandra
		@link http://www.turtlepod.org
		@author Justin Tadlock
		@link http://justintadlock.com
		@copyright Copyright (c) 2012
		@license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
		@link http://justintadlock.com/archives/2012/08/21/post-formats-chat
		
		@global array $_post_format_chat_ids An array of IDs for the chat rows based on the author.
		@param string $chat_author Author of the current chat row.
		@return int The ID for the chat row based on the author.
	*/
	
	
	function pixelwars_theme_post_format_chat_row_id( $chat_author )
	{
		global $_post_format_chat_ids;
		
		
		/* Let's sanitize the chat author to avoid craziness and differences like "John" and "john". */
		$chat_author = strtolower( strip_tags( $chat_author ) );
		
		
		/* Add the chat author to the array. */
		$_post_format_chat_ids[] = $chat_author;
		
		
		/* Make sure the array only holds unique values. */
		$_post_format_chat_ids = array_unique( $_post_format_chat_ids );
		
		
		/* Return the array key for the chat author and add "1" to avoid an ID of "0". */
		return absint( array_search( $chat_author, $_post_format_chat_ids ) ) + 1;
	}
	
	
	/* Filter the content of chat posts. */
	add_filter( 'the_content', 'pixelwars_theme_post_format_chat_content' );


/* ============================================================================================================================================= */


	remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5);
	
	
	function photographer_remove_wc_breadcrumbs()
	{
		remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
	}
	
	add_action('init', 'photographer_remove_wc_breadcrumbs');
	
	
	function photographer_header_add_to_cart_fragment($fragments)
	{
		ob_start();
		$count = WC()->cart->cart_contents_count;
		
		?>
			<a class="shopping-cart" href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>" title="<?php esc_html_e('View your shopping cart', 'read'); ?>">
				<?php
					if ($count > 0)
					{
						?>
							<span>
								<?php
									echo esc_html($count);
								?>
							</span>
						<?php            
					}
				?>
			</a> <!-- .shopping-cart -->
		<?php
		
		$fragments['a.shopping-cart'] = ob_get_clean();
		
		return $fragments;
	}
	
	add_filter('woocommerce_add_to_cart_fragments', 'photographer_header_add_to_cart_fragment');
	
	
	function photographer_wc_cart_count()
	{
		if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))))
		{
			$count = WC()->cart->cart_contents_count;
			
			?>
				<a class="shopping-cart" href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>" title="<?php esc_html_e('View your shopping cart', 'read'); ?>">
					<?php
						if ($count > 0)
						{
							?>
								<span>
									<?php
										echo esc_html($count);
									?>
								</span>
							<?php
						}
					?>
				</a> <!-- .shopping-cart -->
			<?php
		}
	}
	
	add_action('photographer_header_cart_icon', 'photographer_wc_cart_count');


/* ============================================================================================================================================= */


	function pixelwars_options_wp_head()
	{
		?>

<!--[if lt IE 9]>
	<script src="<?php echo get_template_directory_uri(); ?>/js/ie.js"></script>
<![endif]-->
		<?php
		
		$image_logo_height = get_option('image_logo_height', '100');
		
		if ($image_logo_height != '100')
		{
			?>

<style type="text/css">.site-title img { max-height: <?php echo $image_logo_height; ?>px; }</style>
			<?php
		}
		
		$custom_css = stripcslashes( get_option( 'custom_css', "" ) );
	
		if ($custom_css != "")
		{
			echo '<style type="text/css">' . "\n";
			
				echo $custom_css;
			
			echo "\n" . '</style>' . "\n";
		}
		
		$external_css = stripcslashes( get_option( 'external_css', "" ) );
		echo $external_css;
		
		$tracking_code_head = stripcslashes( get_option( 'tracking_code_head', "" ) );
		echo $tracking_code_head;
	}
	
	add_action( 'wp_head', 'pixelwars_options_wp_head' );


/* ============================================================================================================================================= */


	function pixelwars_options_wp_footer()
	{
		$external_js = stripcslashes( get_option( 'external_js', "" ) );
		echo $external_js;
		
		$tracking_code_body = stripcslashes( get_option( 'tracking_code_body', "" ) );
		echo $tracking_code_body;
	}
	
	add_action( 'wp_footer', 'pixelwars_options_wp_footer' );


/* ============================================================================================================================================= */


	if (is_admin())
	{
		include_once(get_template_directory() . '/admin/theme-options.php');
	}
	
	include_once(get_template_directory() . '/admin/post-type-portfolio.php');
	include_once(get_template_directory() . '/admin/meta-box-portfolio-details.php');
	include_once(get_template_directory() . '/admin/meta-box-sidebar.php');
	include_once(get_template_directory() . '/admin/meta-box-title-visibility.php');
	include_once(get_template_directory() . '/admin/widget-social-feed.php');
	include_once(get_template_directory() . '/admin/widget-flickr.php');
	include_once(get_template_directory() . '/admin/post-gallery.php');
	include_once(get_template_directory() . '/admin/navigation-archive.php');
	include_once(get_template_directory() . '/admin/shortcodes.php');
	include_once(get_template_directory() . '/admin/shortcode-generator.php');
	include_once(get_template_directory() . '/admin/customizer.php');
	include_once(get_template_directory() . '/admin/install-plugins.php');
	include_once(get_template_directory() . '/admin/demo-import.php');

?>