-
Notifications
You must be signed in to change notification settings - Fork 0
/
eletube.php
74 lines (58 loc) · 2.2 KB
/
eletube.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace Eletube;
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://www.hennewelt.de
* @since 1.0.0
* @package Eletube
*
* @wordpress-plugin
* Plugin Name: Eletube
* Plugin URI:
* Description: Eletube adds a Widget for Youtube-Lists to Elementor.
* Version: 1.0.0
* Author: Sascha Hennemann
* Author URI: https://www.hennewelt.de
* License: MIT License
* License URI: https://opensource.org/license/mit
* Text Domain: eletube
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( !defined( 'WPINC' ) ) {
die;
}
define( 'Eletube_VERSION', '1.0,0' );
define( 'Eletube_DIR', str_replace( '\\', '/', __DIR__ ) );
define( 'Eletube_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'Eletube_CACHE_DIR', wp_upload_dir()['basedir'] . '/eletube-cache' );
final class Eletube {
private function __construct() {
if ( !is_dir( Eletube_CACHE_DIR ) ) {
mkdir( Eletube_CACHE_DIR );
}
if ( !is_dir( Eletube_CACHE_DIR . '/thumbnails' ) ) {
mkdir( Eletube_CACHE_DIR . '/thumbnails' );
}
add_action( 'elementor/widgets/widgets_registered', [ $this, 'registerElementorWidgets' ], 15 );
add_action( 'wp_enqueue_scripts', [ $this, 'registerScriptsAndStyle' ] );
}
public function registerElementorWidgets( $widgetsManager ) {
require_once( Eletube_DIR . '/widgets/EletubeWidget.php' );
$widgetsManager->register_widget_type( new EletubeWidget() );
}
public function registerScriptsAndStyle() {
wp_enqueue_script( 'eletube-js', Eletube_URL . '/js/eletube.js' );
wp_enqueue_style( 'eletube-css', Eletube_URL . '/css/eletube.css' );
}
public static function run() {
new self();
}
}
Eletube::run();