Completed
Push — master ( 74c2eb...05bb7a )
by Christian
01:23
created

helper.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace PodloveSubscribeButton;
4
5
function for_every_podcast_blog($callback) {
6
	global $wpdb;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
7
8
	$plugin  = basename(\PodloveSubscribeButton\PLUGIN_DIR) . '/' . \PodloveSubscribeButton\PLUGIN_FILE_NAME;
9
	$blogids = $wpdb->get_col("SELECT blog_id FROM " . $wpdb->blogs);
10
11
	if (!is_array($blogids))
12
		return;
13
14
	foreach ($blogids as $blog_id) {
15
		switch_to_blog($blog_id);
16
		if (is_plugin_active($plugin)) {
17
			$callback();
18
		}
19
		restore_current_blog();
20
	}
21
}