-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtakin.php
More file actions
47 lines (42 loc) · 1.47 KB
/
takin.php
File metadata and controls
47 lines (42 loc) · 1.47 KB
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
<?php
/*
Plugin Name: Takin
Plugin URI: https://github.com/ProjetsMerlin/takin
Description: Takin permet d'afficher les 24 dernier articles comme un calendrier de l'avent.
Version: 1.0.0
Requires at least: 6.9
Requires PHP: 8.3.1
Author: Merlin
Author URI: https://lintermediaire.be/auteur/merlin
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: takin
*/
if (!defined('ABSPATH')) exit;
$takin_pluginVersion = "1.0.0";
/* Ajouter un template dans la liste des templates WordPress */
function takin_register_template($templates)
{
$templates['takin-template.php'] = 'Takin';
return $templates;
}
add_filter('theme_page_templates', 'takin_register_template');
/* Charger le template lorsqu'il est sélectionné */
function takin_load_template($template)
{
if (is_page()) {
$page_template = get_post_meta(get_the_ID(), '_wp_page_template', true);
if ($page_template === 'takin-template.php') {
return plugin_dir_path(__FILE__) . 'takin-template.php';
}
}
return $template;
}
add_filter('template_include', 'takin_load_template');
/* Ajout des styles (+ Tailwind CSS) */
function takin_addStyle($takin_pluginVersion)
{
wp_enqueue_script('tailwind', plugin_dir_url(__FILE__) . '/assets/tailwind.3.4.17.js', [], "3.4.17", null, false);
wp_enqueue_style('takin_snow', plugin_dir_url(__FILE__) . '/assets/takin.css', [], $takin_pluginVersion);
}
add_action('wp_enqueue_scripts', 'takin_addStyle');