$value ) { $new_array[ $key ] = $value; if ( $key === $needle ) { $new_array[ $new_key ] = $new_value; } } return $new_array; } /** * Helper to create links to edit.php with params. * * @since 4.4.0 * * @param string[] $args Associative array of URL parameters for the link. * @param string $link_text Link text. * @param string $css_class Optional. Class attribute. Default empty string. * @return string The formatted link string. * * located in wordpress/wp-admin/includes/class-wp-posts-list-talbe.php */ function get_edit_link( $args, $link_text, $css_class = '' ) { $url = add_query_arg( $args, 'edit.php' ); $class_html = ''; $aria_current = ''; if ( ! empty( $css_class ) ) { $class_html = sprintf( ' class="%s"', esc_attr( $css_class ) ); if ( 'current' === $css_class ) { $aria_current = ' aria-current="page"'; } } return sprintf( '%s', esc_url( $url ), $class_html, $aria_current, $link_text ); } /** * The origin of Tiktok Seller Center in different countries are different * We need to set the origin according to the country */ function get_tts_seller_center_origin() { $country_origin_map = array( 'GB' => 'uk', 'US' => 'us', 'ID' => 'id', 'TH' => 'th', 'MY' => 'my', 'VN' => 'vn', 'PH' => 'ph', ); $country = WC()->countries->get_base_country(); return "https://seller-{$country_origin_map[$country]}.tiktok.com"; }