max_num_pages; global $post; $postid = ''; if ( is_object($post) ) { $postid = $post->ID; } $bento_grid_mode = 'nogrid'; $bento_grid_setting = get_post_meta( $postid, 'bento_page_grid_mode', true ); if ( get_page_template_slug($postid) == 'page-grid.php' ) { if ( $bento_grid_setting == 'rows' ) { $bento_grid_mode = 'fitRows'; } else { $bento_grid_mode = 'packery'; } } $bento_full_width_grid = 'off'; if ( get_post_meta( $postid, 'bento_grid_full_width', true ) == 'on' ) { $bento_full_width_grid = 'on'; } wp_localize_script( 'bento-theme-scripts', 'bentoThemeVars', array( 'menu_config' => get_theme_mod( 'bento_menu_config' ), 'fixed_menu' => get_theme_mod( 'bento_fixed_header' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'query_vars' => json_encode( $bento_query->query ), 'max_pages' => $bento_max_pages, 'grid_mode' => $bento_grid_mode, 'full_width_grid' => $bento_full_width_grid, )); } function bento_localize_admin_scripts() { wp_localize_script( 'bento-admin-scripts', 'bentoAdminVars', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), )); } // Custom styles function bento_insert_custom_styles() { $custom_css = ''; // Grid global $post; if ( is_singular() && get_page_template_slug( $post->ID ) == 'page-grid.php' ) { $bento_grid_gutter = 10; $bento_grid_column = 3; $bento_grid_column_width = 33.3333; if ( get_post_meta($post->ID, 'bento_page_columns', true) > 0 ) { $bento_grid_column = get_post_meta($post->ID, 'bento_page_columns', true); } $bento_grid_column_width = 100 / $bento_grid_column; $bento_gutter_setting = get_post_meta($post->ID, 'bento_page_item_margins', true); if ( is_numeric($bento_gutter_setting) ) { $bento_grid_gutter = $bento_gutter_setting; } if ( strpos($bento_gutter_setting, 'px') !== false ) { $bento_grid_gutter = substr($bento_gutter_setting, 0, -2); } $bento_grid_double_width = $bento_grid_column_width * 2; $custom_css .= ' @media screen and (min-width: 10em) { .grid-item, .grid-sizer { width: 100%; } } @media screen and (min-width: 48em) { .grid-item, .grid-sizer { width: '.$bento_grid_column_width.'%; } .grid-masonry .grid-item.tile-2x1, .grid-masonry .grid-item.tile-2x2 { width: '.$bento_grid_double_width.'%; } } .grid-container { margin: 0 -'.$bento_grid_gutter.'px; } .grid-item-inner { padding: '.$bento_grid_gutter.'px; } .grid-rows .grid-item { margin-bottom: '.$bento_grid_gutter.'px; padding-bottom: '.$bento_grid_gutter.'px; } '; } // Individual page/post settings $postid = ''; if ( is_singular() ) { $postid = $post->ID; $custom_css .= ' .post-header-title h1, .entry-header h1 { color: '.get_post_meta( $postid, 'bento_title_color', true ).'; } .post-header-subtitle { color: '.get_post_meta( $postid, 'bento_subtitle_color', true ).'; } .site-content { background-color: '.get_post_meta( $postid, 'bento_page_background_color', true ).'; } '; if ( get_post_meta( $postid, 'bento_hide_title', true ) == 'on' ) { $custom_css .= ' .post-header-title h1, .entry-title:not(.grid-item-header .entry-title), .post-header-subtitle { display: none; } '; } if ( get_post_meta( $postid, 'bento_title_position', true ) == 'center' ) { $custom_css .= ' .post-header-title, .post-header-subtitle { margin-left: auto; margin-right: auto; } .post-header-title h1, .entry-header h1, .post-header-subtitle, .portfolio-filter { text-align: center; } '; } if ( get_post_meta( $postid, 'bento_uppercase_title', true ) == 'on' ) { $custom_css .= ' .post-header-title h1, .entry-header h1 { text-transform: uppercase; } '; } if ( get_post_meta( $postid, 'bento_activate_header', true ) != '' ) { $custom_css .= ' .post-header { background-image: url('.get_post_meta( $postid, 'bento_header_image', true ).'); } .post-header-overlay { background-color: '.get_post_meta( $postid, 'bento_header_overlay', true ).'; opacity: '.get_post_meta( $postid, 'bento_header_overlay_opacity', true ).'; } .post-header-subtitle { margin-bottom: 0; } .post-header-cta a, .post-header-cta div { border-color: '.get_post_meta( $postid, 'bento_cta_background_color', true ).'; } .post-header-cta .post-header-cta-primary { background-color: '.get_post_meta( $postid, 'bento_cta_background_color', true ).'; color: '.get_post_meta( $postid, 'bento_cta_text_color', true ).'; } .post-header-cta .post-header-cta-secondary { color: '.get_post_meta( $postid, 'bento_cta_background_color', true ).'; } .post-header-cta a:hover, .post-header-cta div:hover { border-color: '.get_post_meta( $postid, 'bento_cta_background_color_hover', true ).'; } .post-header-cta .post-header-cta-primary:hover { background-color: '.get_post_meta( $postid, 'bento_cta_background_color_hover', true ).'; } .post-header-cta .post-header-cta-secondary:hover { color: '.get_post_meta( $postid, 'bento_cta_background_color_hover', true ).'; } .post-header-cta .post-header-cta-secondary { color: '.get_post_meta( $postid, 'bento_cta_secondary_color', true ).'; border-color: '.get_post_meta( $postid, 'bento_cta_secondary_color', true ).'; } .post-header-cta .post-header-cta-secondary:hover { color: '.get_post_meta( $postid, 'bento_cta_secondary_color_hover', true ).'; border-color: '.get_post_meta( $postid, 'bento_cta_secondary_color_hover', true ).'; } @media screen and (min-width: 48em) { .post-header-title { padding-top: '.get_post_meta( $postid, 'bento_header_image_height', true ).'; padding-bottom: '.get_post_meta( $postid, 'bento_header_image_height', true ).'; } } '; if ( get_post_meta( $postid, 'bento_transparent_header', true ) == 'on' && get_theme_mod( 'bento_menu_config' ) != 'side' ) { $custom_css .= ' .site-header.no-fixed-header { background: transparent; position: absolute; top: 0; width: 100%; z-index: 1; } .primary-menu > li > .sub-menu { border-top-color: transparent; } .no-fixed-header .primary-menu > li > a, .site-header .mobile-menu-trigger, .site-header .ham-menu-trigger { color: '.get_post_meta( $postid, 'bento_menu_color', true ).'; } .no-fixed-header .primary-menu > li > a:hover { color: '.get_post_meta( $postid, 'bento_menu_color_hover', true ).'; } '; } } } return $custom_css; } // Dismiss novice header on button click function bento_dismiss_novice() { $option = $_POST['novice_option']; $new_value = 'dismissed'; if ( current_user_can('install_themes') ) { update_option( $option, $new_value ); } } // Load custom template tags if ( file_exists( get_template_directory() . '/includes/template-tags.php' ) ) { require_once get_template_directory() . '/includes/template-tags.php'; } // Set the content width function bento_theme_adjust_content_width() { if ( ! isset( $content_width ) ) { $content_width = 1080; } } // Enable threaded comments function bento_enable_threaded_comments() { if ( !is_admin() ) { if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1) ) wp_enqueue_script('comment-reply'); } } // Initialize navigation menus register_nav_menus( array( 'primary-menu' => 'Primary Menu', 'footer-menu' => 'Footer Menu', ) ); // Register sidebars function bento_register_sidebars() { if ( function_exists('register_sidebar') ) { register_sidebar( array( 'name'=>'Sidebar', 'id' => 'bento_sidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name'=>'Footer', 'id' => 'bento_footer', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', )); if ( class_exists( 'WooCommerce' ) ) { register_sidebar( array( 'name'=>'WooCommerce', 'id' => 'bento_woocommerce', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } } } // Initialize the metabox class if ( ! class_exists( 'CMB2_Bootstrap_2221' ) ) { if ( file_exists( get_template_directory() . '/includes/metaboxes/init.php' ) ) { require_once ( get_template_directory().'/includes/metaboxes/init.php' ); } } // Initialize the class for activating bundled plugins if ( file_exists( get_template_directory() . '/includes/plugin-activation/class-tgm-plugin-activation.php' ) ) { require_once ( get_template_directory().'/includes/plugin-activation/class-tgm-plugin-activation.php' ); } function bento_register_required_plugins() { $plugins = array( array( 'name' => 'Page Builder', 'slug' => 'siteorigin-panels', 'required' => false, ), array( 'name' => 'Page Builder: Extra Elements', 'slug' => 'so-widgets-bundle', 'required' => false, ), ); // Array of configuration settings $config = array( 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to bundled plugins. 'menu' => 'bento-install-plugins', // Menu slug. 'parent_slug' => 'themes.php', // Parent menu slug. 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. '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. ); tgmpa( $plugins, $config ); } // Custom excerpt ellipses function bento_custom_excerpt_more($more) { return esc_html__('Continue reading', 'bento').' →'; } // Extra body classes function bento_extra_classes( $classes ) { global $post; $postid = ''; if ( is_object($post) ) { $postid = $post->ID; } // Sidebar configuration if ( is_singular() ) { if ( class_exists( 'WooCommerce' ) && is_woocommerce() ) { if ( ! is_active_sidebar( 'bento_woocommerce' ) || get_post_meta( $postid, 'bento_sidebar_layout', true ) == 'full-width' || is_cart() || is_checkout() ) { $classes[] = 'no-sidebar'; } else { $classes[] = 'has-sidebar'; if ( get_post_meta( $postid, 'bento_sidebar_layout', true ) == 'left-sidebar' ) { $classes[] = 'left-sidebar'; } else { $classes[] = 'right-sidebar'; } } } else { if ( ( ! is_active_sidebar( 'bento_sidebar' ) && get_post_type( $postid ) != 'project' ) || get_post_meta( $postid, 'bento_sidebar_layout', true ) == 'full-width' ) { $classes[] = 'no-sidebar'; } else { $classes[] = 'has-sidebar'; if ( get_post_meta( $postid, 'bento_sidebar_layout', true ) != '' ) { $classes[] = get_post_meta( $postid, 'bento_sidebar_layout', true ); } else { $classes[] = 'right-sidebar'; } } } } else { if ( class_exists( 'WooCommerce' ) && is_woocommerce() ) { if ( is_shop() ) { $page_id = woocommerce_get_page_id('shop'); if ( get_post_meta( $page_id, 'bento_sidebar_layout', true ) == 'full-width' ) { $classes[] = 'no-sidebar'; } else { $classes[] = get_post_meta( $page_id, 'bento_sidebar_layout', true ); $classes[] = 'has-sidebar'; } } else { if ( is_active_sidebar( 'bento_woocommerce' ) ) { $classes[] = 'has-sidebar'; $classes[] = 'right-sidebar'; } else { $classes[] = 'no-sidebar'; } } } else { if ( is_active_sidebar( 'bento_sidebar' ) ) { $classes[] = 'has-sidebar'; $classes[] = 'right-sidebar'; } else { $classes[] = 'no-sidebar'; } } } // Boxed website layout if ( get_theme_mod( 'bento_website_layout' ) == 1 ) { $classes[] = 'boxed-layout'; } // Extended header if ( get_post_meta( $postid, 'bento_activate_header', true ) == 'on' ) { $classes[] = 'extended-header'; } // Header configuration if ( get_theme_mod( 'bento_menu_config' ) == 1 ) { $classes[] = 'header-centered'; } else if ( get_theme_mod( 'bento_menu_config' ) == 2 ) { $classes[] = 'header-hamburger'; } else if ( get_theme_mod( 'bento_menu_config' ) == 3 ) { $classes[] = 'header-side'; } else { $classes[] = 'header-default'; } // WooCommerce shop columns if ( class_exists( 'WooCommerce' ) && is_shop() ) { $classes[] = 'shop-columns-'.get_theme_mod( 'bento_wc_shop_columns' ); } return $classes; } // Adds a class to post depending on whether it has a thumbnail function bento_has_thumb_class($classes) { global $post; $postid = ''; if ( is_object($post) ) { $postid = $post->ID; } if ( has_post_thumbnail($postid) ) { $classes[] = 'has-thumb'; } else { $classes[] = 'no-thumb'; } return $classes; } // Remove prefixes from archive page titles function bento_cleaner_archive_titles($title) { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '', false ); } elseif ( is_author() ) { $title = '' . get_the_author() . '' ; } return $title; } // Allow uploading fonts function bento_font_uploading( $existing_mimes ){ $existing_mimes['svg'] = 'image/svg+xml'; $existing_mimes['ttf'] = 'application/x-font-ttf'; $existing_mimes['otf'] = 'application/x-font-opentype'; $existing_mimes['woff'] = 'application/font-woff'; $existing_mimes['eot'] = 'application/vnd.ms-fontobject'; return $existing_mimes; } // Count the number of active widgets function bento_count_footer_widgets( $params ) { global $wp_registered_widgets; global $sidebars_widgets; $widget_count = 0; if ( isset ( $sidebars_widgets['bento_footer'] ) ) { foreach ( $sidebars_widgets['bento_footer'] as $widget_id ) { if ( function_exists( 'pll_current_language' ) && is_object( $wp_registered_widgets[ $widget_id ]['callback'][0] ) ) { $widget_options = get_option( 'widget_' . $wp_registered_widgets[ $widget_id ]['callback'][0]->id_base ); $widget_number = preg_replace( '/[^0-9.]+/i', '', $widget_id ); $current_widget_options = $widget_options[ $widget_number ]; if ( $current_widget_options['pll_lang'] == pll_current_language() ) { $widget_count++; } } else { $widget_count ++; } } } if ( isset( $params[0]['id'] ) && $params[0]['id'] == 'bento_footer' ) { $class = 'class="column-'.$widget_count.' '; $params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']); } return $params; } // Load more posts with ajax function bento_ajax_pagination() { $url = wp_get_referer(); $post_id = url_to_postid( $url ); global $bento_parent_page_id; $bento_parent_page_id = $post_id; $query_args = bento_grid_query(); $query_args['paged'] = $_POST['page'] + 1; $post_types = get_post_meta( $post_id, 'bento_page_content_types', true ); $query_args['post_type'] = $post_types; $bento_grid_number_items = get_post_meta( $post_id, 'bento_page_number_items', true ); if ( ctype_digit($bento_grid_number_items) && ctype_digit($bento_grid_number_items) != 0 ) { $query_args['posts_per_page'] = (int)$bento_grid_number_items; } else { $query_args['posts_per_page'] = get_option('posts_per_page'); } $pagination_query = new WP_Query( $query_args ); if ( $pagination_query->have_posts() ) { while ( $pagination_query->have_posts() ) { $pagination_query->the_post(); // Include the page content if ( get_page_template_slug( $post_id ) == 'page-grid.php' ) { get_template_part( 'content', 'grid' ); } else { get_template_part( 'content' ); } } } die(); } // Custom query for grid pages function bento_grid_query() { global $post; global $post_id; if ( isset( $post->ID ) ) { $post_id = $post->ID; } $bento_grid_query_args = array(); $post_types = get_post_meta( $post_id, 'bento_page_content_types', true ); $bento_grid_query_args['post_type'] = $post_types; if ( is_front_page() ) { $bento_paged = ( get_query_var('page') ) ? get_query_var('page') : 1; } else { $bento_paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; } $bento_grid_query_args['paged'] = $bento_paged; $bento_grid_number_items = get_post_meta( $post_id, 'bento_page_number_items', true ); if ( ctype_digit($bento_grid_number_items) && ctype_digit($bento_grid_number_items) != 0 ) { $bento_grid_query_args['posts_per_page'] = (int)$bento_grid_number_items; } else { $bento_grid_query_args['posts_per_page'] = get_option('posts_per_page'); } return $bento_grid_query_args; } // Page settings metaboxes function bento_metaboxes() { // Define strings $bento_prefix = 'bento_'; $bento_ep_url = wp_kses( 'Expansion Pack', array( 'a' => array( 'href' => array(), 'target' => array(), ), ) ); // Function to add a multicheck with post types add_action( 'cmb2_render_multicheck_posttype', 'bento_render_multicheck_posttype', 10, 5 ); function bento_render_multicheck_posttype( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { if ( version_compare( CMB2_VERSION, '2.2.2', '>=' ) ) { $field_type_object->type = new CMB2_Type_Radio( $field_type_object ); } $cpts = array( 'post', 'project' ); if ( class_exists( 'WooCommerce' ) ) { $cpts[] = 'product'; } $options = ''; $i = 1; $values = (array) $escaped_value; if ( $cpts ) { foreach ( $cpts as $cpt ) { $args = array( 'value' => $cpt, 'label' => $cpt, 'type' => 'checkbox', 'name' => $field->args['_name'] . '[]', ); if ( in_array( $cpt, $values ) ) { $args[ 'checked' ] = 'checked'; } if ( $cpt == 'project' && get_option( 'bento_ep_license_status' ) != 'valid' ) { $args[ 'disabled' ] = 'disabled'; } $options .= $field_type_object->list_input( $args, $i ); $i++; } } $classes = false === $field->args( 'select_all_button' ) ? 'cmb2-checkbox-list no-select-all cmb2-list' : 'cmb2-checkbox-list cmb2-list'; echo $field_type_object->radio( array( 'class' => $classes, 'options' => $options ), 'multicheck_posttype' ); } // SEO settings $bento_seo_settings = new_cmb2_box( array( 'id' => 'seo_settings_metabox', 'title' => esc_html__( 'SEO Settings', 'bento' ), 'object_types' => array( 'post', 'page', 'project', 'product' ), 'context' => 'normal', 'priority' => 'low', 'show_names' => true, ) ); if ( get_option( 'bento_ep_license_status' ) == 'valid' ) { $bento_seo_settings->add_field( array( 'name' => esc_html__( 'Meta title', 'bento' ), 'desc' => esc_html__( 'Input the meta title - the text to be used by search engines as well as browser tabs (recommended max length - 60 symbols); the post title will be used by default if this field is empty.', 'bento' ), 'id' => $bento_prefix . 'meta_title', 'type' => 'text', ) ); $bento_seo_settings->add_field( array( 'name' => esc_html__( 'Meta description', 'bento' ), 'desc' => esc_html__( 'Input the meta description - the text to be used by search engines on search result pages (recommended max length - 160 symbols); the first part of the post body will be used by default is this field is left blank.', 'bento' ), 'id' => $bento_prefix . 'meta_description', 'type' => 'textarea', 'attributes' => array( 'rows' => 3, ), ) ); } else { $bento_seo_settings->add_field( array( 'name' => esc_html__( 'Meta title', 'bento' ), 'desc' => sprintf( esc_html__( 'Install the %s to set the meta title for individual posts and pages', 'bento' ), $bento_ep_url ), 'id' => $bento_prefix . 'meta_title', 'type' => 'text', 'attributes' => array( 'readonly' => 'readonly', 'disabled' => 'disabled', ), ) ); $bento_seo_settings->add_field( array( 'name' => esc_html__( 'Meta description', 'bento' ), 'desc' => sprintf( esc_html__( 'Install the %s to set the meta description for individual posts and pages', 'bento' ), $bento_ep_url ), 'id' => $bento_prefix . 'meta_description', 'type' => 'textarea', 'attributes' => array( 'rows' => 3, 'readonly' => 'readonly', 'disabled' => 'disabled', ), ) ); } // General page/post settings $bento_general_settings = new_cmb2_box( array( 'id' => 'post_settings_metabox', 'title' => esc_html__( 'General Settings', 'bento' ), 'object_types' => array( 'post', 'page', 'project', 'product' ), 'context' => 'normal', 'priority' => 'low', 'show_names' => true, ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Sidebar layout', 'bento' ), 'desc' => esc_html__( 'Choose whether to display a sidebar and on which side of the content', 'bento' ), 'id' => $bento_prefix . 'sidebar_layout', 'type' => 'select', 'options' => array( 'right-sidebar' => esc_html__( 'Right Sidebar (default)', 'bento' ), 'left-sidebar' => esc_html__( 'Left Sidebar', 'bento' ), 'full-width' => esc_html__( 'Full Width', 'bento' ), ), 'default' => 'right-sidebar', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Page background color', 'bento' ), 'desc' => esc_html__( 'Choose the background color for current page/post. This will override any settings in the Theme Options', 'bento' ), 'id' => $bento_prefix . 'page_background_color', 'type' => 'colorpicker', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Hide featured image', 'bento' ), 'desc' => esc_html__( 'Check this option if you DO NOT want to display the featured image (thumbnail) on the page; it will still be used for the corresponding tile on the "columns" or "rows" grid pages.', 'bento' ), 'id' => $bento_prefix . 'hide_thumb', 'type' => 'checkbox', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Hide title', 'bento' ), 'desc' => esc_html__( 'Check this option if you DO NOT want to display the title on the page', 'bento' ), 'id' => $bento_prefix . 'hide_title', 'type' => 'checkbox', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Uppercase title', 'bento' ), 'desc' => esc_html__( 'Check this option if you want the page title to be entirely in uppercase (useful for landing pages).', 'bento' ), 'id' => $bento_prefix . 'uppercase_title', 'type' => 'checkbox', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Title position', 'bento' ), 'desc' => esc_html__( 'Choose the position of the title; default is left-aligned.', 'bento' ), 'id' => $bento_prefix . 'title_position', 'type' => 'select', 'options' => array( 'left' => esc_html__( 'Left-aligned (default)', 'bento' ), 'center' => esc_html__( 'Centered', 'bento' ), ), 'default' => 'left', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Title color', 'bento' ), 'desc' => esc_html__( 'Choose the text color for the title of this post. This will override any settings in the Theme Options', 'bento' ), 'id' => $bento_prefix . 'title_color', 'type' => 'colorpicker', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Subtitle', 'bento' ), 'desc' => esc_html__( 'Input the subtitle for the page.', 'bento' ), 'id' => $bento_prefix . 'subtitle', 'type' => 'textarea', ) ); $bento_general_settings->add_field( array( 'name' => esc_html__( 'Subtitle color', 'bento' ), 'desc' => esc_html__( 'Choose the text color for the subtitle of this page; default is #999999 (light grey).', 'bento' ), 'id' => $bento_prefix . 'subtitle_color', 'type' => 'colorpicker', 'default' => '#999999', ) ); // Extended header settings $bento_header_settings = new_cmb2_box( array( 'id' => 'post_header_metabox', 'title' => esc_html__( 'Page Header Settings', 'bento' ), 'object_types' => array( 'post', 'page', 'project', 'product' ), 'context' => 'normal', 'priority' => 'low', 'show_names' => true, ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Activate extended header', 'bento' ), 'desc' => esc_html__( 'Check this box to enable extended header options such as header image and call-to-action-buttons.', 'bento' ), 'id' => $bento_prefix . 'activate_header', 'type' => 'checkbox', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Header height', 'bento' ), 'desc' => esc_html__( 'Choose the title top and bottom padding, which will affect the header height; default is 10%', 'bento' ), 'id' => $bento_prefix . 'header_image_height', 'type' => 'select', 'options' => array( '' => esc_html__( 'Choose value', 'bento' ), '5%' => '5%', '10%' => esc_html__( '10% (default)', 'bento' ), '15%' => '15%', '20%' => '20%', '25%' => '25%', ), 'default' => '10%', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Header image', 'bento' ), 'desc' => esc_html__( 'Upload the image to serve as the header; recommended size is 1400x300 pixels and above, yet mind the file size - excessively large images may worsen user experience', 'bento' ), 'id' => $bento_prefix . 'header_image', 'type' => 'file', ) ); if ( get_option( 'bento_ep_license_status' ) == 'valid' ) { $bento_header_settings->add_field( array( 'name' => esc_html__( 'Header video', 'bento' ), 'desc' => esc_html__( 'Upload the video file to be used as header background; if this is active, the header image will serve as a placeholder for mobile devices; .mp4 files are recommended, but you can also use .ogv and .webm formats. Please mind the file size - excessively large images may worsen user experience', 'bento' ), 'id' => $bento_prefix . 'header_video_source', 'type' => 'file', ) ); } $bento_header_settings->add_field( array( 'name' => esc_html__( 'Header image overlay color', 'bento' ), 'desc' => esc_html__( 'Choose the color for the image overlay, designed to make the title text stand out more clearly', 'bento' ), 'id' => $bento_prefix . 'header_overlay', 'type' => 'colorpicker', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Header image overlay opacity', 'bento' ), 'desc' => esc_html__( 'Choose the opacity level for the image overlay; 0.0 is fully transparent, 1.0 is fully opaque, default is 0.3', 'bento' ), 'id' => $bento_prefix . 'header_overlay_opacity', 'type' => 'select', 'options' => array( '' => esc_html__( 'Choose value', 'bento' ), '0.0' => '0.0', '0.1' => '0.1', '0.2' => '0.2', '0.3' => esc_html__( '0.3 (default)', 'bento' ), '0.4' => '0.4', '0.5' => '0.5', '0.6' => '0.6', '0.7' => '0.7', '0.8' => '0.8', '0.9' => '0.9', '1.0' => '1.0', ), 'default' => '0.3', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Transparent website header', 'bento' ), 'desc' => esc_html__( 'Check this option to make the website header (the top area with the menu and the logo) look like a transparent overlay on top of the header image on this page.', 'bento' ), 'id' => $bento_prefix . 'transparent_header', 'type' => 'checkbox', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Website menu color on this page', 'bento' ), 'desc' => esc_html__( 'Choose the color for the website menu on this page (useful for the transparent header).', 'bento' ), 'id' => $bento_prefix . 'menu_color', 'type' => 'colorpicker', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Website menu mouse-hover color on this page', 'bento' ), 'desc' => esc_html__( 'Choose the mouse-over color for the website menu on this page (useful for the transparent header).', 'bento' ), 'id' => $bento_prefix . 'menu_color_hover', 'type' => 'colorpicker', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Call-to-action button text', 'bento' ), 'desc' => esc_html__( 'Input the text for an optional call-to-action button.', 'bento' ), 'id' => $bento_prefix . 'cta_primary_text', 'type' => 'text_medium', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Call-to-action button link', 'bento' ), 'desc' => esc_html__( 'Paste the URL link to point the call-to-action button to; leave this blank to scroll the page below the header on button click.', 'bento' ), 'id' => $bento_prefix . 'cta_primary_link', 'type' => 'text', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Call-to-action button background color', 'bento' ), 'desc' => esc_html__( 'Choose the background color for the call-to-action buttons; default is #00b285 (green-blue).', 'bento' ), 'id' => $bento_prefix . 'cta_background_color', 'type' => 'colorpicker', 'default' => '#00b285', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Call-to-action button mouse-over background color', 'bento' ), 'desc' => esc_html__( 'Choose the text color for the call-to-action buttons on hover; default is #00906c (dark-green).', 'bento' ), 'id' => $bento_prefix . 'cta_background_color_hover', 'type' => 'colorpicker', 'default' => '#00906c', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Call-to-action button text color', 'bento' ), 'desc' => esc_html__( 'Choose the text color for the primary call-to-action button; default is #ffffff (white).', 'bento' ), 'id' => $bento_prefix . 'cta_text_color', 'type' => 'colorpicker', 'default' => '#ffffff', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Secondary call-to-action button text', 'bento' ), 'desc' => esc_html__( 'Input the text for an optional secondary call-to-action button.', 'bento' ), 'id' => $bento_prefix . 'cta_secondary_text', 'type' => 'text_medium', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Secondary call-to-action button link', 'bento' ), 'desc' => esc_html__( 'Paste the URL link to point the secondary call-to-action button to; leave this blank to scroll the page below the header on button click.', 'bento' ), 'id' => $bento_prefix . 'cta_secondary_link', 'type' => 'text', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Secondary call-to-action button color', 'bento' ), 'desc' => esc_html__( 'Choose the text and border color for the secondary call-to-action button; default is #00b285 (green-blue) or the same as the primary button.', 'bento' ), 'id' => $bento_prefix . 'cta_secondary_color', 'type' => 'colorpicker', ) ); $bento_header_settings->add_field( array( 'name' => esc_html__( 'Secondary call-to-action button mouse-over color', 'bento' ), 'desc' => esc_html__( 'Choose the text and border color for the secondary call-to-action button on hover; default is #00906c (dark-green) or the same as the primary button.', 'bento' ), 'id' => $bento_prefix . 'cta_secondary_color_hover', 'type' => 'colorpicker', ) ); // Map header settings if ( get_option( 'bento_ep_license_status' ) == 'valid' ) { $bento_headermap_settings = new_cmb2_box( array( 'id' => 'post_headermap_metabox', 'title' => esc_html__( 'Map Header', 'bento' ), 'object_types' => array( 'page' ), 'context' => 'normal', 'priority' => 'low', 'show_names' => true, ) ); $bento_headermap_settings->add_field( array( 'name' => esc_html__( 'Activate Google Maps header', 'bento' ), 'desc' => esc_html__( 'Check this box to enable Google Maps header; note that this will deactivate the extended header image/video.', 'bento' ), 'id' => $bento_prefix . 'activate_headermap', 'type' => 'checkbox', ) ); $maps_key_url = 'https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key'; $maps_key_text = sprintf( wp_kses( esc_html__( 'Input the API key for this instance of Maps - you can find detailed instructions on generating your API key here.', 'bento' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( $maps_key_url ) ); $bento_headermap_settings->add_field( array( 'name' => esc_html__( 'Google Maps API key', 'bento' ), 'desc' => $maps_key_text, 'id' => $bento_prefix . 'headermap_key', 'type' => 'text', ) ); $bento_headermap_settings->add_field( array( 'name' => esc_html__( 'Map center location', 'bento' ), 'desc' => esc_html__( 'Input the address (country, city, or exact address) of the location on which to center the map.', 'bento' ), 'id' => $bento_prefix . 'headermap_center', 'type' => 'text', ) ); $bento_headermap_settings->add_field( array( 'name' => esc_html__( 'Map height', 'bento' ), 'desc' => esc_html__( 'Select the height of the map, in pixels.', 'bento' ), 'id' => $bento_prefix . 'headermap_height', 'type' => 'select', 'options' => array( '100' => '100', '200' => '200', '300' => '300', '400' => esc_html__( '400 (default)', 'bento' ), '500' => '500', '600' => '600', '700' => '700', ), 'default' => '400', ) ); $bento_headermap_settings->add_field( array( 'name' => esc_html__( 'Map zoom level', 'bento' ), 'desc' => esc_html__( 'Choose the zoom level for the map, 1 being entire world and 20 being individual buildings.', 'bento' ), 'id' => $bento_prefix . 'headermap_zoom', 'type' => 'select', 'options' => array( 1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12', 13 => '13', 14 => '14', 15 => esc_html__( '15 (default)', 'bento' ), 16 => '16', 17 => '17', 18 => '18', 19 => '19', 20 => '20', ), 'default' => 15, ) ); $snazzymaps_url = 'https://snazzymaps.com'; $snazzymaps_link = sprintf( wp_kses( esc_html__( 'You can insert the code for custom map styling here; check Snazzymaps.com for ready-made snippets: when on the page of the particular style, click on the "Copy" button or simply select and copy the code under the "Javascript Style Array" heading.', 'bento' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $snazzymaps_url ) ); $bento_headermap_settings->add_field( array( 'name' => esc_html__( 'Map custom style', 'bento' ), 'desc' => $snazzymaps_link, 'id' => $bento_prefix . 'headermap_style', 'type' => 'textarea', ) ); } // Masonry tile settings $bento_tile_settings = new_cmb2_box( array( 'id' => 'tile_settings_metabox', 'title' => esc_html__( 'Masonry Tile Settings / Only for displaying on "Grid" page template with "Masonry" grid type', 'bento' ), 'object_types' => array( 'post', 'project', 'product' ), 'context' => 'normal', 'priority' => 'low', 'show_names' => true, ) ); $bento_tile_settings->add_field( array( 'name' => esc_html__( 'Tile size', 'bento' ), 'desc' => esc_html__( 'Choose the size of the tile relative to the default 1x1 tile (defined by the number of columns in the grid)', 'bento' ), 'id' => $bento_prefix . 'tile_size', 'type' => 'select', 'options' => array( '1x1' => esc_html__( '1x1 (default)', 'bento' ), '1x2' => '1x2', '2x1' => '2x1', '2x2' => '2x2', ), 'default' => '1x1', ) ); $bento_tile_settings->add_field( array( 'name' => esc_html__( 'Tile overlay color', 'bento' ), 'desc' => esc_html__( 'Choose the color for an overlay for the tile background image; default is #666666 (grey)', 'bento' ), 'id' => $bento_prefix . 'tile_overlay_color', 'type' => 'colorpicker', 'default' => '#666666', ) ); $bento_tile_settings->add_field( array( 'name' => esc_html__( 'Tile image', 'bento' ), 'desc' => esc_html__( 'Upload the image to be used in the tile; if this field is empty, the featured image (thumbnail) will be used.', 'bento' ), 'id' => $bento_prefix . 'tile_image', 'type' => 'file', ) ); $bento_tile_settings->add_field( array( 'name' => esc_html__( 'Tile overlay opacity', 'bento' ), 'desc' => esc_html__( 'Select the opacity level for an overlay for the tile background image, 0 is fully transparent (default is 0.6)', 'bento' ), 'id' => $bento_prefix . 'tile_overlay_opacity', 'type' => 'select', 'options' => array( '' => esc_html__( 'Choose value', 'bento' ), '0.0' => '0.0', '0.1' => '0.1', '0.2' => '0.2', '0.3' => '0.3', '0.4' => '0.4', '0.5' => '0.5', '0.6' => esc_html__( '0.6 (default)', 'bento' ), '0.7' => '0.7', '0.8' => '0.8', '0.9' => '0.9', '1.0' => '1.0', ), 'default' => '0.6', ) ); $bento_tile_settings->add_field( array( 'name' => esc_html__( 'Tile text color', 'bento' ), 'desc' => esc_html__( 'Choose the color for the text inside the tile; default is #ffffff (white)', 'bento' ), 'id' => $bento_prefix . 'tile_text_color', 'type' => 'colorpicker', 'default' => '#ffffff', ) ); $bento_tile_settings->add_field( array( 'name' => esc_html__( 'Tile text size', 'bento' ), 'desc' => esc_html__( 'Choose the text size for the tile; default is 16px', 'bento' ), 'id' => $bento_prefix . 'tile_text_size', 'type' => 'select', 'options' => array( '12' => '12', '13' => '13', '14' => '14', '16' => esc_html__( '16 (default)', 'bento' ), '18' => '18', '20' => '20', '24' => '24', '28' => '28', ), 'default' => '16', ) ); // Grid page settings $bento_grid_settings = new_cmb2_box( array( 'id' => 'grid_settings_metabox', 'title' => esc_html__( 'Grid Settings', 'bento' ), 'object_types' => array( 'page' ), 'context' => 'normal', 'priority' => 'low', 'show_names' => true, ) ); $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Grid mode', 'bento' ), 'desc' => esc_html__( 'Choose which grid type to use on this page', 'bento' ), 'id' => $bento_prefix . 'page_grid_mode', 'type' => 'select', 'options' => array( 'columns' => 'Columns', 'masonry' => 'Masonry', 'rows' => 'Rows', ), 'default' => 'columns', ) ); $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Number of columns', 'bento' ), 'desc' => esc_html__( 'Select the number of columns in the grid or number of base tiles per line in masonry', 'bento' ), 'id' => $bento_prefix . 'page_columns', 'type' => 'select', 'options' => array( '1' => '1', '2' => '2', '3' => esc_html__( '3 (default)', 'bento' ), '4' => '4', '5' => '5', '6' => '6', ), 'default' => '3', ) ); if ( get_option( 'bento_ep_license_status' ) == 'valid' ) { $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Content types', 'bento' ), 'id' => $bento_prefix . 'page_content_types', 'type' => 'multicheck_posttype', 'default' => 'post', ) ); } else { $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Content types', 'bento' ), 'desc' => sprintf( esc_html__( 'Install the %s to use the "project" (portfolio) content type', 'bento' ), $bento_ep_url ), 'id' => $bento_prefix . 'page_content_types', 'type' => 'multicheck_posttype', 'default' => 'post', ) ); } $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Items per page', 'bento' ), 'desc' => esc_html__( 'Input the number of items to display per page; default is the number set in "Settings - Reading" admin section', 'bento' ), 'id' => $bento_prefix . 'page_number_items', 'type' => 'text_small', 'default' => '10', ) ); $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Item margins', 'bento' ), 'desc' => esc_html__( 'Input the margin width in pixels (default is 10)', 'bento' ), 'id' => $bento_prefix . 'page_item_margins', 'type' => 'text_small', 'default' => '10', ) ); $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Hide tile overlays', 'bento' ), 'desc' => esc_html__( 'Only display tile overlays in masonry on mouse hover', 'bento' ), 'id' => $bento_prefix . 'hide_tile_overlays', 'type' => 'checkbox', ) ); $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Force full width', 'bento' ), 'desc' => esc_html__( 'Check this option if you want the grid to stretch the entire width of the screen', 'bento' ), 'id' => $bento_prefix . 'grid_full_width', 'type' => 'checkbox', ) ); $bento_grid_settings->add_field( array( 'name' => esc_html__( 'Load items on same page', 'bento' ), 'desc' => esc_html__( 'Replace the standard pagination with a button which loads next items without refreshing the page', 'bento' ), 'id' => $bento_prefix . 'page_ajax_load', 'type' => 'checkbox', ) ); } // SiteOrigin Content Builder integration // Add extra attribute to rows function bento_extra_row_attr( $attributes, $grid ) { if ( ! empty( $grid['style'] ) ) { if ( ! empty ( $grid['style']['class'] ) ) { $attributes['data-extraid'] = $grid['style']['class']; } } return $attributes; } // Add divs with ids before each row which has extra classes (useful for one-page layouts) function bento_content_builder_row_ids( $code, $grid, $attr ) { if ( ! empty( $attr['data-extraid'] ) ) { $rowclasses = $attr['data-extraid']; $extradiv = ''; return $extradiv; } } // WooCommerce integration // Declare new content wrappers function bento_woo_wrapper_start() { echo '
'; } function bento_woo_wrapper_end() { echo '
'; $page_id = ''; global $post; if ( is_shop() ) { $page_id = woocommerce_get_page_id('shop'); } else if ( $post ) { $page_id = $post->ID; } if ( is_active_sidebar( 'bento_woocommerce' ) ) { if ( get_post_meta( $page_id, 'bento_sidebar_layout', true ) != 'full-width' || is_product_category() ) { echo ''; } } echo '
'; } // Remove plugin styling function bento_woo_dequeue_styles( $enqueue_styles ) { unset( $enqueue_styles['woocommerce-general'] ); return $enqueue_styles; } // Hide image placeholder for products without thumbnails function woocommerce_template_loop_product_thumbnail() { global $post; if ( has_post_thumbnail() ) { echo get_the_post_thumbnail( $post->ID, 'shop_catalog' ); } } // Change the "Add to cart" button text function bento_woo_custom_cart_button_text() { return ''; } // Custom number of products per shop page function bento_woo_loop_perpage() { $bento_wc_shop_num = get_theme_mod( 'bento_wc_shop_number_items' ); return 'return '.$bento_wc_shop_num.';'; } // Custom number of columns on the shop page function bento_woo_loop_columns() { $bento_wc_shop_col = (int)get_theme_mod( 'bento_wc_shop_columns' ); return $bento_wc_shop_col; } // Adjust single product layout so that the sections flow more naturally function bento_woo_single_product_sections_start() { echo '
'; } function bento_woo_single_product_sections_end() { echo '
'; woocommerce_output_related_products(); } // Custom search form function bento_woo_custom_product_searchform( $form ) { $form = ' '; return $form; } ?>