mirror of
https://github.com/10h30/yeuchaybo.git
synced 2026-07-18 14:13:56 +09:00
Initial
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?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 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user