td { padding-right: 10px; } '; $inline_styles .= '.option-wm-nutrition-facts .repeater-cell select { width: 100%; } '; $inline_styles .= '.wm-meta-wrap .repeater-cell .option >td { padding: 10px; } '; $inline_styles .= '.option.form-input-tip > th, .option.form-input-tip > td, .option.form-input-tip:hover > th, .option.form-input-tip:hover > td { background-color: #0aac8e; color: #fff; } '; $inline_styles .= '.option.form-input-tip p.description { color: #fff; opacity: .75; } .option.form-input-tip input { font-weight: 800; } '; $inline_styles .= '.repeater-cell tbody tr { display: inline-block; width: 50% !important; vertical-align: top; } '; $inline_styles .= '.repeater-cell tbody tr { display: inline-block; width: 70% !important; vertical-align: top; } '; $inline_styles .= '.repeater-cell tbody tr.form-input-tip { width: 30% !important; } '; $inline_styles .= '.repeater-cell { table-layout: fixed; } '; $inline_styles .= '.repeater-cell td { display: block; margin: 0; box-sizing: border-box; } '; $inline_styles .= '.repeater-cell p.description { display: none; } '; //Enqueue (only on specific admin pages) if ( 'post' === $current_screen->base ) { //Styles wp_add_inline_style( 'wm-metabox-styles', apply_filters( 'wmhook_esc_css', $inline_styles ) ); //Scripts wp_enqueue_script( 'suggest' ); wp_enqueue_script( 'wm-admin', wm_get_stylesheet_directory_uri( 'js/admin.js' ), array( 'suggest', 'wm-metabox-scripts' ), WM_SCRIPTS_VERSION, true ); } } } // /wm_admin_assets_plus /** * 30) Additional taxonomies */ /** * Create new ingredients taxonomy terms * * @param int $post_id */ if ( ! function_exists( 'wm_create_ingredients' ) ) { function wm_create_ingredients( $post_id = null ) { //Helper variables $taxonomy = 'ingredients'; //Requirements check if ( empty( $post_id ) ) { $post_id = get_the_ID(); } if ( empty( $post_id ) || ! taxonomy_exists( $taxonomy ) ) { return false; } //Helper variables $post_id = absint( $post_id ); $terms = array(); //Processing if ( is_admin() && current_user_can( 'edit_posts', $post_id ) && ! wp_is_post_revision( $post_id ) && isset( $_REQUEST ) && ! empty( $_REQUEST ) && isset( $_REQUEST['wm-ingredients'] ) && ! empty( $_REQUEST['wm-ingredients'] ) ) { foreach ( $_REQUEST['wm-ingredients'] as $key => $item ) { if ( $term = trim( $item['ingredient'] ) ) { //If the term doesn't exist, create it if ( ! empty( $term ) && ! term_exists( $term, $taxonomy ) ) { wp_insert_term( $term, $taxonomy ); } $post_term = get_term_by( 'name', $term, $taxonomy ); $terms[] = $post_term->slug; } } // /foreach wp_set_object_terms( $post_id, array_unique( $terms ), $taxonomy ); } } } // /wm_create_ingredients /** * 40) Display recipe */ /** * Is recipe page? */ if ( ! function_exists( 'wm_is_recipe' ) ) { function wm_is_recipe() { return ( function_exists( 'wma_meta_option' ) && wma_meta_option( 'instructions' ) ); } } // /wm_is_recipe /** * Display recipe * * @link https://support.google.com/webmasters/answer/173379 * @link http://schema.org/Recipe * * @param string $content */ if ( ! function_exists( 'wm_content_recipe' ) ) { function wm_content_recipe( $content ) { //Requirements check if ( ! is_single() || ! wm_is_recipe() ) { return $content; } //Helper variables $output = array(); if ( ! trim( $content ) ) { $prefix = ''; } else { $prefix = '
' . __( 'Skip to recipe', 'wm_domain' ) . '
'; } //Preparing output $output[10] = '' . sprintf( __( '%s is premium WordPress theme developed by WebMan. You can obtain other professional WordPress themes at WebManDesign.eu. Thank you for using this awesome theme!', 'wm_domain' ), '' . WM_THEME_NAME . '', add_query_arg( array( 'utm_source' => WM_THEME_SHORTNAME . '-theme-credits' ), esc_url( WM_THEME_AUTHOR_URI ) ) ) . '
'; /** * Merge theme options and sort theme out */ $options = array_merge( $options, $plus_options ); ksort( $options ); //Output return $options; } } // /wm_theme_options_plus /** * Credits text */ if ( ! function_exists( 'wm_custom_text_credits' ) ) { function wm_custom_text_credits( $output ) { return get_theme_mod( 'text-credits' ); } } // /wm_custom_text_credits /** * Front Posts title */ if ( ! function_exists( 'wm_custom_text_front_title_posts' ) ) { function wm_custom_text_front_title_posts( $output ) { return get_theme_mod( 'text-front-title-posts' ); } } // /wm_custom_text_front_title_posts /** * Front Menu title */ if ( ! function_exists( 'wm_custom_text_front_title_menu' ) ) { function wm_custom_text_front_title_menu( $output ) { return get_theme_mod( 'text-front-title-menu' ); } } // /wm_custom_text_front_title_menu /** * 100) Other functions */ /** * "Plus" theme setup */ if ( ! function_exists( 'wm_setup_plus' ) ) { function wm_setup_plus() { //Post formats support add_theme_support( 'post-formats', apply_filters( 'wmhook_wm_setup_plus_post_formats', array( 'audio', 'gallery', 'image', 'link', 'quote', 'status', 'video', ) ) ); //Disable Food Menu if requested if ( get_theme_mod( 'disable-food-menu' ) ) { remove_theme_support( 'nova_menu_item' ); } } } // /wm_setup_plus /** * Upgrade from standard to "Plus" theme */ if ( ! function_exists( 'wm_plus_upgrade' ) ) { function wm_plus_upgrade() { if ( ( $get_theme_mods = array_filter( get_theme_mods() ) ) && empty( $get_theme_mods ) && $standard_theme_mod = get_option( 'theme_mods_' . WM_THEME_SHORTNAME ) ) { update_option( 'theme_mods_' . get_option( 'stylesheet' ), $standard_theme_mod ); } } } // /wm_plus_upgrade /** * Modify helper variable * * @param array $helper */ if ( ! function_exists( 'wm_helper_var_plus' ) ) { function wm_helper_var_plus( $helper ) { //Preparing output /** * Nutrition facts * * Array keys are schema.org values. * @link http://schema.org/NutritionInformation */ $helper['nutrition-facts'] = array( 'calories' => _x( 'Calories', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'proteinContent' => _x( 'Protein', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'fiberContent' => _x( 'Fiber', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'carbohydrateContent' => _x( 'Carbohydrates', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'sugarContent' => _x( '- Sugars', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'fatContent' => _x( 'Fat', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'saturatedFatContent' => _x( '- Saturated fat', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'unsaturatedFatContent' => _x( '- Unsaturated fat', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'transFatContent' => _x( '- Trans fat', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'cholesterolContent' => _x( 'Cholesterol', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), 'sodiumContent' => _x( 'Sodium', 'According to http://schema.org/NutritionInformation.', 'wm_domain' ), ); //Widget areas $helper['widget-areas']['banner'] = array( 'name' => __( 'Custom Banner', 'wm_domain' ), 'description' => __( 'This widget area will replace the banner area on front page. You can insert your custom banner (slider) shortcode into a text widget to display it.', 'wm_domain' ), ); //Output return $helper; } } // /wm_helper_var_plus /** * Get custom banner * * @param string $output */ if ( ! function_exists( 'wm_get_custom_banner' ) ) { function wm_get_custom_banner( $output = '' ) { if ( is_active_sidebar( 'banner' ) ) { ob_start(); echo ''; return ob_get_clean(); } return ''; } } // /wm_get_custom_banner /** * Print custom banner */ if ( ! function_exists( 'wm_the_custom_banner' ) ) { function wm_the_custom_banner() { echo wm_get_custom_banner(); } } // /wm_the_custom_banner /** * Disable post title * * @param bool $disable */ if ( ! function_exists( 'wm_disable_post_title' ) ) { function wm_disable_post_title( $disable ) { //Helper variables $disabled_post_formats = array( 'link', 'quote', 'status' ); if ( ! is_single() && has_excerpt() ) { $disabled_post_formats[] = 'image'; } //Preparing output if ( in_array( get_post_format(), $disabled_post_formats ) ) { $disable = true; } //Output return $disable; } } // /wm_disable_post_title /** * Menu item image permalink * * @since 1.1 * @version 1.3 * * @param array $permalink */ if ( ! function_exists( 'wm_permalink_recipe_image' ) ) { function wm_permalink_recipe_image( $permalink ) { //Preparing output if ( 'nova_menu_item' === get_post_type( get_the_ID() ) && wm_is_recipe() ) { $permalink = array( esc_url( get_permalink() ) ); } //Output return $permalink; } } // /wm_permalink_recipe_image /** * Menu item title permalink * * @since 1.1 * @version 1.3 * * @param array $permalink */ if ( ! function_exists( 'wm_permalink_recipe_title' ) ) { function wm_permalink_recipe_title( $permalink ) { //Preparing output if ( 'nova_menu_item' === get_post_type( get_the_ID() ) && wm_is_recipe() ) { $permalink = array( '', '' ); } //Output return $permalink; } } // /wm_permalink_recipe_title /** * Minutes to hours * * @param int $minutes * @param bool $meta Whether to display the time in microformat format. * * @return string */ if ( ! function_exists( 'wm_minutes_to_hours' ) ) { function wm_minutes_to_hours( $minutes, $meta = false ) { //Preparing output $hrs = intval( $minutes / 60 ); $min = absint( $minutes % 60 ); $minutes = ''; if ( $hrs ) { $minutes .= ( ! $meta ) ? ( sprintf( _nx( '1 hour', '%d hours', $hrs, 'Recipe preparation duration.', 'wm_domain' ), $hrs ) . ' ' ) : ( $hrs . 'H' ); } if ( $min ) { $minutes .= ( ! $meta ) ? ( sprintf( _nx( '1 minute', '%d minutes', $min, 'Recipe preparation duration.', 'wm_domain' ), $min ) . ' ' ) : ( $min . 'M' ); } //Output return trim( $minutes ); } } // /wm_minutes_to_hours /** * Categorize Food Menu post type * * This is to allow for recipes being grouped together with * a category across post types. */ if ( ! function_exists( 'wm_categorize_food_menu' ) ) { function wm_categorize_food_menu() { register_taxonomy_for_object_type( 'category', 'nova_menu_item' ); } } // /wm_categorize_food_menu ?>