| @@ -1,19 +1,24 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | /** |
| 3 | 3 | * Jetpack Twitter Card handling. |
| 4 | 4 | * |
| 5 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards instead. | |
| 5 | 6 | * @package automattic/jetpack |
| 6 | 7 | */ |
| 7 | 8 | |
| 9 | +use Automattic\Jetpack\Post_Media\Twitter_Cards; | |
| 10 | + | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit( 0 ); | |
| 13 | +} | |
| 14 | + | |
| 8 | 15 | /** |
| 9 | 16 | * Twitter Cards |
| 10 | 17 | * |
| 11 | - * Hooks onto the Open Graph protocol and extends it by adding only the tags | |
| 12 | - * we need for twitter cards. | |
| 18 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards instead. | |
| 13 | 19 | * |
| 14 | - * @see /wp-content/blog-plugins/open-graph.php | |
| 15 | - * @see https://dev.twitter.com/cards/overview | |
| 20 | + * @see Automattic\Jetpack\Post_Media\Twitter_Cards | |
| 16 | 21 | */ |
| 17 | 22 | class Jetpack_Twitter_Cards { |
| 18 | 23 | |
| 19 | 24 | /** |
| @@ -18,194 +23,52 @@ | ||
| 18 | 23 | |
| 19 | 24 | /** |
| 20 | 25 | * Adds Twitter Card tags. |
| 21 | 26 | * |
| 27 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::twitter_cards_tags() instead. | |
| 28 | + * | |
| 22 | 29 | * @param array $og_tags Existing OG tags. |
| 23 | 30 | * |
| 24 | 31 | * @return array OG tags inclusive of Twitter Card output. |
| 25 | 32 | */ |
| 26 | 33 | public static function twitter_cards_tags( $og_tags ) { |
| 27 | - global $post; | |
| 28 | - $post_id = ( $post instanceof WP_Post ) ? $post->ID : null; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * Maximum alt text length. | |
| 32 | - * | |
| 33 | - * @see https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary-card-with-large-image.html | |
| 34 | - */ | |
| 35 | - $alt_length = 420; | |
| 36 | - | |
| 37 | - if ( post_password_required() ) { | |
| 38 | - return $og_tags; | |
| 39 | - } | |
| 40 | - | |
| 41 | - /** This action is documented in class.jetpack.php */ | |
| 42 | - if ( apply_filters( 'jetpack_disable_twitter_cards', false ) ) { | |
| 43 | - return $og_tags; | |
| 44 | - } | |
| 45 | - | |
| 46 | - /* | |
| 47 | - * These tags apply to any page (home, archives, etc). | |
| 48 | - */ | |
| 49 | - | |
| 50 | - // If we have information on the author/creator, then include that as well. | |
| 51 | - if ( ! empty( $post ) && ! empty( $post->post_author ) ) { | |
| 52 | - /** This action is documented in modules/sharedaddy/sharing-sources.php */ | |
| 53 | - $handle = apply_filters( 'jetpack_sharing_twitter_via', '', $post_id ); | |
| 54 | - if ( ! empty( $handle ) && ! self::is_default_site_tag( $handle ) ) { | |
| 55 | - $og_tags['twitter:creator'] = self::sanitize_twitter_user( $handle ); | |
| 56 | - } | |
| 57 | - } | |
| 58 | - | |
| 59 | - $site_tag = self::site_tag(); | |
| 60 | - /** This action is documented in modules/sharedaddy/sharing-sources.php */ | |
| 61 | - $site_tag = apply_filters( 'jetpack_sharing_twitter_via', $site_tag, ( is_singular() ? $post_id : null ) ); | |
| 62 | - /** This action is documented in modules/sharedaddy/sharing-sources.php */ | |
| 63 | - $site_tag = apply_filters( 'jetpack_twitter_cards_site_tag', $site_tag, $og_tags ); | |
| 64 | - if ( ! empty( $site_tag ) ) { | |
| 65 | - $og_tags['twitter:site'] = self::sanitize_twitter_user( $site_tag ); | |
| 66 | - } | |
| 67 | - | |
| 68 | - if ( ! is_singular() || ! empty( $og_tags['twitter:card'] ) ) { | |
| 69 | - /** | |
| 70 | - * Filter the default Twitter card image, used when no image can be found in a post. | |
| 71 | - * | |
| 72 | - * @module sharedaddy | |
| 73 | - * | |
| 74 | - * @since 5.9.0 | |
| 75 | - * | |
| 76 | - * @param string $str Default image URL. | |
| 77 | - */ | |
| 78 | - $image = apply_filters( 'jetpack_twitter_cards_image_default', '' ); | |
| 79 | - if ( ! empty( $image ) ) { | |
| 80 | - $og_tags['twitter:image'] = $image; | |
| 81 | - } | |
| 82 | - | |
| 83 | - return $og_tags; | |
| 84 | - } | |
| 85 | - | |
| 86 | - $the_title = get_the_title(); | |
| 87 | - if ( ! $the_title ) { | |
| 88 | - $the_title = get_bloginfo( 'name' ); | |
| 89 | - } | |
| 90 | - $og_tags['twitter:text:title'] = $the_title; | |
| 91 | - | |
| 92 | - /* | |
| 93 | - * The following tags only apply to single pages. | |
| 94 | - */ | |
| 95 | - | |
| 96 | - $card_type = 'summary'; | |
| 97 | - | |
| 98 | - // Try to give priority to featured images. | |
| 99 | - if ( class_exists( 'Jetpack_PostImages' ) && ! empty( $post_id ) ) { | |
| 100 | - $post_image = Jetpack_PostImages::get_image( | |
| 101 | - $post_id, | |
| 102 | - array( | |
| 103 | - 'width' => 144, | |
| 104 | - 'height' => 144, | |
| 105 | - ) | |
| 106 | - ); | |
| 107 | - if ( ! empty( $post_image ) && is_array( $post_image ) ) { | |
| 108 | - // 4096 is the maximum size for an image per https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary . | |
| 109 | - if ( | |
| 110 | - isset( $post_image['src_width'] ) && isset( $post_image['src_height'] ) | |
| 111 | - && (int) $post_image['src_width'] <= 4096 | |
| 112 | - && (int) $post_image['src_height'] <= 4096 | |
| 113 | - ) { | |
| 114 | - // 300x157 is the minimum size for a summary_large_image per https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary-card-with-large-image . | |
| 115 | - if ( (int) $post_image['src_width'] >= 300 && (int) $post_image['src_height'] >= 157 ) { | |
| 116 | - $card_type = 'summary_large_image'; | |
| 117 | - $og_tags['twitter:image'] = esc_url( add_query_arg( 'w', 640, $post_image['src'] ) ); | |
| 118 | - } else { | |
| 119 | - $og_tags['twitter:image'] = esc_url( add_query_arg( 'w', 144, $post_image['src'] ) ); | |
| 120 | - } | |
| 121 | - | |
| 122 | - // Add the alt tag if we have one. | |
| 123 | - if ( ! empty( $post_image['alt_text'] ) ) { | |
| 124 | - // Shorten it if it is too long. | |
| 125 | - if ( strlen( $post_image['alt_text'] ) > $alt_length ) { | |
| 126 | - $og_tags['twitter:image:alt'] = esc_attr( mb_substr( $post_image['alt_text'], 0, $alt_length ) . '…' ); | |
| 127 | - } else { | |
| 128 | - $og_tags['twitter:image:alt'] = esc_attr( $post_image['alt_text'] ); | |
| 129 | - } | |
| 130 | - } | |
| 131 | - } | |
| 132 | - } | |
| 133 | - } | |
| 134 | - | |
| 135 | - // Only proceed with media analysis if a featured image has not superseded it already. | |
| 136 | - if ( empty( $og_tags['twitter:image'] ) && empty( $og_tags['twitter:image:src'] ) ) { | |
| 137 | - if ( ! class_exists( 'Jetpack_Media_Summary' ) ) { | |
| 138 | - require_once JETPACK__PLUGIN_DIR . '_inc/lib/class.media-summary.php'; | |
| 139 | - } | |
| 140 | - | |
| 141 | - // Test again, class should already be auto-loaded in Jetpack. | |
| 142 | - // If not, skip extra media analysis and stick with a summary card. | |
| 143 | - if ( class_exists( 'Jetpack_Media_Summary' ) && ! empty( $post_id ) ) { | |
| 144 | - $extract = Jetpack_Media_Summary::get( $post_id ); | |
| 145 | - | |
| 146 | - if ( 'gallery' === $extract['type'] ) { | |
| 147 | - list( $og_tags, $card_type ) = self::twitter_cards_define_type_based_on_image_count( $og_tags, $extract ); | |
| 148 | - } elseif ( 'video' === $extract['type'] ) { | |
| 149 | - // Leave as summary, but with large pict of poster frame (we know those comply to Twitter's size requirements). | |
| 150 | - $card_type = 'summary_large_image'; | |
| 151 | - $og_tags['twitter:image'] = esc_url( add_query_arg( 'w', 640, $extract['image'] ) ); | |
| 152 | - } else { | |
| 153 | - list( $og_tags, $card_type ) = self::twitter_cards_define_type_based_on_image_count( $og_tags, $extract ); | |
| 154 | - } | |
| 155 | - } | |
| 156 | - } | |
| 157 | - | |
| 158 | - $og_tags['twitter:card'] = $card_type; | |
| 159 | - | |
| 160 | - // Make sure we have a description for Twitter, their validator isn't happy without some content (single space not valid). | |
| 161 | - if ( ! isset( $og_tags['og:description'] ) || '' === trim( $og_tags['og:description'] ) || __( 'Visit the post for more.', 'jetpack' ) === $og_tags['og:description'] ) { // empty( trim( $og_tags['og:description'] ) ) isn't valid php. | |
| 162 | - $has_creator = ( ! empty( $og_tags['twitter:creator'] ) && '@wordpressdotcom' !== $og_tags['twitter:creator'] ) ? true : false; | |
| 163 | - if ( ! empty( $extract ) && 'video' === $extract['type'] ) { // use $extract['type'] since $card_type is 'summary' for video posts. | |
| 164 | - /* translators: %s is the post author */ | |
| 165 | - $og_tags['twitter:description'] = ( $has_creator ) ? sprintf( __( 'Video post by %s.', 'jetpack' ), $og_tags['twitter:creator'] ) : __( 'Video post.', 'jetpack' ); | |
| 166 | - } else { | |
| 167 | - /* translators: %s is the post author */ | |
| 168 | - $og_tags['twitter:description'] = ( $has_creator ) ? sprintf( __( 'Post by %s.', 'jetpack' ), $og_tags['twitter:creator'] ) : __( 'Visit the post for more.', 'jetpack' ); | |
| 169 | - } | |
| 170 | - } | |
| 171 | - | |
| 172 | - if ( empty( $og_tags['twitter:image'] ) && empty( $og_tags['twitter:image:src'] ) ) { | |
| 173 | - /** This action is documented in class.jetpack-twitter-cards.php */ | |
| 174 | - $image = apply_filters( 'jetpack_twitter_cards_image_default', '' ); | |
| 175 | - if ( ! empty( $image ) ) { | |
| 176 | - $og_tags['twitter:image'] = $image; | |
| 177 | - } | |
| 178 | - } | |
| 179 | - | |
| 180 | - return $og_tags; | |
| 34 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::twitter_cards_tags' ); | |
| 35 | + return Twitter_Cards::twitter_cards_tags( $og_tags ); | |
| 181 | 36 | } |
| 182 | 37 | |
| 183 | 38 | /** |
| 184 | 39 | * Sanitize the Twitter user by normalizing the @. |
| 185 | 40 | * |
| 41 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::sanitize_twitter_user() instead. | |
| 42 | + * | |
| 186 | 43 | * @param string $str Twitter user value. |
| 187 | 44 | * |
| 188 | 45 | * @return string Twitter user value. |
| 189 | 46 | */ |
| 190 | 47 | public static function sanitize_twitter_user( $str ) { |
| 191 | - return '@' . preg_replace( '/^@/', '', $str ); | |
| 48 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::sanitize_twitter_user' ); | |
| 49 | + return Twitter_Cards::sanitize_twitter_user( $str ); | |
| 192 | 50 | } |
| 193 | 51 | |
| 194 | 52 | /** |
| 195 | 53 | * Determines if a site tag is one of the default WP.com/Jetpack ones. |
| 196 | 54 | * |
| 55 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::is_default_site_tag() instead. | |
| 56 | + * | |
| 197 | 57 | * @param string $site_tag Site tag. |
| 198 | 58 | * |
| 199 | 59 | * @return bool True if the default site tag is being used. |
| 200 | 60 | */ |
| 201 | 61 | public static function is_default_site_tag( $site_tag ) { |
| 202 | - return in_array( $site_tag, array( '@wordpressdotcom', '@jetpack', 'wordpressdotcom', 'jetpack' ), true ); | |
| 62 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::is_default_site_tag' ); | |
| 63 | + return Twitter_Cards::is_default_site_tag( $site_tag ); | |
| 203 | 64 | } |
| 204 | 65 | |
| 205 | 66 | /** |
| 206 | 67 | * Give priority to the creator tag if using the default site tag. |
| 207 | 68 | * |
| 69 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::prioritize_creator_over_default_site() instead. | |
| 70 | + * | |
| 208 | 71 | * @param string $site_tag Site tag. |
| 209 | 72 | * @param array $og_tags OG tags. |
| 210 | 73 | * |
| 211 | 74 | * @return string Site tag. |
| @@ -210,17 +73,17 @@ | ||
| 210 | 73 | * |
| 211 | 74 | * @return string Site tag. |
| 212 | 75 | */ |
| 213 | 76 | public static function prioritize_creator_over_default_site( $site_tag, $og_tags = array() ) { |
| 214 | - if ( ! empty( $og_tags['twitter:creator'] ) && self::is_default_site_tag( $site_tag ) ) { | |
| 215 | - return $og_tags['twitter:creator']; | |
| 216 | - } | |
| 217 | - return $site_tag; | |
| 77 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::prioritize_creator_over_default_site' ); | |
| 78 | + return Twitter_Cards::prioritize_creator_over_default_site( $site_tag, $og_tags ); | |
| 218 | 79 | } |
| 219 | 80 | |
| 220 | 81 | /** |
| 221 | 82 | * Define the Twitter Card type based on image count. |
| 222 | 83 | * |
| 84 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::twitter_cards_define_type_based_on_image_count() instead. | |
| 85 | + * | |
| 223 | 86 | * @param array $og_tags Existing OG tags. |
| 224 | 87 | * @param array $extract Result of the Image Extractor class. |
| 225 | 88 | * |
| 226 | 89 | * @return array |
| @@ -225,124 +88,86 @@ | ||
| 225 | 88 | * |
| 226 | 89 | * @return array |
| 227 | 90 | */ |
| 228 | 91 | public static function twitter_cards_define_type_based_on_image_count( $og_tags, $extract ) { |
| 229 | - $card_type = 'summary'; | |
| 230 | - $img_count = $extract['count']['image']; | |
| 231 | - | |
| 232 | - if ( empty( $img_count ) ) { | |
| 233 | - | |
| 234 | - // No images, use Blavatar as a thumbnail for the summary type. | |
| 235 | - if ( function_exists( 'blavatar_domain' ) ) { | |
| 236 | - $blavatar_domain = blavatar_domain( site_url() ); | |
| 237 | - if ( blavatar_exists( $blavatar_domain ) ) { | |
| 238 | - $og_tags['twitter:image'] = blavatar_url( $blavatar_domain, 'img', 240 ); | |
| 239 | - } | |
| 240 | - } | |
| 241 | - | |
| 242 | - // Second fall back, Site Logo. | |
| 243 | - if ( empty( $og_tags['twitter:image'] ) && ( function_exists( 'jetpack_has_site_logo' ) && jetpack_has_site_logo() ) ) { | |
| 244 | - $og_tags['twitter:image'] = jetpack_get_site_logo( 'url' ); | |
| 245 | - } | |
| 246 | - | |
| 247 | - // Third fall back, Site Icon. | |
| 248 | - if ( empty( $og_tags['twitter:image'] ) && has_site_icon() ) { | |
| 249 | - $og_tags['twitter:image'] = get_site_icon_url( '240' ); | |
| 250 | - } | |
| 251 | - | |
| 252 | - // Not falling back on Gravatar, because there's no way to know if we end up with an auto-generated one. | |
| 253 | - | |
| 254 | - } elseif ( $img_count && ( 'image' === $extract['type'] || 'gallery' === $extract['type'] ) ) { | |
| 255 | - // Test for $extract['type'] to limit to image and gallery, so we don't send a potential fallback image like a Gravatar as a photo post. | |
| 256 | - $card_type = 'summary_large_image'; | |
| 257 | - $og_tags['twitter:image'] = esc_url( add_query_arg( 'w', 1400, ( empty( $extract['images'] ) ) ? $extract['image'] : $extract['images'][0]['url'] ) ); | |
| 258 | - } | |
| 259 | - | |
| 260 | - return array( $og_tags, $card_type ); | |
| 92 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::twitter_cards_define_type_based_on_image_count' ); | |
| 93 | + return Twitter_Cards::twitter_cards_define_type_based_on_image_count( $og_tags, $extract ); | |
| 261 | 94 | } |
| 262 | 95 | |
| 263 | 96 | /** |
| 264 | 97 | * Updates the Twitter Card output. |
| 265 | 98 | * |
| 99 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::twitter_cards_output() instead. | |
| 100 | + * | |
| 266 | 101 | * @param string $og_tag A single OG tag. |
| 267 | 102 | * |
| 268 | 103 | * @return string Result of the OG tag. |
| 269 | 104 | */ |
| 270 | 105 | public static function twitter_cards_output( $og_tag ) { |
| 271 | - return ( str_contains( $og_tag, 'twitter:' ) ) ? preg_replace( '/property="([^"]+)"/', 'name="\1"', $og_tag ) : $og_tag; | |
| 106 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::twitter_cards_output' ); | |
| 107 | + return Twitter_Cards::twitter_cards_output( $og_tag ); | |
| 272 | 108 | } |
| 273 | 109 | |
| 274 | 110 | /** |
| 275 | 111 | * Adds settings section and field. |
| 112 | + * | |
| 113 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::settings_init() instead. | |
| 276 | 114 | */ |
| 277 | 115 | public static function settings_init() { |
| 278 | - add_settings_section( 'jetpack-twitter-cards-settings', 'Twitter Cards', '__return_false', 'sharing' ); | |
| 279 | - add_settings_field( | |
| 280 | - 'jetpack-twitter-cards-site-tag', | |
| 281 | - __( 'Twitter Site Tag', 'jetpack' ), | |
| 282 | - array( __CLASS__, 'settings_field' ), | |
| 283 | - 'sharing', | |
| 284 | - 'jetpack-twitter-cards-settings', | |
| 285 | - array( | |
| 286 | - 'label_for' => 'jetpack-twitter-cards-site-tag', | |
| 287 | - ) | |
| 288 | - ); | |
| 116 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::settings_init' ); | |
| 117 | + Twitter_Cards::settings_init(); | |
| 289 | 118 | } |
| 290 | 119 | |
| 291 | 120 | /** |
| 292 | 121 | * Add global sharing options. |
| 122 | + * | |
| 123 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::sharing_global_options() instead. | |
| 293 | 124 | */ |
| 294 | 125 | public static function sharing_global_options() { |
| 295 | - do_settings_fields( 'sharing', 'jetpack-twitter-cards-settings' ); | |
| 126 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::sharing_global_options' ); | |
| 127 | + Twitter_Cards::sharing_global_options(); | |
| 296 | 128 | } |
| 297 | 129 | |
| 298 | 130 | /** |
| 299 | 131 | * Get the Twitter Via tag. |
| 300 | 132 | * |
| 133 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::site_tag() instead. | |
| 134 | + * | |
| 301 | 135 | * @return string Twitter via tag. |
| 302 | 136 | */ |
| 303 | 137 | public static function site_tag() { |
| 304 | - $site_tag = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? | |
| 305 | - trim( get_option( 'twitter_via' ) ) : | |
| 306 | - Jetpack_Options::get_option_and_ensure_autoload( 'jetpack-twitter-cards-site-tag', '' ); | |
| 307 | - if ( empty( $site_tag ) ) { | |
| 308 | - /** This action is documented in modules/sharedaddy/sharing-sources.php */ | |
| 309 | - return apply_filters( 'jetpack_sharing_twitter_via', '', null ); | |
| 310 | - } | |
| 311 | - return $site_tag; | |
| 138 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::site_tag' ); | |
| 139 | + return Twitter_Cards::site_tag(); | |
| 312 | 140 | } |
| 313 | 141 | |
| 314 | 142 | /** |
| 315 | 143 | * Output the settings field. |
| 144 | + * | |
| 145 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::settings_field() instead. | |
| 316 | 146 | */ |
| 317 | 147 | public static function settings_field() { |
| 318 | - wp_nonce_field( 'jetpack-twitter-cards-settings', 'jetpack_twitter_cards_nonce', false ); | |
| 319 | - ?> | |
| 320 | - <input type="text" id="jetpack-twitter-cards-site-tag" class="regular-text" name="jetpack-twitter-cards-site-tag" value="<?php echo esc_attr( get_option( 'jetpack-twitter-cards-site-tag' ) ); ?>" /> | |
| 321 | - <p class="description" style="width: auto;"><?php esc_html_e( 'The Twitter username of the owner of this site\'s domain.', 'jetpack' ); ?></p> | |
| 322 | - <?php | |
| 148 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::settings_field' ); | |
| 149 | + Twitter_Cards::settings_field(); | |
| 323 | 150 | } |
| 324 | 151 | |
| 325 | 152 | /** |
| 326 | 153 | * Validate the settings submission. |
| 154 | + * | |
| 155 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::settings_validate() instead. | |
| 327 | 156 | */ |
| 328 | 157 | public static function settings_validate() { |
| 329 | - if ( isset( $_POST['jetpack_twitter_cards_nonce'] ) && wp_verify_nonce( $_POST['jetpack_twitter_cards_nonce'], 'jetpack-twitter-cards-settings' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 330 | - update_option( 'jetpack-twitter-cards-site-tag', isset( $_POST['jetpack-twitter-cards-site-tag'] ) ? trim( ltrim( wp_strip_all_tags( filter_var( wp_unslash( $_POST['jetpack-twitter-cards-site-tag'] ) ) ), '@' ) ) : '' ); | |
| 331 | - } | |
| 158 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::settings_validate' ); | |
| 159 | + Twitter_Cards::settings_validate(); | |
| 332 | 160 | } |
| 333 | 161 | |
| 334 | 162 | /** |
| 335 | 163 | * Initiates the class. |
| 164 | + * | |
| 165 | + * @deprecated 15.6 Use Automattic\Jetpack\Post_Media\Twitter_Cards::init() instead. | |
| 336 | 166 | */ |
| 337 | 167 | public static function init() { |
| 338 | - add_filter( 'jetpack_open_graph_tags', array( __CLASS__, 'twitter_cards_tags' ), 11 ); // $priority=11: this should hook into jetpack_open_graph_tags after 'class.jetpack-seo.php' has done so. | |
| 339 | - add_filter( 'jetpack_open_graph_output', array( __CLASS__, 'twitter_cards_output' ) ); | |
| 340 | - add_filter( 'jetpack_twitter_cards_site_tag', array( __CLASS__, 'site_tag' ), -99 ); | |
| 341 | - add_filter( 'jetpack_twitter_cards_site_tag', array( __CLASS__, 'prioritize_creator_over_default_site' ), 99, 2 ); | |
| 342 | - add_action( 'admin_init', array( __CLASS__, 'settings_init' ) ); | |
| 343 | - add_action( 'sharing_global_options', array( __CLASS__, 'sharing_global_options' ) ); | |
| 344 | - add_action( 'sharing_admin_update', array( __CLASS__, 'settings_validate' ) ); | |
| 168 | + _deprecated_function( __METHOD__, '15.6', 'Automattic\Jetpack\Post_Media\Twitter_Cards::init' ); | |
| 169 | + Twitter_Cards::init(); | |
| 345 | 170 | } |
| 346 | 171 | } |
| 347 | 172 | |
| 348 | -Jetpack_Twitter_Cards::init(); | |
| 173 | +Twitter_Cards::init(); | |