includes(); $this->init(); add_action( 'wp_head', [ $this, 'print_schema' ] ); add_filter( 'init', [ $this, 'shortcode' ] ); add_action( 'wp_enqueue_scripts', [ $this, 'frontend_assets' ] ); add_filter( 'plugin_row_meta', [ $this, 'plugin_links' ], 10, 2 ); } /** * Include all files * * @since 1.0.0 * @access public * * @return void */ public function includes() { require_once WP_FAQ_SCHEMA_PATH . 'includes/class-option-page.php'; require_once WP_FAQ_SCHEMA_PATH . 'includes/class-metabox.php'; } /** * Initialize * * Initialize some classes which is not require hook. * * @since 1.0.0 * @access public * * @return void */ public function init() { new Metabox(); new Option_Page(); } /** * Print FAQ schema at Header * * @return void */ public function print_schema() { $faqs = get_post_meta( get_the_ID(), '_wp_faq_schema', true ); if ( ! is_singular() && ! is_tax() && ! is_category() && ! is_tag() ) { return; } if ( is_tax() || is_category() || is_tag() ) { $term = get_queried_object(); $faqs = get_term_meta( $term->term_id, '_wp_faq_schema', true ); } if ( empty( $faqs ) ) { return; } $schema_array = [ '@context' => 'https://schema.org', '@type' => 'FAQPage', 'mainEntity' => [], ]; if ( ! empty( $faqs ) ) { foreach ( $faqs as $faq ) { $schema_array['mainEntity'][] = [ '@type' => 'Question', 'name' => $faq['q'], 'acceptedAnswer' => [ '@type' => 'Answer', 'text' => $faq['a'], ], ]; } } ?> 0, 'title' => '', ), $atts ); $faqs = get_post_meta( get_the_ID(), '_wp_faq_schema', true ); if ( empty( $faqs ) ) { return ''; } $is_accordion = isset( $atts['accordion'] ) ? intval( $atts['accordion'] ) : 0; $wrap_class = [ 'wp-faq-schema-wrap' ]; if ( 1 === $is_accordion ) { $wrap_class[] = 'wp-faq-schema-accordion'; } ob_start(); ?>