• Resolved novels76

    (@novels76)


    Hello! I’m looking to add a third phone number to my Speed Contact Bar installation. All three numbers are land lines and I’ve been able to add two numbers, but not a third, despite attempting to use the plugin’s hooks. Any help and advice would be greatly appreciated! Thanks in advance! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Martin Stehle

    (@hinjiriyo)

    You can do that with a self-written PHP function. Please read the section “ADD AN ITEM TO THE PERSONAL CONTACT INFORMATION LIST” on the plugin’s homepage.

    Thread Starter novels76

    (@novels76)

    Thanks for your reply Martin! I’ve tried to do what you’ve recommended previously. However, when I add the code to either my functions.php file, or to the plugin directly, I receive the following error:

    Parse error: syntax error, unexpected ‘for’ (T_FOR) in /home4/abcdef76/public_html/website.com/wp-content/plugins/scb-change-cellphone-icon.php on line 26.

    Plugin Author Martin Stehle

    (@hinjiriyo)

    Without looking at the code I can not help. Please take a look at the reported line 26 of the script.

    Thread Starter novels76

    (@novels76)

    I’m sorry, Martin. Line 26 is as follows:
    speed_contact_bar_data for altering the personal contact informations list”

    Here’s the entire 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: http://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;
    }
    speed_contact_bar_data for altering the personal contact informations list
    speed_contact_bar_icons for altering the social media icons list
    speed_contact_bar_style for altering the style of the contact bar
    // Let the function work
    add_filter( ‘speed_contact_bar_data’, ‘scb_change_cellphone_icon’ );
    // Passed parameter: an array of personal contact data as list items
    function change_speed_contact_bar_data ( $list_items ) {

    // Adds an item as first item in the list via array_unshift()
    // The content has to be surrounded by the LI element
    array_unshift( $list_items, ‘

    • Hello World
    • ‘ );

      // Re-orders the list items and returns the new list
      // Here: ( a, b, c, d ) => ( c, d, a, b )
      return array(
      $list_items[ 2 ],
      $list_items[ 3 ],
      $list_items[ 0 ],
      $list_items[ 1 ],
      );

      }

      // Let the function work
      add_filter( ‘speed_contact_bar_data’, ‘change_speed_contact_bar_data’ );

      Again, I truly appreciate your help! I will be leaving a five star review, plus a donation to buy you a coffee/beer!

    Plugin Author Martin Stehle

    (@hinjiriyo)

    Sorry for my late answer. Please replace the entire code of the plugin “Speed Contact Bar: Cellphone to Phone” in the PHP file with that 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: http://stehle-internet.de/
    */
    
    /*
     * Changes phone data
     */
    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;
    	}
    	// Adds third phone number
    	$phonenumber = '123456789';
    	array_splice( $list_items, $i + 1, 0, array( '<li id="scb_third_phone"><a href="tel:'.$phonenumber.'"><img src="'.plugins_url().'/speed-contact-bar/public/assets/images/phone_bright.svg" width="48" height="48" alt="Phone number"><span>'.$phonenumber.'</span></a></li>' ) );
    	// Returns the list
    	return $list_items;
    }
    // Let the function work
    add_filter( 'speed_contact_bar_data', 'scb_change_cellphone_icon' );
    
    /*
     * Makes 3rd phone number invisible in small displays
     */
    function scb_change_style ( $css_code ) {
    	// add style for 3rd phone number
    	$css_code .= "<style type='text/css'>\n";
    	$css_code .= '@media screen and (max-width:768px) {#scb-wrapper #scb_third_phone span {display:none;}}';
    	$css_code .= "\n";
    	$css_code .= "</style>\n";
    	// Returns changed CSS
    	return $css_code;
    }
    // Let the function work
    add_filter( 'speed_contact_bar_style', 'scb_change_style' );

    … and change the phone number 123456789 in line 27 $phonenumber = '123456789'; to your desired number.

    If you would want the dark phone icon instead of the bright icon please change in line 28 the name phone_bright to phone_dark.

    I would be glad about your review and coffee money.

    Thread Starter novels76

    (@novels76)

    Wow! Thank you SO much, Martin! I’ve left you a 5-star review for your plugin and have send you some coffee money as well for your efforts. Much appreciated!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding a Third Phone Number (Non Mobile)’ is closed to new replies.