/**
* REST API: WP_REST_Widget_Types_Controller class
*
* @package WordPress
* @subpackage REST_API
* @since 5.8.0
*/
/**
* Core class to access widget types via the REST API.
*
* @since 5.8.0
*
* @see WP_REST_Controller
*/
class WP_REST_Widget_Types_Controller extends WP_REST_Controller {
/**
* Constructor.
*
* @since 5.8.0
*/
public function __construct() {
$this->namespace = 'wp/v2';
$this->rest_base = 'widget-types';
}
/**
* Registers the widget type routes.
*
* @since 5.8.0
*
* @see register_rest_route()
*/
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base,
array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => $this->get_collection_params(),
),
'schema' => array( $this, 'get_public_item_schema' ),
)
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P[a-zA-Z0-9_-]+)',
array(
'args' => array(
'id' => array(
'description' => __( 'The widget type id.' ),
'type' => 'string',
),
),
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_item' ),
'permission_callback' => array( $this, 'get_item_permissions_check' ),
'args' => $this->get_collection_params(),
),
'schema' => array( $this, 'get_public_item_schema' ),
)
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P[a-zA-Z0-9_-]+)/encode',
array(
'args' => array(
'id' => array(
'description' => __( 'The widget type id.' ),
'type' => 'string',
'required' => true,
),
'instance' => array(
'description' => __( 'Current instance settings of the widget.' ),
'type' => 'object',
),
'form_data' => array(
'description' => __( 'Serialized widget form data to encode into instance settings.' ),
'type' => 'string',
'sanitize_callback' => function( $string ) {
$array = array();
wp_parse_str( $string, $array );
return $array;
},
),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'permission_callback' => array( $this, 'get_item_permissions_check' ),
'callback' => array( $this, 'encode_form_data' ),
),
)
);
}
/**
* Checks whether a given request has permission to read widget types.
*
* @since 5.8.0
*
* @param WP_REST_Request $request Full details about the request.
* @return true|WP_Error True if the request has read access, WP_Error object otherwise.
*/
public function get_items_permissions_check( $request ) {
return $this->check_read_permission();
}
/**
* Retrieves the list of all widget types.
*
* @since 5.8.0
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function get_items( $request ) {
$data = array();
foreach ( $this->get_widgets() as $widget ) {
$widget_type = $this->prepare_item_for_response( $widget, $request );
$data[] = $this->prepare_response_for_collection( $widget_type );
}
return rest_ensure_response( $data );
}
/**
* Checks if a given request has access to read a widget type.
*
* @since 5.8.0
*
* @param WP_REST_Request $request Full details about the request.
* @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise.
*/
public function get_item_permissions_check( $request ) {
$check = $this->check_read_permission();
if ( is_wp_error( $check ) ) {
return $check;
}
$widget_id = $request['id'];
$widget_type = $this->get_widget( $widget_id );
if ( is_wp_error( $widget_type ) ) {
return $widget_type;
}
return true;
}
/**
* Checks whether the user can read widget types.
*
* @since 5.8.0
*
* @return true|WP_Error True if the widget type is visible, WP_Error otherwise.
*/
protected function check_read_permission() {
if ( ! current_user_can( 'edit_theme_options' ) ) {
return new WP_Error(
'rest_cannot_manage_widgets',
__( 'Sorry, you are not allowed to manage widgets on this site.' ),
array(
'status' => rest_authorization_required_code(),
)
);
}
return true;
}
/**
* Gets the details about the requested widget.
*
* @since 5.8.0
*
* @param string $id The widget type id.
* @return array|WP_Error The array of widget data if the name is valid, WP_Error otherwise.
*/
public function get_widget( $id ) {
foreach ( $this->get_widgets() as $widget ) {
if ( $id === $widget['id'] ) {
return $widget;
}
}
return new WP_Error( 'rest_widget_type_invalid', __( 'Invalid widget type.' ), array( 'status' => 404 ) );
}
/**
* Normalize array of widgets.
*
* @since 5.8.0
*
* @global WP_Widget_Factory $wp_widget_factory
* @global array $wp_registered_widgets The list of registered widgets.
*
* @return array Array of widgets.
*/
protected function get_widgets() {
global $wp_widget_factory, $wp_registered_widgets;
$widgets = array();
foreach ( $wp_registered_widgets as $widget ) {
$parsed_id = wp_parse_widget_id( $widget['id'] );
$widget_object = $wp_widget_factory->get_widget_object( $parsed_id['id_base'] );
$widget['id'] = $parsed_id['id_base'];
$widget['is_multi'] = (bool) $widget_object;
if ( isset( $widget['name'] ) ) {
$widget['name'] = html_entity_decode( $widget['name'], ENT_QUOTES, get_bloginfo( 'charset' ) );
}
if ( isset( $widget['description'] ) ) {
$widget['description'] = html_entity_decode( $widget['description'], ENT_QUOTES, get_bloginfo( 'charset' ) );
}
unset( $widget['callback'] );
$classname = '';
foreach ( (array) $widget['classname'] as $cn ) {
if ( is_string( $cn ) ) {
$classname .= '_' . $cn;
} elseif ( is_object( $cn ) ) {
$classname .= '_' . get_class( $cn );
}
}
$widget['classname'] = ltrim( $classname, '_' );
$widgets[ $widget['id'] ] = $widget;
}
return $widgets;
}
/**
* Retrieves a single widget type from the collection.
*
* @since 5.8.0
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function get_item( $request ) {
$widget_id = $request['id'];
$widget_type = $this->get_widget( $widget_id );
if ( is_wp_error( $widget_type ) ) {
return $widget_type;
}
$data = $this->prepare_item_for_response( $widget_type, $request );
return rest_ensure_response( $data );
}
/**
* Prepares a widget type object for serialization.
*
* @since 5.8.0
*
* @param array $widget_type Widget type data.
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response Widget type data.
*/
public function prepare_item_for_response( $widget_type, $request ) {
$fields = $this->get_fields_for_response( $request );
$data = array(
'id' => $widget_type['id'],
);
$schema = $this->get_item_schema();
$extra_fields = array(
'name',
'description',
'is_multi',
'classname',
'widget_class',
'option_name',
'customize_selective_refresh',
);
foreach ( $extra_fields as $extra_field ) {
if ( ! rest_is_field_included( $extra_field, $fields ) ) {
continue;
}
if ( isset( $widget_type[ $extra_field ] ) ) {
$field = $widget_type[ $extra_field ];
} elseif ( array_key_exists( 'default', $schema['properties'][ $extra_field ] ) ) {
$field = $schema['properties'][ $extra_field ]['default'];
} else {
$field = '';
}
$data[ $extra_field ] = rest_sanitize_value_from_schema( $field, $schema['properties'][ $extra_field ] );
}
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
$data = $this->add_additional_fields_to_object( $data, $request );
$data = $this->filter_response_by_context( $data, $context );
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $widget_type ) );
/**
* Filters the REST API response for a widget type.
*
* @since 5.8.0
*
* @param WP_REST_Response $response The response object.
* @param array $widget_type The array of widget data.
* @param WP_REST_Request $request The request object.
*/
return apply_filters( 'rest_prepare_widget_type', $response, $widget_type, $request );
}
/**
* Prepares links for the widget type.
*
* @since 5.8.0
*
* @param array $widget_type Widget type data.
* @return array Links for the given widget type.
*/
protected function prepare_links( $widget_type ) {
return array(
'collection' => array(
'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
),
'self' => array(
'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $widget_type['id'] ) ),
),
);
}
/**
* Retrieves the widget type's schema, conforming to JSON Schema.
*
* @since 5.8.0
*
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'widget-type',
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'Unique slug identifying the widget type.' ),
'type' => 'string',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'name' => array(
'description' => __( 'Human-readable name identifying the widget type.' ),
'type' => 'string',
'default' => '',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'description' => array(
'description' => __( 'Description of the widget.' ),
'type' => 'string',
'default' => '',
'context' => array( 'view', 'edit', 'embed' ),
),
'is_multi' => array(
'description' => __( 'Whether the widget supports multiple instances' ),
'type' => 'boolean',
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
'classname' => array(
'description' => __( 'Class name' ),
'type' => 'string',
'default' => '',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
),
);
$this->schema = $schema;
return $this->add_additional_fields_schema( $this->schema );
}
/**
* An RPC-style endpoint which can be used by clients to turn user input in
* a widget admin form into an encoded instance object.
*
* Accepts:
*
* - id: A widget type ID.
* - instance: A widget's encoded instance object. Optional.
* - form_data: Form data from submitting a widget's admin form. Optional.
*
* Returns:
* - instance: The encoded instance object after updating the widget with
* the given form data.
* - form: The widget's admin form after updating the widget with the
* given form data.
*
* @since 5.8.0
*
* @global WP_Widget_Factory $wp_widget_factory
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function encode_form_data( $request ) {
global $wp_widget_factory;
$id = $request['id'];
$widget_object = $wp_widget_factory->get_widget_object( $id );
if ( ! $widget_object ) {
return new WP_Error(
'rest_invalid_widget',
__( 'Cannot preview a widget that does not extend WP_Widget.' ),
array( 'status' => 400 )
);
}
// Set the widget's number so that the id attributes in the HTML that we
// return are predictable.
if ( isset( $request['number'] ) && is_numeric( $request['number'] ) ) {
$widget_object->_set( (int) $request['number'] );
} else {
$widget_object->_set( -1 );
}
if ( isset( $request['instance']['encoded'], $request['instance']['hash'] ) ) {
$serialized_instance = base64_decode( $request['instance']['encoded'] );
if ( ! hash_equals( wp_hash( $serialized_instance ), $request['instance']['hash'] ) ) {
return new WP_Error(
'rest_invalid_widget',
__( 'The provided instance is malformed.' ),
array( 'status' => 400 )
);
}
$instance = unserialize( $serialized_instance );
} else {
$instance = array();
}
if (
isset( $request['form_data'][ "widget-$id" ] ) &&
is_array( $request['form_data'][ "widget-$id" ] )
) {
$new_instance = array_values( $request['form_data'][ "widget-$id" ] )[0];
$old_instance = $instance;
$instance = $widget_object->update( $new_instance, $old_instance );
/** This filter is documented in wp-includes/class-wp-widget.php */
$instance = apply_filters(
'widget_update_callback',
$instance,
$new_instance,
$old_instance,
$widget_object
);
}
$serialized_instance = serialize( $instance );
$widget_key = $wp_widget_factory->get_widget_key( $id );
$response = array(
'form' => trim(
$this->get_widget_form(
$widget_object,
$instance
)
),
'preview' => trim(
$this->get_widget_preview(
$widget_key,
$instance
)
),
'instance' => array(
'encoded' => base64_encode( $serialized_instance ),
'hash' => wp_hash( $serialized_instance ),
),
);
if ( ! empty( $widget_object->widget_options['show_instance_in_rest'] ) ) {
// Use new stdClass so that JSON result is {} and not [].
$response['instance']['raw'] = empty( $instance ) ? new stdClass : $instance;
}
return rest_ensure_response( $response );
}
/**
* Returns the output of WP_Widget::widget() when called with the provided
* instance. Used by encode_form_data() to preview a widget.
* @since 5.8.0
*
* @param string $widget The widget's PHP class name (see class-wp-widget.php).
* @param array $instance Widget instance settings.
* @return string
*/
private function get_widget_preview( $widget, $instance ) {
ob_start();
the_widget( $widget, $instance );
return ob_get_clean();
}
/**
* Returns the output of WP_Widget::form() when called with the provided
* instance. Used by encode_form_data() to preview a widget's form.
*
* @since 5.8.0
*
* @param WP_Widget $widget_object Widget object to call widget() on.
* @param array $instance Widget instance settings.
* @return string
*/
private function get_widget_form( $widget_object, $instance ) {
ob_start();
/** This filter is documented in wp-includes/class-wp-widget.php */
$instance = apply_filters(
'widget_form_callback',
$instance,
$widget_object
);
if ( false !== $instance ) {
$return = $widget_object->form( $instance );
/** This filter is documented in wp-includes/class-wp-widget.php */
do_action_ref_array(
'in_widget_form',
array( &$widget_object, &$return, $instance )
);
}
return ob_get_clean();
}
/**
* Retrieves the query params for collections.
*
* @since 5.8.0
*
* @return array Collection parameters.
*/
public function get_collection_params() {
return array(
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
);
}
}
활동사항 – 재중한인과학기술자협회
http://kseach.org/ksc
Welcome to KSEACH
Fri, 17 Dec 2021 02:50:40 +0000
ko-KR
hourly
1
https://wordpress.org/?v=5.8.10
http://kseach.org/ksc/wp-content/uploads/2016/04/cropped-logo512-32x32.png
활동사항 – 재중한인과학기술자협회
http://kseach.org/ksc
32
32
-
재중 한인과학기술자협회(KSEACH) 2021년 제7회 총회 및 학술대회
http://kseach.org/ksc/archives/1720
http://kseach.org/ksc/archives/1720#respond
Fri, 17 Dec 2021 01:37:52 +0000
http://kseach.org/ksc/?p=1720
재중한인과학기술자협회는 한국과학기술단체총연합회와 글로벌혁신센터과 함께 12월 4일 베이징 중관촌 원진 호텔에서 ‘한중 수교 30주년: 앞으로의 전망 및 재중과협의 역할’이라는 주제로 2021년 제 7차 총회/학술대회를 개최했다. 이번 학술대회는 방역 상황을 감안해 온/오프라인을 병행하여 진행하였고, 현장에서는 40여명이, 온라인에서는 20여명이 참석했다. 또한, 이 행사는 주중한국대사관과 한중과기협력센터가 후원했다.
]]>
http://kseach.org/ksc/archives/1720/feed
0
-
재중과협 상해지부/글로벌 혁신센터 (KIC 중국) 간담회
http://kseach.org/ksc/archives/1717
http://kseach.org/ksc/archives/1717#respond
Fri, 17 Dec 2021 01:30:21 +0000
http://kseach.org/ksc/?p=1717
12월 15일, 재중과협 상해지부는 글로벌혁신센터(KIC 중국)의 김종문 센터장과 이유리 부장, 그리고 한국벤처투자(KVIC)의 조천 과장과 함께 상해 민항구 한마당 식당에서 간담회를 가졌다. 이 자리에서 김종문 센터장과 조천 과장은 각각의 기관에서 한국의 혁신 기업과 기술형 기업의 중국 진출을 어떻게 지원하고 있는지를 소개하고, 재중과협과의 향후 창업이나 기술의 사업화을 위한 지원 방향에 대해 설명하였다. 또한 재중과협과 함께 중국 내의 한인 과학기술자들의 네트워크를 넓히는 방안과, 재중과협과 상해지부의 미래발전전략 등에 대해서 논의하였다. 이번 간담회에는 상해시 내의 이공계 분야에 종사하는 재중과협 회원들 뿐만이 아니라, 경제, 경영, 행정 등의 인문사회 분야의 교수들과 연구원들도 같이 참여해서 향후 협력방안 등의 폭넓은 논의가 이루어졌다.
]]>
http://kseach.org/ksc/archives/1717/feed
0
-
2019 재중한인과학기술자협회 총회 및 학술대회
http://kseach.org/ksc/archives/1227
http://kseach.org/ksc/archives/1227#respond
Mon, 02 Dec 2019 15:53:02 +0000
http://kseach.org/ksc/?p=1227
안녕하십니까.
지난 11월 30일 회원님들의 참여와 관심속에 2019년 재중한인과학기술자협회 총회 및 학술대회가 성공적으로 마무리 되었습니다. 이번 총회 및 학술대회에서 제 3대 회장 및 감사가 투표 를 통해 선정되었습니다.
【제 3대 회장】
【제 3대 감사】
이덕순 (북경항공항천대)
신명신 (북경자동차연구소 北京汽车动力总成有限公司)
선정되신 3분께 다시 한 번 축하의 말씀을 전합니다.
학술대회를 위해 발표해주신 발표자분들과 토론자분들께 감사 인사를 드립니다. 또한, 이번 총회 및 학술대회에 적극적으로 도움을 주신 주중국대한민국대사관, 한국과학기술단체총연합회, 한중과학기술협력센터, SK 하이닉스, 중국 삼성 관계자 및 STAFF 지원해주신 학생분들께도 다시 한번 감사드립니다.
2019 총회 및 학술대회에는 특별히 재미과협 차기회장님과 부회장님이 참석해주셨습니다. 이번 기회를 통해, 앞으로 재중과협과 재미과협의 활발한 교류를 기대해봅니다.
바쁘신 와중에 자리에 참석하여 주신 회원님 분들과 참석하지 못하였지만 관심과 응원을 보여주신 모든 회원님들께도 감사의 말씀을 올리고 더욱 발전하는 재중한인과학기술자협회가 되도록 하겠습니다.
※ 총회 사진자료를 함께 첨부합니다.
]]>
http://kseach.org/ksc/archives/1227/feed
0
-
2019 재중한인과학기술자협회 춘계학술대회
http://kseach.org/ksc/archives/959
http://kseach.org/ksc/archives/959#respond
Wed, 01 May 2019 12:24:21 +0000
http://kseach.org/ksc/?p=959
안녕하십니까.
지난 4월 26일 회원님들의 참여와 관심속에 2019년 재중한인과학기술자협회 춘계학술대회가 성공적으로 마무리 되었습니다.
학술대회를 위해 발표를 해주신 발표자 분들과 적극적으로 도움을 주신 주중국대한민국대사관, 한국과학기술단체총연합회, 한중과학기술협력센터 관계자 및 STAFF 지원해주신 학생분께 다시한번 감사드립니다.
또한 바쁘신 와중에 자리에 참석하여 주신 회원님 분들과 참석하지 못하였지만 관심과 응원을 보여주신 모든 회원님들께도 감사의 말씀을 올리고 더욱 발전하는 재중한인과학기술자협회가 되도록 하겠습니다.
※ 총회 사진자료를 함께 첨부합니다.
]]>
http://kseach.org/ksc/archives/959/feed
0
-
2018 재중한인과학기술자협회 총회 및 학술대회
http://kseach.org/ksc/archives/819
http://kseach.org/ksc/archives/819#respond
Thu, 13 Dec 2018 06:43:08 +0000
http://kseach.org/ksc/?p=819
안녕하십니까.
지난 12월 1일 회원님들의 참여와 관심속에 2018년 재중한인과학기술자협회 총회 및 학술대회가 성공적으로 마무리 되었습니다.
학술대회를 위해 발표를 해주신 발표자 분들과 적극적으로 도움을 주신 주중국대한민국대사관, 한국과학기술단체총연합회, 한중과학기술협력센터, SK하이닉스 관계자 및 STAFF지원해주신 학생분께 다시한번 감사드립니다.
※ 총회 사진자료를 함께 첨부합니다.
]]>
http://kseach.org/ksc/archives/819/feed
0
-
2018재중한인과학기술자협회 추계학술대회_충칭
http://kseach.org/ksc/archives/731
http://kseach.org/ksc/archives/731#respond
Thu, 01 Nov 2018 06:48:04 +0000
http://kseach.org/ksc/?p=731
안녕하십니까.
지난 10월 20일 회원님들의 참여와 관심속에 2018년 재중한인과학기술자협회 추계학술대회가 성공적으로 마무리 되었습니다.
학술대회를 위해 발표를 해주신 발표자 분들과 적극적으로 도움을 주신 재중과협 서남권 지부, 주 청뚜 대한민국 총영사관, 한국 카이스트 및 충칭이공대학 관계자 및 학생여러분께 다시한번 감사드립니다.
*첨부 : 추계학술대회 사진자료
]]>
http://kseach.org/ksc/archives/731/feed
0
-
2018년 재중과학자협회 춘계학술대회
http://kseach.org/ksc/archives/575
http://kseach.org/ksc/archives/575#respond
Tue, 01 May 2018 20:12:45 +0000
http://kseach.org/ksc/?p=575
안녕하십니까.
지난 4월 21일 회원님들의 참여와 관심속에 2018년 재중과학자협회 춘계학술대회가 Crown Plaza Lido Hotel 에서 진행되었습니다.
교수님들의 발표와 참석하신 회원님들의 열렬한 토론 사이에서 좋은 의견들이 나왔고 결과적으로 참석하신 모든 분들과 재중과협에도 좋은 학술대회가 되었습니다.
다시한번 회원님들의 많은 참여와 관심에 감사드립니다.
첨부: 춘계학술대회 사진자료
]]>
http://kseach.org/ksc/archives/575/feed
0
-
4사 산업혁명 강연회
http://kseach.org/ksc/archives/538
http://kseach.org/ksc/archives/538#respond
Wed, 28 Mar 2018 06:36:24 +0000
http://kseach.org/ksc/?p=538
3.23일 포스코 “4차 산업혁명 강연회”
정홍식 칭화대 교수 강연회 전체 사회 진행
이우근 칭화대 교수 “미래 4차산업 혁명을 통한 한중 경제 협력” 주제 강연
]]>
http://kseach.org/ksc/archives/538/feed
0
-
재중한인과학기술자협회 정관 및 회원관리 관련 임원회의 진행 (회의록_20180308)
http://kseach.org/ksc/archives/509
http://kseach.org/ksc/archives/509#respond
Fri, 09 Mar 2018 08:12:08 +0000
http://kseach.org/ksc/?p=509
안녕하십니까.
재중과협 정관 및 회원관리 관련 임원회의가 3월 8일 진행되었습니다.
회의록 첨부 드립니다.
감사합니다.
회의록_180308
]]>
http://kseach.org/ksc/archives/509/feed
0
-
2017 KDAI글로벌 학생작품공모전 지도교수상 수상_ 김준봉 교수
http://kseach.org/ksc/archives/460
http://kseach.org/ksc/archives/460#respond
Mon, 29 Jan 2018 03:14:23 +0000
http://kseach.org/ksc/?p=460
KDAI글로벌 학생작품공모전 김준봉 교수 “지도교수상 수상”
현. 북경공업대 건축학과 교수
전. 연변과학기술대 교수
건축학
]]>
http://kseach.org/ksc/archives/460/feed
0