true ) ) as $taxonomy ) { add_action( "{$taxonomy}_edit_form", array( $this, 'render' ), 20, 2 ); } } /** * Loads scripts on the term edit screen. * * @param string $hook Admin page hook. * @return void */ public function enqueue( $hook ) { if ( 'term.php' !== $hook ) { return; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading the term being edited. $term_id = isset( $_GET['tag_ID'] ) ? absint( $_GET['tag_ID'] ) : 0; $term = $term_id ? get_term( $term_id ) : null; if ( ! $term || is_wp_error( $term ) || ! is_taxonomy_viewable( $term->taxonomy ) ) { return; } $context = Context::for_term( $term ); $link = get_term_link( $term ); Metabox::enqueue_editor_assets( array( 'objectType' => 'term', 'objectId' => (int) $term->term_id, 'editor' => 'term', 'defaults' => array( 'title' => $context->setting_for( 'title' ), 'description' => $context->setting_for( 'description' ), ), 'variables' => Metabox::variable_values( $context ), 'permalink' => is_wp_error( $link ) ? home_url( '/' ) : $link, 'siteName' => get_bloginfo( 'name' ), 'homeUrl' => home_url( '/' ), 'favicon' => get_site_icon_url( 32 ), 'analysis' => false, 'readability' => false, 'locale' => get_locale(), 'defaultImage' => (string) wp_get_attachment_image_url( (int) Options::get( 'og_default_image_id' ), 'large' ), ) ); } /** * Prints the box below the term form fields. * * @param \WP_Term $term Term. * @param string $taxonomy Taxonomy. * @return void */ public function render( $term, $taxonomy ) { ?>