Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BACKGROUND PARALLAX METABOX */
- add_action( 'add_meta_boxes', 'pagebackgroundparallax_add_box' );
- add_action( 'save_post', 'pagebackgroundparallax_save_postdata' );
- //ADDING THE METABOX
- function pagebackgroundparallax_add_box() {
- $screens = array( 'page' );
- foreach ($screens as $screen) {
- add_meta_box(
- 'pagebackgroundparallax_sectionid',
- __( 'Fixed Background (aka "Parallax Effect")', 'pagebackgroundparallax_textdomain'),
- 'pagebackgroundparallax_inner_custom_box',
- $screen
- );
- }
- }
- //ADDING THE INNER BOX
- function pagebackgroundparallax_inner_custom_box( $post ) {
- $selected2 = 'selected="selected"';
- $selected1 = "";
- wp_nonce_field( plugin_basename( __FILE__ ), 'backgroundparallax_noncename' );
- $value005 = get_post_meta( $post->ID, 'dbn_backgroundparallax', true );
- echo '<label for="backgroundparallax_new_field">';
- _e("", 'backgroundcolor_textdomain' );
- echo '</label> ';
- echo '<select id="backgroundparallax_new_field" name="backgroundparallax_new_field">';
- echo '<option value="" '. $selected1 .' >Disabled</option>';
- echo '<option value="fixed" '. $selected2 .'>Enabled</option>';
- echo '</select>';
- }
- //STORING THE DATA INTO THE DATABASE
- function pagebackgroundparallax_save_postdata( $post_id ) {
- if ( 'page' == $_POST['post_type'] ) {
- if ( ! current_user_can( 'edit_page', $post_id ) )
- return;
- } else {
- }
- if ( ! isset( $_POST['backgroundparallax_noncename'] ) || ! wp_verify_nonce( $_POST['backgroundparallax_noncename'], plugin_basename( __FILE__ ) ) )
- return;
- $post_ID = $_POST['post_ID'];
- $pagebackgroundparallax= ( $_POST['backgroundparallax_new_field'] );
- add_post_meta($post_ID, 'dbn_backgroundparallax', $pagebackgroundparallax, true) or
- update_post_meta($post_ID, 'dbn_backgroundparallax', $pagebackgroundparallax);
- }
- /* BACKGROUND PARALLAX METABOX */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement