Conditions | 7 |
Paths | 16 |
Total Lines | 34 |
Code Lines | 21 |
Lines | 12 |
Ratio | 35.29 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
22 | public static function checkPlugin() |
||
23 | { |
||
24 | $flyntCoreActive = class_exists('\\Flynt\\Render'); |
||
25 | $acfActive = class_exists('acf'); |
||
26 | |||
27 | View Code Duplication | if (!$flyntCoreActive) { |
|
|
|||
28 | add_action('admin_notices', function () { |
||
29 | echo '<div class="error"><p>Flynt Core Plugin not activated. Make sure you activate the plugin on the <a href="' |
||
30 | . esc_url(admin_url('plugins.php')) . '">plugin page</a>.</p></div>'; |
||
31 | }); |
||
32 | } |
||
33 | |||
34 | View Code Duplication | if (!$acfActive) { |
|
35 | add_action('admin_notices', function () { |
||
36 | echo '<div class="error"><p>ACF Plugin not activated. Make sure you activate the plugin on the <a href="' |
||
37 | . esc_url(admin_url('plugins.php')) . '">plugin page</a>.</p></div>'; |
||
38 | }); |
||
39 | } |
||
40 | |||
41 | if (!$acfActive || !$flyntCoreActive) { |
||
42 | add_filter('template_include', function () { |
||
43 | $newTemplate = locate_template('plugin-inactive.php'); |
||
44 | if ('' != $newTemplate) { |
||
45 | return $newTemplate; |
||
46 | } else { |
||
47 | return 'One or more required Plugins are not active! Please <a href="' |
||
48 | . esc_url(admin_url('plugins.php')) |
||
49 | . '">activate all required plugins</a> and reload the page.'; |
||
50 | } |
||
51 | }); |
||
52 | } |
||
53 | |||
54 | return $acfActive && $flyntCoreActive; |
||
55 | } |
||
56 | } |
||
57 |
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.