|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+<?php
|
|
|
2
|
+/*
|
|
|
3
|
+* Remove COMMENTS in its entirety
|
|
|
4
|
+*/
|
|
|
5
|
+// Removes COMMENTS from admin menu
|
|
|
6
|
+add_action( 'admin_menu', 'remove_admin_menus' );
|
|
|
7
|
+function remove_admin_menus() {
|
|
|
8
|
+ remove_menu_page( 'edit-comments.php' );
|
|
|
9
|
+}
|
|
|
10
|
+// Removes COMMENTS from post and pages
|
|
|
11
|
+add_action('init', 'remove_comment_support', 100);
|
|
|
12
|
+function remove_comment_support() {
|
|
|
13
|
+ remove_post_type_support( 'post', 'comments' );
|
|
|
14
|
+ remove_post_type_support( 'page', 'comments' );
|
|
|
15
|
+}
|
|
|
16
|
+// Removes COMMENTS from admin bar
|
|
|
17
|
+add_action( 'wp_before_admin_bar_render', 'remove_comments_admin_bar' );
|
|
|
18
|
+function remove_comments_admin_bar() {
|
|
|
19
|
+ global $wp_admin_bar;
|
|
|
20
|
+ $wp_admin_bar->remove_menu('comments');
|
|
|
21
|
+}
|
|
|
22
|
+
|
|
|
23
|
+// Allow [shortcode] in templates
|
|
|
24
|
+add_action( 'acf/init', 'set_acf_settings' );
|
|
|
25
|
+function set_acf_settings() {
|
|
|
26
|
+ acf_update_setting( 'enable_shortcode', true );
|
|
|
27
|
+}
|
|
|
28
|
+
|
|
|
29
|
+add_filter( 'acf/shortcode/allow_in_block_themes_outside_content', '__return_true' );
|
|
|
30
|
+
|
|
|
31
|
+
|
|
|
32
|
+// General Settings - Set Default Featured Image Placeholder if none exists
|
|
|
33
|
+if ( ! class_exists( 'DefaultThumbnailID' ) ) {
|
|
|
34
|
+ class DefaultThumbnailID {
|
|
|
35
|
+ private static $instance;
|
|
|
36
|
+ public function __construct() {
|
|
|
37
|
+ // Add the option field to the General page.
|
|
|
38
|
+ add_action( 'admin_init', array( &$this, 'show_default_thumbnail_id_option' ) );
|
|
|
39
|
+ // Check if the default featured image exists.
|
|
|
40
|
+ add_filter( 'has_post_thumbnail', array( &$this, 'set_has_post_thumbnail_value' ) );
|
|
|
41
|
+ // Display the default featured image.
|
|
|
42
|
+ add_filter( 'post_thumbnail_html', array( &$this, 'set_default_post_thumbnail_image' ), 10, 4 );
|
|
|
43
|
+ }
|
|
|
44
|
+ public static function get_instance() {
|
|
|
45
|
+ if ( is_null( self::$instance ) ) {
|
|
|
46
|
+ self::$instance = new self();
|
|
|
47
|
+ }
|
|
|
48
|
+ return self::$instance;
|
|
|
49
|
+ }
|
|
|
50
|
+ public function show_default_thumbnail_id_option() {
|
|
|
51
|
+ register_setting(
|
|
|
52
|
+ 'general', // General page
|
|
|
53
|
+ '_default_thumbnail_id' // Option name
|
|
|
54
|
+ );
|
|
|
55
|
+ add_settings_field(
|
|
|
56
|
+ 'default_thumbnail_id', // ID
|
|
|
57
|
+ __( 'Default thumbnail ID', 'text-domain' ), // Option title
|
|
|
58
|
+ array( &$this, 'display_input_field' ), // Display callback
|
|
|
59
|
+ 'general', // General page
|
|
|
60
|
+ 'default' // General page section
|
|
|
61
|
+ );
|
|
|
62
|
+ }
|
|
|
63
|
+ public function display_input_field() {
|
|
|
64
|
+ $value = get_option( '_default_thumbnail_id' );
|
|
|
65
|
+ $value = wp_attachment_is_image( $value ) ? $value : '';
|
|
|
66
|
+ ?>
|
|
|
67
|
+ <input id="default_thumbnail_id" value="<?php echo esc_attr( $value ); ?>" name="_default_thumbnail_id"/>
|
|
|
68
|
+ <?php
|
|
|
69
|
+ }
|
|
|
70
|
+ function set_has_post_thumbnail_value( $has_image ) {
|
|
|
71
|
+ $default_thumbnail_id = get_option( '_default_thumbnail_id' );
|
|
|
72
|
+ if ( ! empty( $default_thumbnail_id ) ) {
|
|
|
73
|
+ $has_image = true;
|
|
|
74
|
+ }
|
|
|
75
|
+ return $has_image;
|
|
|
76
|
+ }
|
|
|
77
|
+ function set_default_post_thumbnail_image( $image, $post_id, $post_thumbnail_id, $size ) {
|
|
|
78
|
+ $default_thumbnail_id = get_option( '_default_thumbnail_id' );
|
|
|
79
|
+ if ( empty( $image ) && ! empty( $default_thumbnail_id ) ) {
|
|
|
80
|
+ $image = wp_get_attachment_image( $default_thumbnail_id, $size );
|
|
|
81
|
+ }
|
|
|
82
|
+ return $image;
|
|
|
83
|
+ }
|
|
|
84
|
+ }
|
|
|
85
|
+ // Instantiate the class object.
|
|
|
86
|
+ DefaultThumbnailID::get_instance();
|
|
|
87
|
+ }
|
|
|
88
|
+
|
|
|
89
|
+?>
|