is_post_editor_page(), $editor_id ) ) { return; } // Setup the icon - currently using a dashicon. $icon = ''; printf( '%s %s', esc_attr( $editor_id ), esc_attr__( 'Add Form', 'wpforms-lite' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $icon, esc_html__( 'Add Form', 'wpforms-lite' ) ); $min = wpforms_get_min_suffix(); // If we have made it this far then load the JS. wp_enqueue_script( 'wpforms-editor', WPFORMS_PLUGIN_URL . "assets/js/admin-editor{$min}.js", [ 'jquery' ], WPFORMS_VERSION, true ); add_action( 'admin_footer', [ $this, 'shortcode_modal' ] ); } /** * Check if we are on the post editor admin page. * * @since 1.6.2 * * @returns boolean True if it is post editor admin page. */ public function is_post_editor_page() { if ( ! is_admin() ) { return false; } // get_current_screen() is loaded after 'admin_init' hook and may not exist yet. if ( ! function_exists( 'get_current_screen' ) ) { return false; } $screen = get_current_screen(); return $screen !== null && $screen->parent_base === 'edit'; } /** * Modal window for inserting the form shortcode into TinyMCE. * * Thickbox is old and busted so we don't use that. Creating a custom view in * Backbone would make me pull my hair out. So instead we offer a small clean * modal that is based off of the WordPress insert link modal. * * @since 1.0.0 */ public function shortcode_modal() { ?>