wpsc_get_the_post_id_by_shortcode

Located in: theme.functions.php

Functions that call this hook: wpsc_get_the_post_id_by_shortcode()

Arguments Accepted: $id, $shortcode

Version Introduced: 3.8.9

Description: Filter the post ID corresponding to a certain shortcode.

Code in context:

[php highlight=”1259″ firstline=”1234″]

function wpsc_get_the_post_id_by_shortcode( $shortcode ) {

$shortcode_options = array(

‘[productspage]’ => ‘product_list_url’,

‘[shoppingcart]’ => ‘shopping_cart_url’,

‘[checkout]’ => ‘shopping_cart_url’,

‘[transactionresults]’ => ‘transact_url’,

‘[userlog]’ => ‘user_account_url’

);

if ( ! isset( $shortcode_options[$shortcode] ) )

return 0;

$page_ids = get_option( ‘wpsc_shortcode_page_ids’, false );

if ( $page_ids === false ) {

wpsc_update_permalink_slugs();

$page_ids = get_option( ‘wpsc_shortcode_page_ids’, false );

}

$post_id = isset( $page_ids[$shortcode] ) ? $page_ids[$shortcode] : null;

// For back compat

$post_id = apply_filters( ‘wpec_get_the_post_id_by_shortcode’, $post_id );

return apply_filters( ‘wpsc_get_the_post_id_by_shortcode’, $post_id, $shortcode );

}

[/php]