@@ -207,6 +207,151 @@ function eduadmin_get_booking_view( $attributes ) {
207207 return $ str ;
208208}
209209
210+ function eduadmin_get_programmeinfo ( $ attributes ) {
211+ $ t = EDU ()->start_timer ( __METHOD__ );
212+ global $ wp_query ;
213+ $ attributes = shortcode_atts (
214+ array (
215+ 'programmeid ' => null ,
216+ 'programmename ' => null ,
217+ 'programmepublicname ' => null ,
218+ 'programmeimage ' => null ,
219+ 'programmeimagetext ' => null ,
220+ 'courseprice ' => null ,
221+ 'eventprice ' => null ,
222+ 'programmedescriptionshort ' => null ,
223+ 'programmedescription ' => null ,
224+ 'programmegoal ' => null ,
225+ 'programmetarget ' => null ,
226+ 'programmeprerequisites ' => null ,
227+ 'courseafter ' => null ,
228+ 'programmequote ' => null ,
229+ 'courseeventlist ' => null ,
230+ 'showmore ' => null ,
231+ 'courseattributeid ' => null ,
232+ 'courseattributehasvalue ' => null ,
233+ 'courseeventlistfiltercity ' => null ,
234+ 'pagetitlejs ' => null ,
235+ 'bookurl ' => null ,
236+ 'courseinquiryurl ' => null ,
237+ 'order ' => null ,
238+ 'orderby ' => null ,
239+ 'ondemand ' => false ,
240+ 'allcourses ' => false ,
241+ ),
242+ normalize_empty_atts ( $ attributes ),
243+ 'eduadmin-programmeinfo '
244+ );
245+ $ api_key = EDU ()->get_option ( 'eduadmin-api-key ' );
246+
247+ $ ret_str = '' ;
248+
249+ if ( empty ( $ api_key ) ) {
250+ EDU ()->stop_timer ( $ t );
251+
252+ return 'Please complete the configuration: <a href=" ' . admin_url () . 'admin.php?page=eduadmin-settings">EduAdmin - Api Authentication</a> ' ;
253+ }
254+
255+ if ( empty ( $ attributes ['programmeid ' ] ) || str_replace ( array (
256+ '” ' ,
257+ '″ ' ,
258+ ), '' , $ attributes ['programmeid ' ] ) <= 0 ) {
259+ if ( isset ( $ wp_query ->query_vars ['edu_programme ' ] ) ) {
260+ $ exploded_id = explode ( '_ ' , $ wp_query ->query_vars ['edu_programme ' ] )[1 ];
261+ $ programme_id = $ exploded_id ;
262+ } else {
263+ EDU ()->stop_timer ( $ t );
264+
265+ return 'Missing programmeid in attributes ' ;
266+ }
267+ } else {
268+ $ programme_id = str_replace (
269+ array (
270+ '” ' ,
271+ '″ ' ,
272+ ),
273+ '' ,
274+ $ attributes ['programmeid ' ]
275+ );
276+ }
277+
278+ if ( ! empty ( $ programme_id ) ) {
279+ $ programme = EDUAPI ()->OData ->Programmes ->GetItem (
280+ $ programme_id ,
281+ null ,
282+ 'ProgrammeStarts( ' .
283+ '$filter= ' .
284+ 'HasPublicPriceName ' .
285+ ' and StatusId eq 1 ' .
286+ ' and (ApplicationOpenDate le ' . date_i18n ( 'c ' ) . ' or ApplicationOpenDate eq null) ' .
287+ ' and StartDate ge ' . date_i18n ( 'c ' ) .
288+ '; ' .
289+ '$orderby= ' .
290+ 'StartDate ' .
291+ '; ' .
292+ '$expand= ' .
293+ 'Courses($orderby=ProgrammeCourseSortIndex),Events($expand=EventDates($orderby=StartDate;$select=StartDate,EndDate;);$orderby=ProgrammeCourseSortIndex),PriceNames ' .
294+ '),PriceNames '
295+ );
296+
297+ if ( isset ( $ programme ["@error " ] ) ) {
298+ EDU ()->stop_timer ( $ t );
299+
300+ return $ programme ["@error " ];
301+ }
302+
303+ if ( isset ( $ attributes ['programmename ' ] ) ) {
304+ $ ret_str .= $ programme ['InternaProgrammeName ' ];
305+ }
306+
307+ if ( isset ( $ attributes ['programmepublicname ' ] ) ) {
308+ $ ret_str .= $ programme ['ProgrammeName ' ];
309+ }
310+
311+ if ( isset ( $ attributes ['programmeimage ' ] ) ) {
312+ $ ret_str .= $ programme ['ImageUrl ' ];
313+ }
314+
315+ if ( isset ( $ attributes ['programmeimagetext ' ] ) ) {
316+ $ ret_str .= $ programme ['ImageText ' ];
317+ }
318+
319+ if ( isset ( $ attributes ['programmedescriptionshort ' ] ) ) {
320+ $ ret_str .= $ programme ['DescriptionShort ' ];
321+ }
322+
323+ if ( isset ( $ attributes ['programmedescription ' ] ) ) {
324+ $ ret_str .= $ programme ['Description ' ];
325+ }
326+
327+ if ( isset ( $ attributes ['programmequote ' ] ) ) {
328+ $ ret_str .= $ programme ['Quote ' ];
329+ }
330+
331+ if ( isset ( $ attributes ['programmegoal ' ] ) ) {
332+ $ ret_str .= $ programme ['CourseGoal ' ];
333+ }
334+
335+ if ( isset ( $ attributes ['programmetarget ' ] ) ) {
336+ $ ret_str .= $ programme ['TargetGroup ' ];
337+ }
338+
339+ if ( isset ( $ attributes ['programmeprerequisites ' ] ) ) {
340+ $ ret_str .= $ programme ['Prerequisites ' ];
341+ }
342+
343+ if ( isset ( $ attributes ['courseafter ' ] ) ) {
344+ $ ret_str .= $ programme ['CourseAfter ' ];
345+ }
346+
347+ $ ret_str .= print_r ( $ programme , true );
348+ }
349+
350+ EDU ()->stop_timer ( $ t );
351+
352+ return $ ret_str ;
353+ }
354+
210355function eduadmin_get_detailinfo ( $ attributes ) {
211356 $ t = EDU ()->start_timer ( __METHOD__ );
212357 global $ wp_query ;
@@ -819,4 +964,5 @@ function eduadmin_get_programme_booking( $attributes ) {
819964 add_shortcode ( 'eduadmin-programme-list ' , 'eduadmin_get_programme_list ' );
820965 add_shortcode ( 'eduadmin-programme-detail ' , 'eduadmin_get_programme_details ' );
821966 add_shortcode ( 'eduadmin-programme-book ' , 'eduadmin_get_programme_booking ' );
967+ add_shortcode ( 'eduadmin-programmeinfo ' , 'eduadmin_get_programmeinfo ' );
822968}
0 commit comments