• Resolved djbaxter

    (@djbaxter)


    My client is two partners and I want to have phone numbers for both.

    Right now, it shows the phone icon for one and the cell icon for the other. I want both to use the phone icon.

    What do I edit to do this? Or can I add some custom CSS to do it?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter djbaxter

    (@djbaxter)

    I was able to do this for now as follows:

    In file speed-contact-bar/public/class-speed-contact-bar.php:

    Change reference from “cellphone_%s.svg” below to “phone_%s.svg”

    				if ( isset( $this->stored_settings[ 'cellphone_text' ] ) and '' != $this->stored_settings[ 'cellphone_text' ] ) {
    					$link_text = $this->stored_settings[ 'cellphone_text' ];
    				} else {
    					$link_text = esc_html( $this->stored_settings[ 'cellphone' ] );
    				}
    				$link_href = $this->esc_phonenumber( $this->stored_settings[ 'cellphone' ] );
    				$contact_list[] = sprintf(
    					'<li id="scb-cellphone"><a href="tel:%s"><img src="%sassets/images/cellphone_%s.svg" width="%d" height="%d" alt="%s" /><span>%s</span></a></li>',
    Thread Starter djbaxter

    (@djbaxter)

    But of course when the plugin is next updated that will be overwritten so it’s only a temporary workaround.

    Plugin Author Martin Stehle

    (@hinjiriyo)

    You are right, that is a temporary workaround. There is a safer way: You can use the hook ‘speed_contact_bar_data’ for altering the personal contact informations list. You can find a short documentation on the plugin’s page under “Hooks”.

    Thread Starter djbaxter

    (@djbaxter)

    So if I make the change that way, it will override the settings in speed-contact-bar/public/class-speed-contact-bar.php next time the plugin updates?

    Thread Starter djbaxter

    (@djbaxter)

    Sorry, I’m not clear on where to make the change.

    I assume if I want the changes to stick through updates, I need to (1) create a NEW plugin – I don’t know how to do that; or (2) edit the functions.php file for my theme.

    I don’t know how to do option 1 and if I use option 2, won’t any updates to my theme override my changes?

    Plugin Author Martin Stehle

    (@hinjiriyo)

    If your theme is a child theme no update will override the functions.php of the child theme, only of the parent theme.

    If you use the theme not as a child theme the next updates will override the functions.php and your changes will be deleted. So here a plugin is the safest way.

    To create this plugin please create a file with the name ‘scb-change-cellphone-icon.php’ with this code:

    <?php
    /**
     * Plugin Name: Speed Contact Bar: Cellphone to Phone
     * Description: Changes the icon for the cellphone number into the icon for the phone number
     * Version:     1.0
     * Author:      Martin Stehle
     * Author URI:  https://stehle-internet.de/
     */
    
    function scb_change_cellphone_icon ( $list_items ) {
    	// Looks for the filename of the cellphone icon in each items
    	for ( $i = 0; $i < count( $list_items ); $i++ ) {
    		if ( false === strpos( $list_items[ $i ], 'images/cellphone_' ) ) {
    			continue;
    		}
    		$list_items[ $i ] = preg_replace(
    			'/images\/cellphone_/',
    			'images/phone_',
    			$list_items[ $i ]
    		);
    		break;
    	}
    	// Returns the list
    	return $list_items;
    }
    
    // Let the function work
    add_filter( 'speed_contact_bar_data', 'scb_change_cellphone_icon' );

    Then

    1. upload the file to your server in the folder ‘/wp-content/plugins/’
    2. go to the backend of your site
    3. go to the Plugins page
    4. look for the plugin ‘Speed Contact Bar: Cellphone to Phone’
    5. and activate it.

    That’s all.

    • This reply was modified 7 years, 6 months ago by Martin Stehle.
    Thread Starter djbaxter

    (@djbaxter)

    Wow. Thank you.

    That’s more than I was expecting. Much appreciated. ??

    Plugin Author Martin Stehle

    (@hinjiriyo)

    I would glad about a review by you. ??

    Plugin Author Martin Stehle

    (@hinjiriyo)

    Oh, you wrote that! Thank you!

    Thread Starter djbaxter

    (@djbaxter)

    Thank you! ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Change cell phone icon to phone icon’ is closed to new replies.