Ask your WordPress questions! Pay money and get answers fast! (more info)

SHORTCODE FOR APPOINTMENT PLUGIN WordPress

  • SOLVED

I have bought a +appointment plugin from WPMU.

This plugin came with two shortcodes:

[app_services] that makes this:

<div class="app_services"><div class="app_services_dropdown">
<div class="app_services_dropdown_title">Please select a service:</div>
<div class="app_services_dropdown_select"><select name="app_select_services" class="app_select_services">
<option value="1" selected="selected">service 1</option>
<option value="2">service 2</option>
<input type="button" class="app_services_button" value="Show available times"></div></div>
<div class="app_service_excerpts"><div class="app_service_excerpt" id="app_service_excerpt_1"></div>
<div style="display:none" class="app_service_excerpt" id="app_service_excerpt_2"></div></div></div></div>


(This make in a page/post to display a list of services to be selected regardgless a "Service Provider".)


and,

[app_service_providers]


<div class="app_workers"><div class="app_workers_dropdown"><div class="app_workers_dropdown_title">Please choose a service provider:</div><div class="app_workers_dropdown_select"><select name="app_select_workers" class="app_select_workers"><option value="0">No preference</option><option value="3">Service Provider 1</option><option value="5">Service provider 2</option></select><input type="button" class="app_workers_button" value="Show available times"></div></div><div class="app_worker_excerpts"><div style="display:none" class="app_worker_excerpt" id="app_worker_excerpt_3"></div><div style="display:none" class="app_worker_excerpt" id="app_worker_excerpt_5"></div></div></div>


(This make in display in a calendar for a time availablity for an appointment of an specific "Service Provider", but no for an specific service.)


Let say that we need to make a new shortcode in Wp thats displays a list of products for a Specific provider...
something like:


[app_services_by_provider_1]

Answers (1)

2013-01-11

Dbranes answers:

Hi, it looks like you are looking for a shortcode of this type:

[find_app_services provider="1"]

I guess you could extend the previous shortcodes, just look for


add_shortcode('app_services','some_function');
add_shortcode('app_service_providers','some_function');


in the plugin files to see the code. Then you could add your own shortcode like this

add_shortcode('find_app_service','find_app_service_func');
function find_app_service_func($atts){
extract(shortcode_atts(array(
'provider' => 1,
), $atts));


$provider = (int) $provider;

//
// some adjusted code from the previous two shortcodes ...
//

return $provider;
}


Hope this skeleton helps.


miguel angarita comments:

/**
* Check if there are more than one shortcodes for certain shortcode types
* @since 1.0.5
* @return bool
*/
function has_duplicate_shortcode( $post_id ) {
$post = get_post( $post_id );
if ( is_object( $post) && $post && strpos( $post->post_content, '[app_' ) !== false ) {
if ( substr_count( $post->post_content, '[app_services' ) > 1 || substr_count( $post->post_content, '[app_service_providers' ) > 1
|| substr_count( $post->post_content, '[app_confirmation' ) > 1 || substr_count( $post->post_content, '[app_paypal' ) > 1
|| substr_count( $post->post_content, '[app_login' ) > 1 ) {
return true;
}
}
return false;
}

/**