Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //define('WP_DEBUG', true);
- $post_types =array();
- $hided_for_current_post_type = false;
- $custom_post_type = "case_study";
- $single_type_posts = array();//posts types with only one post allowed
- $meta_box_fields = array('meta-text','meta-text1','meta-text2','meta-text3','box1_title','box_title','box_title1','box_title2','box_description','client','channel','logistics','news-bolddata','news-innercont','news-subhead','news-highlighthead','news-subcont','box1_link_title','box1_link_url','about_content','case_study_title1',
- 'case_study_title2','case_study_content','case_study_button_title','case_study_button_link'
- );
- $meta_box_files = array('image1','image2','image3','image4','detail_box1_image','box_image','case_study_image');
- function frnt_case_stdy_callback() {
- global $post;
- $id = $post->ID;
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $meta = get_post_meta( $id);
- //print_r($meta);
- ?>
- <style>
- #post-body-content {
- width: 85%;
- height: 1200px !important;
- background: #fff
- }
- #box_title1 {
- font-family: "Rock Salt" !important;
- }
- #box_title2 {
- font-family: 'Titillium Web', sans-serif;
- font-size: 2.5em;
- font-weight: 800;
- }
- </style>
- <p>
- <div style="width:100% !important;height:600px !important;float:left;margin-top:5%">
- <label for="case_study_title1" ><?php _e( 'Title1', 'box_domain' )?></label>
- <div style="width:100%;height:200px">
- <input type="text" style="width:100%;height:300px;float:left !important" name="case_study_title1" id="case_study_title1" value = '<?php if ( isset ( $meta['case_study_title1'] ) ) echo $meta['case_study_title1'][0]; ?>' />
- </div>
- <div style="width:100% !important;height:600px !important;float:left;margin-top:5%">
- <label for="case_study_title1" ><?php _e( 'Title2', 'box_domain' )?></label>
- <div style="width:100%;height:200px">
- <input type="text" style="width:100%;height:300px;float:left !important" name="case_study_title2" id="case_study_title2" value = '<?php if ( isset ( $meta['case_study_title2'] ) ) echo $meta['case_study_title2'][0]; ?>' />
- </div>
- <div style="width:100%;height:200px">
- <textarea type="text" style="width:100%;height:300px;float:left !important" name="case_study_content" id="case_study_content" ><?php if ( isset ( $meta['case_study_content'] ) ) echo $meta['case_study_content'][0]; ?></textarea>
- </div>
- </div>
- </p>
- <?php
- }
- add_action('init', 'init_theme');
- add_action( 'after_setup_theme', 'plastec_wp_setup' );
- function load_custom_fonts() {
- echo "<link href='http://fonts.googleapis.com/css?family=Oswald:400,700|Open+Sans|Dosis|Rock+Salt|Titillium+Web:400,200,200italic,300,300italic,400italic,600italic,600,700,700italic,900|Glegoo' rel='stylesheet' type='text/css'>";
- }
- function init_theme() {
- global $single_type_posts;
- global $custom_post_type;
- global $hided_for_current_post_type;
- register_pl_main_menu() ;
- register_case_studies();
- register_main_content() ;
- register_front_detail_box1();
- register_front_detail_boxes();
- register_front_bottom_box();
- register_front_casestudy_slider();
- register_services() ;
- register_news() ;
- register_footer_about_content();
- add_action('admin_head','load_custom_fonts');
- reset_editor('news');//removes default editor
- $custom_p_types = array(
- array(
- 'post_type_name' => 'main_content',
- 'allowed_no_of_posts' => 1
- ) ,
- array(
- 'post_type_name' => 'front_detail_box1',
- 'allowed_no_of_posts' => 1
- ),
- array(
- 'post_type_name' => 'front_detail_boxes',
- 'allowed_no_of_posts' => 3
- ),
- array(
- 'post_type_name' => 'front_bottom_box',
- 'allowed_no_of_posts' => 1
- ),
- array(
- 'post_type_name' => 'footer_about_content',
- 'allowed_no_of_posts' => 1
- ),
- array(
- 'post_type_name' => 'front_casestudy_slider',
- 'allowed_no_of_posts' => 3
- )
- );
- foreach($custom_p_types as $custom_p_type) {
- $p_t_name = $custom_p_type['post_type_name'];
- $p_t_posts = $custom_p_type['allowed_no_of_posts'];
- $post_count = get_posts_count($p_t_name );
- if($post_count>=$p_t_posts) {//if there is one post, dont allow more posts
- array_push($single_type_posts,$p_t_name );
- }
- }
- add_action( 'admin_menu', 'hide_add_new_custom_type' );
- add_action('admin_head', 'hide_add_new_button');
- add_filter( 'post_row_actions', 'hide_trash_option', 10, 1 );
- }
- /*Function to hide addnew button in post type*/
- function hide_add_new_custom_type()
- {
- global $single_type_posts;
- global $submenu;
- // replace my_type with the name of your post type
- foreach($single_type_posts as $custom_post)
- unset($submenu['edit.php?post_type='.$custom_post][10]);//removed hover links 'add new' and 'all posts' for specific post type
- }
- function hide_trash_option() {
- global $single_type_posts;
- global $actions;
- $proceed = false;
- $t_post = get_post_type();
- foreach($single_type_posts as $s_post) {
- if($s_post == $t_post) {
- $proceed = true;
- break;
- }
- }
- if($proceed) {
- unset( $actions['trash'] );
- }
- }
- function hide_add_new_button() {/*removes add new post button for custom post type*/
- global $custom_post_type;
- global $single_type_posts;
- $proceed = false;
- $t_post = get_post_type();
- foreach($single_type_posts as $s_post) {
- if($s_post == $t_post) {
- $proceed = true;
- break;
- }
- }
- if($proceed) {
- echo '<style type="text/css">
- #favorite-actions {display:none;}
- .add-new-h2{display:none;}
- .tablenav{display:none;}
- </style>';
- }
- }
- function get_posts_count($post_type) {
- $count_posts = wp_count_posts( $post_type)->publish;
- return $count_posts;
- }
- function register_front_casestudy_slider() {
- global $post_types;
- array_push($post_types, 'front_casestudy_slider');
- $labels = array(
- 'name' => _x('Home Page Case Study Slider', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add case study', 'case study'),
- 'add_new_item' => __('Add case study'),
- 'edit_item' => __('Edit case study'),
- 'new_item' => __('New case study'),
- 'view_item' => __('View case study'),
- 'search_items' => __('Search case study'),
- 'not_found' => __('No case study found'),
- 'not_found_in_trash' => __('No case study found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => false
- );
- register_post_type( 'front_casestudy_slider' , $args );
- }
- function register_pl_main_menu() {
- register_nav_menu( 'primary', 'Header Area' );
- $menuname = 'Main Navigation Menu';
- $bpmenulocation = 'Header Area 3` ';
- // Does the menu exist already?
- $menu_exists = wp_get_nav_menu_object( $menuname );
- // If it doesn't exist, let's create it.
- if( !$menu_exists){
- $menu_id = wp_create_nav_menu($menuname);
- // Set up default BuddyPress links and add them to the menu.
- wp_update_nav_menu_item($menu_id, 0, array(
- 'menu-item-title' => __('Home'),
- 'menu-item-classes' => 'home',
- 'menu-item-url' => home_url( '/' ),
- 'menu-item-status' => 'publish'));
- wp_update_nav_menu_item($menu_id, 0, array(
- 'menu-item-title' => __('Our Services'),
- 'menu-item-classes' => 'our-services',
- 'menu-item-url' => home_url( '/our-services/' ),
- 'menu-item-status' => 'publish'));
- wp_update_nav_menu_item($menu_id, 0, array(
- 'menu-item-title' => __('About Us'),
- 'menu-item-classes' => 'about-us',
- 'menu-item-url' => home_url( '/about-us/' ),
- 'menu-item-status' => 'publish'));
- wp_update_nav_menu_item($menu_id, 0, array(
- 'menu-item-title' => __('Case Studies'),
- 'menu-item-classes' => 'case-studies',
- 'menu-item-url' => home_url( '/case-studies/' ),
- 'menu-item-status' => 'publish'));
- wp_update_nav_menu_item($menu_id, 0, array(
- 'menu-item-title' => __('News'),
- 'menu-item-classes' => 'news',
- 'menu-item-url' => home_url( '/news/' ),
- 'menu-item-status' => 'publish'));
- wp_update_nav_menu_item($menu_id, 0, array(
- 'menu-item-title' => __('Gallery'),
- 'menu-item-classes' => 'gallery',
- 'menu-item-url' => home_url( '/gallery/' ),
- 'menu-item-status' => 'publish'));
- wp_update_nav_menu_item($menu_id, 0, array(
- 'menu-item-title' => __('Contact Us'),
- 'menu-item-classes' => 'contact-us',
- 'menu-item-url' => home_url( '/contact-us/' ),
- 'menu-item-status' => 'publish'));
- // Grab the theme locations and assign our newly-created menu
- // to the BuddyPress menu location.
- if( !has_nav_menu( $bpmenulocation ) ){
- $locations = get_theme_mod('nav_menu_locations');
- $locations[$bpmenulocation] = $menu_id;
- set_theme_mod( 'nav_menu_locations', $locations );
- }
- }
- }
- function register_my_menu() {
- register_nav_menu('header-menu',__( 'Header Menu' ));
- global $menu;
- global $submenu;
- $menu[5][0] = 'News';
- $submenu['<span class="skimlinks-unlinked">edit.php</span>'][5][0] = 'News Items';
- $submenu['<span class="skimlinks-unlinked">edit.php</span>'][10][0] = 'Add News Item';
- }
- function register_footer_about_content() {
- global $post_types;
- array_push($post_types, 'footer_about_content');
- $labels = array(
- 'name' => _x('Footer About Content', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add content', 'case study'),
- 'add_new_item' => __('Add content'),
- 'edit_item' => __('Edit content'),
- 'new_item' => __('New content'),
- 'view_item' => __('View content '),
- 'search_items' => __('Search content'),
- 'not_found' => __('No content found'),
- 'not_found_in_trash' => __('No content found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => false
- );
- register_post_type( 'footer_about_content' , $args );
- }
- function register_front_detail_box1() {
- global $post_types;
- array_push($post_types, 'front_detail_box1');
- $labels = array(
- 'name' => _x('Home Page Detail Box1', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add data', 'case study'),
- 'add_new_item' => __('Add data'),
- 'edit_item' => __('Edit data'),
- 'new_item' => __('New Data'),
- 'view_item' => __('View data '),
- 'search_items' => __('Search data'),
- 'not_found' => __('No data found'),
- 'not_found_in_trash' => __('No data found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => false
- );
- register_post_type( 'front_detail_box1' , $args );
- }
- function register_front_detail_boxes() {
- global $post_types;
- array_push($post_types, 'front_detail_boxes');
- $labels = array(
- 'name' => _x('Home Page Detail Boxes', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add data', 'case study'),
- 'add_new_item' => __('Add data'),
- 'edit_item' => __('Edit data'),
- 'new_item' => __('New Data'),
- 'view_item' => __('View data '),
- 'search_items' => __('Search data'),
- 'not_found' => __('No data found'),
- 'not_found_in_trash' => __('No data found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => false
- );
- register_post_type( 'front_detail_boxes' , $args );
- }
- function register_front_bottom_box() {
- global $post_types;
- array_push($post_types, 'front_bottom_box');
- $labels = array(
- 'name' => _x('Home Page Bottom Box', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add data', 'case study'),
- 'add_new_item' => __('Add data'),
- 'edit_item' => __('Edit data'),
- 'new_item' => __('New Data'),
- 'view_item' => __('View data '),
- 'search_items' => __('Search data'),
- 'not_found' => __('No data found'),
- 'not_found_in_trash' => __('No data found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => false
- );
- register_post_type( 'front_bottom_box' , $args );
- }
- function register_news() {
- global $post_types;
- array_push($post_types, 'news');
- $labels = array(
- 'name' => _x('News', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add news', 'case study'),
- 'add_new_item' => __('Add news item'),
- 'edit_item' => __('Edit news'),
- 'new_item' => __('New news item'),
- 'view_item' => __('View news '),
- 'search_items' => __('Search news'),
- 'not_found' => __('No news found'),
- 'not_found_in_trash' => __('No news found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('thumbnail','title','editor')
- );
- register_post_type( 'news' , $args );
- }
- function register_services() {
- global $post_types;
- array_push($post_types, 'service');
- $labels = array(
- 'name' => _x('Services', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add service', 'case study'),
- 'add_new_item' => __('Add new service'),
- 'edit_item' => __('Edit service'),
- 'new_item' => __('New service'),
- 'view_item' => __('View service'),
- 'search_items' => __('Search service'),
- 'not_found' => __('No services found'),
- 'not_found_in_trash' => __('No services found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('thumbnail','title','editor')
- );
- register_post_type( 'service' , $args );
- }
- function register_case_studies() {
- global $post_types;
- array_push($post_types, 'case_study');
- $labels = array(
- 'name' => _x('Case Studies', 'Case studies will appear on case studies page'),
- 'add_new' => _x('Add Case Study', 'case study'),
- 'add_new_item' => __('Add new case study'),
- 'edit_item' => __('Edit case study'),
- 'new_item' => __('New case study'),
- 'view_item' => __('View case study'),
- 'search_items' => __('Search case studies'),
- 'not_found' => __('No case studies found'),
- 'not_found_in_trash' => __('No case studies found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('thumbnail','title','editor')
- );
- register_post_type( 'case_study' , $args );
- }
- function register_main_content() {
- global $post_types;
- array_push($post_types, 'main_content');
- $labels = array(
- 'name' => _x('Home Page Featured Contents', 'The main content will appear in top portion of home page'),
- 'add_new' => _x('Add Front Featured Content', 'portfolio item'),
- 'add_new_item' => __('Add Front Featured Content'),
- 'edit_item' => __('Edit Front Featured Content'),
- 'new_item' => __('New Front Featured Content'),
- 'view_item' => __('View Front Featured Content'),
- 'search_items' => __('Search Front Featured Content'),
- 'not_found' => __('Nothing found'),
- 'not_found_in_trash' => __('Nothing found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('thumbnail','editor','title')
- );
- register_post_type( 'main_content' , $args );
- }
- function plastec_wp_setup() {
- // This theme uses a custom image size for featured images, displayed on "standard" posts.
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop
- add_theme_support( 'menus' );
- programmatically_create_post();
- }
- function prfx_custom_meta() {
- add_meta_box( 'prfx_meta', __( 'Featured Title', 'prfx-textdomain' ), 'prfx_meta_callback', 'main_content' );
- add_meta_box( 'case_stdy_meta', __( 'Case Study Details', 'case_stdy_domain' ), 'case_study_callback', 'case_study' );
- add_meta_box( 'news_meta', __( 'News details', 'news_domain' ), 'news_callback', 'news' );
- add_meta_box( 'frnt_detail_box1_meta', __( 'Box Data', 'box_domain' ), 'frnt_detail_bx1_callback', 'front_detail_box1' );
- add_meta_box( 'frnt_detail_boxes_meta', __( 'Box Data', 'box_domain' ), 'frnt_detail_boxes_callback', 'front_detail_boxes' );
- add_meta_box( 'frnt_bottom_box_meta', __( 'Box Data', 'box_domain' ), 'frnt_bottom_box_callback', 'front_bottom_box' );
- add_meta_box( 'footer_about_meta', __( 'Footer About Content', 'box_domain' ), 'footer_about_callback', 'footer_about_content' );
- // add_meta_box( 'front_case_stdy_meta', __( 'Case Study Details', 'prfx-textdomain' ), 'frnt_case_stdy_callback', 'front_casestudy_slider' );
- }
- function footer_about_callback() {
- global $post;
- $id = $post->ID;
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $meta = get_post_meta( $id);
- //print_r($meta);
- ?>
- <style>
- #post-body-content {
- width: 85%;
- height: 1200px !important;
- background: #fff
- }
- #box_title1 {
- font-family: "Rock Salt" !important;
- }
- #box_title2 {
- font-family: 'Titillium Web', sans-serif;
- font-size: 2.5em;
- font-weight: 800;
- }
- </style>
- <p>
- <div style="width:100% !important;height:600px !important;float:left;margin-top:5%">
- <label for="box1_link_url" ><?php _e( 'About Content', 'box_domain' )?></label>
- <div style="width:100%;height:200px">
- <textarea type="text" style="width:100%;height:300px;float:left !important" name="about_content" id="about_content" ><?php if ( isset ( $meta['about_content'] ) ) echo $meta['about_content'][0]; ?></textarea>
- </div>
- </p>
- <?php
- }
- function frnt_bottom_box_callback() {
- global $post;
- $id = $post->ID;
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $meta = get_post_meta( $id);
- //print_r($meta);
- ?>
- <style>
- #post-body-content {
- width: 85%;
- height: 1200px !important;
- background: #fff
- }
- #box_title1 {
- font-family: "Rock Salt" !important;
- }
- #box_title2 {
- font-family: 'Titillium Web', sans-serif;
- font-size: 2.5em;
- font-weight: 800;
- }
- </style>
- <p>
- <div style="width:100% !important;height:600px !important;float:left;margin-top:5%">
- <label for="box_title1" ><?php _e( 'Title 1', 'box_domain' )?></label>
- <input type="text" style="width:100%" name="box_title1" id="box_title1" value="<?php if ( isset ( $meta['box_title1'] ) ) echo $meta['box_title1'][0]; ?>"
- <label for="box_title2" ><?php _e( 'Title 2', 'box_domain' )?></label>
- <input type="text" style="width:100%" name="box_title2" id="box_title2" value="<?php if ( isset ( $meta['box_title2'] ) ) echo $meta['box_title2'][0]; ?>"
- <br />
- <label for="box1_link_url" ><?php _e( 'Description', 'box_domain' )?></label>
- <div style="width:100%;height:200px">
- <textarea type="text" style="width:100%;height:300px;float:left !important" name="box_description" id="box_description" ><?php if ( isset ( $meta['box_description'] ) ) echo $meta['box_description'][0]; ?></textarea>
- </div>
- <?php// print_r($meta);?>
- <?php// $state = ''; if( isset ( $meta['featured'] ) && $meta['featured'][0] =='checked') $state = "checked"; ?>
- <!-- <input type="checkbox" <?php echo $state;?> name="featured" id="featured" value =' <?php if($state == 'checked') echo "checked";else echo "unchecked" ?>' >-->
- </p>
- <?php
- }
- function frnt_detail_boxes_callback() {
- global $post;
- $id = $post->ID;
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $meta = get_post_meta( $id);
- //print_r($meta);
- ?>
- <style>
- #post-body-content {
- width: 85%;
- height: 1200px !important;
- background: #fff
- }
- #box_title {
- font-family: "Rock Salt" !important;
- }
- </style>
- <p>
- <div style="width:100% !important;height:600px !important;float:left;margin-top:5%">
- <label for="box1_title" ><?php _e( 'Title', 'box_domain' )?></label>
- <input type="text" style="width:100%" name="box_title" id="box_title" value="<?php if ( isset ( $meta['box_title'] ) ) echo $meta['box_title'][0]; ?>"
- <label for ='detail_box1_image'><?php _e( 'Detail Image ', 'box_domain' )?>
- </label>
- <input type="file" style="width:100%" size = '1000' name="box_image" id="box_image" />
- <?php if ( isset ( $meta['box_image'] ) ):?>
- <img style="width:300px" src = '<?php echo $meta['box_image'][0]; ?>' />
- <?php endif;?>
- <br />
- <label for="box1_link_url" ><?php _e( 'Description', 'box_domain' )?></label>
- <div style="width:100%;height:200px">
- <textarea type="text" style="width:100%;height:300px;float:left !important" name="box_description" id="box_description" ><?php if ( isset ( $meta['box_description'] ) ) echo $meta['box_description'][0]; ?></textarea>
- </div>
- <?php// print_r($meta);?>
- <?php// $state = ''; if( isset ( $meta['featured'] ) && $meta['featured'][0] =='checked') $state = "checked"; ?>
- <!-- <input type="checkbox" <?php echo $state;?> name="featured" id="featured" value =' <?php if($state == 'checked') echo "checked";else echo "unchecked" ?>' >-->
- </p>
- <?php
- }
- function frnt_detail_bx1_callback() {
- global $post;
- $id = $post->ID;
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $meta = get_post_meta( $id);
- //print_r($meta);
- ?>
- <style>
- #post-body-content {
- width: 85%;
- height: 1200px !important;
- background: #fff
- }
- #box1_title {
- font-family: "Rock Salt" !important;
- }
- </style>
- <p>
- <div style="width:100% !important;height:600px !important;float:left;margin-top:5%">
- <label for="box1_title" ><?php _e( 'Title', 'box_domain' )?></label>
- <input type="text" style="width:100%" name="box1_title" id="box1_title" value="<?php if ( isset ( $meta['box1_title'] ) ) echo $meta['box1_title'][0]; ?>"
- <label for ='detail_box1_image'><?php _e( 'Detail Image ', 'box_domain' )?>
- </label>
- <input type="file" style="width:100%" size = '1000' name="detail_box1_image" id="detail_box1_image" />
- <?php if ( isset ( $meta['detail_box1_image'] ) ):?>
- <img style="width:300px" src = '<?php echo $meta['detail_box1_image'][0]; ?>' />
- <?php endif;?>
- <br />
- <label for="box1_link_title" ><?php _e( 'Button Link Title ', 'box_domain' )?></label>
- <input type="text" style="width:100%" name="box1_link_title" id="box1_link_title" value="<?php if ( isset ( $meta['box1_link_title'] ) ) echo $meta['box1_link_title'][0]; ?>" />
- <label for="box1_link_url" ><?php _e( 'Button Link Url ', 'box_domain' )?></label>
- <div style="width:100%;height:200px">
- <label style="width:auto;float:left !important;font-size:1.2em;padding-top:1%;padding-right:1%"><?php echo site_url(); ?>/</label>
- <input type="text" style="width:65%;float:left !important" name="box1_link_url" id="box1_link_url" value="<?php if ( isset ( $meta['box1_link_url'] ) ) echo $meta['box1_link_url'][0]; ?>" />
- </div>
- <?php// print_r($meta);?>
- <?php// $state = ''; if( isset ( $meta['featured'] ) && $meta['featured'][0] =='checked') $state = "checked"; ?>
- <!-- <input type="checkbox" <?php echo $state;?> name="featured" id="featured" value =' <?php if($state == 'checked') echo "checked";else echo "unchecked" ?>' >-->
- </p>
- <?php
- }
- function case_study_callback() {
- global $post;
- $id = $post->ID;
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $meta = get_post_meta( $id);
- //print_r($meta);
- ?>
- <p>
- <label for="client" ><?php _e( 'Client ', 'case_stdy_domain' )?></label>
- <input type="text" style="width:100%" name="client" id="client" value="<?php if ( isset ( $meta['client'] ) ) echo $meta['client'][0]; ?>" />
- <label for ='channel'><?php _e( 'Channel ', 'case_stdy_domain' )?>
- </label>
- <input type="text" style="width:100%" name="channel" id="channel" value="<?php if ( isset ( $meta['channel'] ) ) echo $meta['channel'][0]; ?>" />
- <label for ='logistics'><?php _e( 'Logistics ', 'case_stdy_domain' )?>
- </label>
- <input type="text" style="width:100%" name="logistics" id="logistics" value="<?php if ( isset ( $meta['logistics'] ) ) echo $meta['logistics'][0]; ?>" />
- <hr />
- <label for ='image1'><?php _e( 'Image1 ', 'case_stdy_domain' )?>
- </label>
- <input type="file" style="width:100%" size = '1000' name="image1" id="image1" />
- <img style="width:300px" src = '<?php if ( isset ( $meta['image1'] ) ) echo $meta['image1'][0]; ?>' />
- <hr />
- <label for ='image2'><?php _e( 'Image2 ', 'case_stdy_domain' )?>
- </label>
- <input type="file" size = '1000' style="width:100%" name="image2" id="image2" />
- <img style="width:300px" src = '<?php if ( isset ( $meta['image2'] ) ) echo $meta['image2'][0]; ?>' />
- <hr />
- <label for ='image3'><?php _e( 'Image3 ', 'case_stdy_domain' )?>
- </label>
- <input type="file" style="width:100%" name="image3" id="image3" />
- <img style="width:300px" size = '1000' src = '<?php if ( isset ( $meta['image3'] ) ) echo $meta['image3'][0]; ?>' />
- <?php// print_r($meta);?>
- <?php// $state = ''; if( isset ( $meta['featured'] ) && $meta['featured'][0] =='checked') $state = "checked"; ?>
- <!-- <input type="checkbox" <?php echo $state;?> name="featured" id="featured" value =' <?php if($state == 'checked') echo "checked";else echo "unchecked" ?>' >-->
- </p>
- <?php
- }
- function news_callback($post) {
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $prfx_stored_meta = get_post_meta( $post->ID );
- // print_r($meta);
- ?>
- <style>
- textarea {
- height:200px;
- }
- </style>
- <p>
- <label for="news-bolddata" ><?php _e( 'Featured news content ', 'news_domain' )?></label>
- <textarea style="width:100%" name="news-bolddata" id="news-bolddata" ><?php if ( isset ( $prfx_stored_meta['news-bolddata'] ) ) echo $prfx_stored_meta['news-bolddata'][0]; ?> </textarea>
- </p>
- <p>
- <label for="news-innercont" ><?php _e( 'News Inner content ', 'news_domain' )?></label>
- <textarea style="width:100%" name="news-innercont" id="news-innercont" ><?php if ( isset ( $prfx_stored_meta['news-innercont'] ) ) echo $prfx_stored_meta['news-innercont'][0]; ?> </textarea>
- </p>
- <p>
- <label for="news-subhead" ><?php _e( 'Subheading: ', 'news_domain' )?></label>
- <input type="text" style="width:100%" name="news-subhead" id="news-subhead" value="<?php if ( isset ( $prfx_stored_meta['news-subhead'] ) ) echo $prfx_stored_meta['news-subhead'][0]; ?>" />
- </p>
- <p>
- <label for="news-highlighthead" ><?php _e( 'Subheading highlight: ', 'news_domain' )?></label>
- <input type="text" style="width:100%" name="news-highlighthead" id="news-highlighthead" value="<?php if ( isset ( $prfx_stored_meta['news-highlighthead'] ) ) echo $prfx_stored_meta['news-highlighthead'][0]; ?>" />
- </p>
- <p>
- <label for="news-subcont" ><?php _e( 'News sub content ', 'news_domain' )?></label>
- <textarea style="width:100%" name="news-subcont" id="news-subcont" ><?php if ( isset ( $prfx_stored_meta['news-subcont'] ) ) echo $prfx_stored_meta['news-subcont'][0]; ?> </textarea>
- </p>
- <?php
- }
- function prfx_meta_callback( $post ) {
- wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
- $prfx_stored_meta = get_post_meta( $post->ID );
- // print_r($meta);
- ?>
- <style>
- .meta-text {
- width:100%;
- font-family: 'Dosis', sans-serif;
- font-size: 3.2em;
- text-transform:uppercase;
- }
- .meta-text1 {
- color: #1fd2d3 !important;
- }
- </style>
- <p>
- <label for="meta-text" ><?php _e( 'Front page feature title part 1: ', 'prfx-textdomain' )?></label>
- <input type="text" class = 'meta-text' name="meta-text" id="meta-text" value="<?php if ( isset ( $prfx_stored_meta['meta-text'] ) ) echo $prfx_stored_meta['meta-text'][0]; ?>" />
- </p>
- <p>
- <label for="meta-text" ><?php _e( 'Front page feature title part 2: ', 'prfx-textdomain' )?></label>
- <input type="text" class = 'meta-text' name="meta-text1" id="meta-text1" value="<?php if ( isset ( $prfx_stored_meta['meta-text1'] ) ) echo $prfx_stored_meta['meta-text1'][0]; ?>" />
- </p>
- <p>
- <label for="meta-text" ><?php _e( 'Front page feature title part 3: ', 'prfx-textdomain' )?></label>
- <input type="text" class = 'meta-text meta-text1' name="meta-text2" id="meta-text2" value="<?php if ( isset ( $prfx_stored_meta['meta-text2'] ) ) echo $prfx_stored_meta['meta-text2'][0]; ?>" />
- </p>
- <p>
- <label for="meta-text" ><?php _e( 'Front page feature title part 4: ', 'prfx-textdomain' )?></label>
- <input type="text" class="meta-text" name="meta-text3" id="meta-text3" value="<?php if ( isset ( $prfx_stored_meta['meta-text3'] ) ) echo $prfx_stored_meta['meta-text3'][0]; ?>" />
- </p>
- <?php
- }
- /**
- * Saves the custom meta input*/
- function prfx_meta_save( $post_id ) {
- require_once(ABSPATH . "wp-admin" . '/includes/image.php');
- require_once(ABSPATH . "wp-admin" . '/includes/file.php');
- require_once(ABSPATH . "wp-admin" . '/includes/media.php');
- // Checks save status
- global $meta_box_fields;
- global $meta_box_files;
- $is_autosave = wp_is_post_autosave( $post_id );
- $is_revision = wp_is_post_revision( $post_id );
- $is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
- // Exits script depending on save status
- if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
- return;
- }
- // Checks for input and sanitizes/saves if needed
- if(!isset($_POST['featured'])) {
- $_POST['featured'] = 'unchecked';
- }
- // print_r($_POST);
- // exit;
- foreach($meta_box_fields as $meta_box_field) {
- if( isset( $_POST[ $meta_box_field] ) ) {
- update_post_meta( $post_id, $meta_box_field, sanitize_text_field( $_POST[ $meta_box_field] ) );
- }
- }
- // exit;
- // print_r($_FILES);
- if(!empty( $_FILES )) {
- foreach($meta_box_files as $meta_box_field) {
- if( isset( $_FILES[ $meta_box_field] ) ) {
- if($_FILES[ $meta_box_field] ['size']>0) {
- $goal_image_file = wp_upload_bits( $_FILES[$meta_box_field]['name'], null, file_get_contents( $_FILES[$meta_box_field]['tmp_name'] ) );
- $attachment_id = media_handle_upload($meta_box_field, $post_id);
- //print_r($goal_image_file);
- //exit;
- if( false == $goal_image_file['error'] ) {
- update_post_meta( $post_id,$meta_box_field, $goal_image_file['url'] );
- }
- }
- }
- }
- }
- }
- add_action( 'save_post', 'prfx_meta_save' );
- function foo_move_deck() {
- global $post_types;
- # Get the globals:
- global $post, $wp_meta_boxes;
- # Output the "advanced" meta boxes:
- do_meta_boxes(get_current_screen(), 'advanced',$post);
- # Remove the initial "advanced" meta boxes:
- foreach($post_types as $post_type)
- unset($wp_meta_boxes[$post_type]['advanced']);
- }
- function reset_editor($post_type)
- {
- global $_wp_post_type_features;
- $feature = "editor";
- if ( !isset($_wp_post_type_features[$post_type]) )
- {
- }
- elseif ( isset($_wp_post_type_features[$post_type][$feature]) )
- unset($_wp_post_type_features[$post_type][$feature]);
- }
- add_action( 'add_meta_boxes', 'prfx_custom_meta' );
- add_action('edit_form_after_title', 'foo_move_deck');
- add_action( 'post_edit_form_tag' , 'post_edit_form_tag' );
- function post_edit_form_tag( ) {
- echo ' enctype="multipart/form-data"';
- }
- function admin_menu_actions() {
- //hide_add_new_custom_type('case_study');
- remove_admin_menu_pages() ;
- }
- add_action( 'admin_menu', 'admin_menu_actions' );
- function remove_admin_menu_pages() {
- remove_menu_page('edit.php');
- remove_menu_page('edit-comments.php');
- remove_menu_page('tools.php');
- remove_menu_page('upload.php');
- //remove_menu_page('themes.php');
- }
- /*Creating posts for pages programatically*/
- /*
- $post = array(
- 'post_type' => 'page' ,
- 'page_template'=>'home-template'
- ); */
- // Insert the post into the database
- //wp_insert_post( $post );
- function programmatically_create_post() {
- // Initialize the page ID to -1. This indicates no action has been taken.
- $post_id = -1;
- // Setup the author, slug, and title for the post
- $author_id = 1;
- $slug = 'example-post';
- $title = 'Home page post';
- // If the page doesn't already exist, then create it
- if( null == get_page_by_title( $title ) ) {
- // Set the post ID so that we know the post was created successfully
- $post_id = wp_insert_post(
- array(
- 'comment_status' => 'closed',
- 'ping_status' => 'closed',
- 'post_author' => $author_id,
- 'post_name' => $slug,
- 'post_title' => $title,
- 'post_status' => 'publish',
- 'post_type' => 'page|news'
- )
- );
- // Priority of box in display order
- // Otherwise, we'll stop
- } else {
- // Arbitrarily use -2 to indicate that the page with the title already exists
- $post_id = -2;
- } // end if
- } // end programmatically_create_post
- function trusted_page_sup() {
- if ( isset( $_GET['post'] ) )
- $post_id = $_GET['post'];
- elseif ( isset( $_POST['post_ID'] ) )
- $post_id = $_POST['post_ID'];
- else
- $post_id = get_the_ID();
- if ( ! $post_id )
- return;
- if ( 'page' != get_post_type( $post_id ) )
- return;
- if ( 'page-template.php' == get_post_meta( $post_id, '_wp_page_template', true ) ) {
- $tsuppliers2 = new Super_Custom_Post_Meta( 'page' );
- $tsuppliers2->add_meta_boxes( array(
- 'id' => 'Contact-details',
- 'context' => 'side',
- 'priority'=> 'high',
- 'post-type' => 'page',
- 'fields' => array(
- 'base' => array('type'=>'select', 'options' => array('vermont','cape town')),
- 'Address' => array( 'type' => 'textarea' ),
- 'Tel:' => array('type' => 'text'),
- 'Fax' => array('type' => 'text'),
- 'Email' => array('type' => 'text'),
- 'Website' => array('type' => 'text'),
- )
- ) );
- }
- }
- /*
- Remove post row actions
- add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );
- function remove_row_actions( $actions )
- {
- if( get_post_type() === 'post' )
- unset( $actions['edit'] );
- unset( $actions['view'] );
- unset( $actions['trash'] );
- unset( $actions['inline hide-if-no-js'] );
- return $actions;
- }
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement