-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathljs-tools.php
executable file
·118 lines (95 loc) · 3.48 KB
/
ljs-tools.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
*
* @link https://decided.to
* @since 1.0.0
* @package Ljs_Tools
*
* @wordpress-plugin
* Plugin Name: LJS Tools
* Plugin URI: https://github.com/matebitte/ljs_tools
* Description: Fügt post types für Beschlüsse sowie pasende Tags/Kategorien hinzu. Deaktiviert Kommentare. Für updates @[email protected] folgen :)
* Version: 1.0.0
* Author: Emilia Leo Weigel
* Author URI: https://decided.to
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: ljs-tools
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// key: ljs = linksjugend sachsen
/**
* Include files whom are referenced
*/
include "includes/ljs-comments.php";
include "includes/ljs-post-types.php";
include "includes/ljs-taxonomies.php";
include "includes/ljs-roles.php";
include "admin/ljs-settings.php";
///////////////////////////////////////////////
/**
* registering various hooks
*/
if (get_option( 'ljs_deactivate_comments' ) == true) {
// disable comments
add_action("wp_before__render", "ljs_remove_admin_bar_render");
add_action("init", "ljs_remove_comment_support");
add_action("admin_menu", "ljs_remove_comments_admin_menus");
}
if (get_option( 'ljs_add_custom_post_type' ) == true) {
// add ljp & beschlüsze
add_action("init", "ljs_add_post_type_beschlusz", 0);
add_action("init", "ljs_add_taxonomy_plenum", 1);
add_action("init", "ljs_add_taxonomy_gremium", 1);
add_action( "admin_menu", "ljs_change_tags_to_themen", 1);
}
// add admin page for simple settings
add_action('admin_menu', 'ljs_add_admin_submenu'); // add admin menu
add_action( 'admin_init', 'ljs_settings_init' ); // initialize settings
///////////////////////////////////////////////
/**
* The code that runs during plugin activation.
*/
function activate_ljs_tools() {
// set default options
// set_option( 'ljs_deactivate_comments' ) == true
// add ljp & beschlüsze
ljs_add_post_type_beschlusz();
ljs_add_taxonomy_plenum();
ljs_add_taxonomy_gremium();
ljs_change_tags_to_themen();
// remove comment post type
remove_post_type_support("post", "comments");
remove_post_type_support("page", "comments");
// remove admin menus for comments
remove_menu_page('edit-comments.php');
// remove comment menu from admin bar
global $wp_admin_bar;
$wp_admin_bar->remove_menu("comments");
// Clear the permalinks after the post type has been registered.
flush_rewrite_rules();
}
/**
* The code that runs during plugin deactivation.
*/
function deactivate_ljs_tools() {
// enable comments
remove_action("wp_before__render", "ljs_remove_admin_bar_render");
remove_action("init", "ljs_remove_comment_support", 100);
remove_action("admin_menu", "ljs_remove_comments_admin_menus");
// add ljp & beschlüsze
remove_action("init", "ljs_add_post_type_beschlusz");
remove_action("init", "ljs_add_taxonomy_plenum", 0);
remove_action("init", "ljs_add_taxonomy_gremium", 0);
remove_action( "admin_menu", "ljs_change_tags_to_themen");
// Clear the permalinks after the post type has been unregistered.
flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'activate_ljs_tools');
register_deactivation_hook(__FILE__, 'deactivate_ljs_tools');
register_uninstall_hook(__FILE__, 'uninstall_ljs_tools');
// 2023 emilia leo weigel