Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 2,026 through 2,040 (of 3,958 total)
  • Author
    Posts
  • Anh TranAnh Tran
    Keymaster

    For my understanding, what this js is doing is counting the number of checked items with class=like, and displaying the counter, right?

    Yes, that's right.

    I was wondering, can I also include this in the page from where I launch the Frontend Submission? Because then I can control the location where I want the counter to be displayed.

    Yes, by putting it in a custom JS file will help you control everything easier.

    By the way, I created the .js file, stored it in the js folder of my theme, and included the call in the functions.php, but it doesn’t show a counter, and I don’t know if it counts…

    As it's in the js folder of your theme, you need to change the code in functions.php code to this:

    add_action( 'wp_enqueue_scripts', function() {
        wp_enqueue_script( 'custom-handle', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '', true );
    } );

    And please change the #selector in the snippet to the CSS selector of the element you want to show the total likes.

    Anh TranAnh Tran
    Keymaster

    Oh, I should have made it clear. It's the JavaScript code, so you should put it in your theme main script file. Or better, create a JS file (assume its name is custom.js) in your theme folder, and put this content inside:

    $( function() {
        // Snippet goes here.
        var total = 0;
        $( '.like input:checked' ).each( function() {
            total += $(this).val();
        } );
        // Output total somewhere
        $( '#selector' ).text( total );
    
        // More snippet goes here.
    } );

    And then in your functions.php file of the theme, add the following code:

    add_action( 'wp_enqueue_scripts', function() {
        wp_enqueue_script( 'custom-handle', get_template_directory_uri() . '/custom.js', array( 'jquery' ), '', true );
    } );

    This thing is quite technical, though.

    Anh TranAnh Tran
    Keymaster

    Hi Doug,

    Thanks a lot for your feedback.

    There are 2 issues here:

    • Auto-complete works for both address and street_address field (which doesn't start with "address"). I've fixed this bug in the latest version, please update.
    • The street_address is not auto-populated: I spent hours reading the Google docs, while it clearly states that the street_address is supported, but all the examples are showing street_number and route only. I think you can use custom binding to get the street address part, like this:
    array(
        'id'      => 'street_address',
        'type'    => 'text',
        'name'    => 'Street Address',
        'binding' => 'street_number + " " + route',
    ),
    in reply to: Limit check box selections #10407
    Anh TranAnh Tran
    Keymaster

    I'm afraid it's not available for select field type. But you can do that with select_advanced. See this option on select2 docs.

    Anh TranAnh Tran
    Keymaster

    I've tried to test with 2 addresses and the auto complete works for both. This is the screenshot:

    https://imgur.elightup.com/NPZX1Am.png

    "Find Address" also works for me. Maybe I'm using the latest code of the Meta Box plugin on Github. Have you tried it?

    in reply to: No Relationship posts displaying #10405
    Anh TranAnh Tran
    Keymaster

    Let me update the extension to remove the post_type rule. People still can set the post types anyway.

    Update 1: Done! Version 1.3.1 is available.

    Update 2: I was too rush. The 'post_type' seems to be related to many things. I have to revert it to the previous version.

    in reply to: No Relationship posts displaying #10399
    Anh TranAnh Tran
    Keymaster

    Hi Doug,

    It's unexpected behaviour, but it has a reason. To make the query can get posts from any side of the connection, the plugin sets the post_type to any in the query. And WP_Query checks for exclude_from_search in this case. See this:

    https://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters

    'any' - retrieves any type except revisions and types with 'exclude_from_search' set to true.

    I don't know why WordPress sets that :(. It seems kind of weird to me.

    Anh TranAnh Tran
    Keymaster

    Hi,

    Are "Tampa" and "St Pete" terms of the "office location" taxonomy?

    If so, you have some ways to store the actual address of each location (each term):

    • Use the default WordPress term's description for actual address (https://imgur.elightup.com/GIU2Bbb.png). If you don't use the description for any purpose, it's good to use it for address, cause it doesn't require any coding.
    • Or you can use the MB Term Meta extension to add a text field "Address" for "office location" taxonomy. You can use the MB Builder to create that field for you if you're not familiar with coding. Just remember to go to Settings tab and select "Terms" & "Taxonomy" for the setting "Show meta box" for.

    After that, you'll be able to enter address for each location ("term") when you edit them.

    To show the office address, you can use this snippet:

    $locations = wp_get_object_terms( get_the_ID(),  'office_location_taxonomy' );
    if ( ! empty( $locations ) && ! is_wp_error( $locations ) ) {
        $location = reset( $locations );
        echo 'Address: ', $location->description; // If you use term description.
        echo 'Address: ', rwmb_meta( 'address_field_id', array( 'object_type' => 'term' ), $location->term_id ); // If you use MB Term Meta
    }
    in reply to: No Relationship posts displaying #10395
    Anh TranAnh Tran
    Keymaster

    Hi Doug,

    I've tested your code and found the bug: In the query for single.php, it should be 'from' => get_the_ID(). Your connection is from event to speakers, so if you're on event page, the connection direction should be "from" this event.

    in reply to: Can't get Geolocation autocomplete to work, nor maps #10394
    Anh TranAnh Tran
    Keymaster

    Hi Doug,

    I've worked with the map field and Geolocation in the last couple of days and made some improvements. I've just released a new version of Geolocation extension with a better compatibility with the map field. Previously both Geolocation and map field try to enqueue their own Google Maps scripts, which causes some kind of conflict. This conflict was fine until recently, it prevents some autocomplete for the address field.

    Can you please update it or the Meta Box AIO and let me know how it goes?

    Regarding the "Find Address" button, I also added some small improvements if the map is inside a group. The change is not in the new version of Meta Box yet. It's on Github and you can download it here:

    https://github.com/wpmetabox/meta-box/

    I'm making some other improvements and will release new version of Meta Box when they're done.

    in reply to: clolor picker field problem with front end forms #10386
    Anh TranAnh Tran
    Keymaster

    Hi,

    I've just tested and see no JS errors in the console. Would you mind sharing the code of the meta box you created?

    Anh TranAnh Tran
    Keymaster

    Hi,

    To make things easier, I'd suggest adding a common CSS class (like) for all the radios. You can do that with the class attribute of the field.

    Then, you can perform some JS code like this:

    1. Get total value:
    var total = 0;
    $( '.like input:checked' ).each( function() {
        total += $(this).val();
    } );
    // Output total somewhere
    $( '#selector' ).text( total );

    Anyway, as all the radio have values 1 or 0, the total value is equal to the number of "likes", which can be done with the following code.

    1. Get number of likes:
    var total = $( '.like input:checked' ).length;
    // Show an error message
    if ( total > 30 ) {
        alert( 'You have selected more than 30 likes. Please select again' );
        // or
        $( '.error-message' ).text( 'You have selected more than 30 likes. Please select again' );
    }
    in reply to: Covering indexes #10384
    Anh TranAnh Tran
    Keymaster

    Hi David,

    When you create a table, you can set which column(s) are indexed. Just put the columns you want to index in the last param of MB_Custom_Table_API::create function.

    For example, this code will index the column email:

    MB_Custom_Table_API::create( 'my_custom_table', array(
        'address' => 'TEXT NOT NULL',
        'phone'   => 'TEXT NOT NULL',
        'email'   => 'VARCHAR(20) NOT NULL',
    ), array( 'email' ) );

    See the docs for more info.

    If you want to do that manually with raw SQL, you can do that via a tool like phpMyAdmin.

    Anh TranAnh Tran
    Keymaster

    You can:

    • Get the author of the submitted post (via post_id)
    • Get the current user ID

    And just compare them. When they match, output the shortcode. Otherwise, output some error message.

    in reply to: No wpautop - pulling meta from blog page #10359
    Anh TranAnh Tran
    Keymaster

    Hi,

    This line is correct:

    echo wpautop( $rwmb_meta( 'blog_intro', '' $blog_id ) );

    However, both wpautop and non-wpautop versions have nothing to do with div tags. They only wrap paragraphs into p tags and ignores the br. The div must be entered in the field content. So I'd suggest you ask for the access to the field content and make the change manually, or ask who entered that check the markup in the "Text" mode.

Viewing 15 posts - 2,026 through 2,040 (of 3,958 total)