Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- @ini_set( 'upload_max_size' , '64M' );
- @ini_set( 'post_max_size', '64M');
- @ini_set( 'max_execution_time', '300' );
- // Navigation
- register_nav_menus( array(
- 'main' => __( 'Primary Navigation' ),
- 'footer-menu' => __( 'Footer Navigation' ),
- ) );
- // Register scripts
- function my_scripts_method() {
- wp_deregister_script( 'jquery' );
- wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
- wp_enqueue_script( 'jquery' );
- }
- add_action('wp_enqueue_scripts', 'my_scripts_method');
- // Add first_item and last_item class to last li in wp_nav_menu lists
- function add_first_and_last($output) {
- $output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1);
- $output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item'));
- return $output;
- }
- add_filter('wp_nav_menu', 'add_first_and_last');
- //register sidebars
- if ( function_exists('register_sidebar') )
- register_sidebar(array('name' => 'header-search',
- ));
- register_sidebar(array('name' => 'twitter',
- ));
- //register_sidebar(array('name' => 'footer-external-news',
- //));
- register_sidebar(array('name' => 'page',
- ));
- //register_sidebar(array('name' => 'news',
- //));
- //register_sidebar(array('name' => 'events',
- //));
- //register_sidebar(array('name' => 'resources',
- //));
- //register custom posts
- register_post_type( 'blocks',
- array(
- 'label' => __( 'Homepage Blocks' ),
- 'singular_label' => __( 'Homepage Block' ),
- '_builtin' => false, // It's a custom post type, not built in!
- 'public' => true,
- 'menu_position' => 5,
- 'query_var' => true,
- 'hierarchical' => true,
- 'attributes' => true,
- 'supports' => array('title'),
- 'rewrite' => array('slug'=>'block'),
- )
- );
- register_post_type( 'sponsors',
- array(
- 'label' => __( 'Sponsors' ),
- 'singular_label' => __( 'Sponsor' ),
- '_builtin' => false, // It's a custom post type, not built in!
- 'public' => true,
- 'menu_position' => 6,
- 'query_var' => true,
- 'hierarchical' => true,
- 'attributes' => true,
- 'supports' => array('title', 'editor'),
- 'rewrite' => array('slug'=>'sponsors'),
- )
- );
- register_post_type( 'where_to',
- array(
- 'label' => __( 'Where to' ),
- 'singular_label' => __( 'Where to' ),
- '_builtin' => false, // It's a custom post type, not built in!
- 'public' => true,
- 'menu_position' => 5,
- 'query_var' => true,
- 'hierarchical' => true,
- 'attributes' => true,
- 'supports' => array('title', 'editor', 'thumbnail'),
- 'rewrite' => array('slug'=>'where_to'),
- )
- );
- register_post_type( 'whats_going_on',
- array(
- 'label' => __( 'What is going on' ),
- 'singular_label' => __( 'What is going on' ),
- '_builtin' => false, // It's a custom post type, not built in!
- 'public' => true,
- 'menu_position' => 5,
- 'query_var' => true,
- 'hierarchical' => true,
- 'attributes' => true,
- 'supports' => array('title', 'editor', 'thumbnail'),
- 'rewrite' => array('slug'=>'whats_going_on'),
- )
- );
- // Custom Meta Boxes
- //// Setup Meta Box Data
- global $prefix;
- $prefix = 'cf_';
- $meta_boxes = array();
- // For Home Blocks
- $meta_boxes[] = array(
- 'id' => 'block_meta_box_title_location',
- 'title' => 'Title and Location',
- 'pages' => array('blocks'), // post type
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => true, // Show field names left of input
- 'fields' => array(
- array(
- 'name' => 'Title',
- 'id' => 'blockTitle',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Subtitle',
- 'id' => 'blockSubTitle',
- 'type' => 'text'
- ),
- array(
- 'name' => 'What is the position of this block on the Homepage?',
- 'id' => 'blockLocation',
- 'type' => 'select',
- 'options' => array(
- array('name' => '', 'value' => ''),
- array('name' => 'Welcome', 'value' => 'welcome'),
- array('name' => 'Page Link x4', 'value' => 'pageLinkX4'),
- array('name' => 'Page Link x3', 'value' => 'pageLinkX3'),
- array('name' => 'Banner', 'value' => 'banner')
- )
- )
- )
- );
- $meta_boxes[] = array(
- 'id' => 'block_meta_box_content',
- 'title' => 'Content',
- 'pages' => array('blocks'), // post type
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => true, // Show field names left of input
- 'fields' => array(
- array(
- 'name' => 'Image',
- 'id' => 'blockImage',
- 'desc' => 'Which image do you want to use? Copy/Paste the image URL from the media Library here.',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Image Alt Tag',
- 'id' => 'blockALT',
- 'desc' => 'For good SEO lable the image, try and use relevant keywords.',
- 'type' => 'text'
- ),
- array(
- 'name' => 'URL',
- 'id' => 'blockURL',
- 'desc' => 'When the user clicks on the links in this block, where do you want them to go?',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Description',
- 'id' => 'blockText',
- 'type' => 'textarea'
- )
- )
- );
- // For Sponsors
- $meta_boxes[] = array(
- 'id' => 'block_meta_box_sponsors',
- 'title' => 'Sponsors',
- 'pages' => array('sponsors'), // post type
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => true, // Show field names left of input
- 'fields' => array(
- array(
- 'name' => 'Image',
- 'id' => 'sponsorImage',
- 'desc' => 'Which logo/image do you want to use? Copy/Paste the image URL from the media Library here.',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Image Alt Tag',
- 'id' => 'sponsorALT',
- 'desc' => 'For good SEO lable the image, try and use relevant keywords.',
- 'type' => 'text'
- ),
- array(
- 'name' => 'URL',
- 'id' => 'sponsorURL',
- 'desc' => 'When the user clicks on the links in this block, where do you want them to go?',
- 'type' => 'text'
- )
- )
- );
- // For Whats going on
- $meta_boxes[] = array(
- 'id' => 'block_meta_box_whats_going_on_what',
- 'title' => 'Type',
- 'pages' => array('whats_going_on'), // post type
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => true, // Show field names left of input
- 'fields' => array(
- array(
- 'name' => 'Type',
- 'id' => 'block_meta_box_whats_going_on_type',
- 'type' => 'select',
- 'options' => array(
- array('name' => '', 'value' => ''),
- array('name' => 'Market', 'value' => 'Market'),
- array('name' => 'Demo', 'value' => 'Demo'),
- array('name' => 'Offer', 'value' => 'Offer')
- )
- )
- )
- );
- // For Where to
- $meta_boxes[] = array(
- 'id' => 'block_meta_box_where_to_what',
- 'title' => 'Where to',
- 'pages' => array('where_to'), // post type
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => true, // Show field names left of input
- 'fields' => array(
- array(
- 'name' => 'Type',
- 'id' => 'block_meta_box_where_to_type',
- 'type' => 'select',
- 'options' => array(
- array('name' => '', 'value' => ''),
- array('name' => 'Eat', 'value' => 'Eat'),
- array('name' => 'Stay', 'value' => 'Stay')
- )
- )
- )
- );
- $meta_boxes[] = array(
- 'id' => 'block_meta_box_where_to_details',
- 'title' => 'Details',
- 'pages' => array('where_to'), // post type
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => true, // Show field names left of input
- 'fields' => array(
- array(
- 'name' => 'Business Name',
- 'id' => 'where_to_name',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Business Type',
- 'id' => 'where_to_type',
- 'desc' => 'What type of hotel/restuarant is it?',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Business Location',
- 'id' => 'where_to_location',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Business Address',
- 'id' => 'where_to_address',
- 'type' => 'textarea'
- ),
- array(
- 'name' => 'Business Phone',
- 'id' => 'where_to_phone',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Business Web',
- 'id' => 'where_to_web',
- 'type' => 'text'
- ),
- array(
- 'name' => 'Business Email',
- 'id' => 'where_to_email',
- 'type' => 'text'
- ),
- )
- );
- //-- Begin moving post editor to notes metabox ---------
- // Comment this out to disable
- $meta_boxes[] = array(
- 'id' => 'block_meta_box_where_to_desc',
- 'title' => 'Description',
- 'pages' => array('where_to'), // post type
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => false, // Show field names left of input
- 'fields' => array()
- );
- //-- Pause moving post editor
- //-- Unpause moving post editor
- function crm_move_posteditor( $hook ) {
- if ( $hook == 'post.php' OR $hook == 'post-new.php' ) {
- wp_enqueue_script( 'jquery' );
- add_action('admin_print_footer_scripts','crm_move_posteditor_scripts');
- }
- }
- add_action( 'admin_enqueue_scripts', 'crm_move_posteditor', 10, 1 );
- function crm_move_posteditor_scripts() {
- ?>
- <script type="text/javascript">
- jQuery('#postdiv, #postdivrich').prependTo('#block_meta_box_where_to_desc .inside');
- </script>
- <style type="text/css">
- #normal-sortables {margin-top: 20px;}
- #titlediv { margin-bottom: 0px; }
- #postdiv.postarea, #postdivrich.postarea { margin:0; }
- #post-status-info { line-height:1.4em; font-size:13px; }
- #custom_editor .inside { margin:2px 6px 6px 6px; }
- #ed_toolbar { display:none; }
- #postdiv #ed_toolbar, #postdivrich #ed_toolbar { display:block; }
- </style>
- <?php
- }
- //-- End moving post editor
- // Create Meta Box
- include_once( '_/metabox/init.php' );
- // Add ability to upload Adobe files (photoshop, etc)
- // MIME types found at http://www.webmaster-toolkit.com/mime-types.shtml
- function crm_add_upload_support( $mimes ) {
- $mimes['psd'] = 'application/psd';
- $mimes['eps'] = 'application/postscript';
- $mimes['ai'] = 'application/postscript';
- return $mimes;
- }
- add_filter( 'upload_mimes','crm_add_upload_support' );
- // important: note the priority of 99, the js needs to be placed after tinymce loads
- add_action('admin_print_footer_scripts','my_admin_print_footer_scripts',99);
- function my_admin_print_footer_scripts()
- {
- ?><script type="text/javascript">/* <![CDATA[ */
- jQuery(function($)
- {
- var i=1;
- $('.theEditor textarea').each(function(e)
- {
- var id = $(this).attr('id');
- if (!id)
- {
- id = 'theEditor-' + i++;
- $(this).attr('id',id);
- }
- tinyMCE.execCommand('mceAddControl', false, id);
- });
- });
- /* ]]> */</script><?php
- }
- // Customise Admin
- //// Menu Order
- function custom_menu_order($menu_ord) {
- if (!$menu_ord) return true;
- return array(
- 'index.php', // Dashboard
- 'separator1', // First separator
- 'edit.php', // Posts
- 'edit.php?post_type=page', // Pages
- 'edit.php?post_type=blocks',
- 'edit.php?post_type=where_to',
- 'edit.php?post_type=whats_going_on',
- 'edit.php?post_type=sponsors',
- 'edit.php?post_type=event',
- 'separator2', // Second separator
- 'upload.php', // Media
- 'link-manager.php', // Links
- 'edit-comments.php', // Comments
- 'themes.php', // Appearance
- 'plugins.php', // Plugins
- 'users.php', // Users
- 'tools.php', // Tools
- 'options-general.php', // Settings
- 'separator-last', // Last separator
- );
- }
- add_filter('custom_menu_order', 'custom_menu_order'); // Activate custom_menu_order
- add_filter('menu_order', 'custom_menu_order');
- //// Remove items
- function edit_admin_menus() {
- global $menu;
- global $submenu;
- $menu[5][0] = 'News'; // Change Posts name
- $submenu['edit.php'][5][0] = 'All News';
- $submenu['edit.php'][10][0] = 'Add News';
- remove_menu_page('link-manager.php'); // Remove the Links Menu
- }
- add_action( 'admin_menu', 'edit_admin_menus' );
- // post thumbnails
- if ( function_exists( 'add_theme_support' ) ) {
- add_theme_support( 'post-thumbnails', array( 'post', 'where_to', 'whats_going_on' ) );
- set_post_thumbnail_size( 140, 105, true ); // default Post Thumbnail dimensions (cropped)
- }
- // conditional placeholder EM
- /**
- * add some conditional output conditions for Events Manager
- * @param string $replacement
- * @param string $condition
- * @param string $match
- * @param object $EM_Event
- * @return string
- */
- function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
- if (is_object($EM_Event)) {
- switch ($condition) {
- // #_ATT{Premium}
- case 'has_att_premium':
- if (is_array($EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Premium']))
- $replacement = preg_replace('/\{\/?has_att_premium\}/', '', $match);
- else
- $replacement = '';
- break;
- }
- }
- // return $replacement;
- return ‘filterEventOutputCondition’;
- }
- add_filter('em_event_output_condition', 'filterEventOutputCondition', 10, 4);
- // there should be no blank lines below thing
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement