AlkantarClanX12
| Current Path : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-feature-content/app/ |
| Current File : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-feature-content/app/Plugin.php |
<?php
namespace Leadbox\FeatureContent;
class Plugin {
/** @var string The plugin version number. */
public $version = '0.0.22';
/** @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 = 'feature_content';
/** @var string The plugin slug. */
public $slug = 'leadbox-feature-content';
/** @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_feature_content'),
'fr' => __('French', 'leadbox_feature_content'),
// 'es' => __('Spanish', 'leadbox_feature_content'),
];
}
/**
* 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\FeatureContent);
add_actions(['init', 'rest_api_init'], new Taxonomies\Groups);
add_action( 'init', new Hooks\RegisterBlock );
add_action( 'leadbox_feature_content_block_renderer', function () {
return new Hooks\RenderFeatureContentBlock;
});
add_action( 'do_meta_boxes', new Hooks\RelocateFeaturedImage );
add_action( 'acf/init', new Hooks\RegisterACFFields );
add_action( 'the_post', new Hooks\AppendFeatureContentParameters, 10, 2);
add_action( 'admin_head', new Admin\LoadScripts );
add_action( 'admin_head', new Admin\AdminOrderTerms);
add_action( 'wp_ajax_leadbox_feature_content_ordering', new Admin\PluginPostOrdering);
add_action('restrict_manage_posts', new Admin\TaxonomyFiltering);
add_action( 'wp_ajax_leadbox_feature_content_term_ordering', new Admin\PluginTermOrdering);
add_filter( "views_edit-{$this->post_type}", new Admin\UpdateFeatureContentViews );
add_filter( 'edit_posts_per_page', new Admin\FeatureContentPerPage, 10, 2);
add_shortcode( 'featurecontent', new Shortcodes\FeatureContent );
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);
});
}
}