{"id":29651273,"url":"https://github.com/arraypress/wp-url-utils","last_synced_at":"2026-01-20T16:36:18.445Z","repository":{"id":305775935,"uuid":"1020767875","full_name":"arraypress/wp-url-utils","owner":"arraypress","description":"A lightweight WordPress library for comprehensive URL manipulation, validation, and connectivity checking with bulk operations support.","archived":false,"fork":false,"pushed_at":"2025-07-21T22:20:36.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-22T01:15:38.356Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arraypress.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-16T11:12:53.000Z","updated_at":"2025-07-21T22:20:40.000Z","dependencies_parsed_at":"2025-07-22T01:16:10.811Z","dependency_job_id":"aa1ca9a8-dcd1-400b-a8ab-bcdf29832336","html_url":"https://github.com/arraypress/wp-url-utils","commit_stats":null,"previous_names":["arraypress/wp-url-utils"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/arraypress/wp-url-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-url-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-url-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-url-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-url-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arraypress","download_url":"https://codeload.github.com/arraypress/wp-url-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-url-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266430669,"owners_count":23927169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-22T05:06:30.076Z","updated_at":"2025-10-31T14:06:00.384Z","avatar_url":"https://github.com/arraypress.png","language":"PHP","readme":"# WordPress URL Utilities\n\nComprehensive URL manipulation, validation, connectivity checking, platform detection, and tracking parameter removal for WordPress. Clean APIs for single URLs, bulk operations, HTTP status checking, and privacy-focused URL cleaning.\n\n## Installation\n\n```bash\ncomposer require arraypress/wp-url-utils\n```\n\n## Usage\n\n### Single URL Operations\n\n```php\nuse ArrayPress\\URLUtils\\URL;\n\n// Validation and checks\n$valid = URL::is_valid( 'https://example.com' );\n$external = URL::is_external( 'https://google.com' );\n$https = URL::is_https( 'https://example.com' );\n\n// URL parts\n$domain = URL::get_domain( 'https://example.com/path' ); // example.com\n$path = URL::get_path( 'https://example.com/path' ); // /path\n$extension = URL::get_extension( 'https://example.com/file.pdf' ); // pdf\n\n// Scheme manipulation (Enhanced!)\n$https_url = URL::to_https( 'example.com' );          // https://example.com\n$http_url = URL::to_http( 'example.com' );            // http://example.com\n$custom_scheme = URL::add_scheme( 'example.com', 'https' ); // https://example.com\n\n// URL manipulation\n$relative = URL::make_relative( 'https://mysite.com/page' ); // /page\n$with_params = URL::add_params( $url, [ 'utm_source' =\u003e 'email' ] );\n\n// File type detection\n$is_image = URL::is_image( 'photo.jpg' );\n$is_video = URL::is_video( 'movie.mp4', [ 'mp4', 'avi' ] ); // custom extensions\n\n// Platform detection (NEW!)\n$is_youtube = URL::is_video_platform( 'https://youtube.com/watch?v=abc123' );\n$is_spotify = URL::is_audio_platform( 'https://open.spotify.com/track/123' );\n$is_social = URL::is_social_platform( 'https://facebook.com/page' );\n\n// UTM tracking\n$tracked = URL::add_utm( $url, [\n    'source' =\u003e 'newsletter',\n    'campaign' =\u003e 'summer'\n]);\n\n$smart_utm = URL::add_utm_smart( $url, [ 'campaign' =\u003e 'promo' ] );\n// Auto-detects WordPress context (admin screen, template, etc.)\n\n// Sanitization\n$clean = URL::sanitize( $_POST['website'] );\n$html_safe = URL::sanitize_for_html( $user_url );\n\n// Current page\n$current = URL::current();\n$clean_current = URL::current_clean(); // without query params\n```\n\n### Advanced Platform Detection\n\n```php\n// Enhanced media type detection\nfunction get_media_type( $url ) {\n    if ( URL::is_video( $url ) || URL::is_video_platform( $url ) ) {\n        return 'video';  // Works for both .mp4 files AND YouTube/TikTok links\n    }\n    \n    if ( URL::is_audio( $url ) || URL::is_audio_platform( $url ) ) {\n        return 'audio';  // Works for both .mp3 files AND Spotify/podcast links\n    }\n    \n    if ( URL::is_image( $url ) ) {\n        return 'image';\n    }\n    \n    if ( URL::is_social_platform( $url ) ) {\n        return 'social';\n    }\n    \n    return 'other';\n}\n\n// Content categorization\nfunction categorize_urls( $urls ) {\n    $categorized = [\n        'video' =\u003e [],\n        'audio' =\u003e [],\n        'social' =\u003e [],\n        'other' =\u003e []\n    ];\n    \n    foreach ( $urls as $url ) {\n        if ( URL::is_video_platform( $url ) ) {\n            $categorized['video'][] = $url;\n        } elseif ( URL::is_audio_platform( $url ) ) {\n            $categorized['audio'][] = $url;\n        } elseif ( URL::is_social_platform( $url ) ) {\n            $categorized['social'][] = $url;\n        } else {\n            $categorized['other'][] = $url;\n        }\n    }\n    \n    return $categorized;\n}\n```\n\n### Bulk URL Operations\n\n```php\nuse ArrayPress\\URLUtils\\URLs;\n\n$url_list = [\n    'https://example.com',\n    'http://test.com',\n    'invalid-url',\n    'https://mysite.com/page'\n];\n\n// Filtering\n$valid_urls = URLs::filter_valid( $url_list );\n$external = URLs::filter_by_location( $url_list, 'external' );\n$https_only = URLs::filter_by_protocol( $url_list, 'https' );\n$images = URLs::filter_by_type( $url_list, 'image' );\n\n// Conversion\n$all_https = URLs::to_https( $url_list );\n$all_relative = URLs::make_relative( $url_list );\n\n// Analysis\n$domains = URLs::get_domains( $url_list );\n$found_urls = URLs::extract( $text_content );\n$unique = URLs::remove_duplicates( $url_list );\n\n// Sanitization\n$clean_urls = URLs::sanitize( $url_list );\n$html_safe_urls = URLs::sanitize_for_html( $url_list );\n```\n\n### URL Tracking Parameter Removal\n\n```php\nuse ArrayPress\\URLUtils\\Cleaner;\n\n// Remove all tracking parameters (300+ supported)\n$dirty_url = 'https://example.com/page?utm_source=facebook\u0026fbclid=abc123\u0026gclid=def456\u0026product_id=789';\n$clean_url = Cleaner::strip( $dirty_url );\n// Result: https://example.com/page?product_id=789\n\n// Bulk cleaning\n$urls = [\n    'https://shop.com/product?gclid=abc123\u0026category=shoes',\n    'https://blog.com/post?fbclid=def456\u0026author=john\u0026twclid=xyz'\n];\n$clean_urls = Cleaner::strip_multiple( $urls );\n\n// Complete sanitization pipeline (validate, clean, deduplicate)\n$messy_urls = [\n    'https://example.com?utm_source=test\u0026fbclid=123',\n    'invalid-url',\n    'https://example.com',  // duplicate after cleaning\n    'https://shop.com?gclid=456\u0026category=shoes'\n];\n$sanitized = Cleaner::sanitize( $messy_urls );\n// Result: ['https://example.com', 'https://shop.com?category=shoes']\n\n// Custom parameters and whitelisting\n$custom_clean = Cleaner::strip( $url, ['my_tracker', 'internal_ref'] );\n$keep_important = Cleaner::strip( $url, [], ['page', 'category', 'search'] );\n\n// Check for tracking parameters\nif ( Cleaner::has_tracking( $url ) ) {\n    echo 'This URL contains tracking parameters';\n}\n```\n\n### HTTP Connectivity Checking\n\n```php\nuse ArrayPress\\URLUtils\\Checker;\n\n// Single URL checks\n$reachable = Checker::is_reachable( 'https://example.com' );\n$status = Checker::get_status_code( 'https://example.com' ); // 200, 404, etc.\n$final_url = Checker::get_final_url( 'https://bit.ly/short' ); // follows redirects\n$downloadable = Checker::is_downloadable( 'https://example.com/file.pdf' );\n\n// Comprehensive info\n$info = Checker::get_info( 'https://example.com' );\n// Returns: reachable, status_code, final_url, content_type, error\n\n// Bulk checking\n$results = Checker::check_multiple( $url_list );\n$working_urls = Checker::filter_reachable( $url_list );\n\n// Configuration\nChecker::set_default_timeout( 15 ); // seconds\n```\n\n## Common Use Cases\n\n**Enhanced scheme handling:**\n```php\n// Now handles domain-only URLs!\n$secure_urls = [\n    URL::to_https( 'example.com' ),           // https://example.com\n    URL::to_http( 'secure-site.com' ),       // http://secure-site.com\n    URL::add_scheme( 'api.site.com', 'https' ), // https://api.site.com\n];\n```\n\n**Smart content processing:**\n```php\n// Categorize URLs by platform type\nfunction process_content_urls( $content ) {\n    $urls = URLs::extract( $content );\n    \n    foreach ( $urls as $url ) {\n        if ( URL::is_video_platform( $url ) ) {\n            // Handle video embeds\n            $content = add_video_wrapper( $content, $url );\n        } elseif ( URL::is_audio_platform( $url ) ) {\n            // Handle audio players\n            $content = add_audio_player( $content, $url );\n        } elseif ( URL::is_social_platform( $url ) ) {\n            // Handle social embeds\n            $content = add_social_embed( $content, $url );\n        }\n        \n        // Clean tracking parameters from all URLs\n        $clean_url = Cleaner::strip( $url );\n        $content = str_replace( $url, $clean_url, $content );\n    }\n    \n    return $content;\n}\n```\n\n**Privacy-focused URL sharing:**\n```php\n// Clean URLs before sharing to protect user privacy\n$share_url = Cleaner::strip( $_POST['url'] );\n$safe_url = URL::sanitize_for_html( $share_url );\n```\n\n**Content management:**\n```php\n// Clean tracking from imported content\nfunction clean_imported_content( $content ) {\n    $urls = URLs::extract( $content );\n    foreach ( $urls as $url ) {\n        $clean_url = Cleaner::strip( $url );\n        $content = str_replace( $url, $clean_url, $content );\n    }\n    return $content;\n}\n```\n\n**Form validation with cleaning:**\n```php\n$website = Cleaner::strip( $_POST['website'] );\n$website = URL::sanitize( $website );\nif ( ! URL::is_valid( $website ) ) {\n    $errors[] = 'Invalid website URL';\n}\n```\n\n**Link checking:**\n```php\n$broken_links = [];\nforeach ( $links as $link ) {\n    if ( ! Checker::is_reachable( $link, 5 ) ) {\n        $broken_links[] = $link;\n    }\n}\n```\n\n**Content processing:**\n```php\n$found_urls = URLs::extract( $post_content );\n$external_urls = URLs::filter_by_location( $found_urls, 'external' );\n$clean_urls = Cleaner::strip_multiple( $external_urls );\n$safe_urls = URLs::sanitize_for_html( $clean_urls );\n```\n\n**UTM campaign tracking:**\n```php\n$campaign_url = URL::add_utm_smart( 'https://mysite.com/sale', [\n    'source' =\u003e 'email',\n    'campaign' =\u003e 'black-friday'\n]);\n// Automatically adds medium based on WordPress context\n```\n\n**WordPress Integration Examples:**\n```php\n// Categorize and clean URLs when saving posts\nfunction process_post_urls( $content ) {\n    $urls = URLs::extract( $content );\n    \n    foreach ( $urls as $url ) {\n        // Clean tracking parameters\n        $clean_url = Cleaner::strip( $url );\n        \n        // Ensure HTTPS for external links\n        if ( URL::is_external( $clean_url ) ) {\n            $clean_url = URL::to_https( $clean_url );\n        }\n        \n        // Replace in content\n        $content = str_replace( $url, $clean_url, $content );\n    }\n    \n    return $content;\n}\nadd_filter( 'content_save_pre', 'process_post_urls' );\n\n// Auto-embed platform content\nfunction auto_embed_platforms( $content ) {\n    $urls = URLs::extract( $content );\n    \n    foreach ( $urls as $url ) {\n        if ( URL::is_video_platform( $url ) \u0026\u0026 ! URL::supports_oembed( $url ) ) {\n            // Custom video embed logic\n        } elseif ( URL::is_audio_platform( $url ) ) {\n            // Custom audio player logic\n        }\n    }\n    \n    return $content;\n}\nadd_filter( 'the_content', 'auto_embed_platforms' );\n\n// Enhanced URL processing pipeline\n$processed_url = URL::sanitize_for_html(\n    URL::to_https(\n        Cleaner::strip( $original_url )\n    )\n);\n```\n\n## Platform Coverage\n\n### Video Platforms (30+ supported)\n**Major**: YouTube, Vimeo, TikTok, Instagram, Facebook Watch  \n**Streaming**: Twitch, Dailymotion, Rumble, BitChute  \n**Business**: Wistia, JW Player, Brightcove, Vidyard, Loom  \n**International**: Youku, Bilibili (Chinese), VK, OK.ru (Russian)  \n**Other**: Twitter videos, Reddit videos, Archive.org\n\n### Audio Platforms (25+ supported)\n**Music**: Spotify, Apple Music, YouTube Music, Deezer, Tidal, SoundCloud  \n**Podcasts**: Apple Podcasts, Google Podcasts, Anchor, Overcast, Stitcher  \n**Radio**: TuneIn, iHeart Radio, Pandora  \n**International**: NetEase Music, QQ Music (Chinese)  \n**Other**: Bandcamp, AudioMack, Last.fm, Mixcloud\n\n### Social Media Platforms (40+ supported)\n**Major**: Facebook, Twitter/X, Instagram, LinkedIn, TikTok, Snapchat  \n**Messaging**: WhatsApp, Telegram, Discord, WeChat, LINE  \n**Communities**: Reddit, Pinterest, Tumblr, Mastodon, Threads  \n**Professional**: Behance, Dribbble, Stack Overflow  \n**International**: VK, Weibo, Xiaohongshu (Chinese)  \n**Other**: Nextdoor, Goodreads, Flickr, Meetup\n\n## Tracking Parameter Coverage\n\nThe `Cleaner` class removes **300+ tracking parameters** from:\n\n**Major Platforms:**\n- Google (Analytics, Ads, DoubleClick)\n- Facebook, Instagram, Twitter/X, TikTok, LinkedIn, Snapchat\n- Amazon, eBay, AliExpress, Walmart, Best Buy\n- YouTube, Spotify, Netflix, Twitch\n\n**Marketing Tools:**\n- Email marketing (Mailchimp, HubSpot, Klaviyo)\n- Analytics (Matomo, Piwik, Adobe)\n- Affiliate networks (Impact Radius, Commission Junction)\n- Chinese platforms (Taobao, Bilibili, Xiaohongshu)\n\n**News \u0026 Media:**\n- NY Times, Forbes, Reuters, TechCrunch, BBC, CNN\n\n**International:**\n- Yandex, Seznam, German/French/Czech sites\n\n## All Methods\n\n### URL Class\n- `is_valid()`, `is_external()`, `is_https()`, `is_same_domain()`\n- `get_domain()`, `get_path()`, `get_query()`, `get_extension()`\n- `add_params()`, `remove_params()`, `add_scheme()`, `to_https()`, `to_http()`, `make_relative()`\n- `is_image()`, `is_video()`, `is_audio()` (with custom extensions)\n- `is_video_platform()`, `is_audio_platform()`, `is_social_platform()` ⭐ **NEW**\n- `add_utm()`, `add_utm_smart()`, `sanitize()`, `current()`\n\n### URLs Class\n- `validate()`, `filter_valid()`, `filter_invalid()`\n- `filter_by_location()`, `filter_by_protocol()`, `filter_by_type()`\n- `to_https()`, `make_relative()`, `get_domains()`\n- `extract()`, `remove_duplicates()`, `sanitize()`\n\n### Cleaner Class ⭐ **NEW**\n- `strip()` - Remove tracking parameters from single URL\n- `strip_multiple()` - Bulk tracking parameter removal\n- `sanitize()` - Complete pipeline: validate, clean, deduplicate\n- `has_tracking()` - Check if URL contains tracking parameters\n- `add_params()` - Extend tracking parameter list\n- `get_params()` - View all tracked parameters\n\n### Checker Class\n- `is_reachable()`, `get_status_code()`, `get_final_url()`\n- `is_downloadable()`, `get_info()`\n- `check_multiple()`, `filter_reachable()`\n- `set_default_timeout()`\n\n## Requirements\n\n- PHP 7.4+\n- WordPress 5.0+\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the GPL-2.0-or-later License.\n\n## Support\n\n- [Documentation](https://github.com/arraypress/wp-url-utils)\n- [Issue Tracker](https://github.com/arraypress/wp-url-utils/issues)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fwp-url-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farraypress%2Fwp-url-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fwp-url-utils/lists"}