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] = '
'; $output[10] .= ''; //No need for recipe closing DIV - will be closed with original post closing DIV $output = (array) apply_filters( 'wmhook_wm_content_recipe_output', $output ); //Output return $prefix . $content . implode( '', $output ); } } // /wm_content_recipe /** * Recipe title */ if ( ! function_exists( 'wm_get_content_recipe_title' ) ) { function wm_get_content_recipe_title() { //Requirements check if ( ! function_exists( 'wma_meta_option' ) ) { return; } //Helper variables $output = ''; $title = trim( wma_meta_option( 'recipe-title' ) ); if ( empty( $title ) ) { $title = get_the_title(); } $cook = wma_meta_option( 'cook' ); if ( '_custom' === $cook ) { $cook = strip_tags( wma_meta_option( 'cook-custom' ), '' ); } elseif ( ! empty( $cook ) ) { $cook = get_user_by( 'id', absint( $cook ) ); $cook = '' . $cook->display_name . ''; } else { $cook = '' . get_the_author() . ''; } //Preparing output //Title $output .= $title; //Author //translators: Keep the first letter lowercase as the text is appended to recipe title. $output .= ' ' . sprintf( __( 'recipe by %s', 'wm_domain' ), '' ) . ''; //Output return '

' . $output . '

'; } } // /wm_get_content_recipe_title /** * Recipe meta */ if ( ! function_exists( 'wm_get_content_recipe_meta' ) ) { function wm_get_content_recipe_meta() { //Requirements check if ( ! function_exists( 'wma_meta_option' ) ) { return; } //Helper variables $output = ''; $time_prep = absint( wma_meta_option( 'time-prep' ) ); $time_cook = absint( wma_meta_option( 'time-cook' ) ); $time_total = absint( $time_prep + $time_cook ); if ( 'nova_menu_item' === get_post_type() ) { $category = get_the_term_list( get_the_ID(), 'nova_menu', '', ', ', '' ); } else { $category = get_the_category_list( ', ', '', get_the_ID() ); } $category = apply_filters( 'wm_get_content_recipe_meta_category', $category ); $i = 0; //Preparing output if ( $difficulty = wma_meta_option( 'difficulty' ) ) { $output .= '
  • ' . __( 'Difficulty:', 'wm_domain' ) . ' ' . $difficulty . '
  • '; $i++; } if ( $yield = wma_meta_option( 'yield' ) ) { $output .= '
  • ' . __( 'Yield:', 'wm_domain' ) . ' ' . $yield . '
  • '; $i++; } if ( $time_prep ) { $output .= '
  • ' . __( 'Prep time:', 'wm_domain' ) . ' ' . wm_minutes_to_hours( $time_prep ) . '
  • '; $i++; } if ( $time_cook ) { $output .= '
  • ' . __( 'Cook time:', 'wm_domain' ) . ' ' . wm_minutes_to_hours( $time_cook ) . '
  • '; $i++; } if ( $i ) { $output = '
      ' . $output . '
    '; } $output .= '
    '; $output .= ''; if ( $time_prep ) { $output .= wm_schema_org( 'itemprop="prepTime" content="PT' . wm_minutes_to_hours( $time_prep, 'meta' ) . '"', 'meta' ); } if ( $time_cook ) { $output .= wm_schema_org( 'itemprop="cookTime" content="PT' . wm_minutes_to_hours( $time_cook, 'meta' ) . '"', 'meta' ); } if ( $time_total ) { $output .= wm_schema_org( 'itemprop="totalTime" content="PT' . wm_minutes_to_hours( $time_total, 'meta' ) . '"', 'meta' ); } $output .= wm_schema_org( 'itemprop="recipeCategory" content="' . esc_attr( trim( strip_tags( $category ) ) ) . '"', 'meta' ); $output .= '
    '; //Output return '
    ' . $output . '
    '; } } // /wm_get_content_recipe_meta /** * Recipe ingredients */ if ( ! function_exists( 'wm_get_content_recipe_ingredients' ) ) { function wm_get_content_recipe_ingredients() { //Requirements check if ( ! function_exists( 'wma_meta_option' ) ) { return; } //Helper variables $output = ''; $ingredients = array_filter( (array) wma_meta_option( 'ingredients' ) ); //Preparing output if ( ! empty( $ingredients ) ) { $output .= '
    '; $output .= '

    ' . __( 'Ingredients', 'wm_domain' ) . '

    '; $output .= '
      '; $i = 0; $half = absint( ceil( count( $ingredients ) / 2 ) ); foreach ( $ingredients as $ingredient ) { if ( isset( $ingredient['ingredient'] ) && trim( $ingredient['ingredient'] ) && isset( $ingredient['info'] ) ) { $output_ingredient = '
    • '; $output .= apply_filters( 'wmhook_wm_get_content_recipe_ingredient', $output_ingredient, $ingredient, $term ); if ( ++$i === $half ) { $output .= '
      '; } } } // /foreach $output .= '
    '; $output .= '
    '; } //Output return $output; } } // /wm_get_content_recipe_ingredients /** * Recipe instructions */ if ( ! function_exists( 'wm_get_content_recipe_instructions' ) ) { function wm_get_content_recipe_instructions() { //Requirements check if ( ! function_exists( 'wma_meta_option' ) ) { return; } //Preparing output $output = '

    ' . __( 'Instructions', 'wm_domain' ) . '

    '; $output .= wma_meta_option( 'instructions' ); //Output return '
    ' . $output . '
    '; } } // /wm_get_content_recipe_instructions /** * Recipe nutrition */ if ( ! function_exists( 'wm_get_content_recipe_nutrition' ) ) { function wm_get_content_recipe_nutrition() { //Requirements check if ( ! function_exists( 'wma_meta_option' ) ) { return; } //Helper variables $output = $facts = ''; $nutrition_text = trim( (string) wma_meta_option( 'nutrition' ) ); $nutrition_facts = (array) wm_helper_var( 'nutrition-facts' ); $nutrition_facts_values = (array) wma_meta_option( 'nutrition-facts' ); if ( ! empty( $nutrition_facts_values ) ) { foreach ( $nutrition_facts_values as $fact ) { if ( isset( $fact['fact'] ) && $fact['fact'] && isset( $fact['value'] ) && $fact['value'] ) { $facts .= ''; $facts .= '' . str_replace( '-', '—', $nutrition_facts[ $fact['fact'] ] ) . ':'; $facts .= '' . strip_tags( $fact['value'] ) . ''; $facts .= ''; } } } //Preparing output if ( trim( (string) $nutrition_text . $facts ) ) { $output .= '
    '; $output .= '

    ' . __( 'Nutrition facts', 'wm_domain' ) . '

    '; if ( $nutrition_text ) { $output .= "\r\n" . $nutrition_text; } if ( $facts ) { $output .= "\r\n" . '' . $facts . '
    '; } $output .= '
    '; } //Output return $output; } } // /wm_get_content_recipe_nutrition /** * Recipe print button */ if ( ! function_exists( 'wm_get_content_recipe_print_button' ) ) { function wm_get_content_recipe_print_button() { //Requirements check if ( ! function_exists( 'wma_meta_option' ) ) { return; } //Output return ''; } } // /wm_get_content_recipe_print_button /** * Microformats */ /** * Recipe microformat * * @link https://support.google.com/webmasters/answer/173379 * @link http://schema.org/Recipe * * @param string $output * @param string $element * @param string $output_meta_tag */ if ( ! function_exists( 'wm_microformat_recipe' ) ) { function wm_microformat_recipe( $output, $element, $output_meta_tag ) { //Helper variables $base = apply_filters( 'wmhook_wm_schema_org_base', 'http://schema.org/', $element, $output_meta_tag ); //Preparing output if ( is_single() && wm_is_recipe() ) : switch ( $element ) { case 'entry': $output = 'itemscope itemtype="' . $base . 'Recipe"'; break; case 'entry_body': $output = 'itemprop="description"'; break; case 'nutrition': $output = 'itemscope itemprop="nutrition" itemtype="' . $base . 'NutritionInformation"'; break; default: break; } endif; //Output return $output; } } // /wm_microformat_recipe /** * Recipe post top meta info * * @param array $args */ if ( ! function_exists( 'wm_recipe_top_meta' ) ) { function wm_recipe_top_meta( $args ) { //Prepring output if ( is_single() && wm_is_recipe() ) { //Add category // $args['meta'][] = 'category'; //Remove post author from post meta when recipe is displayed if ( false !== ( $key = array_search( 'author', $args['meta'] ) ) ) { unset( $args['meta'][ $key ] ); } } //Output return $args; } } // /wm_recipe_top_meta /** * Comments microformat */ if ( ! function_exists( 'wm_comments_microformat' ) ) { function wm_comments_microformat() { if ( $comments = get_comments_number() ) { echo wm_schema_org( 'itemprop="interactionCount" content="UserComments:' . $comments . '"', 'meta' ); } } } // /wm_comments_microformat /** * 50) Theme options */ /** * "Plus" theme options * * @since 1.1 * @version 1.3 */ if ( ! function_exists( 'wm_theme_options_plus' ) ) { function wm_theme_options_plus( $options ) { //Preparing output $plus_options = array( /** * Site content colors */ //This is addition to 'Colors' section 100 . 'colors' . 310 => array( 'type' => 'color', 'id' => 'color' . '-content', 'label' => __( 'Background color', 'wm_domain' ), 'default' => '#ffffff', ), 100 . 'colors' . 320 => array( 'type' => 'color', 'id' => 'color' . '-content-text', 'label' => __( 'Text color', 'wm_domain' ), 'default' => '#6a6c6e', ), 100 . 'colors' . 330 => array( 'type' => 'color', 'id' => 'color' . '-content-headings-text', 'label' => __( 'Headings color', 'wm_domain' ), 'default' => '#1a1c1e', ), 100 . 'colors' . 340 => array( 'type' => 'color', 'id' => 'color' . '-content-border', 'label' => __( 'Borders color', 'wm_domain' ), 'default' => '#eaecee', ), /** * Texts */ 250 . 'text' => array( 'id' => 'text', 'type' => 'section', 'theme-customizer-section' => _x( 'Texts', 'Customizer section title.', 'wm_domain' ), 'theme-customizer-panel' => _x( 'Theme', 'Customizer panel title.', 'wm_domain' ), ), 250 . 'text' . 100 => array( 'type' => 'text', 'id' => 'text' . '-front-title-posts', 'label' => __( 'Front page Posts section title', 'wm_domain' ), 'validate' => 'wm_sanitize_text', 'default' => _x( 'News', 'Front page blog posts section title.', 'wm_domain' ), ), 250 . 'text' . 110 => array( 'type' => 'text', 'id' => 'text' . '-front-title-menu', 'label' => __( 'Front page Food menu section title', 'wm_domain' ), 'validate' => 'wm_sanitize_text', 'default' => _x( 'Menu', 'Front page food menu section title.', 'wm_domain' ), ), 250 . 'text' . 120 => array( 'type' => 'textarea', 'id' => 'text' . '-credits', 'label' => __( 'Footer credits text', 'wm_domain' ), 'validate' => 'wm_sanitize_text', 'default' => '© ' . date( 'Y' ) . ' ' . get_bloginfo( 'name' ) . '. ' . sprintf( __( 'Powered by %s.', 'wm_domain' ), 'WordPress' ) . ' ' . sprintf( __( 'Theme by %s.', 'wm_domain' ), 'WebMan Design' ) . ' ' . __( 'Back to top ↑', 'wm_domain' ) . '', ), /** * Features */ 800 . 'features' => array( 'id' => 'features', 'type' => 'section', 'theme-customizer-section' => _x( 'Features', 'Customizer section title.', 'wm_domain' ), 'theme-customizer-panel' => _x( 'Theme', 'Customizer panel title.', 'wm_domain' ), ), 800 . 'features' . 100 => array( 'type' => 'checkbox', 'id' => 'disable' . '-food-menu', 'label' => __( 'Disable food menu', 'wm_domain' ), 'description' => __( 'In case you want to use the theme as recipe blog only, you have the option to disable the Food Menu post type.', 'wm_domain' ), ), ); /** * Credits */ $options[999 . 'credits' . 100]['content'] = '

    ' . __( 'Theme Credits', 'wm_domain' ) . '

    ' . 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 '
    '; dynamic_sidebar( 'banner' ); 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 ?>