| 1 |
<?php |
| 2 |
namespace NestedPages; |
| 3 |
|
| 4 |
/** |
| 5 |
* Primary Plugin Bootstrap |
| 6 |
*/ |
| 7 |
class Bootstrap |
| 8 |
{ |
| 9 |
public function __construct() |
| 10 |
{ |
| 11 |
$this->initializePlugin(); |
| 12 |
add_action( 'wp_loaded', [$this, 'wpLoaded']); |
| 13 |
add_action( 'init', [$this, 'initializeWordPress']); |
| 14 |
add_filter( 'plugin_action_links_' . 'wp-nested-pages/nestedpages.php', [$this, 'settingsLink']); |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* WP Loaded |
| 19 |
*/ |
| 20 |
public function wpLoaded() |
| 21 |
{ |
| 22 |
new Activation\Activate; |
| 23 |
new Redirects; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Initialize Plugin |
| 28 |
*/ |
| 29 |
private function initializePlugin() |
| 30 |
{ |
| 31 |
new Entities\PostType\RegisterPostTypes; |
| 32 |
new Entities\Post\PostTrashActions; |
| 33 |
new Entities\Post\PrivatePostParent; |
| 34 |
new Entities\Listing\ListingActions; |
| 35 |
new Entities\NavMenu\NavMenuActions; |
| 36 |
new Entities\NavMenu\NavMenuTrashActions; |
| 37 |
new Form\Events; |
| 38 |
new Config\Settings; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Wordpress Initialization Actions |
| 43 |
*/ |
| 44 |
public function initializeWordPress() |
| 45 |
{ |
| 46 |
new Entities\AdminMenu\AdminMenu; |
| 47 |
new Entities\DefaultList\DefaultListFactory; |
| 48 |
$this->addLocalization(); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Localization Domain |
| 53 |
*/ |
| 54 |
public function addLocalization() |
| 55 |
{ |
| 56 |
load_plugin_textdomain( |
| 57 |
'wp-nested-pages', |
| 58 |
false, |
| 59 |
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages' ); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Add a link to the settings on the plugin page |
| 64 |
*/ |
| 65 |
public function settingsLink($links) |
| 66 |
{ |
| 67 |
$settings_link = '<a href="options-general.php?page=nested-pages-settings">' . __('Settings', 'wp-nested-pages') . '</a>'; |
| 68 |
array_unshift($links, $settings_link); |
| 69 |
return $links; |
| 70 |
} |
| 71 |
} |