| @@ -1,10 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Yoast\WP\SEO\Helpers; |
| 4 | 4 | |
| 5 | +use WPSEO_Option_Llmstxt; | |
| 5 | 6 | use WPSEO_Option_Social; |
| 6 | 7 | use WPSEO_Option_Titles; |
| 8 | +use WPSEO_Option_Tracking_Only; | |
| 7 | 9 | use WPSEO_Options; |
| 8 | 10 | |
| 9 | 11 | /** |
| 10 | 12 | * A helper object for options. |
| @@ -27,15 +29,16 @@ | ||
| 27 | 29 | |
| 28 | 30 | /** |
| 29 | 31 | * Sets a single field to the options. |
| 30 | 32 | * |
| 31 | - * @param string $key The key to set. | |
| 32 | - * @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. | |
| 33 | 36 | * |
| 34 | 37 | * @return mixed|null Returns value if found. |
| 35 | 38 | */ |
| 36 | - public function set( $key, $value ) { | |
| 37 | - return WPSEO_Options::set( $key, $value ); | |
| 39 | + public function set( $key, $value, $option_group = '' ) { | |
| 40 | + return WPSEO_Options::set( $key, $value, $option_group ); | |
| 38 | 41 | } |
| 39 | 42 | |
| 40 | 43 | /** |
| 41 | 44 | * Get a specific default value for an option. |
| @@ -75,9 +78,9 @@ | ||
| 75 | 78 | |
| 76 | 79 | /** |
| 77 | 80 | * Filter: 'wpseo_replacements_filter_sep' - Allow customization of the separator character(s). |
| 78 | 81 | * |
| 79 | - * @api string $replacement The current separator. | |
| 82 | + * @param string $replacement The current separator. | |
| 80 | 83 | */ |
| 81 | 84 | return \apply_filters( 'wpseo_replacements_filter_sep', $replacement ); |
| 82 | 85 | } |
| 83 | 86 | |
| @@ -108,8 +111,19 @@ | ||
| 108 | 111 | return WPSEO_Option_Titles::get_instance()->get_defaults(); |
| 109 | 112 | } |
| 110 | 113 | |
| 111 | 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 | + /** | |
| 112 | 126 | * Get the available separator options. |
| 113 | 127 | * |
| 114 | 128 | * @return array |
| 115 | 129 | */ |
| @@ -117,26 +131,34 @@ | ||
| 117 | 131 | return WPSEO_Option_Titles::get_instance()->get_separator_options(); |
| 118 | 132 | } |
| 119 | 133 | |
| 120 | 134 | /** |
| 121 | - * Validates a social URL. | |
| 135 | + * Checks whether a social URL is valid, with empty strings being valid social URLs. | |
| 122 | 136 | * |
| 123 | - * @param string $url The url to be validated. | |
| 137 | + * @param string $url The url to be checked. | |
| 124 | 138 | * |
| 125 | - * @return string|false The validated URL or false if the URL is not valid. | |
| 139 | + * @return bool Whether the URL is valid. | |
| 126 | 140 | */ |
| 127 | - public function validate_social_url( $url ) { | |
| 141 | + public function is_social_url_valid( $url ) { | |
| 128 | 142 | return $url === '' || WPSEO_Option_Social::get_instance()->validate_social_url( $url ); |
| 129 | 143 | } |
| 130 | 144 | |
| 131 | 145 | /** |
| 132 | - * Validates a twitter id. | |
| 146 | + * Checks whether a twitter id is valid, with empty strings being valid twitter id. | |
| 133 | 147 | * |
| 134 | - * @param string $twitter_id The twitter id to be validated. | |
| 135 | - * @param bool $strip_at_sign Whether or not to strip the `@` sign. | |
| 148 | + * @param string $twitter_id The twitter id to be checked. | |
| 136 | 149 | * |
| 137 | - * @return string|false The validated twitter id or false if it is not valid. | |
| 150 | + * @return bool Whether the twitter id is valid. | |
| 138 | 151 | */ |
| 139 | - public function validate_twitter_id( $twitter_id, $strip_at_sign = true ) { | |
| 140 | - return WPSEO_Option_Social::get_instance()->validate_twitter_id( $twitter_id, $strip_at_sign ); | |
| 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(); | |
| 141 | 163 | } |
| 142 | 164 | } |