get_queried_object_id() ), $field, true ); if ( ! $custom_field ) { return ''; } # Return custom field, slashes stripped, sanitized if string return is_array( $custom_field ) ? stripslashes_deep( $custom_field ) : stripslashes( wp_kses_decode_entities( $custom_field ) ); } /** * Save post meta / custom field data for a post or page. * * @since 1.0.0 */ function bizznis_save_custom_fields( array $data, $nonce_action, $nonce_name, $post, $post_id ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '1.1.0' ); } # Verify the nonce if ( ! isset( $_POST[ $nonce_name ] ) || ! wp_verify_nonce( $_POST[ $nonce_name ], $nonce_action ) ) { return; } # Don't try to save the data under autosave, ajax, or future post. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return; } if ( defined( 'DOING_CRON' ) && DOING_CRON ) { return; } # Don't save if WP is creating a revision (same as DOING_AUTOSAVE?) if ( 'revision' == get_post_type( $post ) ) { return; } # Check that the user is allowed to edit the post if ( ! current_user_can( 'edit_post', $post->ID ) ) { return; } # Cycle through $data, insert value or delete field foreach ( (array) $data as $field => $value ) { # Save $value, or delete if the $value is empty if ( $value ) { update_post_meta( $post_id, $field, $value ); } else { delete_post_meta( $post_id, $field ); } } } /** * Takes an array of new settings, merges them with the old settings, and pushes them into the database. * * @since 1.1.0 * * @uses BIZZNIS_SETTINGS_FIELD * * @param string|array $new New settings. Can be a string, or an array. * @param string $setting Optional. Settings field name. Default is BIZZNIS_SETTINGS_FIELD. */ function bizznis_update_settings( $new = '', $setting = BIZZNIS_SETTINGS_FIELD ) { return update_option( $setting, wp_parse_args( $new, get_option( $setting ) ) ); }