Advertisement
arktoga

Untitled

Jun 16th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. /* BACKGROUND PARALLAX METABOX */
  2. add_action( 'add_meta_boxes', 'pagebackgroundparallax_add_box' );
  3. add_action( 'save_post', 'pagebackgroundparallax_save_postdata' );
  4.  
  5.  
  6. //ADDING THE METABOX
  7. function pagebackgroundparallax_add_box() {
  8. $screens = array( 'page' );
  9. foreach ($screens as $screen) {
  10. add_meta_box(
  11. 'pagebackgroundparallax_sectionid',
  12. __( 'Fixed Background (aka "Parallax Effect")', 'pagebackgroundparallax_textdomain'),
  13. 'pagebackgroundparallax_inner_custom_box',
  14. $screen
  15. );
  16. }
  17. }
  18.  
  19. //ADDING THE INNER BOX
  20. function pagebackgroundparallax_inner_custom_box( $post ) {
  21.  
  22. $selected2 = 'selected="selected"';
  23. $selected1 = "";
  24.  
  25. wp_nonce_field( plugin_basename( __FILE__ ), 'backgroundparallax_noncename' );
  26. $value005 = get_post_meta( $post->ID, 'dbn_backgroundparallax', true );
  27.  
  28. echo '<label for="backgroundparallax_new_field">';
  29. _e("", 'backgroundcolor_textdomain' );
  30. echo '</label> ';
  31. echo '<select id="backgroundparallax_new_field" name="backgroundparallax_new_field">';
  32. echo '<option value="" '. $selected1 .' >Disabled</option>';
  33. echo '<option value="fixed" '. $selected2 .'>Enabled</option>';
  34. echo '</select>';
  35. }
  36.  
  37. //STORING THE DATA INTO THE DATABASE
  38. function pagebackgroundparallax_save_postdata( $post_id ) {
  39.  
  40. if ( 'page' == $_POST['post_type'] ) {
  41. if ( ! current_user_can( 'edit_page', $post_id ) )
  42. return;
  43. } else {
  44. }
  45.  
  46. if ( ! isset( $_POST['backgroundparallax_noncename'] ) || ! wp_verify_nonce( $_POST['backgroundparallax_noncename'], plugin_basename( __FILE__ ) ) )
  47. return;
  48.  
  49. $post_ID = $_POST['post_ID'];
  50. $pagebackgroundparallax= ( $_POST['backgroundparallax_new_field'] );
  51.  
  52. add_post_meta($post_ID, 'dbn_backgroundparallax', $pagebackgroundparallax, true) or
  53. update_post_meta($post_ID, 'dbn_backgroundparallax', $pagebackgroundparallax);
  54. }
  55. /* BACKGROUND PARALLAX METABOX */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement