bricks all the bricks

This commit is contained in:
2023-02-16 21:22:46 -05:00
commit bbb70ea329
129 changed files with 13476 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace cooini\Inirepo\POPO;
/**
* @ref https://developer.wordpress.org/reference/functions/get_plugin_data/
*/
class pluginInfo
{
/** @var string Plugin Name */
public string $Name;
/** @var string Plugin URI */
public string $PluginURI;
/** @var string Version */
public string $Version;
/** @var string Description */
public string $Description;
/** @var string Author */
public string $Author;
/** @var string Author URI */
public string $AuthorURI;
/** @var string Text Domain */
public string $TextDomain;
/** @var string Domain Path */
public string $DomainPath;
/** @var string Network */
public string $Network;
/** @var string Requires at least */
public string $RequiresWP;
/** @var string Requires PHP */
public string $RequiresPHP;
/** @var string Update URI */
public string $UpdateURI;
}

View File

@@ -0,0 +1,8 @@
<?php
namespace cooini\Inirepo\POPO;
class repository
{
private string $url;
private string $key;
}

View File

@@ -0,0 +1,38 @@
<?php
namespace cooini\iniRepo;
/**
* Fired during plugin activation
*
* @link http://example.com
* @since 1.0.0
*
* @package Inirepo
* @subpackage Inirepo/includes
*/
/**
* Fired during plugin activation.
*
* This class defines all code necessary to run during the plugin's activation.
*
* @since 1.0.0
* @package Inirepo
* @subpackage Inirepo/includes
* @author php.dev@cooini.com
*/
class Inirepo_Activator {
/**
* Short Description. (use period)
*
* Long Description.
*
* @since 1.0.0
*/
public static function activate() {
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace cooini\iniRepo;
/**
* Fired during plugin deactivation
*
* @link http://example.com
* @since 1.0.0
*
* @package Inirepo
* @subpackage Inirepo/includes
*/
/**
* Fired during plugin deactivation.
*
* This class defines all code necessary to run during the plugin's deactivation.
*
* @since 1.0.0
* @package Inirepo
* @subpackage Inirepo/includes
* @author php.dev@cooini.com
*/
class Inirepo_Deactivator {
/**
* Short Description. (use period)
*
* Long Description.
*
* @since 1.0.0
*/
public static function deactivate() {
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace cooini\iniRepo;
/**
* Define the internationalization functionality
*
* Loads and defines the internationalization files for this plugin
* so that it is ready for translation.
*
* @link http://example.com
* @since 1.0.0
*
* @package
* @subpackage Inirepo/includes
*/
/**
* Define the internationalization functionality.
*
* Loads and defines the internationalization files for this plugin
* so that it is ready for translation.
*
* @since 1.0.0
* @package Inirepo
* @subpackage Inirepo/includes
* @author php.dev@cooini.com
*/
class Inirepo_i18n {
/**
* Load the plugin text domain for translation.
*
* @since 1.0.0
*/
public function load_plugin_textdomain() {
load_plugin_textdomain(
'inirepo',
false,
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
);
}
}

View File

@@ -0,0 +1,130 @@
<?php
namespace cooini\iniRepo;
/**
* Register all actions and filters for the plugin
*
* @link http://example.com
* @since 1.0.0
*
* @package Inirepo
* @subpackage Inirepo/includes
*/
/**
* Register all actions and filters for the plugin.
*
* Maintain a list of all hooks that are registered throughout
* the plugin, and register them with the WordPress API. Call the
* run function to execute the list of actions and filters.
*
* @package Inirepo
* @subpackage Inirepo/includes
* @author php.dev@cooini.com
*/
class Inirepo_Loader {
/**
* The array of actions registered with WordPress.
*
* @since 1.0.0
* @access protected
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
*/
protected $actions;
/**
* The array of filters registered with WordPress.
*
* @since 1.0.0
* @access protected
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
*/
protected $filters;
/**
* Initialize the collections used to maintain the actions and filters.
*
* @since 1.0.0
*/
public function __construct() {
$this->actions = array();
$this->filters = array();
}
/**
* Add a new action to the collection to be registered with WordPress.
*
* @since 1.0.0
* @param string $hook The name of the WordPress action that is being registered.
* @param object $component A reference to the instance of the object on which the action is defined.
* @param string $callback The name of the function definition on the $component.
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
*/
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
}
/**
* Add a new filter to the collection to be registered with WordPress.
*
* @since 1.0.0
* @param string $hook The name of the WordPress filter that is being registered.
* @param object $component A reference to the instance of the object on which the filter is defined.
* @param string $callback The name of the function definition on the $component.
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
*/
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
}
/**
* A utility function that is used to register the actions and hooks into a single
* collection.
*
* @since 1.0.0
* @access private
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
* @param string $hook The name of the WordPress filter that is being registered.
* @param object $component A reference to the instance of the object on which the filter is defined.
* @param string $callback The name of the function definition on the $component.
* @param int $priority The priority at which the function should be fired.
* @param int $accepted_args The number of arguments that should be passed to the $callback.
* @return array The collection of actions and filters registered with WordPress.
*/
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
$hooks[] = array(
'hook' => $hook,
'component' => $component,
'callback' => $callback,
'priority' => $priority,
'accepted_args' => $accepted_args
);
return $hooks;
}
/**
* Register the filters and actions with WordPress.
*
* @since 1.0.0
*/
public function run() {
foreach ( $this->filters as $hook ) {
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
foreach ( $this->actions as $hook ) {
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
}
}

224
includes/class-inirepo.php Normal file
View File

@@ -0,0 +1,224 @@
<?php
namespace cooini\iniRepo;
use cooini\iniRepo\admin\admin;
/**
* The file that defines the core plugin class
*
* A class definition that includes attributes and functions used across both the
* public-facing side of the site and the admin area.
*
* @link http://example.com
* @since 1.0.0
*
* @package Inirepo
* @subpackage Inirepo/includes
*/
/**
* The core plugin class.
*
* This is used to define internationalization, admin-specific hooks, and
* public-facing site hooks.
*
* Also maintains the unique identifier of this plugin as well as the current
* version of the plugin.
*
* @since 1.0.0
* @package Inirepo
* @subpackage Inirepo/includes
* @author sbyrd <php.dev@cooini.com>
*/
class Inirepo {
/**
* The loader that's responsible for maintaining and registering all hooks that power
* the plugin.
*
* @since 1.0.0
* @access protected
* @var Inirepo_Loader $loader Maintains and registers all hooks for the plugin.
*/
protected $loader;
/**
* The unique identifier of this plugin.
*
* @since 1.0.0
* @access protected
* @var string $plugin_name The string used to uniquely identify this plugin.
*/
protected $plugin_name;
/**
* The current version of the plugin.
*
* @since 1.0.0
* @access protected
* @var string $version The current version of the plugin.
*/
protected $version;
/**
* Define the core functionality of the plugin.
*
* Set the plugin name and the plugin version that can be used throughout the plugin.
* Load the dependencies, define the locale, and set the hooks for the admin area and
* the public-facing side of the site.
*
* @since 1.0.0
*/
public function __construct() {
if ( defined( 'INIREPO_VERSION' ) ) {
$this->version = INIREPO_VERSION;
} else {
$this->version = '1.0.0';
}
$this->plugin_name = 'inirepo';
$this->load_dependencies();
$this->set_locale();
$this->define_admin_hooks();
$this->define_public_hooks();
}
/**
* Load the required dependencies for this plugin.
*
* Include the following files that make up the plugin:
*
* - Inirepo_Loader. Orchestrates the hooks of the plugin.
* - Inirepo_i18n. Defines internationalization functionality.
* - Inirepo_Admin. Defines all hooks for the admin area.
* - Inirepo_Public. Defines all hooks for the public side of the site.
*
* Create an instance of the loader which will be used to register the hooks
* with WordPress.
*
* @since 1.0.0
* @access private
*/
private function load_dependencies() {
/**
* The class responsible for orchestrating the actions and filters of the
* core plugin.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-inirepo-loader.php';
/**
* The class responsible for defining internationalization functionality
* of the plugin.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-inirepo-i18n.php';
/**
* The class responsible for defining all actions that occur in the admin area.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/admin.php';
/**
* The class responsible for defining all actions that occur in the public-facing
* side of the site.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-inirepo-public.php';
$this->loader = new Inirepo_Loader();
}
/**
* Define the locale for this plugin for internationalization.
*
* Uses the Inirepo_i18n class in order to set the domain and to register the hook
* with WordPress.
*
* @since 1.0.0
* @access private
*/
private function set_locale() {
$plugin_i18n = new Inirepo_i18n();
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
}
/**
* Register all of the hooks related to the admin area functionality
* of the plugin.
*
* @since 1.0.0
* @access private
*/
private function define_admin_hooks() {
$plugin_admin = new admin( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
$this->loader->add_action("admin_menu", $plugin_admin, 'display_menu');
}
/**
* Register all of the hooks related to the public-facing functionality
* of the plugin.
*
* @since 1.0.0
* @access private
*/
private function define_public_hooks() {
$plugin_public = new Inirepo_Public( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
}
/**
* Run the loader to execute all of the hooks with WordPress.
*
* @since 1.0.0
*/
public function run() {
$this->loader->run();
}
/**
* The name of the plugin used to uniquely identify it within the context of
* WordPress and to define internationalization functionality.
*
* @since 1.0.0
* @return string The name of the plugin.
*/
public function get_plugin_name() {
return $this->plugin_name;
}
/**
* The reference to the class that orchestrates the hooks with the plugin.
*
* @since 1.0.0
* @return Inirepo_Loader Orchestrates the hooks of the plugin.
*/
public function get_loader() {
return $this->loader;
}
/**
* Retrieve the version number of the plugin.
*
* @since 1.0.0
* @return string The version number of the plugin.
*/
public function get_version() {
return $this->version;
}
}

1
includes/index.php Normal file
View File

@@ -0,0 +1 @@
<?php // Silence is golden

61
includes/inirepo_old.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
namespace cooini\Inirepo;
class inirepoOld implements pluginInterface
{
protected string $plugin_name = "inirepo";
protected string $plugin_friendly_name = "WP iniRepo";
protected string $version = "1.0.0";
protected array $repos;
public function __construct()
{
if (!$this->load_dependencies())
throw new \Exception("Failed to load plugin dependencies");
if (! $this->hasRequirements())
throw new \Exception();
}
public function activate() : bool
{
if (! $this->hasRequirements())
throw new \Exception("Plugin requirements not met");
if (! $this->isLicensed())
{
throw new \Exception("Plugin is not licensed for this site");
}
}
public function load_dependencies(): bool
{
// TODO: Implement load_dependencies() method.
}
public function hasRequirements(): bool
{
return true;
}
public function isLicensed() : bool
{
return true;
}
public function getVersion(): string
{
return $this->version;
}
public function getPluginName(): string
{
return $this->plugin_name;
}
public function getFriendlyPluginName(): string
{
return $this->plugin_friendly_name;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace cooini\Inirepo\pluginManager;
interface installerInterface
{
}

View File

@@ -0,0 +1,12 @@
<?php
namespace cooini\Inirepo\pluginManager;
class pluginInstaller
{
public ManagerInterface $manager;
public function __construct(ManagerInterface $manager)
{
$this->manager = $manager;
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace cooini\Inirepo\pluginManager;
interface pluginInterface
{
public function hasRequirements() : bool;
public function load_dependencies() : bool;
public function getVersion() : string;
public function getPluginName() : string;
public function getFriendlyPluginName() : string;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace cooini\Inirepo\pluginManager;
use cooini\Inirepo\POPO\repository;
interface ManagerInterface
{
public function getPluginInstaller() ;
public function getRequiredPlugins() : array;
public function getLicensedPlugins() : array;
public function getRepository() : repository;
}