Files
yeuchaybo/lib/functions/general.php
T
Thuan Bui fd25f13a4f Initial
2018-06-26 11:09:22 +07:00

74 lines
1.7 KiB
PHP

<?php
/**
* Child Theme Library
*
* WARNING: This file is a part of the core Child Theme Library.
* DO NOT edit this file under any circumstances. Please use
* the functions.php file to make any theme modifications.
*
* @package SEOThemes\ChildThemeLibrary\Functions
* @link https://github.com/seothemes/child-theme-library
* @author Thuan Bui
* @copyright Copyright © 2018 Thuan Bui
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
add_action( 'after_switch_theme', 'child_theme_display_excerpt_metabox' );
/**
* Display excerpt metabox by default.
*
* The excerpt metabox is hidden by default on the page edit screen which can cause
* confusion for some users if they want to edit or remove the excerpt. To make
* it easier, we want to show the excerpt metabox by default. It only runs
* after switching theme so the current user's screen options are
* updated, allowing them to hide the metabox if not used.
*
* @since 1.0.0
*
* @return void
*/
function child_theme_display_excerpt_metabox() {
$user_id = get_current_user_id();
$post_types = array(
'page',
'post',
'portfolio',
);
foreach ( $post_types as $post_type ) {
$meta_key = 'metaboxhidden_' . $post_type;
$prev_value = get_user_meta( $user_id, $meta_key, true );
if ( ! is_array( $prev_value ) ) {
$prev_value = array(
'genesis_inpost_seo_box',
'postcustom',
'postexcerpt',
'commentstatusdiv',
'commentsdiv',
'slugdiv',
'authordiv',
'genesis_inpost_scripts_box',
);
}
$meta_value = array_diff( $prev_value, array( 'postexcerpt' ) );
update_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
}
}