| @@ -523,29 +523,12 @@ | ||
| 523 | 523 | $validation['valid'] = false; |
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - // The default Open Graph and Twitter images are checked in the field | |
| 528 | - // details above only while their feature is switched on, but they are | |
| 529 | - // stored (and shown in the admin preview's src) either way. | |
| 530 | - $flagged = []; | |
| 531 | - foreach ($field_details as $field) { | |
| 532 | - if ('error' === ($field['status'] ?? '')) { | |
| 533 | - $flagged[] = $field['field'] ?? ''; | |
| 534 | - } | |
| 535 | - } | |
| 536 | - foreach (['default_og_image' => 'Default Open Graph image', 'default_twitter_image' => 'Default Twitter Card image'] as $key => $label) { | |
| 537 | - if (!empty($settings[$key]) && !in_array($key, $flagged, true) | |
| 538 | - && !\ThinkRank\Core\Url_Validator::is_http_url($settings[$key])) { | |
| 539 | - $validation['errors'][] = $label . ' must be an http or https URL.'; | |
| 540 | - $validation['valid'] = false; | |
| 541 | - } | |
| 542 | - } | |
| 543 | - | |
| 544 | 527 | // Validate default image |
| 545 | 528 | if (isset($settings['default_image']) && !empty($settings['default_image'])) { |
| 546 | - if (!\ThinkRank\Core\Url_Validator::is_http_url($settings['default_image'])) { | |
| 547 | - $validation['errors'][] = 'default_image must be an http or https URL'; | |
| 529 | + if (!filter_var($settings['default_image'], FILTER_VALIDATE_URL)) { | |
| 530 | + $validation['errors'][] = 'default_image must be a valid URL'; | |
| 548 | 531 | $validation['valid'] = false; |
| 549 | 532 | } else { |
| 550 | 533 | // Check image dimensions and format |
| 551 | 534 | $image_validation = $this->validate_social_image($settings['default_image']); |
| @@ -783,12 +766,9 @@ | ||
| 783 | 766 | } |
| 784 | 767 | |
| 785 | 768 | // Default Image validation |
| 786 | 769 | if (!empty($settings['default_og_image'])) { |
| 787 | - // http(s) only, and refused rather than warned about: the | |
| 788 | - // value becomes og:image and the admin preview's src, and a | |
| 789 | - // javascript: URL passed is_valid(). | |
| 790 | - if (\ThinkRank\Core\Url_Validator::is_http_url($settings['default_og_image'])) { | |
| 770 | + if (filter_var($settings['default_og_image'], FILTER_VALIDATE_URL)) { | |
| 791 | 771 | $field_details[] = [ |
| 792 | 772 | 'field' => 'default_og_image', |
| 793 | 773 | 'label' => 'Default Open Graph image is configured.', |
| 794 | 774 | 'status' => 'valid', |
| @@ -796,11 +776,11 @@ | ||
| 796 | 776 | ]; |
| 797 | 777 | } else { |
| 798 | 778 | $field_details[] = [ |
| 799 | 779 | 'field' => 'default_og_image', |
| 800 | - 'label' => 'Default Open Graph image must be an http or https URL.', | |
| 801 | - 'status' => 'error', | |
| 802 | - 'icon' => '✗' | |
| 780 | + 'label' => 'Default Open Graph image URL appears invalid.', | |
| 781 | + 'status' => 'warning', | |
| 782 | + 'icon' => '⚠' | |
| 803 | 783 | ]; |
| 804 | 784 | } |
| 805 | 785 | } else { |
| 806 | 786 | $field_details[] = [ |
| @@ -920,9 +900,9 @@ | ||
| 920 | 900 | } |
| 921 | 901 | |
| 922 | 902 | // Default Twitter Image validation |
| 923 | 903 | if (!empty($settings['default_twitter_image'])) { |
| 924 | - if (\ThinkRank\Core\Url_Validator::is_http_url($settings['default_twitter_image'])) { | |
| 904 | + if (filter_var($settings['default_twitter_image'], FILTER_VALIDATE_URL)) { | |
| 925 | 905 | $field_details[] = [ |
| 926 | 906 | 'field' => 'default_twitter_image', |
| 927 | 907 | 'label' => 'Default Twitter Card image is configured.', |
| 928 | 908 | 'status' => 'valid', |
| @@ -930,11 +910,11 @@ | ||
| 930 | 910 | ]; |
| 931 | 911 | } else { |
| 932 | 912 | $field_details[] = [ |
| 933 | 913 | 'field' => 'default_twitter_image', |
| 934 | - 'label' => 'Default Twitter Card image must be an http or https URL.', | |
| 935 | - 'status' => 'error', | |
| 936 | - 'icon' => '✗' | |
| 914 | + 'label' => 'Default Twitter Card image URL appears invalid.', | |
| 915 | + 'status' => 'warning', | |
| 916 | + 'icon' => '⚠' | |
| 937 | 917 | ]; |
| 938 | 918 | } |
| 939 | 919 | } else { |
| 940 | 920 | $field_details[] = [ |
| @@ -3055,9 +3035,9 @@ | ||
| 3055 | 3035 | return $validation; |
| 3056 | 3036 | } |
| 3057 | 3037 | |
| 3058 | 3038 | // Check if URL is valid |
| 3059 | - if (!\ThinkRank\Core\Url_Validator::is_http_url($image_url)) { | |
| 3039 | + if (!filter_var($image_url, FILTER_VALIDATE_URL)) { | |
| 3060 | 3040 | $validation['warnings'][] = 'Invalid image URL'; |
| 3061 | 3041 | return $validation; |
| 3062 | 3042 | } |
| 3063 | 3043 | |