INVP::get_meta( string $unprefixed_meta_key, int $post_id = null )
Retrieves post meta values.
Parameters #Parameters
- $unprefixed_meta_key
-
(string) (Required) A meta key suffix like ‘vin’ or ‘date_entered’.
- $post_id
-
(int) (Optional) A vehicle post ID.
Default value: null
Return #Return
(string|int|double|array)
Source #Source
File: includes/class-invp.php
public static function get_meta( $unprefixed_meta_key, $post_id = null ) { if ( empty( $post_id ) ) { $post_id = get_the_ID(); } $meta_key = apply_filters( 'invp_prefix_meta_key', $unprefixed_meta_key ); // Options are stored as a multi-valued meta field. $single = 'options_array' !== $unprefixed_meta_key; $meta_value = get_post_meta( $post_id, $meta_key, $single ); // Kill dupes for singles. Added after finding duplicate date_entered and last_modified dates. if ( $single ) { $array_value = get_post_meta( $post_id, $meta_key ); if ( $array_value && 1 < count( $array_value ) ) { delete_post_meta( $post_id, $meta_key ); update_post_meta( $post_id, $meta_key, $meta_value ); } } // If key is a number, return a number/zero instead of empty string. if ( self::meta_value_is_number( $meta_key ) ) { if ( empty( $meta_value ) ) { return 0; } if ( false === strpos( $meta_value ?? '', '.' ) ) { return (int) $meta_value; } return (float) $meta_value; } return $meta_value; }
Expand full source codeCollapse full source codeView on Github
Related #Related
Uses #Uses
Uses | Description |
---|---|
includes/class-invp.php: INVP::meta_value_is_number () |
Indicates whether or not a provided $post_meta_key is a number data type. |
includes/integrations/class-contact-form-7.php: invp_prefix_meta_key |
Here’s a query to get the post IDs of the vehicles we want in the order we want. The reason we are not using get_posts is because we want to sort by 3 post meta values |
Used By #Used By
Used By | Description |
---|---|
includes/template-tags.php: invp_get_the_horsepower () |
invp_get_the_horsepower |
includes/template-tags.php: invp_get_the_engine_model () |
invp_get_the_engine_model |
includes/template-tags.php: invp_get_the_engine_make () |
invp_get_the_engine_make |
includes/template-tags.php: invp_get_the_engine_count () |
invp_get_the_engine_count |
includes/template-tags.php: invp_get_the_draft () |
invp_get_the_draft |
includes/template-tags.php: invp_get_the_condition_boat () |
Template tag. Returns the condition of the boat, usually “Excellent” or “Good”. |
includes/template-tags.php: invp_get_the_condition () |
Template tag. Returns the condition of the vehicle, usually “Used” or “New”. |
inventory-presser.php: Inventory_Presser_Plugin::save_vehicle_post_meta () |
Saves vehicle attributes into their corresponding post meta fields when the Save or Update button is clicked in the editor. |
includes/integrations/class-wpforms.php: Inventory_Presser_WPForms::adf_vehicle_xml () |
Creates the vehicle piece of an ADF XML lead. |
includes/integrations/class-classic-editor.php: Inventory_Presser_Classic_Editor::meta_box_html_prices () |
Creates a meta box to help users manage a vehicles prices in the editor. |
includes/integrations/class-classic-editor.php: Inventory_Presser_Classic_Editor::meta_box_html_featured () |
Creates an editor meta box to help users mark vehicles as featured. |
includes/template-tags.php: invp_is_wholesale () |
Returns true if this vehicle is marked wholesale. |
includes/template-tags.php: invp_is_carfax_one_owner () |
Is this vehicle designated a “one owner” by Carfax? |
includes/template-tags.php: invp_is_certified_preowned () |
Is this vehicle certified pre-owned? |
includes/template-tags.php: invp_is_featured () |
Is this vehicle featured in slideshows? |
includes/template-tags.php: invp_is_sold () |
Returns true if this vehicle is sold. |
includes/template-tags.php: invp_have_carfax_report () |
invp_have_carfax_report |
includes/template-tags.php: invp_get_the_year () |
invp_get_the_year |
includes/template-tags.php: invp_get_the_youtube_url () |
Returns this vehicle’s YouTube video URL or empty string. |
includes/template-tags.php: invp_get_the_stock_number () |
invp_get_the_stock_number |
includes/template-tags.php: invp_get_the_VIN () |
Template tag. Returns the vehicles VIN. |
includes/template-tags.php: invp_get_the_title_status () |
invp_get_the_title_status |
includes/template-tags.php: invp_get_the_transmission () |
invp_get_the_transmission |
includes/template-tags.php: invp_get_the_transmission_speeds () |
invp_get_the_transmission_speeds |
includes/template-tags.php: invp_get_the_trim () |
invp_get_the_trim |
includes/template-tags.php: invp_get_the_type () |
invp_get_the_type |
includes/template-tags.php: invp_get_the_price () |
Template tag. Returns the vehicle’s price. |
includes/template-tags.php: invp_get_the_msrp () |
invp_get_the_msrp |
includes/template-tags.php: invp_get_the_payment () |
invp_get_the_payment |
includes/template-tags.php: invp_get_the_odometer () |
Template tag. Returns the odometer formatted as a number with comma separators if it is numeric. Returns any other non-zero value without any formatting. Adds the $append value to any return value but an empty string. |
includes/template-tags.php: invp_get_the_options () |
invp_get_the_options |
includes/template-tags.php: invp_get_the_payment_frequency () |
invp_get_the_payment_frequency |
includes/template-tags.php: invp_get_raw_price () |
invp_get_raw_price |
includes/template-tags.php: invp_get_raw_msrp () |
invp_get_raw_msrp |
includes/template-tags.php: invp_get_the_model () |
invp_get_the_model |
includes/template-tags.php: invp_get_the_make () |
invp_get_the_make |
includes/template-tags.php: invp_get_raw_last_modified () |
Template tag. Returns the timestamp the vehicle was last modified |
includes/template-tags.php: invp_get_the_length () |
Template tag. Boat field. Returns the length of the boat. |
includes/template-tags.php: invp_get_the_fuel () |
invp_get_the_fuel |
includes/template-tags.php: invp_get_the_hull_material () |
Template tag. Boat field. |
includes/template-tags.php: invp_get_the_fuel_economy_value () |
Makes retrieving a fuel economy data point from metadata easier. |
includes/template-tags.php: invp_get_the_engine () |
invp_get_the_engine |
includes/template-tags.php: invp_get_the_edmunds_style_id () |
invp_get_the_edmunds_style_id |
includes/template-tags.php: invp_get_the_drive_type () |
Template tag. Returns the drive type, or a description of how many driven wheels are on the vehicle. |
includes/template-tags.php: invp_get_the_down_payment () |
invp_get_the_down_payment |
includes/template-tags.php: invp_get_the_interior_color () |
invp_get_the_interior_color |
includes/template-tags.php: invp_get_the_doors () |
invp_get_the_doors |
includes/template-tags.php: invp_get_the_description () |
invp_get_the_description |
includes/template-tags.php: invp_get_the_carfax_url_svg () |
Returns a URL to an SVG image button that users click to view Carfax reports or empty string. Sometimes the URL points to an SVG hosted on carfax.com, sometimes it’s an SVG bundled with this plugin. |
includes/template-tags.php: invp_get_the_beam () |
Template tag. Boat field. A boat’s width at its widest point. |
includes/template-tags.php: invp_get_the_body_style () |
Template tag. Returns a string like “Sedan” or “Sport Utility Vehicle.” |
includes/template-tags.php: invp_get_raw_book_value () |
Template tag. Returns the raw book value price as a number and therefore no string formatting or dollar sign. |
includes/template-tags.php: invp_get_the_carfax_url_report () |
Template tag. Returns a URL to a CARFAX vehicle history report. |
includes/template-tags.php: invp_get_the_color () |
Template tag. Returns the exterior color of the vehicle. |
includes/template-tags.php: invp_get_the_dealer_id () |
invp_get_the_dealer_id |
includes/template-tags.php: invp_get_the_availability () |
Template tag. Returns a string like “For Sale” or “Sold.” |
includes/integrations/class-contact-form-7.php: Inventory_Presser_Contact_Form_7::add_mail_tags () |
Replaces mail tags with the data we promised. |
includes/admin/class-admin-photo-arranger.php: Inventory_Presser_Admin_Photo_Arranger::change_parents_and_sequence () |
Runs on edit_post hook. Changes the post_parent values on photos in our magic Gallery block. |
includes/shortcode/class-shortcode-attribute-table.php: Inventory_Presser_Shortcode_Attribute_Table::content () |
Creates the string content that replaces the shortcode. |
includes/class-photo-numberer.php: Inventory_Presser_Photo_Numberer::save_meta_photo_number () |
save_meta_photo_number |
includes/class-photo-numberer.php: Inventory_Presser_Photo_Numberer::add_sequence_number_to_titles () | |
includes/class-badges.php: Inventory_Presser_Badges::add_nextgear () |
Outputs an HTML button to open NextGear Mechanic’s Reports. |
includes/class-template-provider.php: Inventory_Presser_Template_Provider::lie_about_post_thumbnails () |
This method lies about whether vehicles have thumbnails so that all template content can be handled by the shortcode. |