inboundnow / retired-cta

Create Calls to Action for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own CTA templates and more
http://www.inboundnow.com/cta/
1 stars 3 forks source link

Adding a charachter count in the text editor for the 'Tweet to Download' template #81

Closed daprela closed 9 years ago

daprela commented 9 years ago

I was thinking that it would be a good idea to add a charachters count in the text editor. Since the lenght of the message is limited to 120 characters, without a counter it's a bit hard to guess if you are out of the limit. I've analyzed the plugin code but it seems that this addition is not so simple, and it involves many modifications. Maybe I'm overcomplicating the issue, any idea?

atwellpub commented 9 years ago

@daprela You can treat the config.php kind of like a functions.php in the sense that you can add hooks and hook JS listeners to the admin page using code something like this:

add_action( 'admin_print_footer_scripts','cta_tweettodownload_print_admin_scripts' );

function cta_tweettodownload_print_admin_scripts() {
    $screen = get_current_screen();

        if ( !isset( $screen ) || $screen->id != 'wp-call-to-action' || $screen->parent_base != 'edit' ) {
            return;
        }

        ?>
        <script>
        jQuery(document).ready(function() {

        });
        </script>

        <?php

}

Then you could code this improvement in with pure JS listeners. If you wanted to do it I would not be opposed. It would exist as a good example to others on how they might make unusual admin settings changes.