__( 'No FAQs match your search.', 'accordion-faq-plugin' ), 'resultsOne' => __( '1 FAQ found.', 'accordion-faq-plugin' ), /* translators: %d: number of FAQs matching the search query. */ 'resultsMany' => __( '%d FAQs found.', 'accordion-faq-plugin' ), 'expandAll' => __( 'Expand all', 'accordion-faq-plugin' ), 'collapseAll' => __( 'Collapse all', 'accordion-faq-plugin' ), 'rest' => esc_url_raw( rest_url( 'accordion-faq/v1/' ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), ) ); } /** * Auto-enqueue on singular content that contains our shortcode or block. * * @return void */ public function maybe_autoload() { if ( is_singular() ) { $post = get_post(); if ( $post instanceof \WP_Post ) { $content = (string) $post->post_content; if ( has_shortcode( $content, 'quick_faq' ) || has_shortcode( $content, 'accordion_faq' ) || has_shortcode( $content, 'accordion_faq_submit' ) || has_block( 'accordion-faq/faq', $post ) ) { self::enqueue(); } } } } /** * Enqueue the frontend assets. Safe to call multiple times and late * (WordPress prints late-enqueued styles/scripts in the footer). * * @return void */ public static function enqueue() { if ( ! self::$registered ) { // Registration hasn't run yet (e.g. very early call); register now. $assets = new self(); $assets->register_assets(); } wp_enqueue_style( self::HANDLE ); wp_enqueue_script( self::HANDLE ); } }