• Hello.
    I am not an expert and after been reading dozens of post about hooks, i cannot understand how to use them to customize very complex functions.
    About the plugin above, I would like to modify the output layout of the counter, which has classes I don’t want, because I want my own.
    I have analyzed the functions.php file of the plugin and targeted the code snippet used by the short code.
    Now I would like to edit it, but i don’t know how to do. I want to exclude all kind of div and classes used by the plugin.
    I ask here because in the support plugin area I didn’t get sufficient support and help. They probably think any user is very sophisticated and skilled…
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter r99photography

    (@r99photography)

    The function I wanna edit is the following. In particular, the $html variable, where are some CSS classes, divs and spans:

    if ( ! function_exists( 'pvc_post_views' ) ) {
    
    	function pvc_post_views( $post_id = 0, $echo = true ) {
    
    		// get all data
    		$post_id = (int) ( empty( $post_id ) ? get_the_ID() : $post_id );
    		$options = Post_Views_Counter()->options['display'];
    		$views = pvc_get_post_views( $post_id );
    
    		// prepares display
    		$label = apply_filters( 'pvc_post_views_label', (function_exists( 'icl_t' ) ? icl_t( 'Post Views Counter', 'Post Views Label', $options['label'] ) : $options['label'] ), $post_id );
    		$icon_class = ($options['icon_class'] !== '' ? ' ' . esc_attr( $options['icon_class'] ) : '');
    		$icon = apply_filters( 'pvc_post_views_icon', '<span class="post-views-icon dashicons ' . $icon_class . '"></span>', $post_id );
    
    		$html = apply_filters(
    		'pvc_post_views_html', '<div class="post-views post-' . $post_id . ' entry-meta">
    		' . ($options['display_style']['icon'] && $icon_class !== '' ? $icon : '') . '
    		' . ($options['display_style']['text'] ? '<span class="post-views-label">' . $label . ' </span>' : '') . '
    		<span class="post-views-count">' . number_format_i18n( $views ) . '</span>
    		</div>', $post_id, $views, $label, $icon
    		);
    
    		if ( $echo )
    			echo $html;
    		else
    			return $html;
    	}
    
    }

    In this function, as far I understand, the hook to be called by the add_filter() function is “pvc_post_views_html”, do you confirm?
    Unfortunately, I don’t know how to proceed.
    Thanks to whom will help me.

    Bye.
    Riccardo

    Thread Starter r99photography

    (@r99photography)

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘edit functions of Post Views Counter’ is closed to new replies.