• Resolved themechills

    (@themechills)


    Hi Marcel,

    Firstly thank you for your great contribution. I just had a quick question…

    I understand I can customize the form through the CSS etc, however, what if I wanted to change the value of the input type.

    e.g. currently the form comes with the following default:

    <input type="button" value="? Write a new entry.">

    Can I change the value property through the admin or do I need to target this with JS?

    Would appreciate your feedback on this, thanks again.

    Leo

    https://www.ads-software.com/plugins/gwolle-gb/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter themechills

    (@themechills)

    Further to the above, is there a way to add a custom class?

    Plugin Author Marcel Pol

    (@mpol)

    Hi, I would think JavaScript is the most appropriate way. A oneliner with jQuery should be enough.

    Not sure why you want to add a class. You can already target “div#gwolle_gb_write_button input”. Why would you want that?

    Thread Starter themechills

    (@themechills)

    Thanks Marcel.

    The reason I wanted the ability to add a custom class is so I am not trying to override the specificity of the selector.

    I already have a class labeled .button, which I wanted to use on the input element. I know I can do this obviously through JS once again, but wanted to know if it was possible without it.

    Not a problem though, thanks for the clarification.

    Leo

    Plugin Author Marcel Pol

    (@mpol)

    You can always use a filter, like the next part shows. It’s not tested, but should work. It will replace the $old with the $new.
    You can place it in functions.php of your theme, or in your own plugin.
    Make sure you get the raquo symbol right, it gets mangled here apparently.

    <?php
    function your_custom_function($form) {
        // $form is a string
        $old = 'value="? Write a new entry."';
        $new = 'value="Anything you fancy."';
        $form = str_replace( $old, $new, $form );
        return $form;
    }
    add_filter( 'gwolle_gb_write', 'your_custom_function');
    ?>

    Or alternatively:

    <?php
    function your_custom_function($form) {
        // $form is a string
        $old = 'value="? Write a new entry."';
        $new = 'value="Anything you fancy." class="my_custom_class"';
        $form = str_replace( $old, $new, $form );
        return $form;
    }
    add_filter( 'gwolle_gb_write', 'your_custom_function');
    ?>

    Thread Starter themechills

    (@themechills)

    I like that approach, thanks Marcel!

    Thread Starter themechills

    (@themechills)

    Hi Marcel,

    I tried implementing your script above but no changes took effect. I included this in the functions.php file.

    Any thoughts?

    Thanks,

    Leo

    Plugin Author Marcel Pol

    (@mpol)

    It works here.
    Make sure you get the string right, the raquo symbol needs to be a html entity, like & raquo; without the space.
    Best is, you view soucre in your browser, and cut and paste the string.

    Thread Starter themechills

    (@themechills)

    Just thought I would report back Marcel. Your last response worked like a charm, thanks again mate!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Customizing Input Value Attribute’ is closed to new replies.