baseline functions

This commit is contained in:
2025-09-04 16:06:34 +01:00
parent fb9d9fd091
commit 89ca57e44d
27 changed files with 15904 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Admin;
class Comments
{
public function __construct()
{
add_action('admin_init', [$this, 'commentstatusdiv']); // Disable comment status div meta box
add_action('wp_dashboard_setup', [$this, 'dashboard_activity']); // Remove the Activity widget
add_action('wp_before_admin_bar_render', [$this, 'remove_menu_item']); // Remove from admin bar
add_action('admin_menu', [$this, 'admin_menu']); // Remove from backend menu
add_action('wp_dashboard_setup', [$this, 'dashboard_recent_comments']); // Remove Dashboard Meta Box
add_filter('comments_rewrite_rules', '__return_empty_array'); // Remove comment rewrite rule
add_action('after_theme_setup', [$this, 'theme_support']); // Remove comment theme support
add_filter('rewrite_rules_array', [$this, 'rewrite']); // Clean up rewrite rule
}
public function commentstatusdiv()
{
remove_meta_box( 'commentstatusdiv', 'post', 'normal' );
remove_post_type_support( 'post', 'comments' );
remove_meta_box( 'commentstatusdiv', 'page', 'normal' );
remove_post_type_support( 'page', 'comments' );
}
public function dashboard_activity()
{
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' );
}
public function remove_menu_item()
{
global $wp_admin_bar;
$wp_admin_bar->remove_menu('comments');
}
public function admin_menu()
{
remove_menu_page( 'edit-comments.php' );
remove_submenu_page( 'options-general.php', 'options-discussion.php' );
}
public function dashboard_recent_comments()
{
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
}
public function theme_support()
{
remove_theme_support('comments');
}
public function rewrite($rules)
{
foreach ($rules as $rule => $rewrite) {
if (preg_match('/.*(feed)/', $rule)) {
unset($rules[$rule]);
}
if (preg_match('/.*(comment-page)/', $rule)) {
unset($rules[$rule]);
}
}
return $rules;
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Admin;
class DisablePost
{
public function __construct()
{
add_filter('register_post_type_args', [$this, 'args'], 0, 2);
add_filter('register_taxonomy_args', [$this, 'args'], 0, 2);
}
public function args($args, $type)
{
$types = [
'post',
'post_tag',
'category',
];
if(in_array($type, $types)) {
$args['public'] = false;
}
return $args;
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Admin;
class Enqueue
{
public function __construct()
{
add_action( 'admin_enqueue_scripts', [$this, 'fontawesome']);
}
public function fontawesome()
{
wp_enqueue_style(
'fontawesome',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css',
false,
'6.5.2',
'all'
);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Admin;
class Integrations
{
public function __construct()
{
add_action( 'wp_head', [$this, 'FathomAnalytics']);
}
public function FathomAnalytics()
{
$fathomID = get_field('badegg_integrations_fathom_id', 'option');
if($fathomID && WP_ENV == 'production'): ?>
<!-- Fathom - beautiful, simple website analytics -->
<script src="https://cdn.usefathom.com/script.js" data-site="<?= $fathomID ?>" defer></script>
<!-- / Fathom -->
<?php endif;
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Admin;
class Menus
{
public function __construct()
{
add_action('admin_menu', [$this, 'cleanup_appearance']);
}
public function cleanup_appearance()
{
$customize_url = add_query_arg(
'return',
urlencode(
remove_query_arg(
wp_removable_query_args(),
wp_unslash( $_SERVER['REQUEST_URI'] )
)
),
'customize.php'
);
remove_submenu_page( 'themes.php', $customize_url );
remove_submenu_page( 'themes.php', 'widgets.php' );
remove_submenu_page( 'themes.php', 'site-editor.php' );
}
}