sburdett
Forum Replies Created
-
Forum: Plugins
In reply to: [Autoptimize] Conflict with PhotoSwipeThat seems to have done it, thanks!!
Forum: Plugins
In reply to: [Autoptimize] Conflict with PhotoSwipeNo, it’s actually the main image slider at the top. We have a development server running at aircraftsales.xyz, I opened it up for now so you can see the live issue at
https://aircraftsales.xyz/listings/1981-westwind-ii-2/
by clicking on the large image at the top, you will see a blank black window.
Forum: Plugins
In reply to: [Autoptimize] Conflict with PhotoSwipeThanks for the quick response, unfortunately, that did not fix it. One odd thing is that the same plugin is used on this page:
https://aircraftsales.us/inventory/
But that does not seem to be affected. I also tried adding the class of the images used in the photoswipe, pswp__img, to the exclude list… still not working.
Forum: Plugins
In reply to: [CloudSearch] Feature Request – Make Custom Fields SortableShould I go ahead and add other field types (date, date-array, double-array, int-array, latlon, literal, text-array)? I did not need them for my use case but now that you incorporated this feature it may be nice to have for other use cases. Would you like me to code it?
Forum: Plugins
In reply to: [CloudSearch] Import/Export SettingsGreat thanks!
Forum: Plugins
In reply to: [CloudSearch] Feature Request – Make Custom Fields SortableAwsome! Loving the plugin.
- This reply was modified 6 years, 1 month ago by sburdett.
Forum: Plugins
In reply to: [CloudSearch] Analysis SchemeAwesome, thanks!
Forum: Plugins
In reply to: [CloudSearch] Feature Request – Make Custom Fields SortableThe above Code has some bugs in it. Rather than continuously repairing it here I created a GitHub repo and just put the modified files in there.
Forum: Plugins
In reply to: [CloudSearch] Feature Request – Make Custom Fields SortableSo I realized that text fields don’t always sort so well (Especially if the original values are integers or double) So this may be a better option. I added three fields on the settings page that take a csv list of fields. One is for int field, one for double and one for sortable fields. The Code changes for this are:
Code for the “Other Settings” Section of the Settings Page:
**cloud-search/admin/cloud-search-admin-settings.php Line 514 add**<tr valign="top"> <th scope="row"><label for="acs_schema_fields_int"><?php _e( 'Custom field types INT', ACS::PREFIX ) ?></label></th> <td> <input type="text" id="acs_schema_fields_int" name="acs_schema_fields_int" value="<?php echo $settings->acs_schema_fields_int ?>" class="big" /> <div class="acs_row_tips"> <span><?php _e( 'Enter Comma Separated List of fields to be converted to INT in CloudSearch.', ACS::PREFIX ) ?></span> </div> </td> </tr> <tr valign="top"> <th scope="row"><label for="acs_schema_fields_double"><?php _e( 'Custom field types Double', ACS::PREFIX ) ?></label></th> <td> <input type="text" id="acs_schema_fields_double" name="acs_schema_fields_double" value="<?php echo $settings->acs_schema_fields_double ?>" class="big" /> <div class="acs_row_tips"> <span><?php _e( 'Enter Comma Separated List of fields to be converted to Double in CloudSearch.', ACS::PREFIX ) ?></span> </div> </td> </tr> <tr valign="top"> <th scope="row"><label for="acs_schema_fields_sortable"><?php _e( 'Custom field types Sortable', ACS::PREFIX ) ?></label></th> <td> <input type="text" id="acs_schema_fields_sortable" name="acs_schema_fields_sortable" value="<?php echo $settings->acs_schema_fields_sortable ?>" class="big" /> <div class="acs_row_tips"> <span><?php _e( 'Enter Comma Separated List of fields to be Sortable in CloudSearch.', ACS::PREFIX ) ?></span> </div> </td> </tr>
**cloud-search/admin/cloud-search-admin-settings.php Line 665 add**
$settings->acs_schema_fields_int = ( !empty( $_POST[ 'acs_schema_fields_int' ] ) ) ? wp_kses_post( $_POST[ 'acs_schema_fields_int' ] ) : ''; $settings->acs_schema_fields_double = ( !empty( $_POST[ 'acs_schema_fields_double' ] ) ) ? wp_kses_post( $_POST[ 'acs_schema_fields_double' ] ) : ''; $settings->acs_schema_fields_sortable = ( !empty( $_POST[ 'acs_schema_fields_sortable' ] ) ) ? wp_kses_post( $_POST[ 'acs_schema_fields_sortable' ] ) : '';
Code for the Search Schema:
**cloud-search/cloud-search-schema.php Line 261 change function acs_get_custom_index_fields() to:**function acs_get_custom_index_fields() { $fields = array(); // Get settings option $settings = ACS::get_instance()->get_settings(); // Define custom index fields (adding custom fields) $acs_schema_fields = $settings->acs_schema_fields; //Get Custom Field Parameters $acs_int_fields = array_map('trim',str_getcsv($settings->acs_schema_fields_int)); $acs_double_fields = array_map('trim',str_getcsv($settings->acs_schema_fields_double)); $acs_sortable_fields = array_map('trim',str_getcsv($settings->acs_schema_fields_sortable)); if ( ! empty ( $acs_schema_fields ) ) { // If there are some custom fields $acs_schema_fields = explode( ACS::SEPARATOR, $acs_schema_fields ); // Loop custom fields foreach ( $acs_schema_fields as $acs_schema_field ) { // Replace field slug "-" with "_" due to Amazon CloudSearch valid pattern rule $acs_schema_field_clean = str_replace( '-', '_', $acs_schema_field ); // Check if Field is INT or Double if (isset($acs_int_fields) && in_array($acs_schema_field,$acs_int_fields)) { $acs_option_key_field = 'IntOptions'; } else if (isset($acs_double_fields) && in_array($acs_schema_field,$acs_double_fields)) { $acs_option_key_field = 'DoubleOptions'; } else { $acs_option_key_field = 'TextOptions'; } // Check if the field is sortable $acs_sort_enabled_field = (isset($acs_sortable_fields) && in_array($acs_schema_field,$acs_sortable_fields)) ? true : false; // By default all schema fields are indexed as a text string and they are not enabled for facet, highlight or sort $fields[ ACS::CUSTOM_FIELD_PREFIX . $acs_schema_field_clean ] = array( 'type' => 'text', 'option_key' => $acs_option_key_field, 'option_value' => array( 'FacetEnabled' => false, 'SearchEnabled' => true, 'ReturnEnabled' => true, 'SortEnabled' => $acs_sort_enabled_field, 'HighlightEnabled' => false, 'AnalysisScheme' => ACS::ANALYSIS_SCHEMA ) ); } }
Code for the Indexer (To Ensure Data Is Valid):
**cloud-search/cloud-search-indexer.php Line 36 change function acs_prepare_document() to:**function acs_prepare_document( $post, $from_save_transaction = false ) { try { // Get settings option $settings = ACS::get_instance()->get_settings(); // Get author $post_author = $post->post_author; $post_author_info = get_userdata($post_author); $post_author_name = $post_author_info->display_name; if ( empty( $post_author_name ) ) $post_author_name = '-'; // Get default taxonomies $taxonomy_category = acs_get_term_list( $post->ID, 'category' ); $taxonomy_tag = acs_get_term_list( $post->ID, 'post_tag' ); // Get custom taxonomies $taxonomies_custom = array(); $acs_schema_taxonomies = $settings->acs_schema_taxonomies; if ( ! empty ( $acs_schema_taxonomies ) ) { // If there are some custom taxonomies $acs_schema_taxonomies = explode( ACS::SEPARATOR, $acs_schema_taxonomies ); // Loop custom taxonomies foreach ( $acs_schema_taxonomies as $acs_schema_taxonomy ) { // Get current post custom taxonomy values $taxonomy_custom = acs_get_term_list( $post->ID, $acs_schema_taxonomy ); // Replace taxonomy slug "-" with "_" due to Amazon CloudSearch valid pattern rule $acs_schema_taxonomy_clean = str_replace( '-', '_', $acs_schema_taxonomy ); $taxonomies_custom[ ACS::CUSTOM_TAXONOMY_PREFIX . $acs_schema_taxonomy_clean ] = $taxonomy_custom; } } // Get custom fields $fields_custom = array(); $acs_schema_fields = $settings->acs_schema_fields; //Get Custom Field Parameters $acs_int_fields = array_map('trim',str_getcsv($settings->acs_schema_fields_int)); $acs_double_fields = array_map('trim',str_getcsv($settings->acs_schema_fields_double)); if ( ! empty ( $acs_schema_fields ) ) { // If there are some custom fields $acs_schema_fields = explode( ACS::SEPARATOR, $acs_schema_fields ); // Loop custom fields foreach ( $acs_schema_fields as $acs_schema_field ) { // Get current post custom field values if ( $from_save_transaction && isset( $_POST[ $acs_schema_field ] ) ) { // Read from request POST $field_custom = $_POST[ $acs_schema_field ]; } else { // Read from post meta $field_custom = get_post_meta( $post->ID, $acs_schema_field, true ); } // Verfy & Convert INT and Double Fields if (isset($acs_int_fields) && in_array($acs_schema_field,$acs_int_fields)) { $field_custom = intval($field_custom); } else if (isset($acs_double_fields) && in_array($acs_schema_field,$acs_double_fields)) { $field_custom = doubleval($field_custom); } // Replace field slug "-" with "_" due to Amazon CloudSearch valid pattern rule $acs_schema_field_clean = str_replace( '-', '_', $acs_schema_field ); if ( ! empty( $field_custom ) ) $fields_custom[ ACS::CUSTOM_FIELD_PREFIX . $acs_schema_field_clean ] = $field_custom; } } $post_image = ''; if ( ! empty( $settings->acs_schema_fields_custom_image_id ) && is_plugin_active( 'multiple-post-thumbnails/multi-post-thumbnails.php' ) ) { // Retrieve post image from "Multiple Post Thumbnails" plugin if a image id is provided and plugin is active $post_image = MultiPostThumbnails::get_post_thumbnail_url( $post->post_type, $settings->acs_schema_fields_custom_image_id, $post->ID ); } else if ( ! empty( $settings->acs_schema_fields_image_size ) ) { // Retrieve post image if a image size name is provided $image_object = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $settings->acs_schema_fields_image_size ); if ( ! empty( $image_object ) && ! empty( $image_object[0] ) && $image_object[0] != '' ) { // Found image, use it $post_image = $image_object[0]; } } // Prepare fields array (merging default fields and custom fields/taxonomies $fields = array( 'site_id' => acs_get_site_id(), 'blog_id'=> acs_get_blog_id(), 'id' => $post->ID, 'post_type' => $post->post_type, 'post_status' => $post->post_status, 'post_format' => get_post_format( $post->ID ), 'post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_url' => get_permalink($post->ID), 'post_image' => $post_image, 'post_date' => strtotime( $post->post_date ), 'post_date_gmt' => strtotime( $post->post_date_gmt ), 'post_modified' => strtotime( $post->post_modified ), 'post_modified_gmt' => strtotime( $post->post_modified_gmt ), 'post_author' => $post_author, 'post_author_name' => $post_author_name, 'category' => $taxonomy_category, 'tag' => $taxonomy_tag ); if ( ! empty( $taxonomies_custom ) ) $fields = array_merge( $fields, $taxonomies_custom ); if ( ! empty( $fields_custom ) ) $fields = array_merge( $fields, $fields_custom ); // Manipulate standard fields (in your sub-theme add a filter "cloud_search_<POST_TYPE>_fields" that adds all necessary fields of your theme) $fields = apply_filters( "cloud_search_{$post->post_type}_fields", $fields, $post, $from_save_transaction ); // Prepare doc object $doc = array( 'type' => 'add', 'id' => acs_get_document_key( $post->ID ), 'fields' => $fields ); return $doc; } catch ( \Exception $e ) { return null; } }
I could add the other field types (Double Array, Int Array, Date, ect.) if you want but This is all I needed so Unless you wanted me to do it I did not see the point.
- This reply was modified 6 years, 2 months ago by sburdett.
Forum: Plugins
In reply to: [CloudSearch] Validation error for field ‘post_content’Turns out the issue was Unicode Character ‘LINE TABULATION’ (U+000B). This is a valid UTF-8 Character but not a valid XML Character and therefore not valid for Cloud Search. I Just went through and deleted the offending text from the DB but it would be nice if the plugin could parse for these things and remove or delete them. If it was just this one you could just change this function:
function acs_put_documents( $docs ) { try { // Get client $client = acs_get_domain_client(); $docs = json_encode( $docs ); $docs = str_replace("\u000b","",$docs); // Upload documents $result = $client->uploadDocuments( array( 'documents' => $docs, 'contentType' => 'application/json' ) ); // Return result return $result->getPath( 'status' ) == 'success'; } catch ( \Exception $e ) { error_log( __( 'Error uploading documents', ACS::PREFIX ) . ': ' . $e->getMessage() ); return false; } }
but I’m guessing there are others that could be an issue. At first, I did this ^ but I don’t like modifying core plugin files so I opted to go back and just delete the offending text and hope it stays gone. It also would be nice if it threw a more visible error if the documents did not sync. For now, it just throws an error to the admin log. Anyway, just some possible future enhancement suggestions and maybe this can help if someone else encounters this error. It took me a long time to figure it out.
- This reply was modified 6 years, 2 months ago by sburdett.
Forum: Plugins
In reply to: [CloudSearch] Import/Export SettingsForum: Plugins
In reply to: [CloudSearch] Import/Export Settings- This reply was modified 6 years, 2 months ago by sburdett.
Forum: Plugins
In reply to: [CloudSearch] Analysis SchemeFigured it out. The upload was throwing an error to the admin error log I just missed it somehow. This is a test site so the log had a bunch of stuff in it and I just didn’t see the error at first. Just a feature request, it would be nice if there was some more prominent error thrown. If a user didn’t know to check the server error logs they would never see this and just be stuck scratching there head.
The error was caused by a field that was not a string or array:
[29-Aug-2018 20:05:44 UTC] Error uploading documents: { [“The value for the “cf_location_map” field must be a string or array (near operation with index 1; document_id 1_1_3340)”] }
In Case you were curious.
Thanks again, great plugin.
- This reply was modified 6 years, 3 months ago by sburdett.
Forum: Plugins
In reply to: [CloudSearch] Analysis SchemeIt seems to have to do with the number of documents. When I only turn on post and pages it loads up 28 documents. But when I turn on my custom post type, that has around 950 documents, it does not load any. Says sync in progress to 900 then goes away and does not sync any documents.
Here are a couple screen shots:
Forum: Plugins
In reply to: [CloudSearch] Analysis SchemeSO I got that working, basically the same as you show above. For some reason, however, one of the fields, vital to my search, would not populate for any of my documents. SO I deleted the entire domain on Cloud Search and started over. Now for some reason, the documents won’t sync at all. It builds the index, says syncing, but no searchable documents are created. I don’t see any errors to debug. Any ideas?