plugin_name = $plugin_name;
$this->version = $version;
$this->settings = $this->get_settings();
$this->load_dependencies();
}
/**
* Load the required dependencies for this plugin.
*
* Include the following files that make up the plugin:
*
* - Woo_Scratch_Coupon_Card_Default.
*
* @since 1.0.0
* @access private
*/
private function load_dependencies() {
/**
* The class responsible for defining default value
* of the plugin.
*/
}
/**
* Register the stylesheets for the public-facing side of the site.
*
* @since 1.0.0
*/
public function enqueue_styles() {
wp_enqueue_style( $this->plugin_name, plugins_url( '/assets/fancybox/jquery.fancybox.min.css', THREED_PLUGIN_FILE ), array(), $this->version, 'all' );
}
/**
* Register the JavaScript for the public-facing side of the site.
*
* @since 1.0.0
*/
public function enqueue_scripts() {
wp_enqueue_script( $this->plugin_name . '-fancybox', plugins_url( '/assets/fancybox/jquery.fancybox.min.js', THREED_PLUGIN_FILE ), array( 'jquery' ), $this->version, false );
}
/**
* Footer callback to add fancybox script.
*
* @since 1.0.0
*/
public function wp_footer_callback() {
?>
settings = get_option( 'settings-threed-iframe' );
return $this->settings;
}
/**
* Initialize threedvieweronline.
*
* @since 1.0.0
* @return void.
*/
public function threedvieweronline_init_callback() {
add_shortcode( '3Dvo-model', array( $this, 'threedvieweronline_shortcode' ) );
}
/**
* Outputs the data for the shortcode.
*
* @since 1.0.0
* @param array $atts The attributes passed.
* @return html.
*/
public function threedvieweronline_shortcode( $atts ) {
if ( ! is_array( $atts ) ) {
return ''; }
$atts = shortcode_atts(
array(
'url' => '#',
'id' => '3Dvo-model',
'width' => '100%',
'height' => '500px',
'autosize' => true,
'border' => '0',
'scroll' => 'no',
),
$atts,
'THREED'
);
if ( ! filter_var( $atts['url'], FILTER_VALIDATE_URL ) ) {
return '';
}
return '';
}
/**
* Initialize product tab.
*
* @since 1.0.0
* @param array $tabs The tabs array.
* @return html.
*/
public function threed_woo_new_product_tab( $tabs ) {
if ( isset( $this->settings['threed_enable_product_tab'] ) && 'on' === $this->settings['threed_enable_product_tab'] ) {
$title = '3D model';
if ( isset( $this->settings['threed_tab_title'] ) && '' !== $this->settings['threed_tab_title'] ) {
$title = $this->settings['threed_tab_title'];
}
global $product;
$id = $product->get_id();
$value = get_post_meta( $id, 'threed_model_url', true );
if ( '' !== $value ) {
$tabs['desc_tab'] = array(
'title' => esc_html( $title ),
'priority' => 50,
'callback' => array( $this, 'threed_woo_new_product_tab_content' ),
);
}
}
return $tabs;
}
/**
* Display content for the custom WooCommerce product tab.
*
* This function is responsible for rendering the content inside the custom tab
* on the WooCommerce single product page.
*
* @return void
*/
public function threed_woo_new_product_tab_content() {
global $product;
$id = $product->get_id();
$url = get_post_meta( $id, 'threed_model_url', true );
$pwidth = '';
$pheight = '';
$pwidth = get_post_meta( $id, 'threed_piframe_width', true );
$pheight = get_post_meta( $id, 'threed_piframe_height', true );
if ( '' === $pwidth ) {
if ( isset( $this->settings['threed_iframe_width'] ) && '' !== $this->settings['threed_iframe_width'] ) {
$pwidth = $this->settings['threed_iframe_width'];
} else {
$pwidth = '100%';
}
}
if ( '' === $pheight ) {
if ( isset( $this->settings['threed_iframe_height'] ) && '' !== $this->settings['threed_iframe_height'] ) {
$pheight = $this->settings['threed_iframe_height'];
} else {
$pheight = '500px';
}
}
if ( '' !== $url ) {
echo '';
}
}
/**
* Callback function for the WooCommerce single product summary.
*
* Add Icon to product summary if that is selected in settings.
*
* @return void
*/
public function woocommerce_single_product_summary_callback() {
if ( isset( $this->settings['threed_icon_display'] ) && 'after-product-title' === $this->settings['threed_icon_display'] ) {
$this->add_threed_icon();
}
}
/**
* Callback function for the WooCommerce before add to cart form hook.
*
* Add Icon to product before add to cart if that is selected in settings.
*
* @return void
*/
public function woocommerce_before_add_to_cart_form_callback() {
if ( isset( $this->settings['threed_icon_display'] ) && 'after-product-short-description' === $this->settings['threed_icon_display'] ) {
$this->add_threed_icon();
}
}
/**
* Callback function for the WooCommerce after add to cart form hook.
*
* Add Icon to product after add to cart if that is selected in settings.
*
* @return void
*/
public function woocommerce_after_add_to_cart_form_callback() {
if ( isset( $this->settings['threed_icon_display'] ) && 'after-add-to-cart-button' === $this->settings['threed_icon_display'] ) {
$this->add_threed_icon();
}
}
/**
* Add icon.
*
* Outputs the icon html.
*
* @return void
*/
public function add_threed_icon() {
if ( isset( $this->settings['threed_enable_product_icon'] ) && 'on' === $this->settings['threed_enable_product_icon'] ) {
$icon = plugins_url( 'assets/images/logo.png', THREED_PLUGIN_FILE );
if ( isset( $this->settings['threed_icon'] ) && '' !== $this->settings['threed_icon'] ) {
$icon = $this->settings['threed_icon'];
}
global $product;
$id = $product->get_id();
$url = get_post_meta( $id, 'threed_model_url', true );
$attachment_id = attachment_url_to_postid( $url );
if ( 0 === $attachment_id ) {
$image = '
';
} else {
$image = wp_get_attachment_image( $attachment_id );
}
$pwidth = '';
$pheight = '';
$pwidth = get_post_meta( $id, 'threed_piframe_width', true );
$pheight = get_post_meta( $id, 'threed_piframe_height', true );
if ( '' === $pwidth ) {
if ( isset( $this->settings['threed_iframe_width'] ) && '' !== $this->settings['threed_iframe_width'] ) {
$pwidth = $this->settings['threed_iframe_width'];
} else {
$pwidth = '100%';
}
}
if ( '' === $pheight ) {
if ( isset( $this->settings['threed_iframe_height'] ) && '' !== $this->settings['threed_iframe_height'] ) {
$pheight = $this->settings['threed_iframe_height'];
} else {
$pheight = '500px';
}
}
$pos = strpos( $pwidth, '%' );
if ( false === $pos ) {
$pos1 = strpos( $pwidth, 'px' );
if ( false === $pos1 ) {
$pwidth = $pwidth . 'px';
}
}
$pos = strpos( $pheight, '%' );
if ( false === $pos ) {
$pos1 = strpos( $pheight, 'px' );
if ( false === $pos1 ) {
$pheight = $pheight . 'px';
}
}
if ( '' !== $url ) {
echo '' . wp_kses_post( $image ) . '';
echo '';
}
}
}
}