Add: Suport author to marker
This commit is contained in:
parent
ba9eebe2fa
commit
ad8d0b610c
72
soundmap.php
72
soundmap.php
@ -384,7 +384,9 @@ if (!class_exists('Soundmap')){
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
|
||||
add_action('init', array($this, 'add_feed'));
|
||||
add_action('init', array($this,'add_feed'));
|
||||
add_action('init', array($this,'add_author_support_to_posts'));
|
||||
|
||||
//AJAX ACTIONS
|
||||
add_action('wp_ajax_soundmap_JSON_load_markers',array($this, 'JSON_load_markers'));
|
||||
add_action('wp_ajax_nopriv_soundmap_JSON_load_markers',array($this, 'JSON_load_markers'));
|
||||
@ -439,6 +441,8 @@ if (!class_exists('Soundmap')){
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function soundmap_save_term_translation($request) {
|
||||
|
||||
$taxonomy=$request->get_param('taxonomy');
|
||||
@ -452,23 +456,39 @@ if (!class_exists('Soundmap')){
|
||||
$termB = $termA."-es";
|
||||
$termC = $termA."-en";
|
||||
|
||||
if ( term_exists($termA) && term_exists($termB) && term_exists($termC) ) :
|
||||
$translation = [];
|
||||
|
||||
if (term_exists($termA)) :
|
||||
pll_set_term_language(term_exists($termA), 'eu');
|
||||
pll_set_term_language(term_exists($termB), 'es');
|
||||
pll_set_term_language(term_exists($termC), 'en');
|
||||
$translation['eu']=term_exists($termA);
|
||||
endif;
|
||||
|
||||
$translation = array(
|
||||
'eu' => term_exists($termA),
|
||||
'es' => term_exists($termB),
|
||||
'en' => term_exists($termC)
|
||||
);
|
||||
if (term_exists($termB)) :
|
||||
pll_set_term_language(term_exists($termB), 'es');
|
||||
$translation['es']=term_exists($termB);
|
||||
endif;
|
||||
|
||||
if (term_exists($termC)) :
|
||||
pll_set_term_language(term_exists($termC), 'en');
|
||||
$translation['en']=term_exists($termC);
|
||||
endif;
|
||||
|
||||
pll_save_term_translations($translation);
|
||||
|
||||
$response = true;
|
||||
|
||||
endif;
|
||||
// if ( term_exists($termA) && term_exists($termB) && term_exists($termC) ) :
|
||||
//
|
||||
// $translation = array(
|
||||
// 'eu' => term_exists($termA),
|
||||
// 'es' => term_exists($termB),
|
||||
// 'en' => term_exists($termC)
|
||||
// );
|
||||
//
|
||||
//
|
||||
// $response = true;
|
||||
//
|
||||
// endif;
|
||||
|
||||
endif;
|
||||
|
||||
@ -483,11 +503,10 @@ if (!class_exists('Soundmap')){
|
||||
function soundmap_save_post_translation($request) {
|
||||
|
||||
// http://docker:8089/wp-json/soundmap/translate/post?postA=43688&langA=es&postB=12707&langB=eu
|
||||
// http://docker:8089/wp-json/soundmap/translate/post?postA=jentilarrian-txalaparta&langA=eu
|
||||
|
||||
$postA=$request->get_param('postA'); // slug
|
||||
$langA=$request->get_param('langA'); // locale
|
||||
//$postB=$request->get_param('postB');
|
||||
//$langB=$request->get_param('langB');
|
||||
|
||||
$response = false;
|
||||
|
||||
@ -498,20 +517,22 @@ if (!class_exists('Soundmap')){
|
||||
$pC = get_page_by_path( $postA."-en", OBJECT, 'marker' );
|
||||
|
||||
//return new WP_REST_Response(get_page_by_path( "lesaka-ekaitz-elektromagnetikoa-es", OBJECT, 'marker' ));
|
||||
$translation = [];
|
||||
|
||||
if ( $pA && $pB && $pC ) :
|
||||
|
||||
|
||||
|
||||
if ( $pA ) :
|
||||
pll_set_post_language($pA->ID, 'eu');
|
||||
pll_set_post_language($pB->ID, 'es');
|
||||
pll_set_post_language($pC->ID, 'en');
|
||||
$translation['eu']=$pA->ID;
|
||||
endif;
|
||||
|
||||
$translation = array(
|
||||
'eu' => $pA->ID,
|
||||
'es' => $pB->ID,
|
||||
'en' => $pC->ID
|
||||
);
|
||||
if ( $pB ) :
|
||||
pll_set_post_language($pB->ID, 'es');
|
||||
$translation['es']=$pB->ID;
|
||||
endif;
|
||||
|
||||
if ( $pC ) :
|
||||
pll_set_post_language($pC->ID, 'en');
|
||||
$translation['en']=$pC->ID;
|
||||
endif;
|
||||
|
||||
pll_save_post_translations($translation);
|
||||
|
||||
@ -519,8 +540,6 @@ if (!class_exists('Soundmap')){
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
return new WP_REST_Response($response);
|
||||
}
|
||||
|
||||
@ -553,6 +572,9 @@ if (!class_exists('Soundmap')){
|
||||
}
|
||||
|
||||
|
||||
function add_author_support_to_posts() {
|
||||
add_post_type_support( 'marker', 'author' );
|
||||
}
|
||||
|
||||
function add_feed(){
|
||||
global $wp_rewrite;
|
||||
|
Loading…
Reference in New Issue
Block a user