Unexpected end of file (plugin)
-
I had several Custom Post Types in functions.php
I just migrated all of them to individual plugin files, just to be more tidy.the code is the same, how ever, I am getting the same error on every plugin, which is the following:
Parse error: syntax error, unexpected end of file in /Applications/MAMP/htdocs/revistafilm/wp-content/plugins/revistafilm-articulos/revistafilm-articulos.php on line 193
line 193 is the closing php tag.
After some testing, I have discovered that the error is on the ‘enter_title_here’ filter. If I delete that filter, the plugin works just fine. But I don’t know where is the error.
The whole plugin code:
<?php /* Plugin Name: Revista Film: Artículos */ //REGISTRAR CUSTOM POST TYPE add_action('init', 'registrar_CPT' ); //REGISTAR TAXONOMIAS add_action('init', 'registrar_taxonomias' ); //REGISTRAR METABOXES add_action('add_meta_boxes', 'registrar_metaboxes' ); //SALVAR METABOXES INFO add_action( 'save_post' , 'salvar_metaboxes_info'); //REGISTRAR CUSTOM POST TYPE function registrar_CPT() { $labels = array( 'name' => 'Artículos', 'singular_name' => 'Artículo', 'add_new' => 'Agregar nuevo artículo', 'add_new_item' => 'Agregar nuevo artículo', 'edit_item' => 'Editar artículo', 'new_item' => 'Nuevo artículo', 'all_items' => 'Todos los artículos', 'view_item' => 'Ver artículo', 'search_items' => 'Buscar artículos', 'not_found' => 'No se encontraron artículos', 'not_found_in_trash' => 'No se encontraron artículos en la papelera', 'menu_name' => 'Artículos' ); register_post_type('articulos', array( 'labels' => $labels, 'public' => true, 'supports' => array( 'title','editor','thumbnail','excerpt','comments','trackbacks','custom-fields' ), 'has_archive' => true, 'menu_icon' => 'dashicons-admin-page', ) ); //cambiar placeholder del título function title_text_input ( $title ) { if ( get_post_type() == 'articulos' ) { $title = __( 'Título del Artículo' ); } return $title; add_filter( 'enter_title_here', 'title_text_input' ); //agregar descripción para el textarea function textarea_description( $content, $post ) { if ( 'articulos' == $post->post_type ) { $content = 'Ingresar sección principal del artículo'; } return $content; } add_filter( 'default_content', 'textarea_description', 10, 2 ); } // registrar_CPT() //REGISTAR TAXONOMIAS function registrar_taxonomias() { }// registrar_taxonomias() //REGISTRAR METABOXES function registrar_metaboxes() { // register 'subtitulo' metabox add_meta_box( 'articulo-subtitulo', // Unique CSS ID esc_html__( 'Agregar Subtítulo', 'false' ), // Title 'articulos_subtitulo', // Callback function to display meta box information 'articulos', // Admin page (or post type) 'advanced', // Context 'high' // Priority ); // show 'subtitulo' metabox function articulos_subtitulo($post, $box) { //obtener los valores de los metaboxes $subtitulo_articulo = get_post_meta($post->ID, '_subtitulo-articulo', true); //nonce for security wp_nonce_field(plugin_basename(__FILE__), 'articulos_save_custom_meta_boxes'); //subtítulo de artículo echo '<p><input type="text" name="subtitulo-articulo" id="subtitulo-articulo" value="'.esc_attr($subtitulo_articulo).'" placeholder="Ingresar subtítulo (opcional)" style="width:100%;"> </p>'; } // Ubicar el subtítulo debajo del título: Move all "advanced" metaboxes above the default editor add_action('edit_form_after_title', function() { global $post, $wp_meta_boxes; do_meta_boxes(get_current_screen(), 'advanced', $post); unset($wp_meta_boxes[get_post_type($post)]['advanced']); }); //register 'revistas' metaboxes add_meta_box( 'listado-revistas', __('Revistas', ''), 'listar_revistas', 'articulos', 'side', 'default' ); //show 'revistas' CPT metaboxes function listar_revistas($post, $args){ wp_nonce_field( plugin_basename( __FILE__ ), 'listado_revistas_nonce' ); $revista_id = get_post_meta($post->ID, '_revista', true); echo "<p>Selecciona la revista a la que pertenece el artículo</p>"; echo "<select id='revistas' name='revistas'>"; // Query de las revistas $query = new WP_Query( 'post_type=revistas' ); while ( $query->have_posts() ) { $query->the_post(); $id = get_the_ID(); $selected = ""; if($id == $revista_id){ $selected = ' selected="selected"'; } echo '<option' . $selected . ' value=' . $id . '>' . get_the_title() . '</option>'; } echo "</select>"; } // register 'metada' metaboxes add_meta_box( 'articulo-meta-data', // Unique CSS ID esc_html__( 'Metadata', '' ), // Title 'articulos_metadata', // Callback function to display meta box information 'articulos', // Admin page (or post type) 'side', // Context 'default' // Priority ); // show 'metada' metaboxes on admin function articulos_metadata($post, $box) { //obtener los valores de los metaboxes $numero_articulo = get_post_meta($post->ID, '_numero-articulo', true); $autor = get_post_meta($post->ID, '_autor', true); //nonce for security wp_nonce_field(plugin_basename(__FILE__), 'articulos_save_custom_meta_boxes'); //numero de artículo echo '<p><label for="numero-articulo">n° artículo:</label> <input type="number" name="numero-articulo" id="numero-articulo" value="'.esc_attr($numero_articulo).'" style="float:right;"> </p>'; //autor echo '<p><label for="autor">Autor:</label> <input type="text" name="autor" id="autor" value="'.esc_attr($autor).'" style="float:right;"> </p>'; } } // registrar_metaboxes() // SALVAR METABOXES INFO function salvar_metaboxes_info($post_id) { // Guardar datos de metaboxes if ( isset($_POST['numero-articulo']) ) { // if auto saving skip saving our meta box data if ( defined( 'DOING AUTOSAVE' ) && DOING_AUTOSAVE ) return; //check nonce for security check_admin_referer( plugin_basename(__FILE__), 'articulos_save_custom_meta_boxes'); //save the meta box data as post meta using the post ID as a unique prefix update_post_meta( $post_id, '_numero-articulo', sanitize_text_field( $_POST['numero-articulo'] ) ); update_post_meta( $post_id, '_autor', sanitize_text_field( $_POST['autor'] ) ); } // Guardar datos de subtitulo if ( isset($_POST['subtitulo-articulo']) ) { // if auto saving skip saving our meta box data if ( defined( 'DOING AUTOSAVE' ) && DOING_AUTOSAVE ) return; //check nonce for security check_admin_referer( plugin_basename(__FILE__), 'articulos_save_custom_meta_boxes'); //save the meta box data as post meta using the post ID as a unique prefix update_post_meta( $post_id, '_subtitulo-articulo', sanitize_text_field( $_POST['subtitulo-articulo'] ) ); } } // salvar_metaboxes_info() ?>
- The topic ‘Unexpected end of file (plugin)’ is closed to new replies.