johngodley / search-regex

Search Regex adds a powerful set of search and replace functions to WordPress that go beyond the standard searching capabilities, with full regex support.
https://searchregex.com
GNU General Public License v3.0
32 stars 9 forks source link

Search Regex Error #8

Closed Li-An closed 4 years ago

Li-An commented 4 years ago

Hello, error is showing when I try a search on Every Post Types. It does not show if the search is only on Posts. (send error by email is rejected by the way).

Plugin: 2.0
WordPress: 5.4.1 (single)
PHP: 7.3.9
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
JavaScript: https://www.echodesplugins.li-an.fr/wp-content/plugins/search-regex/search-regex.js
REST API: https://www.echodesplugins.li-an.fr/wp-json/

Error: Unexpected end of JSON input (SyntaxError)
Action: search-regex/v1/search/?searchPhrase=alignnone&searchFlags%5B0%5D=case&source%5B0%5D=posts&sourceFlags%5B0%5D=post_guid&perPage=25&page=0&searchDirection=forward GET
Code: 200 OK
Raw: -no data-
johngodley commented 4 years ago

Rejected how?

Do you have any server error logs? Do you have any plugins that add custom post types?

Li-An commented 4 years ago

Yes, I created a little plugin to manage one custom post type.

And rejected saying that the email address does not exist.

johngodley commented 4 years ago

Would it be possible to see the custom post type plugin? I suspect something in that might be triggering an error, and it will help to reproduce it.

https://searchregex.com/contact/

Li-An commented 4 years ago

Here is the code

<?php
/**
 * Plugin Name: ECHO Maison Codes Snippet Plugin
 * Plugin URI: http://www.li-an.fr/blog/
 * Description: Gestion des bouts de code utiles
 * Version: 1.0
 * Author: Li-An
 * Author URI: http://www.li-an.fr/blog/
 */ 

add_action('init', 'my_custom_init');
function my_custom_init()
{
/* notre code PHP pour rajouter les custom post type */
register_post_type(
  'code',
  array(
    'label' => 'Codes',
    'labels' => array(
      'name' => 'Codes',
      'singular_name' => 'Code',
      'all_items' => 'Tous les codes',
      'add_new_item' => 'Ajouter un code',
      'edit_item' => 'Éditer un code',
      'new_item' => 'Nouveau code',
      'view_item' => 'Voir code',
      'search_items' => 'Rechercher parmi les codes',
      'not_found' => 'Pas un code trouvé',  
      'rewrite' => array("slug" => "codes"),
      'query_var' => "codes", // This goes to the WP_Query schema
      'not_found_in_trash'=> 'Pas un code dans la corbeille'
      ),
    'public' => true,
    'capability_type' => 'post',
    'supports' => array(
      'title',
      'editor',
      'thumbnail' ,
      'excerpt',
      'wpcom-markdown',

    ),
    'has_archive' => true
  )
);  
register_taxonomy(
  'utilisation',
  'code',
  array(
    'label' => 'Utilisation',
    'labels' => array(
    'name' => 'Utilisations',
    'singular_name' => 'Utilisation',
    'all_items' => 'Toustes les utilisations',
    'edit_item' => 'Éditer l’utilisation',
    'view_item' => 'Voir l’utilisation',
    'update_item' => 'Mettre à jour l’utilisation',
    'add_new_item' => 'Ajouter une utilisation',
    'new_item_name' => 'Nouvelle utilisation',
    'search_items' => 'Rechercher parmi les utilisations',
    'popular_items' => 'utilisations les plus utilisés'
  ),
  'hierarchical' => false
  )
);
register_taxonomy_for_object_type( 'utilisation', 'code' );
}

function my_cptui_change_posts_per_page( $query ) {
    if ( is_admin() || ! $query->is_main_query() ) {
       return;
    }

    if ( is_post_type_archive( 'code' ) ) {
       $query->set( 'posts_per_page', 30 );
    }
}
add_filter( 'pre_get_posts', 'my_cptui_change_posts_per_page' );

I forget to tell I use https://fr.wordpress.org/plugins/wp-downloadmanager/ (so custom post types here too).

johngodley commented 4 years ago

Thanks! I'll try it out

Li-An commented 4 years ago

Sorry, I did not try the basic test : desactivating other plugins. It works "correctly" in this case. So I have to check witch extension is interfering. But I have another problem. I open a new ticket.