/** * */ function dwci_participant_callback($attrs, $content) { $attrs = shortcode_atts(array('id' => strtoupper(substr(md5('participant-' . time() . uniqid()), 0, 10)), 'photo' => Bootstrap::getPluginUrl() . '/assets/img/no-thumb.png', 'fullname' => 'lorem ipsum dolor sit', 'category' => "0"), $attrs); $attrs['photo'] = $attrs['photo'] == "" ? Bootstrap::getPluginUrl() . '/assets/img/no-thumb.png' : $attrs['photo']; $path = Bootstrap::getPluginPath(); $viewPath = $path . 'templates/participants/participant.php'; ob_start(); require $viewPath; $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Allow registration to a given event id */ function register_callback($atts) { wp_enqueue_style('dwci_form_css', Bootstrap::getPluginUrl() . '/assets/css/admin-events-form.css'); wp_enqueue_script('dwci_form_js', Bootstrap::getPluginUrl() . '/assets/js/admin-events-form.js', array('jquery', 'jquery-ui-datepicker'), '20151228', true); wp_enqueue_script('dwci_form_validator_js', '//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.2.8/jquery.form-validator.min.js', array('jquery'), '20151230', true); $atts = shortcode_atts(array('id' => 'no foo', 'title' => 'Default title'), $atts, 'bartag'); //Check post by id. $myquery = new WP_Query("post_type=event&meta_key=event_id&meta_value={$atts['id']}&order=ASC"); //var_dump($myquery); if (!$myquery->posts[0]) { return '<p class="dwci-error-msg">Undefined event for this contact form.</p>'; } $post = $myquery->posts[0]; $path = Bootstrap::getPluginPath(); $viewPath = $path . 'templates/form.php'; ob_start(); require $viewPath; $output = ob_get_contents(); ob_end_clean(); return $output; }