function wpseo_unicode_to_utf8( $string_array ) { $utf8 = ''; foreach ( $string_array as $unicode ) { if ( $unicode < 128 ) { $utf8 .= chr( $unicode ); } else { if ( $unicode < 2048 ) { $utf8 .= chr( 192 + ( ( $unicode - ( $unicode % 64 ) ) / 64 ) ); $utf8 .= chr( 128 + ( $unicode % 64 ) ); } else { $utf8 .= chr( 224 + ( ( $unicode - ( $unicode % 4096 ) ) / 4096 ) ); $utf8 .= chr( 128 + ( ( ( $unicode % 4096 ) - ( $unicode % 64 ) ) / 64 ) ); $utf8 .= chr( 128 + ( $unicode % 64 ) ); } } } return $utf8; } /** * Run the upgrade procedures. * * @param array $options Options from database to check with. */ function wpseo_local_do_upgrade( $options ) { if ( ! is_array( $options ) ) { return; } $db_version = WPSEO_Local_Core::get_db_version( $options ); if ( version_compare( $db_version, '1.3.1', '<' ) ) { $options_to_convert = [ 'use_multiple_locations', 'opening_hours_24h', 'multiple_opening_hours', ]; // Convert checkbox values from "1" to "on". foreach ( $options as $key => $value ) { if ( ! in_array( $key, $options_to_convert, true ) ) { continue; } if ( $value == '1' ) { WPSEO_Options::set( $key, 'on' ); } } } if ( version_compare( $db_version, '3.4', '<=' ) ) { // Update businesstypes from Attorneys to LegalServices if upgrading from version 3.4 or below. yoast_wpseo_local_update_business_type(); } if ( version_compare( $db_version, '11.0', '<' ) ) { if ( class_exists( 'Yoast_Notification_Center' ) ) { $notification_center = Yoast_Notification_Center::get(); $notification = $notification_center->get_notification_by_id( 'PersonOrCompanySettingError' ); if ( $notification instanceof Yoast_Notification ) { $notification_center->remove_notification( $notification ); } } } if ( version_compare( $db_version, '11.9', '<' ) ) { if ( class_exists( 'Yoast_Notification_Center' ) ) { $notification_center = Yoast_Notification_Center::get(); $notification = $notification_center->get_notification_by_id( 'LocalSEOServerKey' ); if ( $notification instanceof Yoast_Notification ) { $notification_center->remove_notification( $notification ); } } } if ( version_compare( $db_version, '12.1.1', '<' ) ) { // In some situations a wrong value was stored into the database, which is being cleaned here. if ( isset( $options['location_timezone'] ) && is_wp_error( $options['location_timezone'] ) === true ) { WPSEO_Options::set( 'location_timezone', '' ); } } if ( version_compare( $db_version, '12.8', '<' ) ) { if ( class_exists( 'woocommerce' ) ) { $local_pickup_settings = get_option( 'woocommerce_yoast_wcseo_local_pickup_settings' ); if ( isset( $local_pickup_settings['enabled'] ) ) { $value = $local_pickup_settings['enabled']; if ( $local_pickup_settings['enabled'] === 'yes' ) { $value = 0; foreach ( $local_pickup_settings['location_specific'] as $location ) { if ( $location['allowed'] === 'yes' ) { $value++; } } } WPSEO_Options::set( 'woocommerce_local_pickup_setting', $value ); } } } /** * Several options are being prefixed to prevent ambiguity. * * @since 12.3 */ if ( version_compare( $db_version, '12.3', '<' ) ) { $api_key_browser = WPSEO_Options::get( 'api_key_browser' ); $api_key_server = WPSEO_Options::get( 'api_key' ); $custom_marker = WPSEO_Options::get( 'custom_marker' ); $enhanced_search = WPSEO_Options::get( 'enhanced_search' ); if ( ! empty( $api_key_browser ) ) { WPSEO_Options::set( 'local_api_key_browser', $api_key_browser ); } if ( ! empty( $api_key_server ) ) { WPSEO_Options::set( 'local_api_key', $api_key_server ); } if ( ! empty( $custom_marker ) ) { WPSEO_Options::set( 'local_custom_marker', $custom_marker ); } if ( ! empty( $enhanced_search ) ) { WPSEO_Options::set( 'local_enhanced_search', $enhanced_search ); } } } /** * Retrieves excerpt from specific post. * * @param int $post_id The post ID of which the excerpt should be retrieved. * * @return string */ function wpseo_local_get_excerpt( $post_id ) { global $post; $original_post = $post; $post = get_post( $post_id ); setup_postdata( $post ); $output = get_the_excerpt(); // Set back original $post;. $post = $original_post; wp_reset_postdata(); return $output; } /** * Create an upload field for an image */ function wpseo_local_upload_image() { $output = ''; $output = '
' . __( 'If you want the map to display a custom marker pin for your locations, please upload it here.', 'yoast-local-seo' ) . '
'; $output .= ''; $output .= '