S\\s\\u\\p> F Y'; const ANW_TIME_FORMAT = 'l, H:i'; $anw_types = [ ANW_TYPE_USER => __( 'User', ANW_TEXT_DOMAIN ), ANW_TYPE_FIDUCIARY => __( 'Fiduciary', ANW_TEXT_DOMAIN ), ]; require_once 'functions.php'; // --------------------------------------------------------------------------------------------------------------------- // INIT JS/CSS (BEGIN) // --------------------------------------------------------------------------------------------------------------------- function anw_admin_enqueue_scripts() { global $pagenow, $typenow; if ( in_array( $pagenow, [ 'post-new.php', 'post.php' ] ) && ANW_POST_TYPE == $typenow ) { $suffix = ''; //$suffix = SCRIPT_DEBUG ? '' : '.min'; $lang = get_curr_lang(); if ( 'en' != $lang ) { wp_enqueue_script( "anw_datepicker_{$lang}", plugins_url( "js/jquery-ui/datepicker-{$lang}{$suffix}.js", __FILE__ ), [ 'jquery-ui-datepicker' ] ); } wp_enqueue_style( 'anw_jquery_ui', plugins_url( "css/jquery-ui{$suffix}.css", __FILE__ ) ); wp_enqueue_style( 'anw_admin', plugins_url( "css/admin{$suffix}.css", __FILE__ ) ); wp_enqueue_script( 'anw_edit_form', plugins_url( "js/edit-form{$suffix}.js", __FILE__ ), [ 'jquery-ui-datepicker' ] ); $vars = [ 'lang' => $lang, 'plugins_url' => plugins_url( '/', __FILE__ ), ]; wp_localize_script( 'anw_edit_form', 'anw_edit_form', $vars ); } } add_action( 'admin_enqueue_scripts', 'anw_admin_enqueue_scripts' ); function anw_enqueue_scripts() { $suffix = ''; //$suffix = SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_style( 'anw_admin', plugins_url( "css/user{$suffix}.css", __FILE__ ) ); wp_enqueue_script( 'anw_list', plugins_url( "js/list{$suffix}.js", __FILE__ ) ); } add_action( 'wp_enqueue_scripts', 'anw_enqueue_scripts' ); // --------------------------------------------------------------------------------------------------------------------- // INIT JS/CSS (END) // --------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------- // REGISTER POST TYPE (BEGIN) // --------------------------------------------------------------------------------------------------------------------- function anw_register_post_type() { $labels = [ 'name' => __( 'Webinars', ANW_TEXT_DOMAIN ), 'singular_name' => __( 'Webinar', ANW_TEXT_DOMAIN ), 'add_new' => __( 'Add New', ANW_TEXT_DOMAIN ), 'add_new_item' => __( 'Add New Webinar', ANW_TEXT_DOMAIN ), 'edit_item' => __( 'Edit Webinar', ANW_TEXT_DOMAIN ), 'new_item' => __( 'New Webinar', ANW_TEXT_DOMAIN ), 'view_item' => __( 'View Webinar', ANW_TEXT_DOMAIN ), 'view_items' => __( 'View Webinars', ANW_TEXT_DOMAIN ), 'search_items' => __( 'Search Webinars', ANW_TEXT_DOMAIN ), 'not_found' => __( 'No Webinars found.', ANW_TEXT_DOMAIN ), 'not_found_in_trash' => __( 'No Webinars found in Trash.', ANW_TEXT_DOMAIN ), 'all_items' => __( 'All Webinars', ANW_TEXT_DOMAIN ), 'archives' => __( 'Webinar Archives', ANW_TEXT_DOMAIN ), 'attributes' => __( 'Webinar Attributes', ANW_TEXT_DOMAIN ), 'insert_into_item' => __( /** @lang text */ 'Insert into Webinar', ANW_TEXT_DOMAIN ), 'uploaded_to_this_item' => __( 'Uploaded to this webinar', ANW_TEXT_DOMAIN ), 'featured_image' => __( 'Featured Image', ANW_TEXT_DOMAIN ), 'set_featured_image' => __( 'Set featured image', ANW_TEXT_DOMAIN ), 'remove_featured_image' => __( 'Remove featured image', ANW_TEXT_DOMAIN ), 'use_featured_image' => __( 'Use as featured image', ANW_TEXT_DOMAIN ), 'filter_items_list' => __( 'Filter webinars list', ANW_TEXT_DOMAIN ), 'items_list_navigation' => __( 'Webinars list navigation', ANW_TEXT_DOMAIN ), 'items_list' => __( 'Webinars list', ANW_TEXT_DOMAIN ), ]; register_post_type( ANW_POST_TYPE, [ 'labels' => $labels, 'public' => false, 'hierarchical' => false, 'show_ui' => true, 'menu_icon' => 'dashicons-video-alt2', 'capability_type' => 'post', 'supports' => [ 'title', 'editor', 'revisions' ], ] ); } add_action( 'init', 'anw_register_post_type' ); function anw_set_tz() { date_default_timezone_set( get_option( 'timezone_string' ) ); } add_action( 'init', 'anw_set_tz' ); // --------------------------------------------------------------------------------------------------------------------- // REGISTER POST TYPE (END) // --------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------- // INTERNATIONALIZATION (BEGIN) // --------------------------------------------------------------------------------------------------------------------- function anw_textdomain() { $plugin_rel_path = basename( dirname( __FILE__ ) ) . '/languages/'; load_plugin_textdomain( ANW_TEXT_DOMAIN, false, $plugin_rel_path ); } add_action( 'plugins_loaded', 'anw_textdomain' ); // --------------------------------------------------------------------------------------------------------------------- // INTERNATIONALIZATION (END) // --------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------- // WEBINAR EDIT FORM (BEGIN) // --------------------------------------------------------------------------------------------------------------------- function anw_form_additional_fields( $post ) { global $anw_types; if ( ANW_POST_TYPE == $post->post_type ) { $value = get_post_meta( $post->ID, get_related_name( 'webinar_date' ), true ); if ( ! $value ) { $value = mktime(); } $date = date_i18n( 'd/m/Y', $value ); //date_i18n( 'j F Y', $value ); $time_h = date( 'H', $value ); $time_m = date( 'i', $value ); $url = get_post_meta( $post->ID, get_related_name( 'webinar_url' ), true ); $type = get_post_meta( $post->ID, get_related_name( 'webinar_type' ), true ); ?>