Giter VIP home page Giter VIP logo

agentpress-listings's People

Contributors

bgardner avatar kienstra avatar marksabbath avatar nathanrice avatar nickcernis avatar nickthegeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agentpress-listings's Issues

Message - characters of unexpected output during activation

The following message is displayed on plugin activation only with debug enabled:

The plugin generated 211 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

Functionality is fine.

Use WP 4.4 "srcset" attributes for images in Featured Listings Widget

Hello.

This is a suggestion in order tu use the 4.4 srcset data for images.
I have noticed that the images used in the widget area placed in the sidebar are not optimized (loaded bigger than scaled down).

My suggestion is to use change:
$loop .= sprintf( '<a href="%s">%s</a>', get_permalink(), genesis_get_image( array( 'size' => 'properties' ) ) );
to:
$loop .= sprintf( '<a href="%s">%s</a>', get_permalink(), get_the_post_thumbnail( $post_id, 'properties', array( 'class' => '' ) ) );

What do you think?

Remove admin_style()

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'AgentPress_Listings::admin_style' was given in demos/wp-includes/plugin.php on line 470

Remove this from class-listinngs.php

add_action( 'admin_head', array( $this, 'admin_style' ) );

Left over from d1a23aa

AgentPress Listings Search widget select fields lose selection on search results page

As reported on WP.org, the selected taxonomies are lost when viewing search results such as this:

http://demo.studiopress.com/agentpress/?s=&post_type=listing&bedrooms=4-bedrooms

Observed behaviour: No value is selected in the “Bedrooms” select field.
Expected behaviour: “4 bedrooms” (the originally selected query) is preselected in the “Bedrooms” select field.

Adding global $wp_query; near the top of the widget() function in agentpress-listings/includes/class-property-search-widget.php fixes this in my tests.

[property_details] columns

Instead of outputting classes "property-details-col1" and "property-details-col2" - should we change this to use the column classes built into genesis?

cc: @bgardner

_listing_price_sortable key removed on save in 1.3.2

The _listing_price_sortable key is being removed when saving a listing:

https://wordpress.org/support/topic/version-1-3-2-removing-meta_key-_listing_price_sortable/

Impact

New listings and edited listings may fail to appear in search results, archives, or other lists if _listing_price_sortable has been used in the query to select or order them.

The paid plugin Extended AgentPress Listings Widget apparently allows sorting by _listing_price_sortable, for example.

To reproduce

  1. git checkout 1.3.1
  2. Create a listing with a price.
  3. Confirm the saved listing has a _listing_price and _listing_price_sortable:
❯ wp post meta list 7488
+---------+-------------------------+--------------+
| post_id | meta_key                | meta_value   |
+---------+-------------------------+--------------+
| 7488    | _edit_last              | 1            |
| 7488    | _edit_lock              | 1562778936:1 |
| 7488    | _listing_price          | 12345        |
| 7488    | _listing_price_sortable | 12345        |
+---------+-------------------------+--------------+
  1. git checkout 1.3.2
  2. Edit the listing title and save the listing.

The _listing_price_sortable row will now be missing:

❯ wp post meta list 7488
+---------+----------------+--------------+
| post_id | meta_key       | meta_value   |
+---------+----------------+--------------+
| 7488    | _edit_last     | 1            |
| 7488    | _edit_lock     | 1562779081:1 |
| 7488    | _listing_price | 12345        |
+---------+----------------+--------------+

To fix

Fixed for me by changing these lines in agentpress-listings/includes/class-agentpress-listings.php:

-		if ( isset( $property_details['_listing_price'] ) && ! empty( $property_details['_listing_price'] ) ) {
+		if ( isset( $property_details[0]['_listing_price'] ) && ! empty( $property_details[0]['_listing_price'] ) ) {

-			$price_sortable = preg_replace( '/[^0-9\.]/', '', $property_details['_listing_price'] );
+			$price_sortable = preg_replace( '/[^0-9\.]/', '', $property_details[0]['_listing_price'] );

			update_post_meta( $post_id, '_listing_price_sortable', floatval( $price_sortable ) );
		} else {
			delete_post_meta( $post_id, '_listing_price_sortable' );
		}

New posts and posts that were edited would then have to be re-saved after this fix in order to restore the _listing_price_sortable.

Cause

The $property_details data structure changed here in 1.3.2:

$property_details = array_map( 'wp_kses', array( wp_unslash( $_POST['ap'] ) ), array( $this->allowed_tags ) );

And we missed that $property_details needed to become $property_details[0] at all points below that in the code, rather than just the for loop.

Correct link to edit taxonomy.

The link on the taxonomy ID is incorrect on the register taxonomy screen. If you click the ID, it should go to the edit screen similar to categories where clicking the category name or the edit link below it lead to the same page.

Currently, the links on taxonomy IDs lead to a page that says Please complete all required fields.
The incorrect link uses action instead of view.
wp-admin/admin.php?page=register-taxonomies&view=edit&id=test vs
wp-admin/admin.php?page=register-taxonomies&action=edit&id=test

link

Taxonomy Registration

Currently the taxonomies need to be registered with lowercase letters, dashes, and numbers only. Quite often, this instruction is either missed or ignored and customers enter capital letters or symbols.

This can break the listing search widget, scripts on the listing edit pages, and menus. Capital letters are fairly easy to fix by deleting and recreating, but certain symbols result in taxonomies that are broken and require using phpMyAdmin to edit the database to fix the issue.

The solution would be to sanitize the registration to avoid these issues.

Listing Price

When creating a new Listing post type, the Pricing field is stored in the postmeta table as a longtext value, which prohibits it from being sorted/treated like a number when queried.

Map embed and video embed fields are cleared when saving listings

In 1.3.0 and 1.3.1, iframe HTML entered into the Map Embed Code or Video Embed Code fields is cleared when saving the listing:

Screen Shot 2019-05-22 at 15 12 12

To reproduce

  1. Edit or create any listing.
  2. Add this HTML to the map embed code or video embed code fields:

<iframe width="600" height="500" id="gmap_canvas" src="https://maps.google.com/maps?q=university%20of%20san%20francisco&t=&z=13&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>

  1. Save the listing.

The map and video fields will be cleared after saving.

Plain text entered into those fields is not stripped — only HTML.

Cause

Seems to be due to the combination of:

  1. Sanitizing text fields on save here:

$property_details = array_map( 'sanitize_text_field', wp_unslash( $_POST['ap'] ) );

  1. wp_kses_post when displaying the meta boxes here:

printf( '<p><label>%1$s<br /><textarea name="ap[_listing_map]" rows="5" cols="18" style="%2$s">%3$s</textarea></label></p>', esc_html__( 'Enter Map Embed Code:', 'agentpress-listings' ), 'width: 99%;', wp_kses_post( genesis_get_custom_field( '_listing_map' ) ) );
printf( '<p><a class="button" href="%s" onclick="%s">%s</a></p>', '#', 'ap_send_to_editor(\'[property_map]\')', esc_html__( 'Send to text editor', 'agentpress-listings' ) );
echo '</div>';
echo '<div style="width: 45%; float: left;">';
printf( '<p><label>%1$s:<br /><textarea name="ap[_listing_video]" rows="5" cols="18" style="%2$s">%3$s</textarea></label></p>', esc_html__( 'Enter Video Embed Code', 'agentpress-listings' ), 'width: 99%;', wp_kses_post( genesis_get_custom_field( '_listing_video' ) ) );

We could perhaps change the array_map to only act on the text fields, and remove the wp_kses_post on output?

Further info

The issue is not present in 1.2.7.

Sorry to miss this during testing, @marksabbath. (I tested those fields with plain text but not HTML.)

URL slug not translatable

The custom post type slug for listings is not translatable.

The fix for this is below.
class-listings.php line number 91:
'rewrite' => array( 'slug' => _x( 'listings', 'agentpress-listings' ) ),

Property Details fields are not saved when updating listings on WP 5.3.1

Describe the bug
In 1.3.2 and 1.3.3, while on WP Core 5.3.1 content entered into the Property Details input boxes:

Screen Shot 2019-12-14 at 12 11 04 PM

To Reproduce
Steps to reproduce the behavior:

  1. Go to a site running WordPress Core version 5.3.1
  2. Edit an existing listing or make a new listing.
  3. Modify any existing value, or add new values.
  4. Save the value

Expected behavior
The modified fields will be cleared after saving.

Video Replication
https://www.loom.com/share/ea0ce018108942268f06c3ccf11afbb1

Screenshot
Screen Shot 2019-12-14 at 11 44 26 AM

Version

  • WP Core 5.3.1
  • agentpress-listings 1.3.2 and 1.3.3

Device and browser information

  • OS: Mac
  • Browser Chrome
  • Version 79.0.3945.79
    Additional context

Reported at https://wordpress.org/support/topic/agentpress-listings-plugin-error-when-upgrading-wordpress-5-3-1/

Allow taxonomy labels to be translated

As reported by a customer here, Listing taxonomy labels are not currently translatable.

The customer provided the following screenshots from WPML support, who suggest using the gettext filter to add translation support for drop-down labels:

741574-untranslatedsearchlabels

741574-htmlformnottranslatingsearchlabels

741574-exampleflterfunction

Taxonomy ID of 'year' causes subpage URLs to display homepage

If you create a listings taxonomy with an ID of ‘year‘ and then attempt to load any subpages, you will see the homepage at the subpage URL. WP will match the slug against 'year=' instead of 'pagename=', find no year, and serve the homepage:

__dxr-59625-331___studiopress_member_contact__technical_issue_-_rainmaker_digital_helpdesk

We could auto-rename an ID of 'year' to 'years' or 'era' (both of which work).

'year' was the only slug I could reproduce this with — others such as post_id, postname, etc. do not cause an issue.

Taxonomy IDs cannot be renamed via the UI at present, so people encountering this either need to make database edits to rename the ID, or recreate their 'year' taxonomy as 'era' or similar, re-assign their listings to the correct 'era' instead of 'year', then delete the 'year' taxonomy and visit the Settings → Permalinks page to flush rewrite rules.

Editing a Listings taxonomy results in a duplicate taxonomy with no ID

To reproduce:

  1. Go to Listings > Register Taxonomies
  2. Add a new taxonomy with ID ‘bathrooms’, plural name ‘Bathrooms’, and singular name ‘Bathroom’
  3. Edit the taxonomy and change the plural name to ‘Bathroomz’

You’ll see that the edited taxonomy has a blank ID, and that the old unedited version is still present:

screen shot on 2015-01-01 at 14-47-09

The following two error messages are generated when the taxonomy is edited:

[28-Dec-2014 23:29:52 UTC] PHP Notice: Undefined variable: id in /vagrant/wp/wp-content/plugins/agentpress-listings/includes/class-taxonomies.php on line 200

[28-Dec-2014 23:29:52 UTC] PHP Notice: Undefined variable: id in /vagrant/wp/wp-content/plugins/agentpress-listings/includes/class-taxonomies.php on line 204

Attempting to delete the taxonomy results in a ‘nice try, partner’ message.

Modifying the edit_taxonomy() method in class_taxonomies.php to define $id before using it on line 197 appears to fix the issue (fix included in PR#15):

        $id = $args['id'];

        $args = array(
            'labels'       => $labels,
            'hierarchical' => true,
            'rewrite'      => array( 'slug' => $id ),
            'editable'     => 1
        );

        $tax = array( $id => $args );

Additionally, maybe it would be worth changing the message that people see upon attempting to delete a taxonomy with no ID, so that it sounds less accusatory/confusing? (We had a complaint about this.)

Perhaps instead of, “Nice try, partner. But that taxonomy doesn't exist. Click back and try again.”, simply: “Sorry, but that taxonomy could not be deleted.”

Prepare to release 1.3.4

Have you done the following in preparation for release?

  • Bump version in all relevant and necessary locations.
  • Create and execute db upgrade, if necessary.
  • Build the styles/scripts if necessary (npm run build).
  • Generate POT (grunt makepot).
  • Verify CHANGELOG(s) has been updated.

[property_details] shortcode output

Chris Cree shared code to hide empty fields in the [property_details] shortcode for single listing page. So, for example, if Basement isn't filled in, it isn't output in the shortcode.

    function property_details_shortcode( $atts ) {

        global $post;

        $output = '';

        $output .= '<div class="property-details">';

        $output .= '<div class="property-details-col1">';
            foreach ( (array) $this->property_details['col1'] as $label => $key ) {
                $value = get_post_meta($post->ID, $key, true);
                if ( !empty( $value ) ) {
                    $output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) );
                }   
            }
        $output .= '</div><div class="property-details-col2">';
            foreach ( (array) $this->property_details['col2'] as $label => $key ) {
                $value = get_post_meta($post->ID, $key, true);
                if ( !empty( $value ) ) {
                    $output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) );
                }   
            }
        $output .= '</div><div class="clear">';
            $output .= sprintf( '<p><b>%s</b><br /> %s</p></div>', __( 'Additional Features:', 'apl' ), get_the_term_list( $post->ID, 'features', '', ', ', '' ) );

        $output .= '</div>';

        return $output;

    }

Ref: http://wordpress.org/support/topic/shortcode-mod-to-hide-empty-fields

Initially tested to be working.

Show parent categories only in Listing Search widget

Customer request:

“Is there a way that the AgentPress Listing search widget can be searchable by Parent taxonomies, and if that parent is chosen then a sub-child taxonomy will be shown as additional multiple choice options?

Currently, all parent/child taxonomies are showing up and I would only like the child taxonomies to show if that particular parent is chosen.”

Shortcode to display listings in a page or post

A customer requests:

It would be great if there was a way to show the listings on a page or post (maybe there is but I can't figure out how as there seems to be zero documentation).

This could be done with a shortcode that shows a grid or single column list of the listings down the page. Thanks.

Have suggested using this plugin for now: https://wordpress.org/plugins/display-posts-shortcode/

[display-posts post_type="listing" id="123" include_excerpt image_size="medium" wrapper="div"]

Perhaps it would be worth having a shortcode that pulled in more metadata about a specific listing and presented it in a prettier way, though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.