View Single Post
Staro 17.02.2022., 14:41   #2
Libertus
Premium
Moj komp
 
Libertus's Avatar
 
Datum registracije: Jul 2017
Lokacija: Ramura
Postovi: 2,738
Riješio, pa evo rješenje ako nekome može pomoći u budućnosti.

Original funkcija za Hiero temu u /inc/template-tags.php
Code:
function athemes_posted_on() {
	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
	$time_string = sprintf( $time_string,
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() ),
		esc_attr( get_the_modified_date( 'c' ) ),
		esc_html( get_the_modified_date() )
	);

	printf( __( '<span class="posted-on">Posted on %1$s</span><span class="byline"> by %2$s</span>', 'hiero' ),
		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
			esc_url( get_permalink() ),
			esc_attr( get_the_time() ),
			$time_string
		),
		sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
			esc_attr( sprintf( __( 'View all posts by %s', 'hiero' ), get_the_author() ) ),
			esc_html( get_the_author() )
		)
	);
}
Izmijenjeni kod funkcije:
Code:
function athemes_posted_on() {
	$date = get_the_date( 'U' );
	$updated = get_the_modified_date( 'U' );

	if( $updated > ( $date + 86400 ) )
		$time_string = '<time class="entry-date published updated" datetime="%3$s">%4$s</time>';
	else {
		$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
	}
	
	$time_string = sprintf( $time_string,
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() ),
		esc_attr( get_the_modified_date( 'c' ) ),
		esc_html( get_the_modified_date() )
	);

	if( $updated > ( $date + 86400 ) )
		printf( __( '<span class="posted-on">Last updated on %1$s</span><span class="byline"> by %2$s</span>', 'hiero' ),
			sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
				esc_url( get_permalink() ),
				esc_attr( get_the_time() ),
				$time_string
			),
			sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
				esc_attr( sprintf( __( 'View all posts by %s', 'hiero' ), get_the_author() ) ),
				esc_html( get_the_author() )
			)
		);
	else {
		printf( __( '<span class="posted-on">Posted on %1$s</span><span class="byline"> by %2$s</span>', 'hiero' ),
			sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
				esc_url( get_permalink() ),
				esc_attr( get_the_time() ),
				$time_string
			),
			sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
				esc_attr( sprintf( __( 'View all posts by %s', 'hiero' ), get_the_author() ) ),
				esc_html( get_the_author() )
			)
		);
	}
}
Za ovo se mora izmijeniti /inc/template-tags.php u direktoriju teme.
Možda je moglo i kraće / elegantnije, ali ne znam PHP i ovo mi je bilo najlakše sklepati.

Za li netko kako "disable" funkciju teme i "enable" moju funkciju preko plug-ina bez da mijenjam datoteke teme?
Ako se bude nadograđivala tema da ne moram ponovno mijenjati ručno.
Libertus je offline   Reply With Quote