LocalizeScript
Source
File: classes/LocalizeScript.php
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | class LocalizeScript { public function __construct() { add_action( 'admin_enqueue_scripts' , [ $this , 'load_localization' ] ); add_action( 'wp_enqueue_scripts' , [ $this , 'load_localization' ] ); } public function load_localization() { $localization = [ 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'placeholder_img_src' => dozent_placeholder_img_src(), 'current_dashboard_page' => dozent_get_dashboard_url_segment(), 'option_changed_msg' => __( 'Settings have changed, you should save them!' , 'dozent' ), 'new_section_saved' => __( 'New section has been created' , 'dozent' ), 'section_updated_message' => __( 'Section has been updated' , 'dozent' ), 'something_wrong_msg' => __( 'Something went wrong, please try again later' , 'dozent' ), 'lecture_add_msg' => __( 'Lecture has been added' , 'dozent' ), 'course_metabox_save_msg' => __( 'Course has been saved' , 'dozent' ), 'lecture_updated_msg' => __( 'Lecture has been updated' , 'dozent' ), 'expand_btn_see_more_text' => __( '+ See More' , 'dozent' ), 'quiz_add_msg' => __( 'Quiz has been added' , 'dozent' ), 'quiz_updated_msg' => __( 'Quiz has been updated' , 'dozent' ), 'question_add_msg' => __( 'Question has been added' , 'dozent' ), 'question_updated_msg' => __( 'Question has been updated' , 'dozent' ), 'expired' => __( 'Expired' , 'dozent' ), ]; $localization [ 'message' ] = [ 'asked_discussion_question' => __( 'Your question sent to instructor' , 'dozent' ), ]; $localization [ 'instructor_search_term_error' ] = dozent_notice( sprintf( __( 'Enter %d more characters to start search' , 'dozent' ), 3 ), 'warning' , false ); $localization [ 'current_user' ] = is_user_logged_in() ? get_current_user_id() : false; $dozent_localize_object = apply_filters( 'dozent_localize_object' , $localization ); wp_localize_script( 'dozent' , '_dozent' , $dozent_localize_object ); } } |