Dashboard
PHP:
8.0.30
OS:
Linux
User:
hoozgot
/
/
home
/
hoozgot
/
www
/
mountainpassions
/
!Backup
/
example-test
/
wp-content
/
themes
/
peakie-2016
📤 Upload
📝 New File
📁 New Folder
Close
Editing: functions.php
<?php /* * Author: Todd Motto | @toddmotto * URL: html5blank.com | @html5blank * Custom functions, support, custom post types and more. */ /*------------------------------------*\ External Modules/Files \*------------------------------------*/ // Load any external files you have here /*------------------------------------*\ Theme Support \*------------------------------------*/ if (!isset($content_width)) { $content_width = 1130; } if (function_exists('add_theme_support')) { // Add Menu Support add_theme_support('menus'); // Make sure featured images are enabled // Add Thumbnail Theme Support add_theme_support( 'post-thumbnails' ); add_image_size('large', 1130, '', true); // Large Thumbnail add_image_size('medium', 250, '', true); // Medium Thumbnail add_image_size('small', 150, '', true); // Small Thumbnail add_image_size('img-postsbycategory', 339, 250, true); // Index pages Thumbnail add_image_size('info-image', 350,'', true); // Practical Info image //add_image_size('custom-size', 700, 200, true); // Custom Thumbnail Size call using the_post_thumbnail('custom-size'); // Add Support for Custom Backgrounds - Uncomment below if you're going to use /*add_theme_support('custom-background', array( 'default-color' => 'FFF', 'default-image' => get_template_directory_uri() . '/img/bg.jpg' ));*/ // Add Support for Custom Header - Uncomment below if you're going to use /*add_theme_support('custom-header', array( 'default-image' => get_template_directory_uri() . '/img/headers/default.jpg', 'header-text' => false, 'default-text-color' => '000', 'width' => 1920, 'height' => 885, 'random-default' => false, 'wp-head-callback' => $wphead_cb, 'admin-head-callback' => $adminhead_cb, 'admin-preview-callback' => $adminpreview_cb ));*/ // Enables post and comment RSS feed links to head add_theme_support('automatic-feed-links'); // Localisation Support load_theme_textdomain('html5blank', get_template_directory() . '/languages'); } /*------------------------------------*\ Functions \*------------------------------------*/ // MountainPassions main navigation function mp_main_nav() { wp_nav_menu( array( 'theme_location' => 'header-menu', 'menu' => 'main summer menu', 'container' => 'div', 'container_class' => 'header-menu-container', 'container_id' => '', 'menu_class' => 'nav', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul>%3$s</ul>', 'depth' => 0, 'walker' => '' ) ); } // Load HTML5 Blank scripts (header.php) function html5blank_header_scripts() { if ($GLOBALS['pagenow'] != 'wp-login.php' && !is_admin()) { wp_register_script('conditionizr', get_template_directory_uri() . '/js/lib/conditionizr-4.3.0.min.js', array(), '4.3.0'); // Conditionizr wp_enqueue_script('conditionizr'); // Enqueue it! wp_register_script('modernizr', get_template_directory_uri() . '/js/lib/modernizr-2.7.1.min.js', array(), '2.7.1'); // Modernizr wp_enqueue_script('modernizr'); // Enqueue it! wp_register_script('html5blankscripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0.0'); // Custom scripts wp_enqueue_script('html5blankscripts'); // Enqueue it! } } // Load HTML5 Blank conditional scripts function html5blank_conditional_scripts() { if (is_page('pagenamehere')) { wp_register_script('scriptname', get_template_directory_uri() . '/js/scriptname.js', array('jquery'), '1.0.0'); // Conditional script(s) wp_enqueue_script('scriptname'); // Enqueue it! } } // Load HTML5 Blank styles function html5blank_styles() { wp_register_style('normalize', get_template_directory_uri() . '/normalize.css', array(), '1.0', 'all'); wp_enqueue_style('normalize'); // Enqueue it! wp_register_style('googleFont', 'http://fonts.googleapis.com/css?family=Open+Sans:400,600,700|Roboto:400,500|Oswald|Roboto+Condensed|Pontano+Sans|Raleway:400,700,800|PT+Sans|PT+Serif:400italic'); wp_enqueue_style('googleFont'); wp_register_style('html5blank', get_template_directory_uri() . '/style.css', array(), '1.0', 'all'); wp_enqueue_style('html5blank'); // Enqueue it! } // Register HTML5 Blank Navigation function register_html5_menu() { register_nav_menus(array( // Using array to specify more menus if needed 'header-menu' => __('Header Menu', 'html5blank'), // Main Navigation 'sidebar-menu' => __('Sidebar Menu', 'html5blank'), // Sidebar Navigation 'extra-menu' => __('Extra Menu', 'html5blank') // Extra Navigation if needed (duplicate as many as you need!) )); } // Remove the <div> surrounding the dynamic navigation to cleanup markup function my_wp_nav_menu_args($args = '') { $args['container'] = false; return $args; } // Remove Injected classes, ID's and Page ID's from Navigation <li> items function my_css_attributes_filter($var) { return is_array($var) ? array() : ''; } // Remove invalid rel attribute values in the categorylist function remove_category_rel_from_category_list($thelist) { return str_replace('rel="category tag"', 'rel="tag"', $thelist); } // Add page slug to body class, love this - Credit: Starkers Wordpress Theme function add_slug_to_body_class($classes) { global $post; if (is_home()) { $key = array_search('blog', $classes); if ($key > -1) { unset($classes[$key]); } } elseif (is_page()) { $classes[] = sanitize_html_class($post->post_name); } elseif (is_singular()) { $classes[] = sanitize_html_class($post->post_name); } return $classes; } // If Dynamic Sidebar Exists if (function_exists('register_sidebar')) { // Define Primary sidebar register_sidebar(array( 'name' => __('Primary', 'peakie-2016'), 'description' => __('Summer advertisements', 'peakie-2016'), 'id' => 'primary', 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' )); // Define Summer Activities sidebar register_sidebar(array( 'name' => __('Summer activities', 'peakie-2016'), 'description' => __('Summer activities', 'peakie-2016'), 'id' => 'summer-activities', 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="title">', 'after_title' => '</h3>' )); // Define Homepage sidebar register_sidebar(array( 'name' => __('Summer homepage', 'peakie-2016'), 'description' => __('Summer homepage', 'peakie-2016'), 'id' => 'summerhomepage-2', 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' )); // Summer travel ad group AdRotate id ... register_sidebar(array( 'name' => __('Primary', 'peakie-2016'), 'description' => __('Summer advertisements', 'peakie-2016'), 'id' => 'primary', 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' )); // Define Resorts Ad Widget Area 1 register_sidebar(array( 'name' => __('Resorts Advert Widget', 'peakie-2016'), 'description' => __('Google Ad', 'peakie-2016'), 'id' => 's-resorts-1', 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<p class="ad-title">', 'after_title' => '</p>' )); } //Custom sidebars //Sidebar 3 if ( function_exists ('register_sidebar')) { register_sidebar ('winter'); } //Sidebar 4 if ( function_exists ('register_sidebar')) { register_sidebar ('summer'); } //Execute PHP scripts in text widgets function php_execute($html){ if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html); $html=ob_get_contents(); ob_end_clean(); } return $html; } add_filter('widget_text','php_execute',100); // Remove wp_head() injected Recent Comment styles function my_remove_recent_comments_style() { global $wp_widget_factory; remove_action('wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' )); } // Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin function html5wp_pagination() { global $wp_query; $big = 999999999; echo paginate_links(array( 'base' => str_replace($big, '%#%', get_pagenum_link($big)), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages )); } // Custom Excerpts function html5wp_index($length) // Create 20 Word Callback for Index page Excerpts, call using html5wp_excerpt('html5wp_index'); { return 20; } // Create 40 Word Callback for Custom Post Excerpts, call using html5wp_excerpt('html5wp_custom_post'); function html5wp_custom_post($length) { return 40; } // Create the Custom Excerpts callback function html5wp_excerpt($length_callback = '', $more_callback = '') { global $post; if (function_exists($length_callback)) { add_filter('excerpt_length', $length_callback); } if (function_exists($more_callback)) { add_filter('excerpt_more', $more_callback); } $output = get_the_excerpt(); $output = apply_filters('wptexturize', $output); $output = apply_filters('convert_chars', $output); $output = '<p>' . $output . '</p>'; echo $output; } // Custom Read Feature link to Post for homepage function peakie16_view_article($more) { global $post; return '... <a class="read-feature" href="' . get_permalink($post->ID) . '">' . __('Read more', 'html5blank') . '</a>'; } //Remove admin bar function remove_admin_bar() { return false; } // Remove 'text/css' from our enqueued stylesheet function html5_style_remove($tag) { return preg_replace('~\s+type=["\'][^"\']++["\']~', '', $tag); } // Remove thumbnail width and height dimensions that prevent fluid images in the_thumbnail function remove_thumbnail_dimensions( $html ) { $html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html); return $html; } /*=================================================================================== * Add Author Links * =================================================================================*/ function add_to_author_profile( $contactmethods ) { $contactmethods['rss_url'] = 'RSS URL'; $contactmethods['google_profile'] = 'Google Profile URL'; $contactmethods['twitter_profile'] = 'Twitter Profile URL'; $contactmethods['facebook_profile'] = 'Facebook Profile URL'; $contactmethods['pinterest_profile'] = 'Pinterest Profile URL'; $contactmethods['instagram_profile'] = 'Instagram Profile URL'; $contactmethods['linkedin_profile'] = 'Linkedin Profile URL'; return $contactmethods; } add_filter( 'user_contactmethods', 'add_to_author_profile', 10, 1); // Custom Gravatar in Settings > Discussion function html5blankgravatar ($avatar_defaults) { $myavatar = get_template_directory_uri() . '/img/gravatar.jpg'; $avatar_defaults[$myavatar] = "Custom Gravatar"; return $avatar_defaults; } // Threaded Comments function enable_threaded_comments() { if (!is_admin()) { if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) { wp_enqueue_script('comment-reply'); } } } // Custom Comments Callback function html5blankcomments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; extract($args, EXTR_SKIP); if ( 'div' == $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { $tag = 'li'; $add_below = 'div-comment'; } ?> <!-- heads up: starting < for the html tag (li or div) in the next line: --> <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>"> <?php if ( 'div' != $args['style'] ) : ?> <div id="div-comment-<?php comment_ID() ?>" class="comment-body"> <?php endif; ?> <div class="comment-author vcard"> <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['180'] ); ?> <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?> </div> <?php if ($comment->comment_approved == '0') : ?> <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em> <br /> <?php endif; ?> <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"> <?php printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','' ); ?> </div> <?php comment_text() ?> <div class="reply"> <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?> </div> <?php if ( 'div' != $args['style'] ) : ?> </div> <?php endif; ?> <?php } /*------------------------------------*\ Actions + Filters + ShortCodes \*------------------------------------*/ // Add Actions add_action('init', 'html5blank_header_scripts'); // Add Custom Scripts to wp_head add_action('wp_print_scripts', 'html5blank_conditional_scripts'); // Add Conditional Page Scripts add_action('get_header', 'enable_threaded_comments'); // Enable Threaded Comments add_action('wp_enqueue_scripts', 'html5blank_styles'); // Add Theme Stylesheet add_action('init', 'register_html5_menu'); // Add HTML5 Blank Menu //add_action('init', 'create_post_type_html5'); // Add our HTML5 Blank Custom Post Type add_action('widgets_init', 'my_remove_recent_comments_style'); // Remove inline Recent Comment Styles from wp_head() add_action('init', 'html5wp_pagination'); // Add our HTML5 Pagination // Remove Actions remove_action('wp_head', 'feed_links_extra', 3); // Display the links to the extra feeds such as category feeds remove_action('wp_head', 'feed_links', 2); // Display the links to the general feeds: Post and Comment Feed remove_action('wp_head', 'rsd_link'); // Display the link to the Really Simple Discovery service endpoint, EditURI link remove_action('wp_head', 'wlwmanifest_link'); // Display the link to the Windows Live Writer manifest file. remove_action('wp_head', 'index_rel_link'); // Index link remove_action('wp_head', 'parent_post_rel_link', 10, 0); // Prev link remove_action('wp_head', 'start_post_rel_link', 10, 0); // Start link remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // Display relational links for the posts adjacent to the current post. remove_action('wp_head', 'wp_generator'); // Display the XHTML generator that is generated on the wp_head hook, WP version remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); remove_action('wp_head', 'rel_canonical'); remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); // Add Filters add_filter('avatar_defaults', 'html5blankgravatar'); // Custom Gravatar in Settings > Discussion add_filter('body_class', 'add_slug_to_body_class'); // Add slug to body class (Starkers build) add_filter('widget_text', 'do_shortcode'); // Allow shortcodes in Dynamic Sidebar add_filter('widget_text', 'shortcode_unautop'); // Remove <p> tags in Dynamic Sidebars (better!) add_filter('wp_nav_menu_args', 'my_wp_nav_menu_args'); // Remove surrounding <div> from WP Navigation // add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> injected classes (Commented out by default) // add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> injected ID (Commented out by default) // add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> Page ID's (Commented out by default) add_filter('the_category', 'remove_category_rel_from_category_list'); // Remove invalid rel attribute add_filter('the_excerpt', 'shortcode_unautop'); // Remove auto <p> tags in Excerpt (Manual Excerpts only) add_filter('the_excerpt', 'do_shortcode'); // Allows Shortcodes to be executed in Excerpt (Manual Excerpts only) add_filter('excerpt_more', 'html5_blank_view_article'); // Add 'View Article' button instead of [...] for Excerpts add_filter('show_admin_bar', 'remove_admin_bar'); // Remove Admin bar add_filter('style_loader_tag', 'html5_style_remove'); // Remove 'text/css' from enqueued stylesheet add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10); // Remove width and height dynamic attributes to thumbnails add_filter('image_send_to_editor', 'remove_thumbnail_dimensions', 10); // Remove width and height dynamic attributes to post images // Remove Filters remove_filter('the_excerpt', 'wpautop'); // Remove <p> tags from Excerpt altogether // Shortcodes add_shortcode('html5_shortcode_demo', 'html5_shortcode_demo'); // You can place [html5_shortcode_demo] in Pages, Posts now. add_shortcode('html5_shortcode_demo_2', 'html5_shortcode_demo_2'); // Place [html5_shortcode_demo_2] in Pages, Posts now. // Shortcodes above would be nested like this - // [html5_shortcode_demo] [html5_shortcode_demo_2] Here's the page title! [/html5_shortcode_demo_2] [/html5_shortcode_demo] /*------------------------------------*\ Custom Post Types \*------------------------------------*/ // Create 1 Custom Post type for a Demo, called HTML5-Blank /*function create_post_type_html5() { register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category register_taxonomy_for_object_type('post_tag', 'html5-blank'); register_post_type('html5-blank', // Register Custom Post Type array( 'labels' => array( 'name' => __('HTML5 Blank Custom Post', 'html5blank'), // Rename these to suit 'singular_name' => __('HTML5 Blank Custom Post', 'html5blank'), 'add_new' => __('Add New', 'html5blank'), 'add_new_item' => __('Add New HTML5 Blank Custom Post', 'html5blank'), 'edit' => __('Edit', 'html5blank'), 'edit_item' => __('Edit HTML5 Blank Custom Post', 'html5blank'), 'new_item' => __('New HTML5 Blank Custom Post', 'html5blank'), 'view' => __('View HTML5 Blank Custom Post', 'html5blank'), 'view_item' => __('View HTML5 Blank Custom Post', 'html5blank'), 'search_items' => __('Search HTML5 Blank Custom Post', 'html5blank'), 'not_found' => __('No HTML5 Blank Custom Posts found', 'html5blank'), 'not_found_in_trash' => __('No HTML5 Blank Custom Posts found in Trash', 'html5blank') ), 'public' => true, 'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages 'has_archive' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ), // Go to Dashboard Custom HTML5 Blank post for supports 'can_export' => true, // Allows export in Tools > Export 'taxonomies' => array( 'post_tag', 'category' ) // Add Category and Post Tags support )); }*/ /*------------------------------------*\ ShortCode Functions \*------------------------------------*/ // Shortcode Demo with Nested Capability function html5_shortcode_demo($atts, $content = null) { return '<div class="shortcode-demo">' . do_shortcode($content) . '</div>'; // do_shortcode allows for nested Shortcodes } // Shortcode Demo with simple <h2> tag function html5_shortcode_demo_2($atts, $content = null) // Demo Heading H2 shortcode, allows for nesting within above element. Fully expandable. { return '<h2>' . $content . '</h2>'; } // Summer Resort Meta Boxes $summerresort_category_name = 'Summer Resorts'; //Summer Resort Location add_action( 'add_meta_boxes', 'add_summerlocation_options' ); function add_summerlocation_options() { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $favicon_url = get_stylesheet_directory_uri() . ''; $style = "display: inline-block; height: 13px; margin-top: 3px; vertical-align: top;"; $icon = '<img src="' . $favicon_url . '" style="'.$style.'" /> - '; $icon = ''; add_meta_box( 'custom-metabox-summerlocation', $icon.__( 'The Location (Summer)' ), 'summerlocation_options', 'post', 'normal', 'high' ); } } function summerlocation_options( $post ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $summerlocation = get_post_meta( $post->ID, 'summerlocation', true ); wp_editor( $summerlocation, 'summerlocation', array( 'textarea_name' => 'summerlocation', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_summerlocation_metabox' ); function save_summerlocation_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { if( $_POST ) { $summerlocation = get_post_meta( $post->ID, 'summerlocation', true ); $new = $_POST['summerlocation']; if($new && $new != $old && $new != '') { update_post_meta($post_id, 'summerlocation', $new); } } } } // Summer Village add_action( 'add_meta_boxes', 'add_summervillage_options' ); function add_summervillage_options() { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $favicon_url = get_stylesheet_directory_uri() . ''; $style = "display: inline-block; height: 13px; margin-top: 3px; vertical-align: top;"; $icon = '<img src="' . $favicon_url . '" style="'.$style.'" /> - '; $icon = ''; add_meta_box( 'custom-metabox-summervillage', $icon.__( 'The Village (Summer)' ), 'summervillage_options', 'post', 'normal', 'high' ); } } function summervillage_options( $post ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $summervillage = get_post_meta( $post->ID, 'summervillage', true ); wp_editor( $summervillage, 'summervillage', array( 'textarea_name' => 'summervillage', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_summervillage_metabox' ); function save_summervillage_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { if( $_POST ) { $summervillage = get_post_meta( $post->ID, 'summervillage', true ); $new = $_POST['summervillage']; if($new && $new != $old && $new != '') { update_post_meta($post_id, 'summervillage', $new); } } } } //Activities There add_action( 'add_meta_boxes', 'add_resortactivities_options' ); function add_resortactivities_options() { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $favicon_url = get_stylesheet_directory_uri() . ''; $style = "display: inline-block; height: 13px; margin-top: 3px; vertical-align: top;"; $icon = '<img src="' . $favicon_url . '" style="'.$style.'" /> - '; $icon = ''; add_meta_box( 'custom-metabox-resortactivities', $icon.__( 'Resort Activities (Summer)' ), 'resortactivities_options', 'post', 'normal', 'high' ); } } function resortactivities_options( $post ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $resortactivities = get_post_meta( $post->ID, 'resortactivities', true ); wp_editor( $resortactivities, 'resortactivities', array( 'textarea_name' => 'resortactivities', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_resortactivities_metabox' ); function save_resortactivities_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { if( $_POST ) { $resortactivities = get_post_meta( $post->ID, 'resortactivities', true ); $new = $_POST['resortactivities']; if($new && $new != $old && $new != '') { update_post_meta($post_id, 'resortactivities', $new); } } } } //Summer Resort review In Profile add_action( 'add_meta_boxes', 'add_summer_inprofile_metabox' ); function add_summer_inprofile_metabox() { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { add_meta_box( 'summer_inprofile-metabox', __( "Summer Resort In Profile" ), 'summer_inprofile_metabox', 'post', 'normal', 'high' ); } } function summer_inprofile_metabox($post) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { // Summer Resort Name $ip_destination_name = get_post_meta( $post->ID, 'ip_destination_name', true ); echo '<label for="ip_destination_name">Summer Destination Name</label><br />'; echo '<input type="text" name="ip_destination_name" id="ip_destination_name" value="'.$ip_destination_name.'"><br />'; echo '<h1>Activities There</h1>'; //Attractions / Visits $ip_attractions = get_post_meta( $post->ID, 'ip_attractions', true ); echo '<label for="ip_attractions">Attractions / Visits</label><br />'; echo '<select name="ip_attractions" id="ip_attractions">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_attractions == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_attractions == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_attractions == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_attractions == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_attractions == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; //Walking $ip_walking = get_post_meta( $post->ID, 'ip_walking', true ); echo '<label for="ip_walking">Walking</label><br />'; echo '<select name="ip_walking" id="ip_walking">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_walking == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_walking == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_walking == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_walking == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_walking == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; //Cycling $ip_cycling = get_post_meta( $post->ID, 'ip_cycling', true ); echo '<label for="ip_cycling">Cycling</label><br />'; echo '<select name="ip_cycling" id="ip_cycling">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_cycling == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_cycling == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_cycling == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_cycling == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_cycling == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; // Activities (sports/swimming etc.) $ip_activities = get_post_meta( $post->ID, 'ip_activities', true ); echo '<label for="ip_activities">Activities</label><br />'; echo '<select name="ip_activities" id="ip_activities">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_activities == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_activities == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_activities == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_activities == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_activities == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; //Staying There echo '<h1>Staying There</h1>'; //Value for Money $ip_stayingthere_summer_value = get_post_meta( $post->ID, 'ip_stayingthere_summer_value', true ); echo '<label for="ip_stayingthere_summer_value">Value for Money</label><br />'; echo '<select name="ip_stayingthere_summer_value" id="ip_stayingthere_summer_value">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_stayingthere_summer_value == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_stayingthere_summer_value == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_stayingthere_summer_value == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_stayingthere_summer_value == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_stayingthere_summer_value == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; //Accommodation $ip_stayingthere_summer_accom = get_post_meta( $post->ID, 'ip_stayingthere_summer_accom', true ); echo '<label for="ip_stayingthere_summer_accom">Accommodation</label><br />'; echo '<select name="ip_stayingthere_summer_accom" id="ip_stayingthere_summer_accom">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_stayingthere_summer_accom == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_stayingthere_summer_accom == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_stayingthere_summer_accom == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_stayingthere_summer_accom == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_stayingthere_summer_accom == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; //Dining Out $ip_stayingthere_summer_diningout = get_post_meta( $post->ID, 'ip_stayingthere_summer_diningout', true ); echo '<label for="ip_stayingthere_summer_diningout">Dining Out</label><br />'; echo '<select name="ip_stayingthere_summer_diningout" id="ip_stayingthere_summer_diningout">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_stayingthere_summer_diningout == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_stayingthere_summer_diningout == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_stayingthere_summer_diningout == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_stayingthere_summer_diningout == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_stayingthere_summer_diningout == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; //Nightlife $ip_stayingthere_summer_nightlife = get_post_meta( $post->ID, 'ip_stayingthere_summer_nightlife', true ); echo '<label for="ip_stayingthere_summer_nightlife">Nightlife</label><br />'; echo '<select name="ip_stayingthere_summer_nightlife" id="ip_stayingthere_summer_nightlife">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_stayingthere_summer_nightlife == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_stayingthere_summer_nightlife == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_stayingthere_summer_nightlife == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_stayingthere_summer_nightlife == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_stayingthere_summer_nightlife == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; //Village Charm $ip_stayingthere_summer_charm = get_post_meta( $post->ID, 'ip_stayingthere_summer_charm', true ); echo '<label for="ip_stayingthere_summer_charm">Village Charm</label><br />'; echo '<select name="ip_stayingthere_summer_charm" id="ip_stayingthere_summer_charm">'; echo '<option value="" >Select</option>'; echo '<option value="1"'; echo ( $ip_stayingthere_summer_charm == '1') ? ' selected="selected"' : ''; echo '>1 Heart</option>'; echo '<option value="2"'; echo ( $ip_stayingthere_summer_charm == '2') ? ' selected="selected"' : ''; echo '>2 Hearts</option>'; echo '<option value="3"'; echo ( $ip_stayingthere_summer_charm == '3') ? ' selected="selected"' : ''; echo '>3 Hearts</option>'; echo '<option value="4"'; echo ( $ip_stayingthere_summer_charm == '4') ? ' selected="selected"' : ''; echo '>4 Hearts</option>'; echo '<option value="5"'; echo ( $ip_stayingthere_summer_charm == '5') ? ' selected="selected"' : ''; echo '>5 Hearts</option>'; echo '<select><br/>'; } } add_action( 'save_post', 'save_summer_inprofile_metabox' ); function save_summer_inprofile_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { if( $_POST ) { // Resort Name $ip_name = get_post_meta( $post->ID, 'ip_name', true ); $new_ip_name = $_POST['ip_name']; if($new_ip_name && $new_ip_name != $ip_name && $new_ip_name != '') { update_post_meta($post_id, 'ip_name', $new_ip_name); } //Attractions There $ip_attractions = get_post_meta( $post->ID, 'ip_attractions', true ); $new_ip_attractions = $_POST['ip_attractions']; if($new_ip_attractions && $new_ip_attractions != $ip_attractions && $new_ip_attractions != '') { update_post_meta($post_id, 'ip_attractions', $new_ip_attractions); } //Walking $ip_walking = get_post_meta( $post->ID, 'ip_walking', true ); $new_ip_walking = $_POST['ip_walking']; if($new_ip_walking && $new_ip_walking != $ip_walking && $new_ip_walking != '') { update_post_meta($post_id, 'ip_walking', $new_ip_walking); } //Cycling $ip_cycling = get_post_meta( $post->ID, 'ip_cycling', true ); $new_ip_cycling = $_POST['ip_cycling']; if($new_ip_cycling && $new_ip_cycling != $ip_cycling && $new_ip_cycling != '') { update_post_meta($post_id, 'ip_cycling', $new_ip_cycling); } //Activities there $ip_activities = get_post_meta( $post->ID, 'ip_activities', true ); $new_ip_activities = $_POST['ip_activities']; if($new_ip_activities && $new_ip_activities != $ip_activities && $new_ip_activities != '') { update_post_meta($post_id, 'ip_activities', $new_ip_activities); } //Staying There //Value $ip_stayingthere_summer_value = get_post_meta( $post->ID, 'ip_stayingthere_summer_value', true ); $new_ip_stayingthere_summer_value = $_POST['ip_stayingthere_summer_value']; if($new_ip_stayingthere_summer_value && $new_ip_stayingthere_summer_value != $ip_stayingthere_summer_value && $new_ip_stayingthere_summer_value != '') { update_post_meta($post_id, 'ip_stayingthere_summer_value', $new_ip_stayingthere_summer_value); } //Accommodation $ip_stayingthere_summer_accom = get_post_meta( $post->ID, 'ip_stayingthere_summer_accom', true ); $new_ip_stayingthere_summer_accom = $_POST['ip_stayingthere_summer_accom']; if($new_ip_stayingthere_summer_accom && $new_ip_stayingthere_summer_accom != $ip_stayingthere_summer_accom && $new_ip_stayingthere_summer_accom != '') { update_post_meta($post_id, 'ip_stayingthere_summer_accom', $new_ip_stayingthere_summer_accom); } //Dining Out $ip_stayingthere_summer_diningout = get_post_meta( $post->ID, 'ip_stayingthere_summer_diningout', true ); $new_ip_stayingthere_summer_diningout = $_POST['ip_stayingthere_summer_diningout']; if($new_ip_stayingthere_summer_diningout && $new_ip_stayingthere_summer_diningout != $ip_stayingthere_summer_diningout && $new_ip_stayingthere_summer_diningout != '') { update_post_meta($post_id, 'ip_stayingthere_summer_diningout', $new_ip_stayingthere_summer_diningout); } //Nightlife $ip_stayingthere_summer_nightlife = get_post_meta( $post->ID, 'ip_stayingthere_summer_nightlife', true ); $new_ip_stayingthere_summer_nightlife = $_POST['ip_stayingthere_summer_nightlife']; if($new_ip_stayingthere_summer_nightlife && $new_ip_stayingthere_summer_nightlife != $ip_stayingthere_summer_nightlife && $new_ip_stayingthere_summer_nightlife != '') { update_post_meta($post_id, 'ip_stayingthere_summer_nightlife', $new_ip_stayingthere_summer_nightlife); } //Village charm $ip_stayingthere_summer_charm = get_post_meta( $post->ID, 'ip_stayingthere_summer_charm', true ); $new_ip_stayingthere_summer_charm = $_POST['ip_stayingthere_summer_charm']; if($new_ip_stayingthere_summer_charm && $new_ip_stayingthere_summer_charm != $ip_stayingthere_summer_charm && $new_ip_stayingthere_summer_charm != '') { update_post_meta($post_id, 'ip_stayingthere_summer_charm', $new_ip_stayingthere_summer_charm); } } } } //Good Points: Yes, please add_action( 'add_meta_boxes', 'add_summer_goodpoints_options' ); function add_summer_goodpoints_options() { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $favicon_url = get_stylesheet_directory_uri() . ''; $style = "display: inline-block; height: 13px; margin-top: 3px; vertical-align: top;"; $icon = '<img src="' . $favicon_url . '" style="'.$style.'" /> - '; $icon = ''; add_meta_box( 'custom-metabox-summer_goodpoints', $icon.__( 'Yes, please' ), 'summer_goodpoints_options', 'post', 'normal', 'high' ); } } function summer_goodpoints_options( $post ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $summer_goodpoints = get_post_meta( $post->ID, 'summer_goodpoints', true ); wp_editor( $summer_goodpoints, 'summer_goodpoints', array( 'textarea_name' => 'summer_goodpoints', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_summer_goodpoints_metabox' ); function save_summer_goodpoints_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { if( $_POST ) { $summer_goodpoints = get_post_meta( $post->ID, 'summer_goodpoints', true ); $new = $_POST['summer_goodpoints']; if($new && $new != $old && $new != '') { update_post_meta($post_id, 'summer_goodpoints', $new); } } } } //Bad Points: Yes, but... add_action( 'add_meta_boxes', 'add_summer_badpoints_options' ); function add_summer_badpoints_options() { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $favicon_url = get_stylesheet_directory_uri() . ''; $style = "display: inline-block; height: 13px; margin-top: 3px; vertical-align: top;"; $icon = '<img src="' . $favicon_url . '" style="'.$style.'" /> - '; $icon = ''; add_meta_box( 'custom-metabox-summer_badpoints', $icon.__( 'Yes, but...' ), 'summer_badpoints_options', 'post', 'normal', 'high' ); } } function summer_badpoints_options( $post ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $summer_badpoints = get_post_meta( $post->ID, 'summer_badpoints', true ); wp_editor( $summer_badpoints, 'summer_badpoints', array( 'textarea_name' => 'summer_badpoints', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_summer_badpoints_metabox' ); function save_summer_badpoints_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { if( $_POST ) { $summer_badpoints = get_post_meta( $post->ID, 'summer_badpoints', true ); $new = $_POST['summer_badpoints']; if($new && $new != $old && $new != '') { update_post_meta($post_id, 'summer_badpoints', $new); } } } } //Our Tips add_action( 'add_meta_boxes', 'add_summer_ourtips_options' ); function add_summer_ourtips_options() { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $favicon_url = get_stylesheet_directory_uri() . ''; $style = "display: inline-block; height: 13px; margin-top: 3px; vertical-align: top;"; $icon = '<img src="' . $favicon_url . '" style="'.$style.'" /> - '; $icon = ''; add_meta_box( 'custom-metabox-summer_ourtips', $icon.__( 'Summer Our Tips' ), 'summer_ourtips_options', 'post', 'normal', 'high' ); } } function summer_ourtips_options( $post ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { $summer_ourtips = get_post_meta( $post->ID, 'summer_ourtips', true ); wp_editor( $summer_ourtips, 'summer_ourtips', array( 'textarea_name' => 'summer_ourtips', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_summer_ourtips_metabox' ); function save_summer_ourtips_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { $insummerresorts = true; } if ($insummerresorts == true) { if( $_POST ) { $summer_ourtips = get_post_meta( $post->ID, 'summer_ourtips', true ); $new = $_POST['summer_ourtips']; if($new && $new != $old && $new != '') { update_post_meta($post_id, 'summer_ourtips', $new); } } } } // Summer Resort reviews Practical Information add_action( 'add_meta_boxes', 'add_practical_info_options' ); $summerresort_category_name = 'Summer Resorts'; function add_practical_info_options() { global $post, $summerresort_category_name; $insummerresortreviews = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { add_meta_box( 'custom-metabox-practical_info', $icon.__( 'Summer Resorts Practical Information' ), 'practical_info_options', 'post', 'normal', 'high' ); } } function practical_info_options( $post ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { // Where to stay echo '<h1>Where to stay</h1>'; $wheretostay = get_post_meta( $post->ID, 'wheretostay', true ); wp_editor( $wheretostay, 'wheretostay', array( 'textarea_name' => 'wheretostay', 'media_buttons' => true, 'wpautop' => false ) ); // Where to eat echo '<h1>Food and Drink</h1>'; $foodanddrink = get_post_meta( $post->ID, 'foodanddrink', true ); wp_editor( $foodanddrink, 'foodanddrink', array( 'textarea_name' => 'foodanddrink', 'media_buttons' => true, 'wpautop' => false ) ); //Activities to do echo '<h1>Activities to do</h1>'; $activities = get_post_meta( $post->ID, 'activities', true ); wp_editor( $activities, 'activities', array( 'textarea_name' => 'activities', 'media_buttons' => true, 'wpautop' => false ) ); // Places to visit echo '<h1>Places to visit</h1>'; $placestovisit = get_post_meta( $post->ID, 'placestovisit', true ); wp_editor( $placestovisit, 'placestovisit', array( 'textarea_name' => 'placestovisit', 'media_buttons' => true, 'wpautop' => false ) ); // Getting There echo '<h1>Getting There</h1>'; $gettingthere = get_post_meta( $post->ID, 'gettingthere', true ); wp_editor( $gettingthere, 'gettingthere', array( 'textarea_name' => 'gettingthere', 'media_buttons' => true, 'wpautop' => false ) ); //Custom walks/rides etc. echo '<h1>Walks, rides etc.</h1>'; $custom_walks_rides = get_post_meta( $post->ID, 'custom_walks_rides', true ); wp_editor( $custom_walks_rides, 'custom_walks_rides', array( 'textarea_name' => 'custom_walks_rides', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_practical_info_metabox' ); function save_practical_info_metabox( $post_id ) { global $post, $summerresort_category_name; $insummerresorts = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summerresort_category_name, $category_array)) { if( $_POST ) { // Where to stay $old_wheretostay = get_post_meta( $post->ID, 'wheretostay', true ); $new_wheretostay = $_POST['wheretostay']; if($new_wheretostay && $new_wheretostay != $old_wheretostay && $new_wheretostay != '') { update_post_meta($post_id, 'wheretostay', $new_wheretostay); } // Where to eat $old_foodanddrink = get_post_meta( $post->ID, 'foodanddrink', true ); $new_foodanddrink = $_POST['foodanddrink']; if($new_foodanddrink && $new_foodanddrink != $old_foodanddrink && $new_foodanddrink != '') { update_post_meta($post_id, 'foodanddrink', $new_foodanddrink); } // Activities to do $old_activities = get_post_meta( $post->ID, 'activities', true ); $new_activities = $_POST['activities']; if($new_activities && $new_activities != $old_activities && $new_activities != '') { update_post_meta($post_id, 'activities', $new_activities); } // Places to visit $old_placestovisit = get_post_meta( $post->ID, 'placestovisit', true ); $new_placestovisit = $_POST['placestovisit']; if($new_placestovisit && $new_placestovisit != $old_placestovisit && $new_placestovisit != '') { update_post_meta($post_id, 'placestovisit', $new_placestovisit); } // Getting There $old_gettingthere = get_post_meta( $post->ID, 'gettingthere', true ); $new_gettingthere = $_POST['gettingthere']; if($new_gettingthere && $new_gettingthere != $old_gettingthere && $new_gettingthere != '') { update_post_meta($post_id, 'gettingthere', $new_gettingthere); } //Custom walks/rides etc. $old_custom_walks_rides = get_post_meta( $post->ID, 'custom_walks_rides', true ); $new_custom_walks_rides = $_POST['custom_walks_rides']; if($new_custom_walks_rides && $new_custom_walks_rides != $old_custom_walks_rides && $new_custom_walks_rides != '') { update_post_meta($post_id, 'custom_walks_rides', $new_custom_walks_rides); } } } } // Features / Activities Meta Boxes $summeractivities_category_name = 'Summer Activities'; //Summer Features Practical Information add_action( 'add_meta_boxes', 'add_sfeatures_info_options' ); function add_sfeatures_info_options() { global $post, $summeractivities_category_name; $insummeractivities = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summeractivities_category_name, $category_array)) { add_meta_box( 'custom-metabox-sfeatures_info', $icon.__( 'Essential Info' ), 'sfeatures_info_options', 'post', 'normal', 'high' ); } } function sfeatures_info_options( $post ) { global $post, $summeractivities_category_name; $insummeractivities = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summeractivities_category_name, $category_array)) { //Useful Information echo '<h1>Useful Information</h1>'; $sfeatures_info = get_post_meta( $post->ID, 'sfeatures_info', true ); wp_editor( $sfeatures_info, 'sfeatures_info', array( 'textarea_name' => 'sfeatures_info', 'media_buttons' => true, 'wpautop' => false ) ); // When to go echo '<h1>When to go</h1>'; $whentogo = get_post_meta( $post->ID, 'whentogo', true ); wp_editor( $whentogo, 'whentogo', array( 'textarea_name' => 'whentogo', 'media_buttons' => true, 'wpautop' => false ) ); // Where to stay echo '<h1>Where to stay</h1>'; $sfeatures_wheretostay = get_post_meta( $post->ID, 'sfeatures_wheretostay', true ); wp_editor( $sfeatures_wheretostay, 'sfeatures_wheretostay', array( 'textarea_name' => 'sfeatures_wheretostay', 'media_buttons' => true, 'wpautop' => false ) ); // Equipment Required echo '<h1>Equipment Required</h1>'; $equipment = get_post_meta( $post->ID, 'equipment', true ); wp_editor( $equipment, 'equipment', array( 'textarea_name' => 'equipment', 'media_buttons' => true, 'wpautop' => false ) ); // Useful addresses echo '<h1>Useful Addresses</h1>'; $usefuladdresses = get_post_meta( $post->ID, 'usefuladdresses', true ); wp_editor( $usefuladdresses, 'usefuladdresses', array( 'textarea_name' => 'usefuladdresses', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_sfeatures_info_metabox' ); function save_sfeatures_info_metabox( $post_id ) { global $post, $summeractivities_category_name; $insummeractivities = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($summeractivities_category_name, $category_array)) { if( $_POST ) { //Useful Information $old_sfeatures_info = get_post_meta( $post->ID, 'sfeatures_info', true ); $new_sfeatures_info = $_POST['sfeatures_info']; if($new_sfeatures_info && $new_sfeatures_info != $old_sfeatures_info && $new_sfeatures_info != '') { update_post_meta($post_id, 'sfeatures_info', $new_sfeatures_info); } // When to go $old_whentogo = get_post_meta( $post->ID, 'whentogo', true ); $new_whentogo = $_POST['whentogo']; if($new_whentogo && $new_whentogo != $old_whentogo && $new_whentogo != '') { update_post_meta($post_id, 'whentogo', $new_whentogo); } // Where to stay $old_sfeatures_wheretostay = get_post_meta( $post->ID, 'sfeatures_wheretostay', true ); $new_sfeatures_wheretostay = $_POST['sfeatures_wheretostay']; if($new_sfeatures_wheretostay && $new_sfeatures_wheretostay != $old_sfeatures_wheretostay && $new_sfeatures_wheretostay != '') { update_post_meta($post_id, 'sfeatures_wheretostay', $new_sfeatures_wheretostay); } // Equipment Needed $old_equipment = get_post_meta( $post->ID, 'equipment', true ); $new_equipment = $_POST['equipment']; if($new_equipment && $new_equipment != $old_equipment && $new_equipment != '') { update_post_meta($post_id, 'equipment', $new_equipment); } // Useful Addresses $old_usefuladdresses = get_post_meta( $post->ID, 'usefuladdresses', true ); $new_usefuladdresses = $_POST['usefuladdresses']; if($new_usefuladdresses && $new_usefuladdresses != $old_usefuladdresses && $new_usefuladdresses != '') { update_post_meta($post_id, 'usefuladdresses', $new_usefuladdresses); } } } } //Mountain Life & Style Features Practical Information $livingfeatures_category_name = 'Mountain Living'; add_action( 'add_meta_boxes', 'add_livfeatures_info_options' ); function add_livfeatures_info_options() { global $post, $livingfeatures_category_name; $inlivingfeatures = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($livingfeatures_category_name, $category_array)) { $inlivingfeatures = true; } if ($inlivingfeatures == true) { $favicon_url = get_stylesheet_directory_uri() . ''; $style = "display: inline-block; height: 13px; margin-top: 3px; vertical-align: top;"; $icon = '<img src="' . $favicon_url . '" style="'.$style.'" /> - '; $icon = ''; add_meta_box( 'custom-metabox-livfeatures_info', $icon.__( 'Essential Info' ), 'livfeatures_info_options', 'post', 'normal', 'high' ); } } function livfeatures_info_options( $post ) { global $post, $livingfeatures_category_name; $inlivingfeatures = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($livingfeatures_category_name, $category_array)) { $inlivingfeatures = true; } if ($inlivingfeatures == true) { $livfeatures_info = get_post_meta( $post->ID, 'livfeatures_info', true ); wp_editor( $livfeatures_info, 'livfeatures_info', array( 'textarea_name' => 'livfeatures_info', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_livfeatures_info_metabox' ); function save_livfeatures_info_metabox( $post_id ) { global $post, $livingfeatures_category_name; $inlivingfeatures = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($livingfeatures_category_name, $category_array)) { $inlivingfeatures = true; } if ($inlivingfeatures == true) { if( $_POST ) { $livfeatures_info = get_post_meta( $post->ID, 'livfeatures_info', true ); $new = $_POST['livfeatures_info']; if($new && $new != $old && $new != '') { update_post_meta($post_id, 'livfeatures_info', $new); } } } } // Scenic Touring Practical Information add_action( 'add_meta_boxes', 'add_touring_info_options' ); $scenictouring_category_name = 'Scenic Touring'; function add_touring_info_options() { global $post, $scenictouring_category_name; $inscenictouring = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($scenictouring_category_name, $category_array)) { add_meta_box( 'custom-metabox-touring_info', $icon.__( 'Scenic Touring Practical Information' ), 'touring_info_options', 'post', 'normal', 'high' ); } } function touring_info_options( $post ) { global $post, $scenictouring_category_name; $inscenictouring = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($scenictouring_category_name, $category_array)) { // Where to stay echo '<h1>Where to stay</h1>'; $wheretostay = get_post_meta( $post->ID, 'wheretostay', true ); wp_editor( $wheretostay, 'wheretostay', array( 'textarea_name' => 'wheretostay', 'media_buttons' => true, 'wpautop' => false ) ); // Where to eat echo '<h1>Food and Drink</h1>'; $foodanddrink = get_post_meta( $post->ID, 'foodanddrink', true ); wp_editor( $foodanddrink, 'foodanddrink', array( 'textarea_name' => 'foodanddrink', 'media_buttons' => true, 'wpautop' => false ) ); // Things to Do echo '<h1>Places to Visit</h1>'; $placestovisit = get_post_meta( $post->ID, 'placestovisit', true ); wp_editor( $placestovisit, 'placestovisit', array( 'textarea_name' => 'placestovisit', 'media_buttons' => true, 'wpautop' => false ) ); //Origins of the Route echo '<h1>Origins of the Route</h1>'; $routehistory = get_post_meta( $post->ID, 'routehistory', true ); wp_editor( $routehistory, 'routehistory', array( 'textarea_name' => 'routehistory', 'media_buttons' => true, 'wpautop' => false ) ); // Useful Addresses echo '<h1>Useful Addresses</h1>'; $usefuladdresses = get_post_meta( $post->ID, 'usefuladdresses', true ); wp_editor( $usefuladdresses, 'usefuladdresses', array( 'textarea_name' => 'usefuladdresses', 'media_buttons' => true, 'wpautop' => false ) ); } } add_action( 'save_post', 'save_touring_info_metabox' ); function save_touring_info_metabox( $post_id ) { global $post, $scenictouring_category_name; $inscenictouring = ''; $category = get_the_category($post->ID); $category_name = $category[0]->name; $category_array = array(); foreach ($category as $cat) { $category_array[] = $cat->name; } if (in_array($scenictouring_category_name, $category_array)) { if( $_POST ) { // Where to stay $old_wheretostay = get_post_meta( $post->ID, 'wheretostay', true ); $new_wheretostay = $_POST['wheretostay']; if($new_wheretostay && $new_wheretostay != $old_wheretostay && $new_wheretostay != '') { update_post_meta($post_id, 'wheretostay', $new_wheretostay); } // Where to eat $old_foodanddrink = get_post_meta( $post->ID, 'foodanddrink', true ); $new_foodanddrink = $_POST['foodanddrink']; if($new_foodanddrink && $new_foodanddrink != $old_foodanddrink && $new_foodanddrink != '') { update_post_meta($post_id, 'foodanddrink', $new_foodanddrink); } // Places to visit $old_placestovisit = get_post_meta( $post->ID, 'placestovisit', true ); $new_placestovisit = $_POST['placestovisit']; if($new_placestovisit && $new_placestovisit != $old_placestovisit && $new_placestovisit != '') { update_post_meta($post_id, 'placestovisit', $new_placestovisit); } // Origins of the Route $old_routehistory = get_post_meta( $post->ID, 'routehistory', true ); $new_routehistory = $_POST['routehistory']; if($new_routehistory && $new_routehistory != $old_routehistory && $new_routehistory != '') { update_post_meta($post_id, 'routehistory', $new_routehistory); } // Useful Addresses $old_usefuladdresses = get_post_meta( $post->ID, 'usefuladdresses', true ); $new_usefuladdresses = $_POST['usefuladdresses']; if($new_usefuladdresses && $new_usefuladdresses != $old_usefuladdresses && $new_usefuladdresses != '') { update_post_meta($post_id, 'usefuladdresses', $new_usefuladdresses); } } } } //Function to link stylesheet to WP TinyMCE function my_theme_add_editor_styles() { add_editor_style( '/custom-editor-style.css' ); } add_action( 'admin_init', 'my_theme_add_editor_styles' ); ?>
Save
Cancel