♻️ Re-organize workspace folders
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Typebot_Activator
|
||||
{
|
||||
public static function activate()
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Typebot_Deactivator
|
||||
{
|
||||
public static function deactivate()
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
class Typebot_i18n
|
||||
{
|
||||
public function load_plugin_textdomain()
|
||||
{
|
||||
|
||||
load_plugin_textdomain(
|
||||
'typebot',
|
||||
false,
|
||||
dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
class Typebot_Loader
|
||||
{
|
||||
protected $actions;
|
||||
protected $filters;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->actions = array();
|
||||
$this->filters = array();
|
||||
$this->shortcodes = array();
|
||||
}
|
||||
|
||||
public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
|
||||
{
|
||||
$this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
|
||||
}
|
||||
|
||||
public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
|
||||
{
|
||||
$this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
|
||||
foreach ($this->shortcodes as $hook) {
|
||||
add_shortcode($hook['hook'], array($hook['component'], $hook['callback']));
|
||||
}
|
||||
}
|
||||
|
||||
public function add_shortcode($tag, $component, $callback, $priority = 10, $accepted_args = 2)
|
||||
{
|
||||
$this->shortcodes = $this->add($this->shortcodes, $tag, $component, $callback, $priority, $accepted_args);
|
||||
}
|
||||
}
|
75
packages/embeds/wordpress/trunk/includes/class-typebot.php
Normal file
75
packages/embeds/wordpress/trunk/includes/class-typebot.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Typebot
|
||||
{
|
||||
|
||||
protected $loader;
|
||||
protected $plugin_name;
|
||||
protected $version;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (defined('TYPEBOT_VERSION')) {
|
||||
$this->version = TYPEBOT_VERSION;
|
||||
} else {
|
||||
$this->version = '1.0.0';
|
||||
}
|
||||
$this->plugin_name = 'typebot';
|
||||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->define_admin_hooks();
|
||||
$this->define_public_hooks();
|
||||
}
|
||||
|
||||
private function load_dependencies()
|
||||
{
|
||||
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-typebot-loader.php';
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-typebot-i18n.php';
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-typebot-admin.php';
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-typebot-public.php';
|
||||
|
||||
$this->loader = new Typebot_Loader();
|
||||
}
|
||||
|
||||
private function set_locale()
|
||||
{
|
||||
$plugin_i18n = new Typebot_i18n();
|
||||
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
|
||||
}
|
||||
|
||||
private function define_admin_hooks()
|
||||
{
|
||||
$plugin_admin = new Typebot_Admin($this->get_version());
|
||||
$this->loader->add_action('admin_menu', $plugin_admin, 'my_admin_menu');
|
||||
$this->loader->add_action('admin_init', $plugin_admin, 'register_typebot_settings');
|
||||
}
|
||||
|
||||
private function define_public_hooks()
|
||||
{
|
||||
$plugin_public = new Typebot_Public($this->get_plugin_name(), $this->get_version());
|
||||
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'add_head_code');
|
||||
$this->loader->add_shortcode('typebot', $plugin_public, 'add_typebot_container');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
1
packages/embeds/wordpress/trunk/includes/index.php
Normal file
1
packages/embeds/wordpress/trunk/includes/index.php
Normal file
@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
Reference in New Issue
Block a user