*/ class Aec_Shortcodes { /** * The AEC client instance name. * * @since 1.0.0 * @access private * @var string $client_instance The AEC client instance name. */ private $client_instance; /** * Initialize the class and set its properties. * * @param string $client_instance The AEC client instance name. * @since 1.0.0 */ public function __construct($client_instance) { $this->client_instance = $client_instance; } /** * Combine user attributes with known attributes and fill in defaults when needed. Also checks URL query string. * * @param $pairs array Entire list of supported attributes and their defaults. * @param $atts array User defined attributes in shortcode tag. * @return array */ private function parse_atts($pairs, $atts) { $nonce_key = AEC()->get_url_nonce_key(); $nonce_action = AEC()->get_url_nonce_action(); $nonce = isset($_GET[$nonce_key]) ? sanitize_text_field(wp_unslash($_GET[$nonce_key])) : null; $is_nonce_valid = $nonce && wp_verify_nonce($nonce, $nonce_action); $atts = (array)$atts; $out = array(); foreach ($pairs as $name => $default) { if (array_key_exists($name, $atts)) { $out[$name] = $atts[$name]; } elseif(isset($_GET[$name]) && $is_nonce_valid) { $out[$name] = sanitize_text_field(wp_unslash($_GET[$name])); } else { $out[$name] = $default; } } if (!empty($atts)) { foreach ($atts as $name => $unknow_att) { if (!array_key_exists($name, $out)) { $out[$name] = $unknow_att; } } } return $out; } private function getComponentLoader(string $methodName, array $attrs = []): string { $attrs['lang'] = AEC()->get_locale(); $component_loader = AEC()->get_kiosque_component_loader(); return $component_loader->$methodName($attrs); } /** * Webapp AEC events. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_events($attrs) { $attrs = $this->parse_atts([ 'default-view-mode' => '', 'etablishment-branch-id' => '', 'event-type' => '', 'event-tag-ids' => '', 'events-to-show' => '', ], $attrs); return $this->getComponentLoader('getEventListComponent', $attrs); } /** * Webapp AEC events list. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_events_list($atts) { $atts = $this->parse_atts([ 'detail_link' => '', ], $atts); $atts['event-url'] = $atts['detail_link']; return $this->getComponentLoader('getEventsListComponent', $atts); } /** * Webapp AEC next events. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_next_events($atts) { $atts = $this->parse_atts([ 'detail_link' => '', 'quantity-column' => 3, ], $atts); $atts['event-url'] = $atts['detail_link']; return $this->getComponentLoader('getNextEventComponent', $atts); } /** * Webapp AEC event detail. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_event_detail($attrs) { $attrs = $this->parse_atts([ 'event-id' => '', ], $attrs); return $this->getComponentLoader('getEventDetailComponent', $attrs); } /** * Webapp AEC events list grid. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_events_list_grid($atts) { $atts = $this->parse_atts([ 'detail_link' => '', 'quantity-column' => 3, ], $atts); $atts['event-url'] = $atts['detail_link']; return $this->getComponentLoader('getEventListGridComponent', $atts); } /** * Webapp AEC events list wide. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_events_list_wide($atts) { $atts = $this->parse_atts([ 'detail_link' => '', ], $atts); $atts['event-url'] = $atts['detail_link']; return $this->getComponentLoader('getEventListWideComponent', $atts); } /** * Webapp AEC classes list. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.1.4 */ public function webapp_classes_list($attrs) { $attrs = $this->parse_atts([ 'id-etablishment-branch' => '', 'id-period' => '', 'id-classification' => '', 'id-subject' => '', 'id-main-level' => '', 'id-class-type' => '', 'level-id' => '', 'id-class-format' => '', 'location' => '', 'show-all-establishment' => '', 'primary-group-by' => '', 'secondary-group-by' => '', 'course-order-by' => '', ], $attrs); return $this->getComponentLoader('getCourseListComponent', $attrs); } /** * Webapp AEC course detail. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_class_detail($attrs) { $attrs = $this->parse_atts([ 'course-id' => '', 'registration-form-container-id' => '', ], $attrs); return $this->getComponentLoader('getCourseDetailComponent', $attrs); } /** * Webapp AEC contact map. * * @param $atts * @return string * @since 1.0.0 */ public function webapp_contact_map($atts = []) { $atts = $this->parse_atts([ 'display-details' => 'true', 'etablishment_id' => 0, 'height' => 500 ], $atts); $atts['etablishment-branch-id'] = $atts['etablishment_id']; $atts['height'] .= 'px'; return $this->getComponentLoader('getDisplayContactInfoComponent', $atts); } /** * Webapp AEC private tuition form. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_private_tuition($atts) { $atts = $this->parse_atts([ 'product-type-id' => '', ], $atts); return $this->getComponentLoader('getPrivateTuitionComponent', $atts); } /** * Webapp AEC class selection. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_class_selection($attrs) { $attrs = $this->parse_atts([ 'id-subject' => '', 'id-classification' => '', ], $attrs); return $this->getComponentLoader('getSelectClassComponent', $attrs); } /** * Webapp AEC products list. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_products_list($attrs) { $attrs = $this->parse_atts([ 'product-type' => '', 'etablishment-branch-id' => '', 'show-category-title' => '', ], $attrs); return $this->getComponentLoader('getShowProductComponent', $attrs); } /** * Webapp AEC donation form. * * @return string * @since 1.0.0 */ public function webapp_donation_form() { return $this->getComponentLoader('getDonationFormComponent'); } /** * Webapp AEC donation form. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_donation_form_free($attrs) { $attrs = $this->parse_atts(['product-type-id' => ''], $attrs); return $this->getComponentLoader('getDonationFreeFormComponent', $attrs); } /** * Webapp AEC donation form list. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_donation_list($attrs) { $attrs = $this->parse_atts([ 'product-type-ids' => '', 'show-category-title' => '', ], $attrs); return $this->getComponentLoader('getDonationListComponent', $attrs); } /** * Webapp AEC student login form. * * @return string * @since 1.0.0 */ public function webapp_student_login() { return $this->getComponentLoader('getStudentLoginComponent'); } /** * Webapp AEC student password recover form. * * @return string * @since 1.0.11 */ public function webapp_student_password_recover() { return $this->getComponentLoader('getStudentPasswordRecoverComponent'); } /** * Webapp AEC student password update form. * * @return string * @since 1.1.6 */ public function webapp_student_password_update() { return $this->getComponentLoader('getStudentPasswordUpdateComponent'); } /** * Webapp AEC student password reset form. * * @return string * @since 1.0.11 */ public function webapp_student_password_reset() { return $this->getComponentLoader('getStudentPasswordResetComponent'); } /** * Webapp AEC student registration form. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_student_register($atts) { $atts = $this->parse_atts(['is-for-front-desk-account' => ''], $atts); return $this->getComponentLoader('getStudentRegisterComponent', $atts); } /** * Webapp AEC student account. * * @return string * @since 1.0.0 */ public function webapp_student_account(): string { return '