installed plugin Protect Uploads version 0.3

This commit is contained in:
150954cc22a2
2026-07-21 04:21:01 +00:00
committed by Gitium
parent 76d5296d0b
commit 8668957e2a
23 changed files with 1925 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<?php
class Alti_ProtectUploads_Activator extends Alti_ProtectUploads
{
public function run()
{
}
}

View File

@ -0,0 +1,12 @@
<?php
class Alti_ProtectUploads_Deactivator extends Alti_ProtectUploads {
public function run() {
$plugin = new Alti_ProtectUploads_Admin($this->plugin_name, $this->version);
$plugin->remove_index();
$plugin->remove_htaccess();
delete_option( $this->get_plugin_name().'-protection' );
}
}

View File

@ -0,0 +1,31 @@
<?php
class Alti_ProtectUploads_i18n {
/**
* The domain specified for this plugin.
* @var string $domain The domain identifier for this plugin.
*/
private $domain;
/**
* Load the plugin text domain for translation.
*/
public function load_plugin_textdomain() {
load_plugin_textdomain(
$this->domain,
false,
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
);
}
/**
* Set the domain equal to that of the specified domain.
* @param string $domain The domain that represents the locale of this plugin.
*/
public function set_domain( $domain ) {
$this->domain = $domain;
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* Register all actions and filters for the plugin
* from : https://github.com/DevinVinson/WordPress-Plugin-Boilerplate
*
* 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.
*/
class Alti_ProtectUploads_Loader {
/**
* The array of actions registered with WordPress.
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
*/
protected $actions;
/**
* The array of filters registered with WordPress.
* @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.
*/
public function __construct() {
$this->actions = array();
$this->filters = array();
}
/**
* Add a new action to the collection to be registered with WordPress.
* @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 Optional $priority The priority at which the function should be fired.
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
*/
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.
* @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 Optional $priority The priority at which the function should be fired.
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
*/
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.
* @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 Optional $priority The priority at which the function should be fired.
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
* @return type 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.
*/
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'] );
}
}
}

View File

@ -0,0 +1,73 @@
<?php
class Alti_ProtectUploads
{
protected $version;
protected $plugin_name;
protected $loader;
public function __construct()
{
$this->version = '0.3';
$this->plugin_name = 'protect-uploads';
$this->load_dependencies();
$this->set_locale();
$this->define_admin_hooks();
}
private function load_dependencies()
{
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-protect-uploads-loader.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-protect-uploads-i18n.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-protect-uploads-admin.php';
$this->loader = new Alti_ProtectUploads_Loader();
}
/**
* set locale for translation ends.
*/
private function set_locale()
{
$plugin_i18n = new Alti_ProtectUploads_i18n();
$plugin_i18n->set_domain($this->get_plugin_name());
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
}
/**
* action and filter for admin side
*/
private function define_admin_hooks()
{
$plugin_admin = new Alti_ProtectUploads_Admin($this->get_plugin_name(), $this->get_version());
$this->loader->add_action('admin_menu', $plugin_admin, 'add_submenu_page');
$this->loader->add_filter('plugin_action_links_' . $this->get_plugin_name() . '/' . $this->get_plugin_name() . '.php', $plugin_admin, 'add_settings_link');
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
}
public function run()
{
$this->loader->run();
}
public function get_plugin_name()
{
return $this->plugin_name;
}
public function get_loader()
{
return $this->loader;
}
public function get_version()
{
return $this->version;
}
}

View File

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