Author: Keyboard

  • WordPress plugin : Vape DIY calculator

    I just released a free WordPress plugin to embed via a shortcode, an e-liquid DIY calculator based on Jquery and Bootstrap. You can see it in action just below :

    Enter your values
    Recipe Results
    Base10ml
    Boosters2ml
    Flavors1ml
    Your mix
    Base
    Nicotine
    Flavors
    10ml
    10
    3 mg/ml

    Feel free to download it and try it you if you’re interested.

  • Change WordPress heartbeat rate to lower server load

    WordPress heartbeat is made to save your articles automatically but it can slow down your server depending on your site size and all the plugins you got. If you’d like to stil use the feature but lower its saving rate, you can use the following code :

    add_action( 'init', 'customize_heartbeat', 1 );
    
    function customize_heartbeat() {
    
    // Register the wordpress native script if necessary
    
    if (!wp_script_is('heartbeat', 'registered')) {
    
    wp_register_script('heartbeat', includes_url('js/heartbeat.min.js'), array('jquery'), null, true);
    
    }
    
    // Active with a custom interval
    
    add_filter('heartbeat_settings', 'set_heartbeat_interval');
    
    }
    
    function set_heartbeat_interval($settings) {
     // Define interval in seconds
     $settings['interval'] = 120; // Example for 2 minutes (60x2)
     return $settings;
     }
  • How to add a custom H1 title to a tag page

    By default wordpress writes an H1 with the tag term, which can be very limited in terms of SEO. For instance, you may have a tag page title “USA” instead of “News from the United States of America” if your tag is only “USA”. To improve that without any plugin, open your theme’s functions.php file and add the following lines :


    /*
    CUSTOM H1 TITLES FOR TAGS PAGES by Ghyslain 3 mai 2023
    */

    function add_custom_h1_title_field( $term ) {
    $term_id = $term->term_id;
    $custom_h1_title = '';
    if ( isset( $_POST['custom_h1_title'] ) ) {
    $custom_h1_title = sanitize_text_field( $_POST['custom_h1_title'] );
    } elseif ( $term_id ) {
    $custom_h1_title = get_term_meta( $term_id, 'custom_h1_title', true );
    }
    ?>
    <div class="form-field term-group">
    <label for="custom_h1_title"><?php _e( 'Custom H1 title', 'text-domain' ); ?></label>
    <input type="text" class="form-field" name="custom_h1_title" id="custom_h1_title" value="<?php echo esc_attr( $custom_h1_title ); ?>">
    </div>
    <?php
    }

    add_action( 'post_tag_edit_form_fields', 'add_custom_h1_title_field' );
    add_action( 'product_tag_add_form_fields', 'add_custom_h1_title_field' );

    function save_custom_h1_title_field( $term_id ) {
    if ( isset( $_POST['custom_h1_title'] ) ) {
    update_term_meta( $term_id, 'custom_h1_title', sanitize_text_field( $_POST['custom_h1_title'] ) );
    }
    }
    add_action( 'edited_post_tag', 'save_custom_h1_title_field' );
    add_action( 'created_post_tag', 'save_custom_h1_title_field' );

    You will get a new text field in your admin edit screen called “Custom H1 title”.
    Now in your theme’s tag.php file, replace the lines where the H1 was being called by :

    $custom_h1_title = get_term_meta(get_queried_object_id(), 'custom_h1_title', true);
    if ($custom_h1_title) {
    echo esc_html($custom_h1_title);
    } else {
    single_tag_title();
    }

  • How to speed up Disqus plugin

    Disqus is very popular (and expensive for the Pro version) but it can really slow down you site. There is a little trick very useful called Disqus DCL. This little script loads Disqus only when the page scrolls to the comment area. This way Disqus doesn’t load when unecessary. Visit Disqus Conditional Load by Joel James. For more details on installation intructions check out this post on Crunchify.

  • WordPress : How to disable updates for a specific plugin

    If you modified a plugin and don’t want it to appear in the updates list, use this function from rniswonger in your functions.php

    /**
     * Prevent update notification for plugin
     * http://www.thecreativedev.com/disable-updates-for-specific-plugin-in-wordpress/
     * Place in theme functions.php or at bottom of wp-config.php
     */
     function disable_plugin_updates( $value ) {
        $pluginsToDisable = [
            'plugin-folder/plugin.php',
            'plugin-folder2/plugin2.php'
        ];
        if ( isset($value) && is_object($value) ) {
            foreach ($pluginsToDisable as $plugin) {
                if ( isset( $value->response[$plugin] ) ) {
                    unset( $value->response[$plugin] );
                }
            }
        }
        return $value;
    }
    add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' );
  • Macbook Pro 2018 : WIFI problem when connecting USB-C devices

    Your internet connexion drops when you connect any external device to your Macbook Pro touchbar ? The solution is completely insane but really works. Thanks to Joshua King you just have to wrap your dongles with tinfoil to make it work. Unbelievable. This prevents interferences.

    https://www.youtube.com/watch?v=jObj6YnK44Q

  • How CM Tooltip glossary can slow down WordPress

    How CM Tooltip glossary can slow down WordPress

    If you’re using CM ToolTip glossary pro and noticed an abnormal decrease in page speed on your WordPress installation, that might be caused by an option set in CM ToolTip configuration. It came out my SQL database was full of transients, these entries created by some (usually bad coded) plugins to store data in order to increase SQL requests speed. It turned out the cache system used on CM Tooltip glossary did exactly the contrary in my case.

    After few hours looking for a solution to my problem I’ve finally disabled the cache option as shown below :

    Set the cache on off to avoid excessive transients creation in your SQL database

    The site where it happened has few thousands of articles already published, so I’m guessing CM ToolTip glossary was parsing all of them when a user requested the page in order to find items that match the glossary index. SQL overload went so far that several hundreds of thousands transients were created and literally crashed my server after a while.

    Clean transients manually and automatically

    A plugin that really helped me to analyse how WordPress was reacting to these CM Tooltip glossary settings is Transient Cleaner. I strongly advise any wordpress user to use that plugin as a routine to periodically clean his database. Your site speed will feel the difference.

    I also removed search engine plugin Ajax Search Pro,  it doesn’t work that well for me and made really bad sql requests.

  • Free vaping pictures

    Free vaping pictures

    Here are some pictures I give for free if you want to use them, even for commercial purposes.

    Full resolution images

     

  • Paypal bank account confirmation issue : two digits only

    Confirming your bank account with Paypal can be a little bit disappointing sometimes. My last bad experience was about the amounts sent on my account that are supposed to be used through the confirmation process.

    If Paypal sent you 0.06$ you have to enter 06 only. The text field used in their confirmation form is a two digits only and they don’t explain that. So don’t waste your time trying to enter 0.06, just use the last two digits (06 in this case) and you’re good to go.

  • Magpie RSS and special characters

    Your site is not in english and you are trying to import an RSS feed by using the excellent Magpie RSS ? If the feed language is in french for instance you’ll probably get weird characters coming up on your display page.

    The solution is pretty simple. Go in the folder where Magpie RSS is installed and look for rss_fetch.inc

    Around line 357 set the default output and input encoding to UTF-8 like this :

      if ( !defined('MAGPIE_OUTPUT_ENCODING') ) {
     define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
     }
     
     if ( !defined('MAGPIE_INPUT_ENCODING') ) {
     define('MAGPIE_INPUT_ENCODING', 'UTF-8');
     }
This blog is protected by dr Dave\'s Spam Karma 2: 32422 Spams eaten and counting...