$sc_product_templates, 'sc_product' => $sc_product_templates, ]; $template_id = \Bricks\Database::find_template_id( $template_ids, 'content', 'sc_product', get_the_ID(), 'single' ); $active_templates['content'] = $template_id; return $active_templates; } /** * Set the default template for the post type. * This will only apply if the post has not been edited directly by bricks. * * @param array $active_templates Active templates. * @param int $post_id Post ID. * @param string $content_type Content type. * * @return self */ public function setDefaultCollectionTemplate( $active_templates, $post_id, $content_type ) { // Only run my logic on the frontend. if ( ! bricks_is_frontend() ) { return $active_templates; } // Return if single post $content_type is not 'content'. if ( 'archive' !== $content_type ) { return $active_templates; } if ( ! is_tax( 'sc_collection' ) ) { return $active_templates; } if ( ! empty( $active_templates['archive'] ) ) { return $active_templates; } $collection_templates = \Bricks\Templates::get_templates_by_type( 'sc_collection' ); $template_ids = [ 'body' => $collection_templates, 'sc_collection' => $collection_templates, ]; $template_id = \Bricks\Database::find_template_id( $template_ids, 'content', 'sc_collection', get_the_ID(), 'archive' ); $active_templates['archive'] = $template_id; // Set the post content with the template's content. $active_templates['content'] = $template_id; return $active_templates; } /** * Add template types to control options * * @param array $control_options Control options. * * @return array */ public function addTemplateTypes( $control_options ) { $control_options['templateTypes']['sc_product'] = esc_html__( 'SureCart - Single Product', 'surecart' ); $control_options['templateTypes']['sc_collection'] = esc_html__( 'SureCart - Collection Archive', 'surecart' ); return $control_options; } /** * Remove query args for editor. * * @param array $query_args Query arguments. */ public function removeQueryArgsForEditor( array $query_args ): array { // Return if bricks is not loaded. if ( ! function_exists( 'bricks_is_frontend' ) || ! function_exists( 'bricks_is_builder_call' ) ) { return $query_args; } // Return if not frontend or builder call. if ( bricks_is_frontend() && ! bricks_is_builder_call() ) { return $query_args; } if ( isset( $query_args['post__in'] ) ) { unset( $query_args['post__in'] ); } return $query_args; } }