Passed
Push — master ( 1a67fb...1da117 )
by Amit
03:32
created

admin.php ➔ podium_custom_dashboard_widgets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 9
rs 9.6666
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 6 and the first side effect is on line 20.

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
// This file handles the admin area and functions - You can use this file to make changes to the dashboard.
3
4
/************* DASHBOARD WIDGETS *****************/
5
// Disable default dashboard widgets
6
function disable_default_dashboard_widgets()
7
{
8
9
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'core'); // Comments Widget
10
    remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');  // Incoming Links Widget
11
    remove_meta_box('dashboard_plugins', 'dashboard', 'core');         // Plugins Widget
12
    remove_meta_box('dashboard_quick_press', 'dashboard', 'core');     // Quick Press Widget
13
    remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');   // Recent Drafts Widget
14
    remove_meta_box('dashboard_primary', 'dashboard', 'core');
15
    remove_meta_box('dashboard_secondary', 'dashboard', 'core');
16
    remove_meta_box('yoast_db_widget', 'dashboard', 'normal'); // Yoast's SEO Plugin Widget
17
}
18
19
// removing the dashboard widgets
20
add_action('admin_menu', 'disable_default_dashboard_widgets');
21
22
/************* CUSTOMIZE ADMIN *******************/
23
24
// Custom Backend Footer
25
function podium_custom_admin_footer()
26
{
27
    $wp_v         = get_bloginfo('version');
28
    $w_copyrights = _x('<span id="footer-thankyou">Developed by <a href="http://amitt.co.il" target="_blank">Amit Tal</a></span>', 'podium');
29
    return '<p style="direction:lrt;">v' . $wp_v . ' | ' . $w_copyrights . '</p>';
30
}
31
32
// adding it to the admin area
33
add_filter('admin_footer_text', 'podium_custom_admin_footer');
34
35
//ADD featured image thumbnail to WordPress admin columns
36
37
add_filter('manage_posts_columns', 'tcb_add_post_thumbnail_column', 5);
38
add_filter('manage_pages_columns', 'tcb_add_post_thumbnail_column', 5);
39
40
/**
41
 * @param  $cols
42
 * @return mixed
43
 */
44
function tcb_add_post_thumbnail_column($cols)
45
{
46
    $cols['tcb_post_thumb'] = __('Main image');
47
    return $cols;
48
}
49
50
add_action('manage_posts_custom_column', 'tcb_display_post_thumbnail_column', 5, 2);
51
add_action('manage_pages_custom_column', 'tcb_display_post_thumbnail_column', 5, 2);
52
53
/**
54
 * @param $col
55
 * @param $id
56
 */
57
function tcb_display_post_thumbnail_column($col, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $id 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...
58
{
59
60
    switch ($col) {
61
        case 'tcb_post_thumb':
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
62
63
            if (function_exists('the_post_thumbnail')) {
64
                echo the_post_thumbnail('thumbnail');
65
            } else {
66
                echo 'Not supported in theme';
67
            }
68
69
            break;
70
    }
71
72
}
73
74
// Allow svg upload in media
75
/**
76
 * @param  $mimes
77
 * @return mixed
78
 */
79
function cc_mime_types($mimes)
80
{
81
    $mimes['svg']  = 'image/svg+xml';
82
    $mimes['svgz'] = 'image/svg+xml';
83
    return $mimes;
84
}
85
86
add_filter('upload_mimes', 'cc_mime_types');
87
88
89
// Set interval beween heartbewats
90
/**
91
 * @param  $settings
92
 * @return mixed
93
 */
94
function podium_heartbeat_settings($settings)
95
{
96
    $settings['interval'] = 60; //Anything between 15-60
97
    return $settings;
98
}
99
100
add_filter('heartbeat_settings', 'podium_heartbeat_settings');
101