Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Descargas MetaBox
- Plugin URI: http://basdower.com
- Description: Descargas MetaBox agregara un campo de texto para su descarga.
- Version: 1.0
- Author: Basdower
- Author URI: http://basdower.com
- License: GPL2
- */
- function link_get_meta( $value ) {
- global $post;
- $field = get_post_meta( $post->ID, $value, true );
- if ( ! empty( $field ) ) {
- return is_array( $field ) ? stripslashes_deep( $field ) : stripslashes( wp_kses_decode_entities( $field ) );
- } else {
- return false;
- }
- }
- function link_add_meta_box() {
- add_meta_box(
- 'link-link',
- __( 'Descarga', 'link' ),
- 'link_html',
- 'post',
- 'normal',
- 'default'
- );
- }
- add_action( 'add_meta_boxes', 'link_add_meta_box' );
- function link_html( $post) {
- wp_nonce_field( '_link_nonce', 'link_nonce' ); ?>
- <table class="form-table">
- <tr>
- <th style="width:10%"><label for="link_by_basdower">Link</label></th>
- <td><input type="text" name="link_by_basdower" id="link_by_basdower" value="<?php echo link_get_meta( 'link_by_basdower' ); ?>" size="30" style="width:97%"> Ingresa el enlace de tu descarga</td>
- </tr>
- </table>
- <?php
- }
- function link_save( $post_id ) {
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
- if ( ! isset( $_POST['link_nonce'] ) || ! wp_verify_nonce( $_POST['link_nonce'], '_link_nonce' ) ) return;
- if ( ! current_user_can( 'edit_post', $post_id ) ) return;
- if ( isset( $_POST['link_by_basdower'] ) )
- update_post_meta( $post_id, 'link_by_basdower', esc_attr( $_POST['link_by_basdower'] ) );
- }
- add_action( 'save_post', 'link_save' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment