id ) ) { return; } $field = $this->extra; $field['id'] = $this->id; $field['default'] = $this->default; $field['description'] = $this->description; $field['label'] = $this->label; $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; $field['default'] = ( ! $this->meta_value( $thepostid ) && isset( $field['default'] ) ) ? $field['default'] : $this->meta_value( $thepostid ); $field['value'] = isset( $field['value'] ) ? $field['value'] : $field['default']; $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; $duration = learn_press_get_course_duration_support(); $duration_keys = array_keys( $duration ); $default_time = ! empty( $field['default_time'] ) ? $field['default_time'] : end( $duration_keys ); if ( preg_match_all( '!([0-9]+)\s*(' . join( '|', $duration_keys ) . ')?!', $field['value'], $matches ) ) { $a1 = $matches[1][0]; $a2 = in_array( $matches[2][0], $duration_keys ) ? $matches[2][0] : $default_time; } else { $a1 = absint( $field['value'] ); $a2 = $default_time; } // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { foreach ( $field['custom_attributes'] as $attribute => $custom_attribute ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $custom_attribute ) . '"'; } } $html_option = ''; foreach ( $duration as $k => $v ) { $html_option .= sprintf( '', $k, selected( $k, $a2, false ), $v ); } echo '
'; } public function save( $post_id ) { $duration = learn_press_get_course_duration_support(); $duration_keys = array_keys( $duration ); $default_time = ! empty( $this->extra['default_time'] ) ? $this->extra['default_time'] : end( $duration_keys ); $duration = isset( $_POST[ $this->id ][0] ) && $_POST[ $this->id ][0] !== '' ? absint( wp_unslash( $_POST[ $this->id ][0] ) ) . ' ' . trim( wp_unslash( $_POST[ $this->id ][1] ) ) : absint( $this->default ) . ' ' . trim( $default_time ); update_post_meta( $post_id, $this->id, $duration ); } }