Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //METABOXES
- // Metabox das informações de projetos
- add_action('add_meta_boxes', 'portfolio_custom_boxes');
- function portfolio_custom_boxes() {add_meta_box('info-projetos', 'Informações do Projeto', 'rpt_info_projeto', 'post', 'side', 'high');}
- function rpt_info_projeto() {
- global $post;
- echo '<input type="hidden" name="infoprojetometa_noncename" id="infoprojetometa_noncename" value="' .
- wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
- $projeto = get_post_meta($post->ID, '_projeto', true);
- $anocriacao = get_post_meta($post->ID, '_anocriacao', true);
- $role = get_post_meta($post->ID, '_role', true);
- $urlcliente = get_post_meta($post->ID, '_urlcliente', true);
- $urlfacebook = get_post_meta($post->ID, '_urlfacebook', true);
- echo '<p>Tipo de Projeto:</p>';
- echo '<input type="text" name="_projeto" value="' . $projeto . '" class="widefat" />';
- echo '<p>Digite o Ano de Criação do Projeto</p>';
- echo '<input type="text" name="_anocriacao" value="' . $anocriacao . '" class="widefat" />';
- echo '<p>Tarefas Executadas</p>';
- echo '<input type="textarea" name="_role" value="' . $role . '" class="widefat" />';
- echo '<p>Digite a Url do Cliente</p>';
- echo '<input type="text" name="_urlcliente" value="' . $urlcliente . '" class="widefat" />';
- echo '<p>Digite a Url da Fan Page do Facebook</p>';
- echo '<input type="text" name="_urlfacebook" value="' . $urlfacebook . '" class="widefat" />';
- }
- function rpt_save_infoprojeto_meta($post_id, $post) {
- if ( !wp_verify_nonce( $_POST['infoprojetometa_noncename'], plugin_basename(__FILE__) )) { return $post->ID; }
- if ( !current_user_can( 'edit_post', $post->ID )) return $post->ID;
- $infoprojeto_meta['_projeto'] = $_POST['_projeto'];
- $infoprojeto_meta['_anocriacao'] = $_POST['_anocriacao'];
- $infoprojeto_meta['_role'] = $_POST['_role'];
- $infoprojeto_meta['_urlcliente'] = $_POST['_urlcliente'];
- $infoprojeto_meta['_urlfacebook'] = $_POST['_urlfacebook'];
- foreach ($infoprojeto_meta as $key => $value) {
- if( $post->post_type == 'revision' ) return;
- $value = implode(',', (array)$value);
- if(get_post_meta($post->ID, $key, FALSE)) {
- update_post_meta($post->ID, $key, $value);
- } else {
- add_post_meta($post->ID, $key, $value);
- }
- if(!$value) delete_post_meta($post->ID, $key);
- }
- }
- add_action('save_post', 'rpt_save_infoprojeto_meta', 1, 2);
Advertisement
Add Comment
Please, Sign In to add comment