theme-settings.php ➔ pagination()   F
last analyzed

Complexity

Conditions 21
Paths 294

Size

Total Lines 36

Duplication

Lines 2
Ratio 5.56 %

Importance

Changes 0
Metric Value
cc 21
nc 294
nop 2
dl 2
loc 36
rs 2.1583
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php 
2
3
/**
4
 * Read More button in excerpt
5
 */
6
function new_excerpt_more( $more ) {
0 ignored issues
show
Unused Code introduced by
The parameter $more is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
7
	return '... <a class="readmore" href="' . get_permalink() . ' ">Read more <i class="fa fa-external-link"></i></a>';
8
}
9
10
add_filter( 'excerpt_more', 'new_excerpt_more' );
11
12
/**
13
 * Custome Lenght of excerpt
14
 */
15
// function custom_excerpt_length( $length ) {
16
//     return 50;
17
// }
18
// add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
19
20
21
/**
22
 * Numbered Pagination
23
 */
24
function pagination($pages = '', $range = 4)
25
{  
26
	$showitems = ($range * 2)+1;  
27
28
	global $paged;
29
	if(empty($paged)) $paged = 1;
30
31
	if($pages == '')
32
	{
33
		global $wp_query;
34
		$pages = $wp_query->max_num_pages;
35
		if(!$pages)
36
		{
37
			$pages = 1;
38
		}
39
	}   
40
41
	if(1 != $pages)
42
	{
43
		echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
44
		if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";
45 View Code Duplication
		if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a>";
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
47
		for ($i=1; $i <= $pages; $i++)
48
		{
49
			if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
50
			{
51
				echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
52
			}
53
		}
54
55 View Code Duplication
		if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next &rsaquo;</a>";  
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
		if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last &raquo;</a>";
57
		echo "</div>\n";
58
	}
59
}
60
61
62
/**
63
 * stop wp removing div tags
64
 */
65
function tinymce_settings( $settings ) {
66
67
    // html elements being stripped
68
	$settings['extended_valid_elements'] = 'div[*],article[*]';
69
70
    // only html elements to keep
71
    //$settings['valid_elements'] = 'a,strong/b,div,h1,h2,h3,section';
72
73
	// paste elements to keep
74
	//$opts = '*[*]';
75
	//$settings['paste_word_valid_elements'] = $opts;
76
77
    // don't remove line breaks
78
	//$settings['remove_linebreaks'] = false;
79
80
	$settings['allow_html_in_named_anchor'] = true;
81
82
    // convert newline characters to BR
83
	//$settings['convert_newlines_to_brs'] = true;
84
85
    // don't remove redundant BR
86
	//$settings['remove_redundant_brs'] = false;
87
88
	// only html elements to keep
89
	//$settings['wpautop'] = false;
90
91
    // pass back to wordpress
92
93
	return $settings;
94
}
95
96
add_filter( 'tiny_mce_before_init', 'tinymce_settings' );