AlkantarClanX12
| Current Path : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-careers/app/ |
| Current File : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-careers/app/Plugin.php |
<?php
namespace Leadbox\Careers;
class Plugin {
/** @var string The plugin version number. */
public $version = '0.2.14';
/** @var array The plugin settings array. */
public $settings = array();
/** @var array Available languages for the plugin. */
public $languages = array();
/** @var string The post type name. */
public $post_type = 'careers_member';
/** @var string The plugin slug. */
public $slug = 'leadbox-careers';
/** @var bool The plugin is active or not. */
public $enabled;
/**
* Construct the Plugin Class.
*/
function __construct()
{
$this->path = dirname(__DIR__);
// Only in the constructor to
// preserve the gettext functions.
$this->languages = [
'en' => __('English', 'leadbox_careers'),
'fr' => __('French', 'leadbox_careers'),
// 'es' => __('Spanish', 'leadbox_careers'),
];
}
/**
* Handle plugin initialization
*/
public function initialize(): void
{
$this->enabled = $this->isEnabled();
// $this->enabled
// ? $this->loadEnabledHooks()
// : $this->loadDisabledHooks();
$this->loadEnabledHooks();
}
/**
* Handles loading hooks used when plugin is enabled.
*/
protected function loadEnabledHooks(): void
{
add_actions(['init', 'rest_api_init'], new PostTypes\Careers);
add_actions(['init', 'rest_api_init'], new Taxonomies\Departments);
add_action( 'init', new Hooks\RegisterBlock );
add_action( 'leadbox_careers_block_renderer', function () {
return new Hooks\RenderCareersBlock;
});
add_action('do_meta_boxes', function() {
remove_meta_box( 'postimagediv','careers_member','side' );
});
add_action( 'acf/init', new Hooks\RegisterACFFields );
add_action( 'the_post', new Hooks\AppendCareersParameters, 10, 2);
add_action( 'admin_head', new Admin\LoadScripts );
add_action( 'admin_head', new Admin\AdminOrderTerms);
add_action( 'wp_ajax_leadbox_careers_ordering', new Admin\PluginPostOrdering);
add_action('restrict_manage_posts', new Admin\TaxonomyFiltering);
add_action( 'wp_ajax_leadbox_careers_term_ordering', new Admin\PluginTermOrdering);
add_filter( "views_edit-{$this->post_type}", new Admin\UpdateCareersViews );
add_filter( 'edit_posts_per_page', new Admin\CareersPerPage, 10, 2);
add_shortcode( 'careers', new Shortcodes\Careers );
add_filter('pre_set_site_transient_update_plugins', new Admin\Updates\OverrideCorePluginUpdates);
add_filter('plugins_api', new Admin\Updates\OverridePluginsApi, 10, 3);
}
/**
* Handles loading hooks used when plugin is disabled.
*/
protected function loadDisabledHooks(): void
{
add_action('admin_notices', new Admin\MissingLeadboxPlugin);
}
/**
* Checks if the plugin should be enabled or disabled.
*/
protected function isEnabled(): bool
{
if (! $this->isLeadboxPluginActive()) {
return false;
}
return true;
}
/**
* Mirror is_plugin_active functionality outside of admin_init.
*/
protected function isLeadboxPluginActive(): bool
{
return false !== collect(get_option('active_plugins', array()))
->search(function ($plugin) {
return preg_match('/^leadbox[A-Za-z\-]*\/Leadbox.php$/', $plugin);
});
}
}