get_template_directory_uri() . '/partials/')); } function create_posttype() { //Add Slidehow type register_post_type('slideshow', array( 'labels' => array( 'name' => __( 'Slides'), 'singular_name' => __('Slide') ), 'supports' => array( 'title', 'excerpt', 'thumbnail' ), 'show_in_rest' => true, 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'slideshow'), ) ); //Add Entrevista type register_post_type('entrevista', array( 'labels' => array( 'name' => __('Entrevistas'), 'singular_name' => __('Entrevista') ), 'supports' => array('title','thumbnail'), 'show_in_rest' => true, 'public' => true, 'rewrite' => array('slug' => 'catalog'), ) ); //Add Persona register_post_type('entidad', array( 'labels' => array( 'name' => __('Personas'), 'singular_name' => __('Persona') ), 'supports' => array('thumbnail','title'), 'show_in_rest' => true, 'public' => true, 'rewrite' => array('slug'=> 'entidad'), ) ); //ADD EXCERPT TO PAGES add_post_type_support( 'page', 'excerpt' ); } function my_rest_prepare_slideshow($data,$post,$request) { $_data = $data->data; $thumbnail_id = get_post_thumbnail_id($post->ID); #$thumbnail = wp_get_attachment_image_src ($thumbnail_id); $thumbnail = wp_get_attachment_image_src ($thumbnail_id,'full',false); $_data['featured_image_thumbnail_url'] = $thumbnail[0]; $_data['excerpt_clean'] = strip_tags(get_the_excerpt($post->ID)); $_data['link_eu'] = str_replace('http://es.','http://',get_permalink(pll_get_post($post->ID,'eu'))); $_data['link_es'] = str_replace('http://','http://es.',get_permalink(pll_get_post($post->ID,'es'))); //$data = array(array('es',get_permalink(pll_get_post($id,'es'))),array('eus',get_permalink(pll_get_post($id,'eu')))); $data->data = $_data; return $data; } function my_rest_prepare_entrevista($data,$post,$request) { $_data = $data->data; //thumbnail $thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail = wp_get_attachment_image_src ($thumbnail_id); $_data['featured_image_thumbnail_url'] = $thumbnail[0]; //category $_data['category'] = wp_get_post_terms($post->ID,'termino'); //acf $_data['e_idioma'] = get_field('idioma',$post->ID); $_data['e_informantes'] = get_field('informantes',$post->ID); $_data['e_audiovisual'] = get_field('audiovisual',$post->ID); $_data['e_transcripcion'] = get_field('transcripcion',$post->ID); $_data['e_fecha_de_entrevista'] = get_field('fecha_de_entrevista',$post->ID); $find = array('http://','https://'); $_data['link_eu'] = str_replace('http://es.','http://',get_permalink(pll_get_post($post->ID,'eu'))); $_data['link_es'] = str_replace($find,'http://es.',get_permalink(pll_get_post($post->ID,'es'))); $_data['e_localizacion'] = get_field('lugar',$post->ID); $data->data = $_data; return $data; } function anorgatarrak_metabox() { add_meta_box('entrevista-anorgatarrak-metabox',__('Datos entrevista'),'cd_metabox_entrevista', 'entrevista','normal','high'); } function cd_metabox_entrevista() { echo '
Datos relativos a las entrevistas
'; } function remove_menus(){ remove_menu_page( 'edit-comments.php' ); //Comments remove_menu_page( 'edit.php' ); //Posts } function anorgatarrak_get_lan_id(WP_REST_Request $request) { $url = $request['url']; $id = url_to_postid($url); $data = array(array('es',get_permalink(pll_get_post($id,'es'))),array('eus',get_permalink(pll_get_post($id,'eu')))); $response = new WP_REST_Response( $data ); // $postid = url_to_postid( $url ); // https://developer.wordpress.org/reference/functions/register_rest_route/ // get_page_by_path() // return new WP_Error( 'no_author', 'Invalid author', array( 'status' => 404 ) ); return $response; } function create_anorgatarrak_tesaurus() { register_taxonomy( 'termino', 'entrevista', array( 'label' => __('Terminos'), 'rewrite' => array('slug'=> 'termino'), 'hierarchical' => true, ) ); register_taxonomy('profesion','entidad', array ( 'label' => __('Profesiones'), 'rewrite' => array('slug' => 'profesion'), )); register_taxonomy('etapas','entrevista',array( 'label' => _('Etapas del proyecto'), 'rewrite' => array('slug' => 'etapas'), )); } add_action( 'init', 'create_anorgatarrak_tesaurus' ); add_action( 'admin_menu', 'remove_menus' ); add_filter('rest_prepare_slideshow','my_rest_prepare_slideshow', 12, 3); add_filter('rest_prepare_entrevista','my_rest_prepare_entrevista', 12, 3); add_filter('rest_prepare_post','my_rest_prepare_slideshow', 12, 3); add_filter('rest_prepare_page','my_rest_prepare_slideshow', 12, 3); add_theme_support( 'post-thumbnails' ); add_action('init','create_posttype'); //add_action('add_meta_boxes','anorgatarrak_metabox'); add_action('wp_enqueue_scripts', 'anorgatarrak_scripts'); add_action( 'widgets_init', 'anorgatarrak_widgets_init' ); function anorgatarrak_widgets_init() { register_sidebar( array( 'name' => __( 'Main Sidebar', 'anorgatarrak' ), 'id' => 'sidebar-anorgatarrak-1', 'class' => '', 'description' => __( 'Widgets on header', 'anorgatarrak' ), 'before_widget' => ' ', 'before_title' => '', 'after_title' => '', ) ); } function register_anorgatarrak_menu() { register_nav_menu( 'header-menu-anorgatarrak',__( 'Header Menu Anorgatarrak' ) ); register_nav_menu( 'footer-menu-anorgatarrak',__( 'Footer Menu Anorgatarrak' ) ); } add_action( 'init', 'register_anorgatarrak_menu' ); function my_acf_google_map_api( $api ){ $api['key'] = 'AIzaSyCASefiswqiqrc74Ebs68_HI6vubGJMR9M'; return $api; } add_filter('acf/fields/google_map/api', 'my_acf_google_map_api'); add_action( 'rest_api_init', function () { register_rest_route( 'anorgatarrak/v1', '/link/(?P