• Resolved quintessence13

    (@quintessence13)


    Hello everybody !
    Beginner, I am in the process of making my first site using WordPress.
    Regarding the comments, I found my happiness in the plugin ‘Simple Comment Editing for WordPress’.
    The plugin displays, by default, a timer in the form: ’00 minutes and 00 seconds’.
    But, obviously, its designer offers the opportunity to be able to convert this result in the form: ’00: 00 ‘… Which would suit me better. (‘sce.comment.timer.text – Before a timer is outputted in JavaScript.’)
    After looking at the documentation, I noticed that the plugin needs WP-JS-Hooks. Although the link offered on the ‘Simple Comment Editing for WordPress’ site is broken, it seems to me that I found the right script (WP-JS-Hooks)
    I tried to implement the installation by adding these lines in my ‘function.php’ file, but, alas, without success …

    <?php 
    	if ( !function_exists( 'action_initilisation_de_scripts' ) ):
    		function action_initilisation_de_scripts() { wp_enqueue_script( 'wp-js-hooks', get_stylesheet_directory_uri() . '/scripts/wp-js-hooks-master/dist/event-manager.min.js', array( 'jquery') );            
    		}
    	endif;
    	add_action( 'wp_enqueue_scripts', 'action_initilisation_de_scripts' );
    ?>
    <?php
    add_action( 'wp_footer', function() {
        ?>
        <script type="text/javascript">
            jQuery( document ).ready( function( $ ) {
                /* Will give you format of minutes:seconds (e.g., 2:58) */
                if (typeof wp.hooks != 'undefined') {
                    wp.hooks.addFilter( 'sce.comment.timer.text', function( timer_text, minutes_text, seconds_text, minutes, seconds ) {
                        timer_text = '&nbsp;&nbsp;&nbsp;&nbsp;' + minutes;
                        timer_text += ":";
                        if (seconds >= 0) {
                		if( seconds < 10 ) { timer_text += '' + '0' + seconds; }
    			else { timer_text += seconds; }
                        }
                        return timer_text;
                    } );
                }    
            } );
        </script>
        <?php
    } );
    ?>

    Could someone please help me implement this change ?
    Thank you in advance … as well as to Google translate…

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[NSFW] A story of hooks’ is closed to new replies.