Files
carpseeds.pl/wp-content/plugins/jet-woo-builder/includes/documents/class-jet-woo-builder-document-single.php
2024-07-15 11:28:08 +02:00

76 lines
1.3 KiB
PHP

<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Jet_Woo_Builder_Document extends Jet_Woo_Builder_Document_Base {
/**
* @access public
*/
public function get_name() {
return 'jet-woo-builder';
}
/**
* @access public
* @static
*/
public static function get_title() {
return __( 'Jet Woo Template Single', 'jet-woo-builder' );
}
/**
* @access public
*/
public function get_wp_preview_url() {
$main_post_id = $this->get_main_id();
$sample_product = get_post_meta( $main_post_id, '_sample_product', true );
if ( ! $sample_product ) {
$sample_product = $this->query_first_product();
}
$product_id = $sample_product;
return add_query_arg(
array(
'preview_nonce' => wp_create_nonce( 'post_preview_' . $main_post_id ),
'jet_woo_template' => $main_post_id,
),
get_permalink( $product_id )
);
}
/**
* Return preview query args
*
* @return array
*/
public function get_preview_as_query_args() {
jet_woo_builder()->documents->set_current_type( $this->get_name() );
$args = array();
$product = $this->query_first_product();
if ( ! empty( $product ) ) {
$args = array(
'post_type' => 'product',
'p' => $product,
);
}
return $args;
}
}