get_bloginfo('name'), ) ); // Support HTML5 Markup Search Form add_theme_support( 'html5', array( 'search-form' ) ); // Featured Images in Posts/Pages add_theme_support( 'post-thumbnails', array( 'post', 'page' ) ); // Automatic Feed Links add_theme_support( 'automatic-feed-links' ); // Custom Header add_theme_support( 'custom-header' ); // Custom Background // add_theme_support( 'custom-background' ); // Add Editor Style function wpdocs_theme_add_editor_styles() { add_editor_style( 'custom-editor-style.css' ); } add_action( 'admin_init', 'wpdocs_theme_add_editor_styles' ); // Remove Automatic Paragraphs remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop', 99 ); // Enable Shortcodes in Text Widgets add_filter('widget_text','do_shortcode'); // WP Link Pages $defaults = array( 'before' => '

' . esc_html__( 'Pages:', 'mnmlwp' ), 'after' => '

', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => esc_html__( 'Next page', 'mnmlwp'), 'previouspagelink' => esc_html__( 'Previous page', 'mnmlwp' ), 'pagelink' => '%', 'echo' => 1 ); wp_link_pages( $defaults ); // Content Width if ( ! isset( $content_width ) ) $content_width = 1920; // mnmlWP Plugin Activation require_once( dirname(__FILE__) . '/inc/class-tgm-plugin-activation.php' ); add_action( 'tgmpa_register', 'mnmlwp_register_required_plugins' ); function mnmlwp_register_required_plugins() { $plugins = array( array( 'name' => 'mnmlWP Shortcodes', 'slug' => 'mnmlwp-shortcodes', // 'source' => get_template_directory() . '/lib/plugins/tgm-example-plugin.zip', // The plugin source. 'source' => 'https://mnmlwp.de/update/downloads/plugins/mnmlwp-shortcodes-0.1.5.zip', // The plugin source. 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'version' => '0.1.5', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. // 'external_url' => 'https://sebastianhonert.com/mnmlwp/update/downloads/plugins/mnmlwp-contact-form-0.1.1.zip', // If set, overrides default API URL and points to an external URL. 'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active. ), array( 'name' => 'mnmlWP Contact Form', 'slug' => 'mnmlwp-contact-form', // 'source' => get_template_directory() . '/lib/plugins/tgm-example-plugin.zip', // The plugin source. 'source' => 'https://mnmlwp.de/update/downloads/plugins/mnmlwp-contact-form-0.1.4.zip', // The plugin source. 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'version' => '0.1.4', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. 'external_url' => '', // If set, overrides default API URL and points to an external URL. 'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active. ), ); /* * Array of configuration settings. Amend each line as needed. * * TGMPA will start providing localized text strings soon. If you already have translations of our standard * strings available, please help us make TGMPA even better by giving us access to these translations or by * sending in a pull-request with .po file(s) with the translations. * * Only uncomment the strings in the config array if you want to customize the strings. */ $config = array( 'id' => 'mnmlwp', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to bundled plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => false, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. 'strings' => array( 'page_title' => esc_html__( 'Install Required Plugins', 'mnmlwp' ), 'menu_title' => esc_html__( 'Install Plugins', 'mnmlwp' ), /* translators: %s: plugin name. */ 'installing' => esc_html__( 'Installing Plugin: %s', 'mnmlwp' ), /* translators: %s: plugin name. */ 'updating' => esc_html__( 'Updating Plugin: %s', 'mnmlwp' ), 'oops' => esc_html__( 'Something went wrong with the plugin API.', 'mnmlwp' ), 'notice_can_install_required' => _n_noop( /* translators: 1: plugin name(s). */ 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'mnmlwp' ), 'notice_can_install_recommended' => _n_noop( /* translators: 1: plugin name(s). */ 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'mnmlwp' ), 'notice_ask_to_update' => _n_noop( /* translators: 1: plugin name(s). */ 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'mnmlwp' ), 'notice_ask_to_update_maybe' => _n_noop( /* translators: 1: plugin name(s). */ 'There is an update available for: %1$s.', 'There are updates available for the following plugins: %1$s.', 'mnmlwp' ), 'notice_can_activate_required' => _n_noop( /* translators: 1: plugin name(s). */ 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'mnmlwp' ), 'notice_can_activate_recommended' => _n_noop( /* translators: 1: plugin name(s). */ 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'mnmlwp' ), 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'mnmlwp' ), 'update_link' => _n_noop( 'Begin updating plugin', 'Begin updating plugins', 'mnmlwp' ), 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'mnmlwp' ), 'return' => esc_html__( 'Return to Required Plugins Installer', 'mnmlwp' ), 'plugin_activated' => esc_html__( 'Plugin activated successfully.', 'mnmlwp' ), 'activated_successfully' => esc_html__( 'The following plugin was activated successfully:', 'mnmlwp' ), /* translators: 1: plugin name. */ 'plugin_already_active' => esc_html__( 'No action taken. Plugin %1$s was already active.', 'mnmlwp' ), /* translators: 1: plugin name. */ 'plugin_needs_higher_version' => esc_html__( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'mnmlwp' ), /* translators: 1: dashboard link. */ 'complete' => esc_html__( 'All plugins installed and activated successfully. %1$s', 'mnmlwp' ), 'dismiss' => esc_html__( 'Dismiss this notice', 'mnmlwp' ), 'notice_cannot_install_activate' => esc_html__( 'There are one or more required or recommended plugins to install, update or activate.', 'mnmlwp' ), 'contact_admin' => esc_html__( 'Please contact the administrator of this site for help.', 'mnmlwp' ), 'nag_type' => '', // Determines admin notice type - can only be one of the typical WP notice classes, such as 'updated', 'update-nag', 'notice-warning', 'notice-info' or 'error'. Some of which may not work as expected in older WP versions. ), ); tgmpa( $plugins, $config ); } // Customizer & Alpha Color Picker function mnmlwp_customize_register_acp( $wp_customize ) { require_once( realpath(dirname(__FILE__) . '/inc/alpha-color-picker/alpha-color-picker.php') ); } add_action( 'customize_register', 'mnmlwp_customize_register_acp' ); include 'functions/customizer.php'; include 'inc/customizer-reset/customizer-reset.php'; // Breadcrumbs include 'functions/breadcrumbs.php'; // Demo Content include 'demo/functions.php'; // Updater require_once( dirname(__FILE__) . '/functions/update.php' ); // Disable Rich Text Editor // function mnmlwp_disable_richedit() { // return false; // } // // add_filter( 'user_can_richedit', 'mnmlwp_disable_richedit' ); // Main Navigation function mnmlwp_register_main_navigation() { register_nav_menus( array( 'main-nav' => esc_html__( 'Main Navigation', 'mnmlwp' ), ) ); } add_action('after_setup_theme', 'mnmlwp_register_main_navigation'); // Show Navigation/Menu if( ! function_exists ( 'mnmlwp_nav' ) ) { function mnmlwp_nav() { if ( has_nav_menu( 'main-nav' ) ) { echo ''; echo '
'; } } } // Add search form to primary navigation function mnmlwp_add_search_nav_item( $items, $args ) { if( $args->theme_location !== 'main-nav' ) return $items; if( ! get_theme_mod( 'mnmlwp_has_nav_search', true) ) return $items; // $searchform = get_search_form( false ); $searchform = '
'; $items .= '
  • ' . $searchform . '
  • '; return $items; } add_filter( 'wp_nav_menu_items', 'mnmlwp_add_search_nav_item', 10, 2 ); // Widgets & Sidebars function mnmlwp_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'mnmlWP Sidebar', 'mnmlwp' ), 'id' => 'mnmlwp-sidebar', 'description' => 'Default Sidebar', 'class' => '', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '

    ', 'after_title' => '

    ' ) ); register_sidebar( array( 'name' => 'Footer Left', 'id' => 'mnmlwp-footer-left', 'description' => 'Left Footer Column', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => 'Footer Middle', 'id' => 'mnmlwp-footer-middle', 'description' => 'Center Footer Column', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => 'Footer Right', 'id' => 'mnmlwp-footer-right', 'description' => 'Right Footer Column', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => 'Footer Full Width', 'id' => 'mnmlwp-footer-full-width', 'description' => 'Full Width Footer', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); } add_action( 'widgets_init', 'mnmlwp_widgets_init' ); // mnmlWP Recent Posts Widget include dirname(__FILE__) . '/widgets/mnmlwp-recent-posts/mnmlwp-recent-posts.php'; include dirname(__FILE__) . '/widgets/mnmlwp-colored-categories/mnmlwp-colored-categories.php'; // Remove query string from static files function mnmlwp_remove_cssjs_ver( $src ) { if( strpos( $src, '?ver=' ) ) $src = remove_query_arg( 'ver', $src ); return $src; } add_filter( 'style_loader_src', 'mnmlwp_remove_cssjs_ver', 10, 2 ); add_filter( 'script_loader_src', 'mnmlwp_remove_cssjs_ver', 10, 2 ); /** * Add a parent CSS class for nav menu items. * * @param array $items The menu items, sorted by each menu item's menu order. * @return array (maybe) modified parent CSS class. */ function wpdocs_add_menu_parent_class( $items ) { $parents = array(); foreach ( $items as $item ) { if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) { $parents[] = $item->menu_item_parent; } } foreach ( $items as $item ) { if ( in_array( $item->ID, $parents ) ) { $item->classes[] = 'menu-parent-item'; } } return $items; } add_filter( 'wp_nav_menu_objects', 'wpdocs_add_menu_parent_class' ); // Excerpt Length in Words function mnmlwp_excerpt_length($length) { return 60; } add_filter('excerpt_length', 'mnmlwp_excerpt_length'); // Replaces the excerpt "Read More" text by a link function mnmlwp_excerpt_more($more) { global $post; return ' ' . esc_html__('read more', 'mnmlwp') . '…'; } add_filter('excerpt_more', 'mnmlwp_excerpt_more'); // Post List (Archive) if( ! function_exists( 'mnmlwp_get_posts') ) { function mnmlwp_get_posts( $cat = false, $format = 'default' ) { global $wp_query; global $paged; $posts_per_page = get_option('posts_per_page'); if( is_front_page() ) $paged = get_query_var('page'); if ( is_paged() ) { $page_offset = $posts_per_page + ( ( $paged - 2 ) * $posts_per_page ); } else { $page_offset = 0; } $tag = is_tag() ? single_tag_title('', false) : ''; $category = is_category() ? single_cat_title('', false) : ''; $author = is_author() ? get_the_author_meta('nicename') : ''; $year = get_query_var('year'); $monthnum = get_query_var('monthnum') ? get_query_var('monthnum') : '01'; $day = get_query_var('day'); if( $cat ) { $category = $cat; } if( ! is_date() && ! is_search() ) { query_posts( array( 'posts_per_page' => $posts_per_page, 'offset' => $page_offset, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'tag' => $tag, 'category_name' => $category, 'author_name' => $author, 'paged' => $paged, ) ); } $html = ''; if( is_author() ) { $html .= '

    ' . esc_html__('Posts by', 'mnmlwp') . ' ' . ucfirst( $author ) . ' (' . $wp_query->found_posts . ' ' . esc_html__('results', 'mnmlwp') . ')

    '; } if( is_category() ) { $html .= '

    ' . esc_attr__('Category', 'mnmlwp') . ': ' . ucfirst( $category ) . ' (' . $wp_query->found_posts . ' ' . esc_html__('results', 'mnmlwp') . ')

    '; } if( is_tag() ) { $html .= '

    ' . esc_attr__('Tag', 'mnmlwp') . ': ' . ucfirst( $tag ) . ' (' . $wp_query->found_posts . ' ' . esc_html__('results', 'mnmlwp') . ')

    '; } if( is_search() ) { global $s; global $wp_query; $key = esc_html($s); if( $s ) { if( strlen( $s ) > 15 ) { $s = substr( $s, 0, 15 ) . '…'; } $html .= '

    »' . esc_html( $s ) . '« (' . $wp_query->found_posts . ' ' . esc_html__('results', 'mnmlwp') . ')

    '; } else { $html .= '

    ' . esc_html__('No Results', 'mnmlwp') . '

    '; $html .= '

    ' . esc_html__('Please enter a search term.', 'mnmlwp') . '

    '; $html .= get_search_form( false ); return $html; } } if( have_posts() ) : $html .= '
    '; else: $html .= '

    ' . esc_html__('No posts found. You might want to use the search form or go back to the home page.', 'mnmlwp') . '

    '; endif; // Paginate if( ! $cat ) $html .= mnmlwp_paginate_links( $paged ); wp_reset_query(); wp_reset_postdata(); return $html; } } // Post Meta if( ! function_exists ( 'mnmlwp_get_post_meta' ) ) { function mnmlwp_get_post_meta( $post_id, $components = null ) { if( $components === null ) { $components = array( 'author', 'date', 'categories', 'tags', ); } else { $componets = array_map( 'esc_attr', $components ); } $divider = ''; // $author_title = '' . esc_html__('Author', 'mnmlwp') . ': '; $author_title = ''; $author = in_array( 'author', $components ) && get_post_type() === 'post' ? $author_title . '' . get_the_author_meta('display_name') . '' . $divider : ''; $date = in_array( 'date', $components ) ? get_the_date() : ''; $html = '
    '; $html .= '

    ' . $author . $date . '

    '; $html .= in_array( 'categories', $components ) ? mnmlwp_get_post_categories( $post_id ) : ''; $html .= in_array( 'tags', $components ) ? mnmlwp_get_post_tags( $post_id ) : ''; $html .= '
    '; return $html; } } // Get Categories if( ! function_exists( 'mnmlwp_get_post_categories' ) ) { function mnmlwp_get_post_categories( $post_id ) { $categories = wp_get_post_categories( $post_id ); if( empty( $categories ) ) return; $html = '
    '; // $html .= '' . esc_html__('Categories', 'mnmlwp') . ': '; foreach( $categories as $cat ) { $term_id = $cat; $cat_meta = get_option( "category_$term_id" ); $cat_color = isset( $cat_meta['color'] ) ? $cat_meta['color'] : '#0073aa'; $style = 'background:' . $cat_color . ';color:#fff!important'; $cat_name = get_cat_name( $cat ); $cat_name_short = substr( get_cat_name( $cat ), 0, 1 ); $cat_data = get_option("category_$cat"); $category = get_category( $cat ); $html .= '' . $cat_name . ''; // if( $cat !== end($categories) ) // $html .= ', '; } $html .= '
    '; return $html; } } // Post Tags if( ! function_exists('mnmlwp_get_post_tags') ) { function mnmlwp_get_post_tags( $post_id ) { $tags = get_the_tags( $post_id ); if( empty( $tags ) ) return; $html = '
    '; // $html .= '' . esc_html__('Tags', 'mnmlwp') . ': '; foreach( $tags as $tag ) { $html .= '' . $tag->name . ''; // if( $tag !== end($tags) ) // $html .= ', '; } $html .= '
    '; return $html; } } // Paginate links if( ! function_exists ( 'mnmlwp_paginate_links' ) ) { function mnmlwp_paginate_links( $paged = 0 ) { global $wp_query; if( $wp_query->max_num_pages == 1 ) return ''; $big = 999999999; // need an unlikely integer $html = '
    '; $html .= paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, $paged ), 'total' => $wp_query->max_num_pages, 'prev_next' => false, 'show_all' => true, ) ); $html .= '
    '; return $html; } } // Adjacent Posts if( ! function_exists ( 'mnmlwp_adjacent_posts' ) ) { function mnmlwp_adjacent_posts() { // Next & prev post $next_post = get_next_post(); $prev_post = get_previous_post(); $next_post_title = ! empty( $next_post ) ? $next_post->post_title : 'Next'; $prev_post_title = ! empty( $prev_post ) ? $prev_post->post_title : 'Previous'; if( ! empty( $next_post ) || ! empty( $prev_post ) ) { ?> '; $html .= '
    '; if( ! empty( $hero_overlay ) ) { $html .= '
    '; } $html .= '
    ' . $hero_title . '
    '; $html .= '
    '; $html .= ''; return $html; } } /** * Convert hexdec color string to rgb(a) string */ function mnmlwp_hex2rgba($color, $opacity = false) { $default = 'rgb(0,0,0)'; //Return default if no color provided if(empty($color)) return $default; //Sanitize $color if "#" is provided if ($color[0] == '#' ) { $color = substr( $color, 1 ); } //Check if color has 6 or 3 characters and get values if (strlen($color) == 6) { $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); } elseif ( strlen( $color ) == 3 ) { $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); } else { return $default; } //Convert hexadec to rgb $rgb = array_map('hexdec', $hex); //Check if opacity is set(rgba or rgb) if($opacity){ if(abs($opacity) > 1) $opacity = 1.0; $output = 'rgba('.implode(",",$rgb).','.$opacity.')'; } else { $output = 'rgb('.implode(",",$rgb).')'; } //Return rgb(a) color string return $output; } /** * Success Message for Admin after theme was installed */ function mnmlwp_admin_welcome_message() { $welcome = '
    '; $welcome .= '

    ' . esc_html__('Congratulations', 'mnmlwp') . '

    '; $welcome .= '

    ' . sprintf( esc_html__('You successfully installed the mnmlWP WordPress Theme. Please update your theme settings in the %1$s.', 'mnmlwp'), 'Customizer' ) . '

    '; $welcome .= '

    ' . esc_html__('Enjoy your mnmlWP site!', 'mnmlwp') . '

    '; $welcome .= '
    '; echo $welcome; } add_action( 'after_switch_theme', 'mnmlwp_admin_welcome_message' ); /** Add Colorpicker Field to "Add New Category" Form **/ // Thank you, Howdy_McGee! // http://wordpress.stackexchange.com/questions/112866/adding-colorpicker-field-to-category function mnmlwp_add_category_form_custom_fields( $taxonomy ) { echo '

    ' . esc_attr__('Pick a Category Color', 'mnmlwp') . '

    '; } add_action('category_add_form_fields', 'mnmlwp_add_category_form_custom_fields', 30 ); /** * Add Category Meta Fields */ function mnmlwp_add_category_meta_fields( $tag ) { $term_id = $tag->term_id; $cat_meta = get_option( "category_$term_id" ); $color = isset( $cat_meta['color'] ) ? $cat_meta['color'] : '#0073aa'; echo '


    '; } add_action('edit_category_form_fields', 'mnmlwp_add_category_meta_fields'); /** * Save Category Meta Fields */ function mnmlwp_save_category_meta_fields( $term_id ) { if ( isset( $_POST['cat_meta'] ) ) { $term_id = $term_id; $cat_meta = get_option( "category_$term_id"); $cat_keys = array_keys($_POST['cat_meta']); foreach ($cat_keys as $key) { if (isset($_POST['cat_meta'][$key])) { $cat_meta[$key] = sanitize_hex_color( $_POST['cat_meta'][$key] ); } } update_option( "category_$term_id", $cat_meta ); } } add_action('edited_category', 'mnmlwp_save_category_meta_fields'); add_action('created_category', 'mnmlwp_save_category_meta_fields', 11, 1); /** * Meta Boxes for Posts/Pages */ function mnmlwp_add_meta_boxes() { global $post; $screens = get_post_types(); foreach ( $screens as $screen ) { // Add Hide Page Title Option add_meta_box( 'mnmlwp-hide-page-title', esc_html__( 'Hide Page Title?', 'mnmlwp' ), 'mnmlwp_add_meta_boxes_hide_page_title_callback', $screen, 'side', 'low' ); // Add Show Sidebar Option add_meta_box( 'mnmlwp-show-sidebar', esc_html__( 'Show Sidebar?', 'mnmlwp' ), 'mnmlwp_add_meta_boxes_show_sidebar_callback', $screen, 'side', 'low' ); // Hide Breadcrumbs if( get_theme_mod( 'mnmlwp_has_breadcrumbs', true ) ) { add_meta_box( 'mnmlwp-hide-breadcrumbs', esc_html__( 'Hide Breadcrumbs?', 'mnmlwp' ), 'mnmlwp_add_meta_boxes_hide_breadcrumb_callback', $screen ); } // Hide Contact Row if( get_theme_mod( 'mnmlwp_show_contact_row', false ) ) { add_meta_box( 'mnmlwp-hide-contact-row', esc_html__( 'Hide Contact Row?', 'mnmlwp' ), 'mnmlwp_add_meta_boxes_hide_contact_row_callback', $screen ); } // Hero Title $template = get_post_meta( $post->ID, '_wp_page_template', true ); if( 'template-page-hero.php' === $template || 'template-post-hero.php' === $template ) { add_meta_box( 'mnmlwp-hero-image', esc_html__( 'Hero Section', 'mnmlwp' ), 'mnmlwp_add_meta_boxes_hero_image_callback', $screen ); } } } add_action( 'add_meta_boxes', 'mnmlwp_add_meta_boxes' ); function mnmlwp_add_meta_boxes_show_sidebar_callback( $post ) { wp_nonce_field( 'mnmlwp_add_meta_boxes_nonce', 'mnmlwp_add_meta_boxes_nonce' ); $mnmlwp_show_sidebar = get_post_meta( $post->ID, '_mnmlwp_show_sidebar', true ); $checked = $mnmlwp_show_sidebar == 1 ? 'checked' : ''; echo ' ' . esc_html__('Yes, show the sidebar.', 'mnmlwp'); } function mnmlwp_add_meta_boxes_hide_page_title_callback( $post ) { $mnmlwp_hide_page_title = get_post_meta( $post->ID, '_mnmlwp_hide_page_title', true ); $checked = $mnmlwp_hide_page_title == 1 ? 'checked' : ''; echo ' ' . esc_html__('Yes, hide the page title.', 'mnmlwp'); } function mnmlwp_add_meta_boxes_hide_breadcrumb_callback( $post ) { $theme_has_breadcrumbs = get_theme_mod( 'mnmlwp_has_breadcrumbs', true ); $mnmlwp_hide_breadcrumbs = get_post_meta( $post->ID, '_mnmlwp_hide_breadcrumbs', true ); $checked = $mnmlwp_hide_breadcrumbs == 1 ? 'checked' : ''; $disabled = $theme_has_breadcrumbs ? '' : 'disabled="disabled"'; echo ' ' . esc_html__('Check to hide the breadcrumb navigation on this page.', 'mnmlwp'); if( ! $theme_has_breadcrumbs ) { echo '

    ' . esc_html__('Attention', 'mnmlwp') . ':' . esc_html__('The breadcrumb navigation is globally disabled in the theme customization options.', 'mnmlwp') . '

    '; } } function mnmlwp_add_meta_boxes_hide_contact_row_callback( $post ) { $theme_has_contact_row = get_theme_mod( 'mnmlwp_has_contact_row', true ); $mnmlwp_hide_contact_row = get_post_meta( $post->ID, '_mnmlwp_hide_contact_row', true ); $checked = $mnmlwp_hide_contact_row == 1 ? 'checked' : ''; $disabled = $theme_has_contact_row ? '' : 'disabled="disabled"'; echo ' ' . esc_html__('Check to hide the contact row on this page.', 'mnmlwp'); if( ! $theme_has_contact_row ) { echo '

    ' . esc_html__('Attention', 'mnmlwp') . ':' . esc_html__('The contact row is globally disabled in the theme customization options.', 'mnmlwp') . '

    '; } } function mnmlwp_add_meta_boxes_hero_image_callback( $post ) { $hero_title = get_post_meta( $post->ID, '_mnmlwp_hero_title', true ); $has_overlay = get_post_meta( $post->ID, '_mnmlwp_hero_has_overlay', true ); $has_overlay_checked = $has_overlay == 1 ? 'checked' : ''; $hero_overlay_color = get_post_meta( $post->ID, '_mnmlwp_hero_overlay_color', true ); $hero_overlay_opacity = get_post_meta( $post->ID, '_mnmlwp_hero_overlay_opacity', true ) ? get_post_meta( $post->ID, '_mnmlwp_hero_overlay_opacity', true ) : '30'; $has_radial_gradient = get_post_meta( $post->ID, '_mnmlwp_hero_has_radial_gradient', true ); $has_radial_gradient_checked = $has_radial_gradient == 1 ? 'checked' : ''; $has_skew = get_post_meta( $post->ID, '_mnmlwp_hero_has_skew', true ); $has_skew_checked = $has_skew == 1 ? 'checked' : ''; $background_position_horizontal = get_post_meta( $post->ID, '_mnmlwp_hero_background_position_horizontal', true ) ? get_post_meta( $post->ID, '_mnmlwp_hero_background_position_horizontal', true ) : 'center'; $background_position_vertical = get_post_meta( $post->ID, '_mnmlwp_hero_background_position_vertical', true ) ? get_post_meta( $post->ID, '_mnmlwp_hero_background_position_vertical', true ) : 'center'; $has_background_attachment_fixed = get_post_meta( $post->ID, '_mnmlwp_hero_background_attachment_fixed', true ); $has_background_attachment_fixed_checked = $has_background_attachment_fixed == 1 ? 'checked' : ''; echo '
    '; echo ''; echo '
     ' . esc_html__('Display colored overlay?', 'mnmlwp') . ''; echo '

    '; echo '
     ' . esc_html__('Radial gradient?', 'mnmlwp') . ''; echo '

    '; echo '
    '; echo '

     ' . esc_html__('Skew Overlay?', 'mnmlwp') . ''; echo '


    '; echo ''; foreach( array( 'center' => 'Center (default)', 'left' => 'Left', 'right' => 'Right' ) as $key => $val ) { ?>'; echo '

     ' . esc_html__('Fixed Background Position?', 'mnmlwp') . ''; echo '

    ' . esc_html__('Attention', 'mnmlwp'). '! ' . esc_html__('The fixed background setting overwrites the selected background position values. It is also not recommended to use the background overlay together with a fixed background, since the re-rendering of a transparent element might result in in jerky scrolling. The fixed background setting only takes effect with screen sizes >= 768px.', 'mnmlwp') . '

    '; } /** * When the post is saved, saves our custom data. * * @param int $post_id */ function mnmlwp_add_meta_boxes_save( $post_id ) { if ( ! isset( $_POST['mnmlwp_add_meta_boxes_nonce'] ) ) return; if ( ! wp_verify_nonce( $_POST['mnmlwp_add_meta_boxes_nonce'], 'mnmlwp_add_meta_boxes_nonce' ) ) return; if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } // Sanitize user input. $data['mnmlwp-show-sidebar'] = ! isset( $_POST['mnmlwp-show-sidebar'] ) ? 0 : 1; $data['mnmlwp-hide-page-title'] = ! isset( $_POST['mnmlwp-hide-page-title'] ) ? 0 : 1; $data['mnmlwp-hide-breadcrumbs'] = ! isset( $_POST['mnmlwp-hide-breadcrumbs'] ) ? 0 : 1; $data['mnmlwp-hide-contact-row'] = ! isset( $_POST['mnmlwp-hide-contact-row'] ) ? 0 : 1; $data['mnmlwp-hero-title'] = wp_kses_post( $_POST['mnmlwp-hero-title'] ); $data['mnmlwp-hero-has-overlay'] = ! isset( $_POST['mnmlwp-hero-has-overlay'] ) ? 0 : 1; $data['mnmlwp-hero-overlay-color'] = sanitize_text_field( $_POST['mnmlwp-hero-overlay-color'] ); $data['mnmlwp-hero-has-radial-gradient'] = ! isset( $_POST['mnmlwp-hero-has-radial-gradient'] ) ? 0 : 1; $data['mnmlwp-hero-overlay-opacity'] = (int)sanitize_text_field( $_POST['mnmlwp-hero-overlay-opacity'] ); if( $data['mnmlwp-hero-overlay-opacity'] > 100 ) { $data['mnmlwp-hero-overlay-opacity'] = 100; } if( $data['mnmlwp-hero-overlay-opacity'] < 0 ) { $data['mnmlwp-hero-overlay-opacity'] = 0; } $data['mnmlwp-hero-has-skew'] = ! isset( $_POST['mnmlwp-hero-has-skew'] ) ? 0 : 1; $data['mnmlwp-hero-background-position-horizontal'] = sanitize_text_field( $_POST['mnmlwp-hero-background-position-horizontal'] ); $data['mnmlwp-hero-background-position-vertical'] = sanitize_text_field( $_POST['mnmlwp-hero-background-position-vertical'] ); $data['mnmlwp-hero-background-attachment-fixed'] = ! isset( $_POST['mnmlwp-hero-background-attachment-fixed'] ) ? 0 : 1; update_post_meta( $post_id, '_mnmlwp_show_sidebar', $data['mnmlwp-show-sidebar'] ); update_post_meta( $post_id, '_mnmlwp_hide_page_title', $data['mnmlwp-hide-page-title'] ); update_post_meta( $post_id, '_mnmlwp_hide_breadcrumbs', $data['mnmlwp-hide-breadcrumbs'] ); update_post_meta( $post_id, '_mnmlwp_hide_contact_row', $data['mnmlwp-hide-contact-row'] ); update_post_meta( $post_id, '_mnmlwp_hero_title', $data['mnmlwp-hero-title'] ); update_post_meta( $post_id, '_mnmlwp_hero_has_overlay', $data['mnmlwp-hero-has-overlay'] ); update_post_meta( $post_id, '_mnmlwp_hero_overlay_color', $data['mnmlwp-hero-overlay-color'] ); update_post_meta( $post_id, '_mnmlwp_hero_has_radial_gradient', $data['mnmlwp-hero-has-radial-gradient'] ); update_post_meta( $post_id, '_mnmlwp_hero_overlay_opacity', $data['mnmlwp-hero-overlay-opacity'] ); update_post_meta( $post_id, '_mnmlwp_hero_has_skew', $data['mnmlwp-hero-has-skew'] ); update_post_meta( $post_id, '_mnmlwp_hero_background_position_horizontal', $data['mnmlwp-hero-background-position-horizontal'] ); update_post_meta( $post_id, '_mnmlwp_hero_background_position_vertical', $data['mnmlwp-hero-background-position-vertical'] ); update_post_meta( $post_id, '_mnmlwp_hero_background_attachment_fixed', $data['mnmlwp-hero-background-attachment-fixed'] ); } add_action( 'save_post', 'mnmlwp_add_meta_boxes_save' ); // Lists add mnmlWP class function mnmlwp_add_list_class_on_insert( $postarr ) { $postarr['post_content'] = str_replace('