KroneMultimedia /
plugin-timeshift
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Plugin Name: KMM Timeshift |
||
| 4 | * Description: This is a short description of what the plugin does. |
||
| 5 | * Plugin URI: http://github.com/KroneMultiMedia/plugin-timeshift |
||
| 6 | * Version: %TRAVIS_TAG% |
||
| 7 | * Author: Krone.at |
||
| 8 | * Author URI: http://www.krone.at |
||
| 9 | * Licence: MIT |
||
| 10 | * Text Domain: kmm-timeshift |
||
| 11 | * Domain Path: /languages |
||
| 12 | */ |
||
| 13 | |||
| 14 | namespace KMM\Timeshift; |
||
| 15 | |||
| 16 | use KMM\Timeshift\Core; |
||
| 17 | |||
| 18 | if (! function_exists('add_filter')) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * Ensure that autoload is already loaded or loads it if available. |
||
| 25 | * |
||
| 26 | * @param string $class_name |
||
| 27 | * |
||
| 28 | * @return bool |
||
| 29 | */ |
||
| 30 | function ensure_class_loaded($class_name) |
||
| 31 | { |
||
| 32 | |||
| 33 | $class_exists = class_exists($class_name); |
||
| 34 | $autoload_found = file_exists(__DIR__ . '/vendor/autoload.php'); |
||
| 35 | |||
| 36 | // If the class does not exist, and the vendor file is there |
||
| 37 | // maybe the plugin was installed separately via Composer, let's try to load autoload |
||
| 38 | if (! $class_exists && $autoload_found) { |
||
| 39 | @require_once __DIR__ . '/vendor/autoload.php'; |
||
|
0 ignored issues
–
show
|
|||
| 40 | } |
||
| 41 | |||
| 42 | return $class_exists || ( $autoload_found && class_exists($class_name) ); |
||
| 43 | } |
||
| 44 | |||
| 45 | // Exit if classes are not available |
||
| 46 | if (! ensure_class_loaded(__NAMESPACE__ . '\Core')) { |
||
| 47 | return; |
||
| 48 | } |
||
| 49 | |||
| 50 | add_action('plugins_loaded', __NAMESPACE__ . '\main'); |
||
| 51 | |||
| 52 | |||
| 53 | /** |
||
| 54 | * @wp-hook plugins_loaded |
||
| 55 | */ |
||
| 56 | function main() |
||
| 57 | { |
||
| 58 | $i18n = 'kmm-timeshift'; |
||
| 59 | load_plugin_textdomain( |
||
| 60 | $i18n, |
||
| 61 | false, |
||
| 62 | dirname(plugin_basename(__FILE__)) . '/languages' |
||
| 63 | ); |
||
| 64 | |||
| 65 | |||
| 66 | new Core($i18n); |
||
| 67 | |||
| 68 | if (is_admin()) { |
||
| 69 | // Backend |
||
| 70 | |||
| 71 | // TODO: register your backend-code here... |
||
| 72 | } else { |
||
| 73 | // Frontend |
||
| 74 | |||
| 75 | // TODO: register frontend-code here... |
||
| 76 | } |
||
| 77 | } |
||
| 78 |
If you suppress an error, we recommend checking for the error condition explicitly: