ID ); // Define the post types, in which this meta box shall appear add_meta_box( 'instant_articles', // Unique ID esc_html__( 'Instant Articles', 'afbia' ), // Title 'afb_instant_articles', // Callback function 'post', // Admin page (or post type) 'side', // Context 'default' // Priority ); } /// /// BOXES ==================================== /// /** * bg_color_code function. * * @access public * @param mixed $object * @param mixed $box * @return void */ function afb_instant_articles($object, $box){ wp_nonce_field( basename( __FILE__ ), 'lh_data_nonce' ); $afbia_o = (array) get_post_meta($object->ID, "_instant_article_options", true); ?>
post_type ); /* Check if the current user has permission to edit the post. */ if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; /* Get the posted data and sanitize it for use as an HTML class. */ if(isset($_POST[$post_value])){ $new_meta_value = ($_POST[$post_value]); } else { $new_meta_value = NULL; } /* Get the meta value of the custom field key. */ $meta_value = get_post_meta( $post_id, $meta_key, true ); /* If a new meta value was added and there was no previous value, add it. */ if ( $new_meta_value && '' == $meta_value ) add_post_meta( $post_id, $meta_key, $new_meta_value, true ); /* If the new meta value does not match the old value, update it. */ elseif ( $new_meta_value && $new_meta_value != $meta_value ) update_post_meta( $post_id, $meta_key, $new_meta_value ); /* If there is no new meta value but an old value exists, delete it. */ elseif ( '' == $new_meta_value && $meta_value ) delete_post_meta( $post_id, $meta_key, $meta_value ); }