on success, or error object on failure. */ public function update_item( $request ) { $options = $this->get_registered_options(); $params = $request->get_params(); foreach ( $options as $name => $args ) { if ( ! array_key_exists( $name, $params ) ) { continue; } /** * Filters whether to preempt a setting value update via the REST API. * * Allows hijacking the setting update logic and overriding the built-in behavior by * returning true. * * @since 4.7.0 * * @param bool $result Whether to override the default behavior for updating the * value of a setting. * @param string $name Setting name (as shown in REST API responses). * @param mixed $value Updated setting value. * @param array $args Arguments passed to register_setting() for this setting. */ $updated = apply_filters( 'rest_pre_update_setting', false, $name, $request[ $name ], $args ); if ( $updated ) { continue; } /* * A null value for an option would have the same effect as * deleting the option from the database, and relying on the * default value. */ if ( is_null( $request[ $name ] ) ) { /* * A null value is returned in the response for any option * that has a non-scalar value. * * To protect clients from accidentally including the null * values from a response object in a request, we do not allow * options with values that don't pass validation to be updated to null. * Without this added protection a client could mistakenly * delete all options that have invalid values from the * database. */ if ( is_wp_error( rest_validate_value_from_schema( get_option( $args['option_name'], false ), $args['schema'] ) ) ) { return new WP_Error( 'rest_invalid_stored_value', /* translators: %s: Property name. */ sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ), array( 'status' => 500 ) ); } delete_option( $args['option_name'] ); } else { update_option( $args['option_name'], $request[ $name ] ); } } return $this->get_item( $request ); } /** * Retrieves all of the registered options for the Settings API. * * @since 4.7.0 * * @return array Array of registered options. */ protected function get_registered_options() { $rest_options = array(); foreach ( get_registered_settings() as $name => $args ) { if ( empty( $args['show_in_rest'] ) ) { continue; } $rest_args = array(); if ( is_array( $args['show_in_rest'] ) ) { $rest_args = $args['show_in_rest']; } $defaults = array( 'name' => ! empty( $rest_args['name'] ) ? $rest_args['name'] : $name, 'schema' => array(), ); $rest_args = array_merge( $defaults, $rest_args ); $default_schema = array( 'type' => empty( $args['type'] ) ? null : $args['type'], 'title' => empty( $args['label'] ) ? '' : $args['label'], 'description' => empty( $args['description'] ) ? '' : $args['description'], 'default' => isset( $args['default'] ) ? $args['default'] : null, ); $rest_args['schema'] = array_merge( $default_schema, $rest_args['schema'] ); $rest_args['option_name'] = $name; // Skip over settings that don't have a defined type in the schema. if ( empty( $rest_args['schema']['type'] ) ) { continue; } /* * Allow the supported types for settings, as we don't want invalid types * to be updated with arbitrary values that we can't do decent sanitizing for. */ if ( ! in_array( $rest_args['schema']['type'], array( 'number', 'integer', 'string', 'boolean', 'array', 'object' ), true ) ) { continue; } $rest_args['schema'] = rest_default_additional_properties_to_false( $rest_args['schema'] ); $rest_options[ $rest_args['name'] ] = $rest_args; } return $rest_options; } /** * Retrieves the site setting schema, conforming to JSON Schema. * * @since 4.7.0 * * @return array Item schema data. */ public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $options = $this->get_registered_options(); $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'settings', 'type' => 'object', 'properties' => array(), ); foreach ( $options as $option_name => $option ) { $schema['properties'][ $option_name ] = $option['schema']; $schema['properties'][ $option_name ]['arg_options'] = array( 'sanitize_callback' => array( $this, 'sanitize_callback' ), ); } $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } /** * Custom sanitize callback used for all options to allow the use of 'null'. * * By default, the schema of settings will throw an error if a value is set to * `null` as it's not a valid value for something like "type => string". We * provide a wrapper sanitizer to allow the use of `null`. * * @since 4.7.0 * * @param mixed $value The value for the setting. * @param WP_REST_Request $request The request object. * @param string $param The parameter name. * @return mixed|WP_Error */ public function sanitize_callback( $value, $request, $param ) { if ( is_null( $value ) ) { return $value; } return rest_parse_request_arg( $value, $request, $param ); } /** * Recursively add additionalProperties = false to all objects in a schema * if no additionalProperties setting is specified. * * This is needed to restrict properties of objects in settings values to only * registered items, as the REST API will allow additional properties by * default. * * @since 4.9.0 * @deprecated 6.1.0 Use {@see rest_default_additional_properties_to_false()} instead. * * @param array $schema The schema array. * @return array */ protected function set_additional_properties_to_false( $schema ) { _deprecated_function( __METHOD__, '6.1.0', 'rest_default_additional_properties_to_false()' ); return rest_default_additional_properties_to_false( $schema ); } } yers-core-course'), 'circle-border' => esc_html__('Circle Border', 'goodlayers-core-course'), ), 'default' => 'default', 'condition' => array( 'pagination' => 'page' ) ), 'pagination-align' => array( 'title' => esc_html__('Pagination Alignment', 'goodlayers-core-course'), 'type' => 'radioimage', 'options' => 'text-align', 'with-default' => true, 'default' => 'default', 'condition' => array( 'pagination' => 'page' ) ), ) ), // general 'style' => array( 'title' => esc_html__('Style', 'goodlayers-core-course'), 'options' => array( 'course-style' => array( 'title' => esc_html__('Course Style', 'goodlayers-core-course'), 'type' => 'combobox', 'options' => array( 'list' => esc_html__('List', 'goodlayers-core-course'), 'list-info' => esc_html__('List With Info', 'goodlayers-core-course'), 'grid' => esc_html__('Grid', 'goodlayers-core-course'), ) ), 'course-info' => array( 'title' => esc_html__('Course Info', 'goodlayers-core-course'), 'type' => 'multi-combobox', 'options' => goodlayers_core_course_get_custom_tax_list(), 'condition' => array('course-style' => array('list-info', 'grid')) ), 'column-size' => array( 'title' => esc_html__('Column Size', 'goodlayers-core-course'), 'type' => 'combobox', 'options' => array( 60=>1, 30=>2, 20=>3, 15=>4, 12=>5, 10=>6 ), 'default' => 20, 'condition' => array( 'course-style' => 'grid' ) ), 'thumbnail-size' => array( 'title' => esc_html__('Thumbnail Size', 'goodlayers-core-course'), 'type' => 'combobox', 'options' => 'thumbnail-size', 'condition' => array( 'course-style' => 'grid' ) ), 'read-more-button' => array( 'title' => esc_html__('Read More Button', 'goodlayers-core-course'), 'type' => 'checkbox', 'default' => 'enable', 'condition' => array( 'course-style' => 'grid' ) ), // course list info option 'course-list-item-bg' => array( 'title' => esc_html__('Course List Item Background', 'goodlayers-core-course'), 'type' => 'colorpicker', 'condition' => array( 'course-style' => 'list-info' ) ), 'course-list-item-border-size' => array( 'title' => esc_html__('Course List Item Border Size', 'goodlayers-core-course'), 'type' => 'text', 'data-input-type' => 'pixel', 'condition' => array( 'course-style' => 'list-info' ) ), 'course-list-item-border-color' => array( 'title' => esc_html__('Course List Item Border Color', 'goodlayers-core-course'), 'type' => 'colorpicker', 'condition' => array( 'course-style' => 'list-info' ) ), 'course-list-item-hover-border-color' => array( 'title' => esc_html__('Course List Item Hover Border Color', 'goodlayers-core-course'), 'type' => 'colorpicker', 'condition' => array( 'course-style' => 'list-info' ) ), 'course-list-hover-shadow-size' => array( 'title' => esc_html__('Course List Shadow Hover Size', 'goodlayers-core-course'), 'type' => 'custom', 'item-type' => 'padding', 'options' => array('x', 'y', 'size'), 'data-input-type' => 'pixel', 'condition' => array( 'course-style' => 'list-info' ) ), 'course-list-hover-shadow-color' => array( 'title' => esc_html__('Course List Shadow Hover Color', 'goodlayers-core-course'), 'type' => 'colorpicker', 'condition' => array( 'course-style' => 'list-info' ) ), 'course-list-hover-shadow-opacity' => array( 'title' => esc_html__('Course List Shadow Hover Opacity', 'goodlayers-core-course'), 'type' => 'text', 'default' => '0.2', 'description' => esc_html__('Fill the number between 0.01 to 1', 'goodlayers-core-course'), 'condition' => array( 'course-style' => 'list-info' ) ), ) ), 'spacing' => array( 'title' => esc_html__('Spacing', 'goodlayers-core-course'), 'options' => array( 'padding-bottom' => array( 'title' => esc_html__('Padding Bottom ( Item )', 'goodlayers-core-course'), 'type' => 'text', 'data-input-type' => 'pixel', 'default' => $gdlr_core_item_pdb ) ) ), 'item-title' => array( 'title' => esc_html__('Item Title', 'goodlayers-core-course'), 'options' => gdlr_core_block_item_option() ) ); } // get the preview for page builder static function get_preview( $settings = array() ){ $content = self::get_content($settings, true); return $content; } // get the content from settings static function get_content( $settings = array(), $preview = false ){ global $gdlr_core_item_pdb, $page_builder_post_id; // default variable if( empty($settings) ){ $settings = array( 'padding-bottom' => $gdlr_core_item_pdb ); } $settings['course-style'] = empty($settings['course-style'])? 'list': $settings['course-style']; $custom_style = ''; if( $settings['course-style'] == 'list-info' ){ if( !empty($settings['course-list-item-border-size']) ){ $custom_style .= '#custom_style_id .gdlr-core-course-item-list{ '; $custom_style .= 'border-width: ' . $settings['course-list-item-border-size'] . '; '; $custom_style .= 'border-style: solid; '; if( !empty($settings['course-list-item-border-color']) ){ $custom_style .= 'border-color: ' . $settings['course-list-item-border-color'] . '; '; } $custom_style .= '}'; if( !empty($settings['course-list-item-hover-border-color']) ){ $custom_style .= '#custom_style_id .gdlr-core-course-item-list:hover{ '; $custom_style .= 'border-color: ' . $settings['course-list-item-hover-border-color'] . ';'; $custom_style .= gdlr_core_esc_style(array( 'background-shadow-size' => empty($settings['course-list-hover-shadow-size'])? '': $settings['course-list-hover-shadow-size'], 'background-shadow-color' => empty($settings['course-list-hover-shadow-color'])? '': $settings['course-list-hover-shadow-color'], 'background-shadow-opacity' => empty($settings['course-list-hover-shadow-opacity'])? '': $settings['course-list-hover-shadow-opacity'], ), false); $custom_style .= '}'; } } } if( !empty($custom_style) ){ if( empty($settings['id']) ){ global $gdlr_core_course_id; $gdlr_core_course_id = empty($gdlr_core_course_id)? array(): $gdlr_core_course_id; // generate unique id so it does not get overwritten in admin area $rnd_course_id = mt_rand(0, 99999); while( in_array($rnd_course_id, $gdlr_core_course_id) ){ $rnd_course_id = mt_rand(0, 99999); } $gdlr_core_course_id[] = $rnd_course_id; $settings['id'] = 'gdlr-core-course-' . $rnd_course_id; } $custom_style = str_replace('custom_style_id', $settings['id'], $custom_style); if( $preview ){ $custom_style = ''; }else{ gdlr_core_add_inline_style($custom_style); $custom_style = ''; } } // start printing item $ret = '
$settings['padding-bottom'])); } if( !empty($settings['id']) ){ $ret .= ' id="' . esc_attr($settings['id']) . '" '; } $ret .= ' >'; $title_settings = $settings; $title_settings['pdlr'] = false; $ret .= gdlr_core_block_item_title($title_settings); $query = self::query_course($settings); $settings['paged'] = empty($query->query['paged'])? 1: $query->query['paged']; $column = 0; $column_size = (empty($settings['column-size'])? '60': $settings['column-size']); gdlr_core_setup_admin_postdata(); if( $query->have_posts() ){ while($query->have_posts()){ $query->the_post(); $course_id = get_post_meta(get_the_ID(), 'goodlayers-core-course-id', true); $extra_class = ''; if( $settings['course-style'] == 'grid' ){ $column += $column_size; $extra_class .= ' gdlr-core-item-pdlr gdlr-core-column-' . $column_size; if( $column > 60 || $column == $column_size ){ $extra_class .= ' gdlr-core-column-first'; $column = $column_size; } } if( $settings['course-style'] == 'list' ){ $ret .= '
'; $ret .= ''; if( !empty($course_id) ){ $ret .= '' . gdlr_core_text_filter($course_id) . ''; } $ret .= '' . get_the_title() . ''; $ret .= ''; $ret .= ''; $ret .= '
'; }else if( $settings['course-style'] == 'list-info' ){ $ret .= '
empty($settings['course-list-item-bg'])? '': $settings['course-list-item-bg'] )) . ' >'; $ret .= '

'; if( !empty($course_id) ){ $ret .= '' . gdlr_core_text_filter($course_id) . ''; } $ret .= get_the_title(); $ret .= '

'; if( !empty($settings['course-info']) ){ $ret .= self::get_course_info($settings['course-info'], get_the_ID()); } $ret .= '' . esc_html__('More Detail', 'goodlayers-core-course') . ''; $ret .= '
'; }else if( $settings['course-style'] == 'grid' ){ $ret .= '
'; $thumbnail_id = get_post_thumbnail_id(); $settings['thumbnail-size'] = empty($settings['thumbnail-size'])? 'full': $settings['thumbnail-size']; $ret .= '
'; if( !empty($thumbnail_id) ){ $ret .= '
' . gdlr_core_get_image($thumbnail_id, $settings['thumbnail-size']) . '
'; } $ret .= '
'; $ret .= '

'; $ret .= ''; $ret .= get_the_title(); $ret .= ''; $ret .= '

'; if( !empty($settings['course-info']) ){ $ret .= self::get_course_info($settings['course-info'], get_the_ID()); } if( empty($settings['read-more-button']) || $settings['read-more-button'] == 'enable' ){ $ret .= ''; $ret .= esc_html__('Read More', 'goodlayers-core-course'); $ret .= ''; $ret .= ''; } $ret .= '
'; // gdlr-core-course-content-wrap $ret .= '
'; // gdlr-core-course-item-list-inner $ret .= '
'; } } }else{ $ret .= '
'; $ret .= esc_html__('There\'re no item that match your search criteria. Please try again with different keywords.', 'goodlayers-core-course'); $ret .= '
'; } wp_reset_postdata(); gdlr_core_reset_admin_postdata(); if( !empty($settings['pagination']) && $settings['pagination'] == 'page' ){ $ret .= gdlr_core_get_pagination($query->max_num_pages, $settings); } $ret .= '
' . $custom_style; return $ret; } static function query_course( $settings = array() ){ if( !empty($settings['query']) ){ return $settings['query']; } $args = array('post_type' => 'course', 'post_status' => 'publish', 'suppress_filters' => false); if( !empty($settings['keywords']) ){ $args['s'] = $settings['keywords']; } if( !empty($settings['course-id']) ){ $args['meta_query'] = array(array( 'key' => 'goodlayers-core-course-id', 'value' => $settings['course-id'] )); } // category - tag selection $args['tax_query'] = array('relation' => 'AND'); if( !empty($settings['course_category']) ){ if( !is_array($settings['course_category']) ){ $settings['course_category'] = array_map('trim', explode(',', $settings['course_category'])); } array_push($args['tax_query'], array('terms'=>$settings['course_category'], 'taxonomy'=>'course_category', 'field'=>'slug')); } if( !empty($settings['course_tag']) ){ if( !is_array($settings['course_tag']) ){ $settings['course_tag'] = array_map('trim', explode(',', $settings['course_tag'])); } array_push($args['tax_query'], array('terms'=>$settings['course_tag'], 'taxonomy'=>'course_tag', 'field'=>'slug')); } $tax_fields = goodlayers_core_course_get_custom_tax_list(); foreach( $tax_fields as $tax_field => $tax_title ){ if( !empty($settings[$tax_field]) ){ if( !is_array($settings[$tax_field]) ){ $settings[$tax_field] = array_map('trim', explode(',', $settings[$tax_field])); } $args['tax_query'][] = array( array('terms'=>$settings[$tax_field], 'taxonomy'=>$tax_field, 'field'=>'slug') ); } } // order $args['order'] = empty($settings['order'])? 'desc': $settings['order']; $args['orderby'] = empty($settings['orderby'])? 'date': $settings['orderby']; $args['posts_per_page'] = empty($settings['num-fetch'])? 9: $settings['num-fetch']; $args['paged'] = (get_query_var('paged'))? get_query_var('paged') : get_query_var('page'); $args['paged'] = empty($args['paged'])? 1: $args['paged']; return new WP_Query( $args ); } // course item info static function get_course_info( $infos = array(), $post_id = '' ){ $taxs = goodlayers_core_course_get_custom_tax_list(); $ret = ''; foreach( $infos as $tax_slug ){ $terms = get_the_terms($post_id, $tax_slug); $term_name = ''; if( !empty($terms) ){ foreach( $terms as $term ){ $term_name .= empty($term_name)? '': ', '; $term_name .= $term->name; } } if( !empty($term_name) ){ $ret .= '
'; $ret .= '' . $taxs[$tax_slug] . ' : '; $ret .= '' . gdlr_core_text_filter($term_name) . ''; $ret .= '
'; } } if( !empty($ret) ){ $ret = '
' . $ret . '
'; } return $ret; } } // gdlr_core_pb_element_course } // class_exists
Warning: Cannot modify header information - headers already sent by (output started at /htdocs/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php:1) in /htdocs/wp-includes/sitemaps/class-wp-sitemaps-renderer.php on line 126
https://ihfk-man.com/wp-sitemap-posts-post-1.xmlhttps://ihfk-man.com/wp-sitemap-posts-page-1.xmlhttps://ihfk-man.com/wp-sitemap-posts-course-1.xmlhttps://ihfk-man.com/wp-sitemap-posts-personnel-1.xmlhttps://ihfk-man.com/wp-sitemap-posts-portfolio-1.xmlhttps://ihfk-man.com/wp-sitemap-posts-lp_course-1.xmlhttps://ihfk-man.com/wp-sitemap-taxonomies-category-1.xmlhttps://ihfk-man.com/wp-sitemap-taxonomies-course_category-1.xmlhttps://ihfk-man.com/wp-sitemap-users-1.xml