From 4f369a6335181615642238c4c16342bea207c0ec Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Fri, 4 Mar 2022 16:01:06 -0500 Subject: [PATCH] Adds page customization metabox to theme ** Why are these changes being introduced: * We currently have a plugin whose only purpose is to create a metabox with instructions about how to control breadcrumbs on pages. The actual functionality of the breadcrumb is implemented by this theme, however. It makes more sense for the metabox to be part of the theme as well. ** Relevant ticket(s): * n/a ** How does this address that need: * This moves the two functions which create the metabox into the theme functions.php file, wrapped in checks for whether the plugin has already created them. ** Document any side effects to this change: * The functions.php file - currently over 1,000 lines long - will get a bit longer and messier. Ultimately these functions could be their own class, but no other classes exist yet. --- functions.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/functions.php b/functions.php index 414afdfa..667f07ed 100644 --- a/functions.php +++ b/functions.php @@ -1054,3 +1054,33 @@ function ssl_srcset( $sources ) { return $sources; } add_filter( 'wp_calculate_image_srcset', 'ssl_srcset' ); + +/** + * Start a block of functions that implement a metabox on the page editing + * screen. + */ +if ( ! function_exists( 'mitlib_page_customization_meta' ) ) { + /** + * Adds a meta box to the page editing screen + */ + function mitlib_page_customization_meta() { + add_meta_box( 'mitlib_page_customization_meta', __( 'Page Customization', 'prfx-textdomain' ), 'mitlib_page_customization_meta_callback', 'page', 'side', 'high' ); + } +} +add_action( 'add_meta_boxes', 'mitlib_page_customization_meta' ); + +if ( ! function_exists( 'mitlib_page_customization_meta_callback' ) ) { + /** + * Outputs the content of the meta box + * + * @param object $post unused. + */ + function mitlib_page_customization_meta_callback( $post ) { + $post = null; // Wipe Unused argument. + echo 'To customize the breadcrumb and the link to the top-level category at the top of the page, see the Categories box below.'; + } +} +/** + * End the functions which implement the customization metabox on the page + * editing screen. + */