Skip to content

Commit

Permalink
#116 [API] fix: remove WPML trad
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jun 6, 2023
1 parent 320c7ea commit f00db3a
Showing 1 changed file with 0 additions and 106 deletions.
106 changes: 0 additions & 106 deletions modules/api/action/class-api-action.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,6 @@ public function callback_rest_api_init() {
return Rest_Class::g()->check_cap( 'get', $request );
},
) );

register_rest_route( 'wpshop/v2', '/wpml_insert_data', array(
'methods' => array( 'POST' ),
'callback' => array( $this, 'callback_wpml_insert_data' ),
'permission_callback' => function( $request ) {
return Rest_Class::g()->check_cap( 'get', $request );
},
) );

register_rest_route( 'wpshop/v2', '/wpml_delete_data', array(
'methods' => array( 'POST' ),
'callback' => array( $this, 'callback_wpml_delete_data' ),
'permission_callback' => function( $request ) {
return Rest_Class::g()->check_cap( 'get', $request );
},
) );
}

/**
Expand Down Expand Up @@ -275,96 +259,6 @@ public function callback_wps_sync_from_dolibarr( $request ) {
return $response;
}

/**
* Gestion de la route pour synchroniser un objet depuis dolibarr.
*
* @since 2.0.0
* @version 2.0.0
*
* @todo: Validate data request
*
* @param WP_REST_Request $request L'objet contenant les informations de la requête.
*
* @return WP_REST_Response Le statut de synchronisation.
*/
public function callback_wpml_object_id( $request ) {
$param = $request->get_params();
$wpml_id = 10;
//$wpml_id = apply_filters( 'wpml_object_id', $id, 'post', false, "fr");
return $wpml_id;
}

/**
* Gestion de la route pour synchroniser un objet depuis dolibarr.
*
* @since 2.0.0
* @version 2.0.0
*
* @todo: Validate data request
*
* @param WP_REST_Request $request L'objet contenant les informations de la requête.
*
* @return WP_REST_Response Le statut de synchronisation.
*/
public function callback_wpml_insert_data( $request ) {
$param = $request->get_params();

// Create post object
$my_post = array(
'post_title' => $param['label'],
'post_content' => $param['description'],
'post_type' => 'wps-product',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(2)
);

$output = wp_insert_post($my_post);

if ( $output ) {
// https://wpml.org/wpml-hook/wpml_element_type/
$wpml_element_type = apply_filters( 'wpml_element_type', 'wps-product' );

// get the language info of the original post
// https://wpml.org/wpml-hook/wpml_element_language_details/
$get_language_args = array('element_id' => $param['wpshop_id'], 'element_type' => 'wps-product' );
$original_post_language_info = apply_filters( 'wpml_element_language_details', null, $get_language_args );

$set_language_args = array(
'element_id' => $output,
'element_type' => 'post_wps-product',
'trid' => $original_post_language_info->trid,
'language_code' => $param['language_code'],
'source_language_code' => $original_post_language_info->language_code
);

do_action( 'wpml_set_element_language_details', $set_language_args );
//do_action( 'wpml_make_post_duplicates', $output );
}

return $output;
}

/**
* Gestion de la route pour synchroniser un objet depuis dolibarr.
*
* @since 2.0.0
* @version 2.0.0
*
* @todo: Validate data request
*
* @param WP_REST_Request $request L'objet contenant les informations de la requête.
*
* @return WP_REST_Response Le statut de synchronisation.
*/
public function callback_wpml_delete_data( $request ) {
$param = $request->get_params();

$output = wp_delete_post($param['id']);

return $output;
}

/**
* Gestion de la route pour créer une commande sur dolibarr.
*
Expand Down

0 comments on commit f00db3a

Please sign in to comment.