| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /*
- * Remove COMMENTS in its entirety
- */
- // Removes COMMENTS from admin menu
- add_action( 'admin_menu', 'remove_admin_menus' );
- function remove_admin_menus() {
- remove_menu_page( 'edit-comments.php' );
- }
- // Removes COMMENTS from post and pages
- add_action('init', 'remove_comment_support', 100);
- function remove_comment_support() {
- remove_post_type_support( 'post', 'comments' );
- remove_post_type_support( 'page', 'comments' );
- }
- // Removes COMMENTS from admin bar
- add_action( 'wp_before_admin_bar_render', 'remove_comments_admin_bar' );
- function remove_comments_admin_bar() {
- global $wp_admin_bar;
- $wp_admin_bar->remove_menu('comments');
- }
-
- // Allow [shortcode] in templates
- add_action( 'acf/init', 'set_acf_settings' );
- function set_acf_settings() {
- acf_update_setting( 'enable_shortcode', true );
- }
-
- add_filter( 'acf/shortcode/allow_in_block_themes_outside_content', '__return_true' );
-
-
- // General Settings - Set Default Featured Image Placeholder if none exists
- if ( ! class_exists( 'DefaultThumbnailID' ) ) {
- class DefaultThumbnailID {
- private static $instance;
- public function __construct() {
- // Add the option field to the General page.
- add_action( 'admin_init', array( &$this, 'show_default_thumbnail_id_option' ) );
- // Check if the default featured image exists.
- add_filter( 'has_post_thumbnail', array( &$this, 'set_has_post_thumbnail_value' ) );
- // Display the default featured image.
- add_filter( 'post_thumbnail_html', array( &$this, 'set_default_post_thumbnail_image' ), 10, 4 );
- }
- public static function get_instance() {
- if ( is_null( self::$instance ) ) {
- self::$instance = new self();
- }
- return self::$instance;
- }
- public function show_default_thumbnail_id_option() {
- register_setting(
- 'general', // General page
- '_default_thumbnail_id' // Option name
- );
- add_settings_field(
- 'default_thumbnail_id', // ID
- __( 'Default thumbnail ID', 'text-domain' ), // Option title
- array( &$this, 'display_input_field' ), // Display callback
- 'general', // General page
- 'default' // General page section
- );
- }
- public function display_input_field() {
- $value = get_option( '_default_thumbnail_id' );
- $value = wp_attachment_is_image( $value ) ? $value : '';
- ?>
- <input id="default_thumbnail_id" value="<?php echo esc_attr( $value ); ?>" name="_default_thumbnail_id"/>
- <?php
- }
- function set_has_post_thumbnail_value( $has_image ) {
- $default_thumbnail_id = get_option( '_default_thumbnail_id' );
- if ( ! empty( $default_thumbnail_id ) ) {
- $has_image = true;
- }
- return $has_image;
- }
- function set_default_post_thumbnail_image( $image, $post_id, $post_thumbnail_id, $size ) {
- $default_thumbnail_id = get_option( '_default_thumbnail_id' );
- if ( empty( $image ) && ! empty( $default_thumbnail_id ) ) {
- $image = wp_get_attachment_image( $default_thumbnail_id, $size );
- }
- return $image;
- }
- }
- // Instantiate the class object.
- DefaultThumbnailID::get_instance();
- }
-
- ?>
|