'; $cc_divi_404_page_settings = get_option( 'cc_divi_404_page_settings' ); $cc_divi_404_page_librarylayout_ID = $cc_divi_404_page_settings['cc_divi_404_page_librarylayout_choices_select_field']; if ( get_post_status( $cc_divi_404_page_librarylayout_ID ) == 'publish' ) { // The layout exists echo do_shortcode('[et_pb_section global_module="' . $cc_divi_404_page_librarylayout_ID . '"][/et_pb_section]'); } else { // The layout doesnt exist echo '
'; echo '
'; echo '
'; echo '

404 Page Not Found

'; echo '

Divi 404 Page Builder Error: no 404 Divi layout specified.

'; echo '

Need help? View the plugin documentation: Divi 404 Page Builder

'; echo '
'; echo '
'; echo '
'; } echo ''; // END #main-content get_footer(); die(); // Kill any remaining output. An actual appropriate use of die() } /** * Display Fire our meta box setup function on the post editor screen. * @since 1.0.0 */ add_action( 'load-post.php', 'cc_divi_404_page_post_meta_boxes_setup' ); add_action( 'load-post-new.php', 'cc_divi_404_page_post_meta_boxes_setup' ); /** * Setup meta box * @since 1.0.0 */ function cc_divi_404_page_post_meta_boxes_setup() { /* Add meta boxes on the 'add_meta_boxes' hook. */ add_action( 'add_meta_boxes', 'cc_divi_404_page_add_post_meta_boxes' ); /* Save post meta on the 'save_post' hook. */ add_action( 'save_post', 'cc_divi_404_page_save_post_class_meta', 10, 2 ); } /** * Save the meta box's post metadata. * @since 1.0.0 */ function cc_divi_404_page_save_post_class_meta( $post_id, $post ) { /* Verify the nonce before proceeding. */ if ( !isset( $_POST['cc_divi_404_page_post_class_nonce'] ) || !wp_verify_nonce( $_POST['cc_divi_404_page_post_class_nonce'], basename( __FILE__ ) ) ) { return $post_id; } /* Get the post type object. */ $post_type = get_post_type_object( $post->post_type ); /* Check if the current user has permission to edit the post. */ if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { return $post_id; } /* Get the posted data and sanitize it for use as a libraylayout ID */ $new_librarylayout_ID = ( isset( $_POST['librarylayout_ID'] ) ? $_POST['librarylayout_ID'] : '' ); $existing_meta_value = get_option( 'cc_divi_404_page_settings' ); $existing_meta_value['cc_divi_404_page_librarylayout_choices_select_field'] = $new_librarylayout_ID; // update the library layout ID field update_option( 'cc_divi_404_page_settings', $existing_meta_value ); } /** * Add meta box. * @since 1.0.0 */ function cc_divi_404_page_add_post_meta_boxes() { add_meta_box( 'cc_divi_404_page_metabox', // Unique ID __( 'Divi 404 Page Builder' ), // Title 'cc_divi_404_page_post_class_meta_box', // Callback function 'et_pb_layout', // Admin page (or post type) 'side', // Context 'default' // Priority ); } /** * Display the meta box. * @since 1.0.0 */ function cc_divi_404_page_post_class_meta_box( $post ) { $cc_divi_404_page_settings = get_option( 'cc_divi_404_page_settings' ); $cc_divi_404_page_librarylayout_ID = $cc_divi_404_page_settings['cc_divi_404_page_librarylayout_choices_select_field']; wp_nonce_field( basename( __FILE__ ), 'cc_divi_404_page_post_class_nonce' ); ?>

/>