diff options
Diffstat (limited to 'plugins/jetpack/extensions/blocks/wordads/wordads.php')
-rw-r--r-- | plugins/jetpack/extensions/blocks/wordads/wordads.php | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/plugins/jetpack/extensions/blocks/wordads/wordads.php b/plugins/jetpack/extensions/blocks/wordads/wordads.php index 9f67d58b..0b76558c 100644 --- a/plugins/jetpack/extensions/blocks/wordads/wordads.php +++ b/plugins/jetpack/extensions/blocks/wordads/wordads.php @@ -4,10 +4,23 @@ * * @since 7.1.0 * - * @package Jetpack + * @package automattic/jetpack */ -class Jetpack_WordAds_Gutenblock { - const BLOCK_NAME = 'jetpack/wordads'; + +namespace Automattic\Jetpack\Extensions; + +use Automattic\Jetpack\Blocks; +use Jetpack; +use Jetpack_Gutenberg; + +/** + * Jetpack's Ads Block class. + * + * @since 7.1.0 + */ +class WordAds { + const FEATURE_NAME = 'wordads'; + const BLOCK_NAME = 'jetpack/' . self::FEATURE_NAME; /** * Check if site is on WP.com Simple. @@ -44,10 +57,10 @@ class Jetpack_WordAds_Gutenblock { */ public static function register() { if ( self::is_available() ) { - jetpack_register_block( + Blocks::jetpack_register_block( self::BLOCK_NAME, array( - 'render_callback' => array( 'Jetpack_WordAds_Gutenblock', 'gutenblock_render' ), + 'render_callback' => array( __CLASS__, 'gutenblock_render' ), ) ); } @@ -61,7 +74,7 @@ class Jetpack_WordAds_Gutenblock { Jetpack_Gutenberg::set_extension_unavailable( self::BLOCK_NAME, 'WordAds unavailable' ); return; } - // Make the block available. Just in case it wasn't registed before. + // Make the block available. Just in case it wasn't registered before. Jetpack_Gutenberg::set_extension_available( self::BLOCK_NAME ); } @@ -75,7 +88,7 @@ class Jetpack_WordAds_Gutenblock { public static function gutenblock_render( $attr ) { global $wordads; - /** This filter is already documented in modules/wordads/wordads.php `insert_ad()` */ + /** This filter is already documented in modules/wordads/class-wordads.php `insert_ad()` */ if ( empty( $wordads ) || empty( $wordads->params ) @@ -93,7 +106,7 @@ class Jetpack_WordAds_Gutenblock { return $wordads->get_ad( 'inline', 'house' ); } - // section_id is mostly depricated at this point, but it helps us (devs) keep track of which ads end up where + // section_id is mostly deprecated at this point, but it helps us (devs) keep track of which ads end up where // 6 is to keep track of gutenblock ads. $section_id = $wordads->params->blog_id . '6'; $align = 'center'; @@ -104,7 +117,7 @@ class Jetpack_WordAds_Gutenblock { $ad_tag_ids = $wordads->get_ad_tags(); $format = 'mrec'; - if ( isset( $attr['format'] ) && in_array( $attr['format'], array_keys( $ad_tag_ids ), true ) ) { + if ( isset( $attr['format'] ) && isset( $ad_tag_ids[ $attr['format'] ] ) ) { $format = $attr['format']; } @@ -115,12 +128,5 @@ class Jetpack_WordAds_Gutenblock { } } -add_action( - 'init', - array( 'Jetpack_WordAds_Gutenblock', 'register' ) -); - -add_action( - 'jetpack_register_gutenberg_extensions', - array( 'Jetpack_WordAds_Gutenblock', 'set_availability' ) -); +add_action( 'init', array( 'Automattic\\Jetpack\\Extensions\\WordAds', 'register' ) ); +add_action( 'jetpack_register_gutenberg_extensions', array( 'Automattic\\Jetpack\\Extensions\\WordAds', 'set_availability' ) ); |