Skip to content

Commit

Permalink
Admin functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
joanrodas committed Jan 13, 2024
1 parent c05a24e commit 93575d3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 122 deletions.
Empty file added Functionality/Admin/.gitkeep
Empty file.
116 changes: 0 additions & 116 deletions Includes/AssetsLoader.php

This file was deleted.

23 changes: 17 additions & 6 deletions Includes/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,42 @@

class Loader
{
protected $plugin_name;
protected $plugin_version;

public function __construct()
{
$this->plugin_version = defined('PLUGIN_PLACEHOLDER_VERSION') ? PLUGIN_PLACEHOLDER_VERSION : '1.0.0';
$this->plugin_name = 'plugin-placeholder';
$this->loadDependencies();

add_action('plugins_loaded', [$this, 'loadPluginTextdomain']);
}

private function loadDependencies()
{
//FUNCTIONALITY CLASSES
foreach (glob(PLUGIN_PLACEHOLDER_PATH . 'Functionality/*.php') as $filename) {
$class_name = '\\PluginPlaceholder\Functionality\\' . basename($filename, '.php');
if (class_exists($class_name)) {
try {
new $class_name($this->plugin_name, $this->plugin_version);
new $class_name(PLUGIN_PLACEHOLDER_NAME, PLUGIN_PLACEHOLDER_VERSION);
} catch (\Throwable $e) {
pb_log($e);
continue;
}
}
}

//ADMIN FUNCTIONALITY
if( is_admin() ) {
foreach (glob(PLUGIN_PLACEHOLDER_PATH . 'Functionality/Admin/*.php') as $filename) {
$class_name = '\\PluginPlaceholder\Functionality\Admin\\' . basename($filename, '.php');
if (class_exists($class_name)) {
try {
new $class_name(PLUGIN_PLACEHOLDER_NAME, PLUGIN_PLACEHOLDER_VERSION);
} catch (\Throwable $e) {
pb_log($e);
continue;
}
}
}
}
}

public function loadPluginTextdomain()
Expand Down
1 change: 1 addition & 0 deletions plugin-placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}

// PLUGIN CONSTANTS
define('PLUGIN_PLACEHOLDER_NAME', 'plugin-placeholder');
define('PLUGIN_PLACEHOLDER_VERSION', '1.0.0');
define('PLUGIN_PLACEHOLDER_PATH', plugin_dir_path(__FILE__));
define('PLUGIN_PLACEHOLDER_BASENAME', plugin_basename(__FILE__));
Expand Down

0 comments on commit 93575d3

Please sign in to comment.