| @@ -1,9 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Yoast\WP\SEO\Helpers; |
| 4 | 4 | |
| 5 | +use WPSEO_Option_Llmstxt; | |
| 6 | +use WPSEO_Option_Social; | |
| 5 | 7 | use WPSEO_Option_Titles; |
| 8 | +use WPSEO_Option_Tracking_Only; | |
| 6 | 9 | use WPSEO_Options; |
| 7 | 10 | |
| 8 | 11 | /** |
| 9 | 12 | * A helper object for options. |
| @@ -26,15 +29,16 @@ | ||
| 26 | 29 | |
| 27 | 30 | /** |
| 28 | 31 | * Sets a single field to the options. |
| 29 | 32 | * |
| 30 | - * @param string $key The key to set. | |
| 31 | - * @param mixed $value The value to set. | |
| 33 | + * @param string $key The key to set. | |
| 34 | + * @param mixed $value The value to set. | |
| 35 | + * @param string $option_group The lookup table which represents the option_group where the key is stored. | |
| 32 | 36 | * |
| 33 | 37 | * @return mixed|null Returns value if found. |
| 34 | 38 | */ |
| 35 | - public function set( $key, $value ) { | |
| 36 | - return WPSEO_Options::set( $key, $value ); | |
| 39 | + public function set( $key, $value, $option_group = '' ) { | |
| 40 | + return WPSEO_Options::set( $key, $value, $option_group ); | |
| 37 | 41 | } |
| 38 | 42 | |
| 39 | 43 | /** |
| 40 | 44 | * Get a specific default value for an option. |
| @@ -74,9 +78,9 @@ | ||
| 74 | 78 | |
| 75 | 79 | /** |
| 76 | 80 | * Filter: 'wpseo_replacements_filter_sep' - Allow customization of the separator character(s). |
| 77 | 81 | * |
| 78 | - * @api string $replacement The current separator. | |
| 82 | + * @param string $replacement The current separator. | |
| 79 | 83 | */ |
| 80 | 84 | return \apply_filters( 'wpseo_replacements_filter_sep', $replacement ); |
| 81 | 85 | } |
| 82 | 86 | |
| @@ -107,8 +111,19 @@ | ||
| 107 | 111 | return WPSEO_Option_Titles::get_instance()->get_defaults(); |
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | /** |
| 115 | + * Retrieves the tracking only options. | |
| 116 | + * | |
| 117 | + * @codeCoverageIgnore We have to write test when this method contains own code. | |
| 118 | + * | |
| 119 | + * @return string[] The tracking only options. | |
| 120 | + */ | |
| 121 | + public function get_tracking_only_options() { | |
| 122 | + return \array_keys( WPSEO_Option_Tracking_Only::get_instance()->get_defaults() ); | |
| 123 | + } | |
| 124 | + | |
| 125 | + /** | |
| 111 | 126 | * Get the available separator options. |
| 112 | 127 | * |
| 113 | 128 | * @return array |
| 114 | 129 | */ |
| @@ -113,6 +128,37 @@ | ||
| 113 | 128 | * @return array |
| 114 | 129 | */ |
| 115 | 130 | protected function get_separator_options() { |
| 116 | 131 | return WPSEO_Option_Titles::get_instance()->get_separator_options(); |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * Checks whether a social URL is valid, with empty strings being valid social URLs. | |
| 136 | + * | |
| 137 | + * @param string $url The url to be checked. | |
| 138 | + * | |
| 139 | + * @return bool Whether the URL is valid. | |
| 140 | + */ | |
| 141 | + public function is_social_url_valid( $url ) { | |
| 142 | + return $url === '' || WPSEO_Option_Social::get_instance()->validate_social_url( $url ); | |
| 143 | + } | |
| 144 | + | |
| 145 | + /** | |
| 146 | + * Checks whether a twitter id is valid, with empty strings being valid twitter id. | |
| 147 | + * | |
| 148 | + * @param string $twitter_id The twitter id to be checked. | |
| 149 | + * | |
| 150 | + * @return bool Whether the twitter id is valid. | |
| 151 | + */ | |
| 152 | + public function is_twitter_id_valid( $twitter_id ) { | |
| 153 | + return empty( $twitter_id ) || WPSEO_Option_Social::get_instance()->validate_twitter_id( $twitter_id, false ); | |
| 154 | + } | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * Gets the limit for the other included pages. | |
| 158 | + * | |
| 159 | + * @return int The limit for the other included pages. | |
| 160 | + */ | |
| 161 | + public function get_other_included_pages_limit() { | |
| 162 | + return WPSEO_Option_Llmstxt::get_instance()->get_other_included_pages_limit(); | |
| 117 | 163 | } |
| 118 | 164 | } |