quest.
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function update_item( $request ) {
$term = $this->get_term( $request['id'] );
if ( is_wp_error( $term ) ) {
return $term;
}
if ( isset( $request['parent'] ) ) {
if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) {
return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
}
$parent = get_term( (int) $request['parent'], $this->taxonomy );
if ( ! $parent ) {
return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) );
}
}
$prepared_term = $this->prepare_item_for_database( $request );
// Only update the term if we have something to update.
if ( ! empty( $prepared_term ) ) {
if ( ! isset( $prepared_term->{'menu-name'} ) ) {
// wp_update_nav_menu_object() requires that the menu-name is always passed.
$prepared_term->{'menu-name'} = $term->name;
}
$update = wp_update_nav_menu_object( $term->term_id, wp_slash( (array) $prepared_term ) );
if ( is_wp_error( $update ) ) {
return $update;
}
}
$term = get_term( $term->term_id, $this->taxonomy );
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */
do_action( "rest_insert_{$this->taxonomy}", $term, $request, false );
$schema = $this->get_item_schema();
if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
$meta_update = $this->meta->update_value( $request['meta'], $term->term_id );
if ( is_wp_error( $meta_update ) ) {
return $meta_update;
}
}
$locations_update = $this->handle_locations( $term->term_id, $request );
if ( is_wp_error( $locations_update ) ) {
return $locations_update;
}
$this->handle_auto_add( $term->term_id, $request );
$fields_update = $this->update_additional_fields_for_object( $term, $request );
if ( is_wp_error( $fields_update ) ) {
return $fields_update;
}
$request->set_param( 'context', 'view' );
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */
do_action( "rest_after_insert_{$this->taxonomy}", $term, $request, false );
$response = $this->prepare_item_for_response( $term, $request );
return rest_ensure_response( $response );
}
/**
* Deletes a single term from a taxonomy.
*
* @since 5.9.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 delete_item( $request ) {
$term = $this->get_term( $request['id'] );
if ( is_wp_error( $term ) ) {
return $term;
}
// We don't support trashing for terms.
if ( ! $request['force'] ) {
/* translators: %s: force=true */
return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Menus do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
}
$request->set_param( 'context', 'view' );
$previous = $this->prepare_item_for_response( $term, $request );
$result = wp_delete_nav_menu( $term );
if ( ! $result || is_wp_error( $result ) ) {
return new WP_Error( 'rest_cannot_delete', __( 'The menu cannot be deleted.' ), array( 'status' => 500 ) );
}
$response = new WP_REST_Response();
$response->set_data(
array(
'deleted' => true,
'previous' => $previous->get_data(),
)
);
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */
do_action( "rest_delete_{$this->taxonomy}", $term, $response, $request );
return $response;
}
/**
* Returns the value of a menu's auto_add setting.
*
* @since 5.9.0
*
* @param int $menu_id The menu id to query.
* @return bool The value of auto_add.
*/
protected function get_menu_auto_add( $menu_id ) {
$nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
return in_array( $menu_id, $nav_menu_option['auto_add'], true );
}
/**
* Updates the menu's auto add from a REST request.
*
* @since 5.9.0
*
* @param int $menu_id The menu id to update.
* @param WP_REST_Request $request Full details about the request.
* @return bool True if the auto add setting was successfully updated.
*/
protected function handle_auto_add( $menu_id, $request ) {
if ( ! isset( $request['auto_add'] ) ) {
return true;
}
$nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
if ( ! isset( $nav_menu_option['auto_add'] ) ) {
$nav_menu_option['auto_add'] = array();
}
$auto_add = $request['auto_add'];
$i = array_search( $menu_id, $nav_menu_option['auto_add'], true );
if ( $auto_add && false === $i ) {
$nav_menu_option['auto_add'][] = $menu_id;
} elseif ( ! $auto_add && false !== $i ) {
array_splice( $nav_menu_option['auto_add'], $i, 1 );
}
$update = update_option( 'nav_menu_options', $nav_menu_option );
/** This action is documented in wp-includes/nav-menu.php */
do_action( 'wp_update_nav_menu', $menu_id );
return $update;
}
/**
* Returns the names of the locations assigned to the menu.
*
* @since 5.9.0
*
* @param int $menu_id The menu id.
* @return string[] The locations assigned to the menu.
*/
protected function get_menu_locations( $menu_id ) {
$locations = get_nav_menu_locations();
$menu_locations = array();
foreach ( $locations as $location => $assigned_menu_id ) {
if ( $menu_id === $assigned_menu_id ) {
$menu_locations[] = $location;
}
}
return $menu_locations;
}
/**
* Updates the menu's locations from a REST request.
*
* @since 5.9.0
*
* @param int $menu_id The menu id to update.
* @param WP_REST_Request $request Full details about the request.
* @return true|WP_Error True on success, a WP_Error on an error updating any of the locations.
*/
protected function handle_locations( $menu_id, $request ) {
if ( ! isset( $request['locations'] ) ) {
return true;
}
$menu_locations = get_registered_nav_menus();
$menu_locations = array_keys( $menu_locations );
$new_locations = array();
foreach ( $request['locations'] as $location ) {
if ( ! in_array( $location, $menu_locations, true ) ) {
return new WP_Error(
'rest_invalid_menu_location',
__( 'Invalid menu location.' ),
array(
'status' => 400,
'location' => $location,
)
);
}
$new_locations[ $location ] = $menu_id;
}
$assigned_menu = get_nav_menu_locations();
foreach ( $assigned_menu as $location => $term_id ) {
if ( $term_id === $menu_id ) {
unset( $assigned_menu[ $location ] );
}
}
$new_assignments = array_merge( $assigned_menu, $new_locations );
set_theme_mod( 'nav_menu_locations', $new_assignments );
return true;
}
/**
* Retrieves the term's schema, conforming to JSON Schema.
*
* @since 5.9.0
*
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}
$schema = parent::get_item_schema();
unset( $schema['properties']['count'], $schema['properties']['link'], $schema['properties']['taxonomy'] );
$schema['properties']['locations'] = array(
'description' => __( 'The locations assigned to the menu.' ),
'type' => 'array',
'items' => array(
'type' => 'string',
),
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => static function ( $locations, $request, $param ) {
$valid = rest_validate_request_arg( $locations, $request, $param );
if ( true !== $valid ) {
return $valid;
}
$locations = rest_sanitize_request_arg( $locations, $request, $param );
foreach ( $locations as $location ) {
if ( ! array_key_exists( $location, get_registered_nav_menus() ) ) {
return new WP_Error(
'rest_invalid_menu_location',
__( 'Invalid menu location.' ),
array(
'location' => $location,
)
);
}
}
return true;
},
),
);
$schema['properties']['auto_add'] = array(
'description' => __( 'Whether to automatically add top level pages to this menu.' ),
'context' => array( 'view', 'edit' ),
'type' => 'boolean',
);
$this->schema = $schema;
return $this->add_additional_fields_schema( $this->schema );
}
}
Et vestibulum quis a suspendisse – یونی فایل
[vc_row equal_height=”yes” content_placement=”top” css=”.vc_custom_1494415255420{margin-bottom: 5vh !important;}”][vc_column css=”.vc_custom_1499847091930{margin-bottom: 30px !important;}” offset=”vc_col-lg-8 vc_col-md-12″]
[/vc_column][vc_column woodmart_sticky_column=”true” css=”.vc_custom_1499847110653{margin-right: 5px !important;margin-bottom: 48px !important;margin-left: 5px !important;}” offset=”vc_col-lg-4 vc_col-md-12″][vc_row_inner css=”.vc_custom_1494415923456{border-top-width: 10px !important;border-right-width: 10px !important;border-bottom-width: 10px !important;border-left-width: 10px !important;padding-top: 30px !important;padding-right: 30px !important;padding-bottom: 10px !important;padding-left: 30px !important;border-left-color: #f7f7f7 !important;border-left-style: solid !important;border-right-color: #f7f7f7 !important;border-right-style: solid !important;border-top-color: #f7f7f7 !important;border-top-style: solid !important;border-bottom-color: #f7f7f7 !important;border-bottom-style: solid !important;}”][vc_column_inner css=”.vc_custom_1494415839649{padding-top: 0px !important;padding-right: 0px !important;padding-left: 0px !important;}”][vc_custom_heading text=”Our Latest Work” font_container=”tag:h4|font_size:38px|text_align:left|line_height:1″ use_theme_fonts=”yes” css=”.vc_custom_1494494476189{margin-bottom: 15px !important;}”][vc_column_text]
we are creative agency
Accum luctus dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation.
[/vc_column_text][/vc_column_inner][vc_column_inner width=”1/2″ css=”.vc_custom_1499149309417{padding-top: 0px !important;padding-right: 15px !important;padding-left: 0px !important;}”][vc_custom_heading text=”CLIENT” font_container=”tag:h6|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481478899319{margin-bottom: 10px !important;}”][vc_separator color=”custom” accent_color=”#eaeaea” css=”.vc_custom_1481478904779{margin-bottom: 10px !important;}”][vc_custom_heading text=”MINDSPARKLE SHOP” font_container=”tag:p|font_size:12|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481478828484{margin-bottom: 20px !important;}”][vc_custom_heading text=”DESIGNER” font_container=”tag:h6|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481479075767{margin-bottom: 10px !important;}”][vc_separator color=”custom” accent_color=”#eaeaea” css=”.vc_custom_1481478904779{margin-bottom: 10px !important;}”][vc_custom_heading text=”JOHN DOE” font_container=”tag:p|font_size:12|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481479089877{margin-bottom: 20px !important;}”][/vc_column_inner][vc_column_inner width=”1/2″ css=”.vc_custom_1499149316069{padding-top: 0px !important;padding-right: 15px !important;padding-left: 0px !important;}”][vc_custom_heading text=”MATERIALS” font_container=”tag:h6|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481479111070{margin-bottom: 10px !important;}”][vc_separator color=”custom” accent_color=”#eaeaea” css=”.vc_custom_1481478904779{margin-bottom: 10px !important;}”][vc_custom_heading text=”WOOD, PAPER” font_container=”tag:p|font_size:12|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481479127114{margin-bottom: 20px !important;}”][vc_custom_heading text=”WEBSITE” font_container=”tag:h6|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481479156495{margin-bottom: 10px !important;}”][vc_separator color=”custom” accent_color=”#eaeaea” css=”.vc_custom_1481478904779{margin-bottom: 10px !important;}”][vc_custom_heading text=”XTEMOS.COM/WOOD” font_container=”tag:p|font_size:12|text_align:left” use_theme_fonts=”yes” css=”.vc_custom_1481479173904{margin-bottom: 20px !important;}”][/vc_column_inner][/vc_row_inner][/vc_column][/vc_row][vc_row css=”.vc_custom_1494493972768{margin-bottom: 7vh !important;}”][vc_column width=”1/3″]
VULPUTATE A PORTA
Vestibulum nam lobortis scelerisque eu
mi leo orci placerat a parturient congue non
commodo felis in dui
[/vc_column][vc_column width=”1/3″]
SUSCIPIT HABITANT
Ullamcorper adipiscing vel hac a egestas
leo in sit pharetra auctor nibh mauris mi
cum curae nec nasceturam
[/vc_column][vc_column width=”1/3″]
VESTIBULUM CUBILIA
Gravida morbi platea at arcu convallis
a id id suspendisse parturient adipiscing
vestibulum. Praesent interdu.
[/vc_column][/vc_row][vc_row equal_height=”yes” content_placement=”top” css=”.vc_custom_1494415255420{margin-bottom: 5vh !important;}”][vc_column woodmart_sticky_column=”true” css=”.vc_custom_1499847127499{margin-right: 5px !important;margin-bottom: 30px !important;margin-left: 5px !important;}” offset=”vc_col-lg-4 vc_col-md-12″][vc_row_inner css=”.vc_custom_1494418291071{border-top-width: 10px !important;border-right-width: 10px !important;border-bottom-width: 10px !important;border-left-width: 10px !important;padding-top: 30px !important;padding-right: 30px !important;padding-bottom: 30px !important;padding-left: 30px !important;border-left-color: #f7f7f7 !important;border-left-style: solid !important;border-right-color: #f7f7f7 !important;border-right-style: solid !important;border-top-color: #f7f7f7 !important;border-top-style: solid !important;border-bottom-color: #f7f7f7 !important;border-bottom-style: solid !important;}”][vc_column_inner css=”.vc_custom_1494415839649{padding-top: 0px !important;padding-right: 0px !important;padding-left: 0px !important;}”][vc_custom_heading text=”Purus lectus scelerisque
parturient lobortis namar” font_container=”tag:h4|font_size:20px|text_align:left|line_height:1.4″ use_theme_fonts=”yes” css=”.vc_custom_1494495063221{margin-bottom: 15px !important;}”][vc_separator color=”custom” accent_color=”#eaeaea” css=”.vc_custom_1494420107842{margin-bottom: 15px !important;}”][vc_column_text css=”.vc_custom_1494420668496{margin-bottom: 25px !important;}”]
Purus vel sapien a mollis fusce parturient a laoreet vestibulum purus ullamcorper tellus ante at duira convallis ac vel a vestibulum sem ridiculus sapien.
Suscipit habitant vulputate a porta.
Consectetur vestibulum cubilia acc.
Scelerisque litora ipsum parturient.
Id volutpat consequat arcu tristique praesent sed sapien a a sagittis sit condimentum hac ut congue.
[/vc_column_text]
[/vc_column_inner][/vc_row_inner][/vc_column][vc_column css=”.vc_custom_1499847136861{margin-bottom: 30px !important;}” offset=”vc_col-lg-8 vc_col-md-12″]
[/vc_column][/vc_row]
پروژه های مرتبط