*/ 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('getEventListComponent', $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' => '', ], $atts); $atts['event-url'] = $atts['detail_link']; $atts['default-view-mode'] = 'events-list-grid'; return $this->getComponentLoader('getEventListComponent', $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 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 dashboard. * * @return string * @since 1.0.0 */ public function webapp_student_account_dashboard() { return $this->getComponentLoader('getAccountDashboardComponent'); } /** * Webapp AEC student controls. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_student_controls($atts) { $atts = $this->parse_atts([ 'is-wordpress-site' => '', 'login-link' => '', 'register-link' => '', 'account-link' => '', 'logout-link' => '', 'my-cart-link' => '', ], $atts); return $this->getComponentLoader('getStudentControlsComponent', $atts); } /** * Webapp AEC courses search bar. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_classes_search_box($atts) { $atts = (array)$atts; if (isset($atts['url-configuration'])) { $atts['url-configuration'] = htmlentities(trim($atts['url-configuration'])); } return $this->getComponentLoader('getCourseSearchBarComponent', $atts); } /** * Webapp AEC student account. * * @return string * @since 1.0.4 */ public function webapp_shopping_cart() { return $this->getComponentLoader('getShoppingComponent'); } /** * Webapp AEC examination list. * * @param $atts array User defined attributes in shortcode tag. * @return string * @since 1.0.4 */ public function webapp_examination_list($atts) { $atts = $this->parse_atts([ 'examination-type-ids' => '', 'show-category-title' => '', ], $atts); return $this->getComponentLoader('getExaminationListComponent', $atts); } /** * Webapp AEC examination type list. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.4 */ public function webapp_examination_type_list($attrs) { $attrs = $this->parse_atts([ 'examination-type-ids' => '', 'etablishment-branch-id' => '' ], $attrs); return $this->getComponentLoader('getExaminationTypeListComponent', $attrs); } /** * Webapp AEC examination type detail. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.4 */ public function webapp_examination_type_detail($attrs) { $attrs = $this->parse_atts([ 'examination-type-id' => '', 'etablishment-branch-id' => '' ], $attrs); return $this->getComponentLoader('getExaminationTypeDetailComponent', $attrs); } /** * Webapp AEC examination detail. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.4 */ public function webapp_examination_detail($attrs) { $attrs = $this->parse_atts(['examination-id' => ''], $attrs); return $this->getComponentLoader('getExaminationDetailComponent', $attrs); } /** * Webapp AEC Identify Panel. * * @return string * @since 1.0.0 */ public function webapp_identify_panel($attrs) { $attrs = $this->parse_atts(['tag-active' => ''], $attrs); return $this->getComponentLoader('getIdentityPanelComponent', $attrs); } /** * Webapp AEC courses catalog. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_courses_catalog($attrs) { $attrs = $this->parse_atts([ 'etablishment-branch-id' => '', 'period-id' => '', 'classification-id' => '', 'subject-id' => '', 'class-type-id' => '', 'level-id' => '', 'learning-pace' => '', 'sidebar' => '', 'class-format-id' => '', 'localization' => '', 'show-filter-choices' => '', ], $attrs); return $this->getComponentLoader('getCourseCatalogComponent', $attrs); } /** * Webapp AEC courses selection tiles. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_courses_selection_tiles($attrs) { $attrs = $this->parse_atts([ 'etablishment-branch-id' => '', 'period-id' => '', 'classification-id' => '', 'subject-id' => '', 'class-type-id' => '', 'main-level' => '', 'levels-to-filter-by' => '', 'localization' => '', 'class-format-id' => '', 'show-filter-choices' => true, ], $attrs); return $this->getComponentLoader('getCourseSelectionTilesComponent', $attrs); } /** * Webapp AEC courses wizard. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_courses_wizard($attrs) { $attrs = $this->parse_atts([ 'id-subject' => '', 'id-classification' => '', ], $attrs); return $this->getComponentLoader('getCourseWizardComponent', $attrs); } /** * Webapp AEC Newsletter. * * @return string * @since 1.0.4 */ public function webapp_newsletter() { return $this->getComponentLoader('getNewsLetterSubscribeFormComponent'); } /** * Webapp AEC Newsletter Unsubscribe. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.4 */ public function webapp_unsubscribe_newsletter($attrs) { $attrs = $this->parse_atts(['redirect' => ''], $attrs); return $this->getComponentLoader('getNewsLetterUnsubscribeFormComponent', $attrs); } /** * Webapp AEC Newsletter Confirmation. * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.4 */ public function webapp_newsletter_confirmation($attrs) { $attrs = $this->parse_atts(['redirect' => ''], $attrs); return $this->getComponentLoader('getNewsLetterConfirmSubscribeComponent', $attrs); } /** * Webapp AEC Private Tuition Form (new visualization). * * @param $attrs array User defined attributes in shortcode tag. * @return string * @since 1.0.0 */ public function webapp_private_tuition_form($attrs): string { $attrs = $this->parse_atts([ 'product-type-ids' => '', 'product-type-id' => '', ], $attrs); return $this->getComponentLoader('getPrivateTuitionFormComponent', $attrs); } }