Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Version 5.4 broke my ajax submit. In my case I had additional actions binded (jquery) to a custom submit button. These actions, $(…).submit() and $(…).attr(‘disabled’,’disabled’), prevented somehow the ajax submit functionality.

    I managed to fix the reloading error by using the default form button [submit “Submit”]. To change the state of the submit to ‘disabled’ (prevent multiple submits) I had to use a setTimeout to execute the action after the ajax submit.

    jQuery('form.wpcf7-form input[type="submit"]').each( function( i, val )
        {
                jQuery(this).on("click", function(e) {
    
                    var form_id = jQuery(this).closest('.wpcf7').prop('id') ;
    
                    setTimeout(function( )
                    {
                        $( "#" + form_id + " form.wpcf7-form .nen-wpcf7-submit" ).attr('disabled','disabled');
    
                    } , 10 , form_id );
                });
        });
    • This reply was modified 3 years, 1 month ago by nenontwerp.
    • This reply was modified 3 years, 1 month ago by nenontwerp.
    Thread Starter nenontwerp

    (@nenontwerp)

    Gutenberg block admin add:

    function test()
    {
        //
    }

    Database:

    <!-- wp:syntaxhighlighter/code {"language":"php","lineNumbers":true} -->
    <pre class="wp-block-syntaxhighlighter-code">function test()
    {
        //
    }</pre>
    <!-- /wp:syntaxhighlighter/code -->

    Html front:

    <div class="entry-content">
    <p>Any blocks before</p>
    <div><div id="highlighter_933185" class="syntaxhighlighter alignwide php"><div class="toolbar"><span><a href="#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody></tbody></table></div></div>
    <p></p>
    <p>Any blocks after</p>
    </div>

    ALso check out syntaxhighlighter-html of any page by contributor Alex Mills:
    https://alex.blog/wordpress-plugins/syntaxhighlighter/adding-a-new-brush-language/

    PLL_Admin_Strings::get_strings()

    This gives you an array with all registered strings. Try to combine with my previous reply. Array like:

      ["95ea783052defb7fba095a4d78bf16a4"]=>
      array(4) {
        ["name"]=>
        string(12) "Date notation"
        ["string"]=>
        string(5) "j n Y"
        ["context"]=>
        string(9) "WordPress"
        ["multiline"]=>
        bool(false)
      }

    Try this to get clean strings in the error_log. This is without the context. Working on that …

    add_action( 'init' , 'get_polylang_strings' );
       function get_polylang_strings()
       {
            $collector = false;
            
            $option         = get_option('polylang');
            $default        = $option['default_lang']; // or replace by other language-slug
            
            $term           = get_term_by( 'slug' , $default , 'language' ); 
            $posts          = get_posts(array( 'name' => 'polylang_mo_'.$term->term_id , 'post_type' => 'polylang_mo' , 'post_status' => 'private' , 'posts_per_page' =>1 ));
            $post_id        = $posts[0]->ID;
            $translations   = get_post_meta( $post_id , '_pll_strings_translations' , true );
    
            if( $translations )
            {
                    foreach($translations as $translation)
                    {
                        $string_identifier = $translation[0];
                        $string_displayed  = $translation[1];
    
                        $collector .= $string_displayed."\n";
                    }
            }
            else
            {
                    $collector = 'empty (?)';
            }
            error_log($collector);
       }
    Thread Starter nenontwerp

    (@nenontwerp)

    This plugin is not working if you have multiple mailpoetsignup-checkboxes on one submit. I want my users to check the lists they like and not subscibe to multiple list with one checkbox.

    Martin

    Thread Starter nenontwerp

    (@nenontwerp)

    Okay, I think I have to check for something else. It is signing up when I change you code but not adding me to any list. So the ‘0’ should be 1 to be added. I’m go to check my form. Thanks Martin

    Hi bcworkz, guido,

    The numeric key you want to get refers to the id of the widget. To get the id of the widget use the class you’r working with for your widget. It extends ‘WP_Widget’ which has some variables. To get a variable from the class start with $this-> and then the name of the variable. To get the id of the widget: $this->id.
    I’m building a widget to display a cf7-form (contact form 7). Because a widget can be placed twice in 1 sidebar I need a dynamic array key (=widget-id) to get the right data for my widget/form. In my case: the widget name is ‘nen_cf7’, and the generated id’s for my widgets are ‘nen_cf7-2’ and ‘nen_cf7-3’. To get the right key:

    
    $widget_id_full     = $this->id;  // widget name extended with the id
    $widget_id_arr      = explode('-', $widget_id_full); // split in array bits
    $widget_id          = $widget_id_arr[ count($widget_id_arr)-1 ]; // get the last one to get the key
    
    $widget_data        = get_option( 'widget_nen_cf7' ); // get all widget data
    $form_id            = $widget_data[ $widget_id ]['form_id'] ; // get my admin content
    

    To assign different titles to each widget I’m using do_action() with a dynamic action hook.

    
    do_action('before_widget_'.$widget_id_full);
    do_action('after_widget_'.$widget_id_full);
    

    In your functions.php

    
    add_action('before_widget_nen_cf7-2','paste_my_header_one');
    function paste_my_header_one(){
        echo '<h2>Header widget one</h2>';
    }
    add_action('before_widget_nen_cf7-3','paste_my_header_two');
    function paste_my_header_two(){
        echo '<h2>Header widget two</h2>';
    }
    

    oh it did not show:
    There are also a few &nbsp characters programmed

    If you want to see what html is generated try ‘right-click > inspect element’ in your browser (like chrome)

    If you’re not familiar with css try this:

    Current code:

    <p>Newsletter - Dapatkan post, info & analisis kewangan terkini!
    [mailpoetsignup mailpoetsignup-215 mailpoet_list_4 label-inside-span "Saya mahu!"] </p>

    Replace by

    <style>
    div.wpcf7 .saya-mahu-box{
        position: relative;
    }
    div.wpcf7 .saya-mahu-box label{
        margin-left:25px;
        display:block;
    }
    div.wpcf7 .saya-mahu-box span[class*="mailpoetsignup"]{
        position:absolute;
        left:0px;
        top:0px;
    }
    </style>
    <p>Newsletter - Dapatkan post, info & analisis kewangan terkini! </p>
    <div class="saya-mahu-box">
    [mailpoetsignup mailpoetsignup-215 mailpoet_list_4 "Saya mahu!"]
    </div>

    Do not use ‘ label-inside-span’, otherwise it wil not work. The span and label element are generated bij the plugin. There are also a few   characters programmed (none breaking space) . This wil cause an extra line (blank) underneath the checkbox.

    Hopefully it woks for you.

    Martin

    OK cheers!

    Thread Starter nenontwerp

    (@nenontwerp)

    The problem was fixed. The labels stay untouched, even with my coding error.

    Martin

    Check this url:
    http://contactform7.com/custom-layout-for-checkboxes-and-radio-buttons/

    I prefer a vertical alignment when using multiple checkboxes. That way you can have multiple lines of label text perfectly aligning on the right side of the checkbox. When you use inline or inline-block, its possible that they will align to the left (underneath) of the checkbox.

    So the stylesheet should be:

    span.wpcf7-list-item { display: table-row; }
    span.wpcf7-list-item * { display: table-cell; }

    But … this plugin (Mailpoet – Contact Form 7 Integration) does not have the same element structure (??) as cf7. So you have to do some custumizing yourself in your cf7-dashboard. I solved it like this: place your Mailpoet-Signup-form-tag inside a div and give it a class name (like ‘parentdiv’) and do not check the ‘label inside span’ in your Mailpoet-Signup-generator on your cf7-dashboard.

    I added this to my stylesheet:

    div.wpcf7 .parentdiv{
        position: relative;
    }
    div.wpcf7 .parentdiv label{
        margin-left:25px;
        display:block;
    }
    div.wpcf7 .parentdiv span[class*="mailpoetsignup"]{
        position:absolute;
        left:0px;
        top:0px;
    }

    Question for Jesse:
    Why haven’t you programmed your plugin in the same element structure as cf7. So with the class ‘wpcf7-form-control’ as a parent span-element (not added to the checkbox) and ‘wpcf7-list-item’ as a child and ‘wpcf7-list-item-label’ as a span element (not as label element).

    Thanx again Jesse, Martin πŸ™‚

    Thread Starter nenontwerp

    (@nenontwerp)

    Hi Jesse,

    Thanx for your quick fix in your code. But today I found out that your bug became visible because of a bug in my code (jQuery). Normally the cf7-form would check by ajax-post. But because of my bug, there was a post/refresh of the page itself. That’s why you bug came to light πŸ™‚

    thanx Martin

Viewing 13 replies - 1 through 13 (of 13 total)