Passed
Push — master ( 49d43e...8102b2 )
by Amit
03:03
created

extras.php ➔ post_end_class()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 16 and the first side effect is on line 29.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Custom functions that act independently of the theme templates
4
 *
5
 * Eventually, some of the functionality here could be replaced by core features
6
 *
7
 * @package podium
8
 */
9
10
/**
11
 * Adds custom classes to the array of body classes.
12
 *
13
 * @param  array   $classes Classes for the body element.
14
 * @return array
15
 */
16
function podium_body_classes($classes)
17
{
18
19
// Adds a class of group-blog to blogs with more than 1 published author.
20
    if (is_multi_author()) {
21
22
        $classes[] = 'group-blog';
23
24
    }
25
26
    return $classes;
27
}
28
29
add_filter('body_class', 'podium_body_classes');
30
31
// Get post Thumb URL
32
/**
33
 * @param  $post
34
 * @param  $size
35
 * @return mixed
36
 */
37
function get_thumb_url($post, $size = 'full')
38
{
39
40
    if (has_post_thumbnail($post->ID)) {
41
42
        $attachment_id = get_post_thumbnail_id($post->ID);
43
44
        // thumbnail, medium, large, or full
45
        $src = wp_get_attachment_image_src($attachment_id, $size);
46
        return $src[0];
47
48
    }
49
50
    return false;
51
}
52
53
/**
54
 * @param  $limit
55
 * @return string
56
 */
57
function excerpt($limit)
58
{
59
    $excerpt = explode(' ', get_the_excerpt(), $limit);
60
61
    if (count($excerpt) >= $limit) {
62
63
        array_pop($excerpt);
64
        $excerpt = implode(' ', $excerpt);
65
66
    } else {
67
68
        $excerpt = implode(' ', $excerpt);
69
70
    }
71
72
    $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt);
73
    return $excerpt;
74
}
75
76
if (!function_exists('floating_direction')) {
77
    /**
78
     * @param $reverse
79
     */
80
    function floating_direction($reverse = false)
81
    {
82
83
        if ((is_rtl() && !$reverse) || (!is_rtl() && $reverse)) {
84
            return 'right';
85
        } else {
86
            return 'left';
87
        }
88
89
    }
90
91
}
92