Skip to content

Commit

Permalink
seperate pro features
Browse files Browse the repository at this point in the history
  • Loading branch information
devsabbirhossain committed Jan 14, 2025
1 parent 25084d9 commit c66c64c
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ languages/*.

# Build related files
/bin/strauss.phar
/bin
#/bin
build
12 changes: 12 additions & 0 deletions assets/css/frontend.scss
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,15 @@
.light-box-icon:hover {
background-color: rgba(0, 0, 0, 0.8);
}

.admin-bar {
.fancybox-toolbar{
margin-top: 30px;
}
.fancybox-progress {
margin-top: 31px;
}
.fancybox-infobar {
margin-top: 30px;
}
}
44 changes: 34 additions & 10 deletions assets/js/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,56 @@
});

function load_slider() {
var slider_settings = JSON.parse( WC_VARIATION_IMAGES.i18n.slider_data );
var enable_slider = "no" === slider_settings.enable_slider ? false : { delay: slider_settings.slider_delay, disableOnInteraction: false }
var navigation = "no" === slider_settings.hide_navigation ? false : {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
}
var swiper = new Swiper(".mySwiper", {
loop: true,
spaceBetween: 10,
slidesPerView: 4,
loop: slider_settings.loop ? slider_settings.loop : false,
spaceBetween: slider_settings.items_space ? slider_settings.items_space : 4,
slidesPerView: slider_settings.items_per_page ? slider_settings.items_per_page : 4,
freeMode: true,
watchSlidesProgress: true,
});
var swiper2 = new Swiper(".mySwiper2", {
loop: true,
spaceBetween: 10,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
loop: slider_settings.loop ? slider_settings.loop : false,
navigation: navigation,
autoplay: enable_slider,
effect: 'fade',
fadeEffect: {
crossFade: true
},
thumbs: {
swiper: swiper,
},
});

if( "no" === slider_settings.hide_navigation ) {
$(".swiper-button-next").hide();
$(".swiper-button-prev").hide();
}

var lightbox_data = JSON.parse( WC_VARIATION_IMAGES.i18n.lightbox_data );
$("[data-fancybox='gallery']").fancybox({
loop: true,
protect: true,
buttons: [
'fullScreen',
'close'
"zoom",
lightbox_data.slideShow,
lightbox_data.fullScreen,
lightbox_data.share,
"close"
],
zoom: {
enabled: true,
duration: 300
},
thumbs: {
autoStart: true,
axis: "x",
},
});
}

Expand Down
50 changes: 50 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
SLUG=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
WORKING_DIR=$(pwd)
ZIP_DIR=/tmp/${SLUG}

# If slug is not set, exit
if [ -z "$SLUG" ]; then
echo "Slug not set. Exiting."
exit 1
fi
echo "➤ Preparing zip for $VERSION of $SLUG..."

echo "➤ Building plugin..."
composer install
composer update --no-dev
npm install && npm run build
echo "✓ Plugin built!"

# if directory already exists, delete it
if [ -d "$ZIP_DIR" ]; then
rm -rf $ZIP_DIR
fi

echo "➤ Creating ZIP directory..."
mkdir -p "$ZIP_DIR"
echo "✓ ZIP directory created!"

echo "➤ Copying files..."
# If .distignore file exists, use it to exclude files from the SVN repo, otherwise use the default.
if [[ -r "$WORKING_DIR/.distignore" ]]; then
echo "ℹ︎ Using .distignore"
rsync -rc --exclude-from="$WORKING_DIR/.distignore" "$WORKING_DIR/" "$ZIP_DIR/" --delete --delete-excluded
echo "✓ Files copied!"
fi

# Remove empty directories from trunk
find "$ZIP_DIR/" -type d -empty -delete

ZIP_NAME="$SLUG-v$VERSION.zip"
echo "➤ Creating ZIP file..."
# cd to the one level above the ZIP directory and zip it up
cd "$ZIP_DIR/.." || exit 1
zip -q -r "$ZIP_NAME" "${SLUG}/"
mv "$ZIP_NAME" "$WORKING_DIR/"
echo "✓ ZIP file created!"

echo "➤ Cleaning up..."
rm -rf "$ZIP_DIR"
echo "✓ Done!"
4 changes: 2 additions & 2 deletions includes/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public function admin_template_js() {
public function admin_menu() {
add_submenu_page(
'woocommerce',
__( 'Variation Image', 'wc-variation-images' ),
__( 'Variation Image', 'wc-variation-images' ),
__( 'Variation Images', 'wc-variation-images' ),
__( 'Variation Images', 'wc-variation-images' ),
'manage_options',
'wc-variation-images',
array( Settings::class, 'output' )
Expand Down
28 changes: 28 additions & 0 deletions includes/Controllers/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,32 @@ public static function gallery_position_list() {

return apply_filters( 'wc_variation_images_gallery_positions', $positions );
}

/**
* Lightbox Settings.
*
* @since 1.0.0
* @return string
*/
public static function get_lightbox_data() {
$lightbox_config = array();

$lightbox_config = apply_filters( 'wc_variation_images_lightbox_config', $lightbox_config );
$lightbox_config = wp_json_encode( $lightbox_config );
return $lightbox_config;
}

/**
* Slider Settings.
*
* @since 1.0.0
* @return string
*/
public static function get_slider_data() {
$slider_config = array();

$slider_config = apply_filters( 'wc_variation_images_slider_config', $slider_config );
$slider_config = wp_json_encode( $slider_config );
return $slider_config;
}
}
4 changes: 4 additions & 0 deletions includes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WooCommerceVariationImages;

use WooCommerceVariationImages\Controllers\Helpers;

defined( 'ABSPATH' ) || exit;

/**
Expand Down Expand Up @@ -155,6 +157,8 @@ public function frontend_scripts_handler() {
'nonce' => wp_create_nonce( 'wc_variation_images_ajax' ),
'i18n' => array(
'hide_image_zoom' => get_option( 'wc_variation_images_hide_image_zoom', 'no' ),
'lightbox_data' => Helpers::get_lightbox_data(),
'slider_data' => Helpers::get_slider_data(),
),
)
);
Expand Down
15 changes: 9 additions & 6 deletions includes/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct() {
add_filter( 'wc_get_template', array( $this, 'gallery_template_override' ), 60, 2 );
add_action( 'wp', array( $this, 'wc_variation_images_gallery_control' ), 100 );
add_action( 'woocommerce_product_after_variable_attributes', array( $this, 'wc_variation_images_upload_images' ), 10, 3 );
add_action( 'woocommerce_product_thumbnails', array( $this, 'replace_variable_product_image' ) );
/** add_action( 'woocommerce_product_thumbnails', array( $this, 'replace_variable_product_image' ) ); */
}

/**
Expand All @@ -44,11 +44,14 @@ public function gallery_template_override( $template, $template_name ) {
return $old_template;
}

if ( 'single-product/product-image.php' === $template_name ) {
if ( 'no' === get_option( 'wc_variation_images_hide_image_slider', 'no' ) ) {
$template = WC_VARIATION_IMAGES_TEMPLATES_DIR . '/product-image-slider.php';
} else {
$template = WC_VARIATION_IMAGES_TEMPLATES_DIR . '/product-image.php';
$product = wc_get_product();
if ( 'variable' === $product->get_type() ) {
if ( 'single-product/product-image.php' === $template_name ) {
if ( 'no' === get_option( 'wc_variation_images_hide_image_slider', 'no' ) ) {
$template = WC_VARIATION_IMAGES_TEMPLATES_DIR . '/product-image-slider.php';
} else {
$template = WC_VARIATION_IMAGES_TEMPLATES_DIR . '/product-image.php';
}
}
}

Expand Down
55 changes: 32 additions & 23 deletions languages/wc-variation-images.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WC Variation Images 1.2.0\n"
"Report-Msgid-Bugs-To: https://pluginever.com/support/\n"
"POT-Creation-Date: 2025-01-07 08:50:36+00:00\n"
"POT-Creation-Date: 2025-01-12 04:34:21+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand All @@ -25,7 +25,8 @@ msgstr ""
"X-Generator: grunt-wp-i18n 1.0.3\n"

#: includes/Admin/Admin.php:78 includes/Admin/Admin.php:80
#: includes/Products.php:81
#: includes/Admin/Admin.php:111 includes/Admin/Admin.php:112
#: includes/Products.php:147
msgid "Variation Images"
msgstr ""

Expand All @@ -43,10 +44,6 @@ msgid ""
"remove the image. Click and drag image to re-order the image position."
msgstr ""

#: includes/Admin/Admin.php:111 includes/Admin/Admin.php:112
msgid "Variation Image"
msgstr ""

#: includes/Admin/Admin.php:131
#. translators: 1: Plugin name 2: WordPress
msgid ""
Expand All @@ -63,53 +60,61 @@ msgstr ""
msgid "Version %s"
msgstr ""

#: includes/Admin/Settings.php:23
#: includes/Admin/Settings.php:25
msgid "General"
msgstr ""

#: includes/Admin/Settings.php:42
msgid "General settings"
#: includes/Admin/Settings.php:44
msgid "Gallery settings"
msgstr ""

#: includes/Admin/Settings.php:44
#: includes/Admin/Settings.php:46
msgid "The following options affect how the plugin will work."
msgstr ""

#: includes/Admin/Settings.php:49
#: includes/Admin/Settings.php:51
msgid "Hide Image Zoom"
msgstr ""

#: includes/Admin/Settings.php:50
#: includes/Admin/Settings.php:52
msgid "Hide image zoom for variable product"
msgstr ""

#: includes/Admin/Settings.php:54 includes/Admin/Settings.php:65
#: includes/Admin/Settings.php:76
#: includes/Admin/Settings.php:56 includes/Admin/Settings.php:68
#: includes/Admin/Settings.php:80
msgid "No"
msgstr ""

#: includes/Admin/Settings.php:55 includes/Admin/Settings.php:66
#: includes/Admin/Settings.php:77
#: includes/Admin/Settings.php:57 includes/Admin/Settings.php:69
#: includes/Admin/Settings.php:81
msgid "Yes"
msgstr ""

#: includes/Admin/Settings.php:60
#: includes/Admin/Settings.php:63
msgid "Hide Lightbox"
msgstr ""

#: includes/Admin/Settings.php:61
#: includes/Admin/Settings.php:64
msgid "Hide image lightbox for variable product"
msgstr ""

#: includes/Admin/Settings.php:71
#: includes/Admin/Settings.php:75
msgid "Hide Image Slider"
msgstr ""

#: includes/Admin/Settings.php:72
#: includes/Admin/Settings.php:76
msgid "Hide image slider for variable product"
msgstr ""

#: includes/Admin/Settings.php:120
#: includes/Admin/Settings.php:87
msgid "Gallery Position"
msgstr ""

#: includes/Admin/Settings.php:88 includes/Admin/Settings.php:89
msgid "Set Gallery image position"
msgstr ""

#: includes/Admin/Settings.php:134
#: vendor-prefixed/byteever/bytekit-plugin/src/Traits/HasPlugin.php:216
msgid "Documentation"
msgstr ""
Expand Down Expand Up @@ -186,6 +191,10 @@ msgstr ""
msgid "Upgrade now"
msgstr ""

#: includes/Controllers/Helpers.php:23
msgid "Bottom"
msgstr ""

#: includes/Plugin.php:106
#. translators: 1: plugin name 2: WooCommerce
msgid "%1$s requires %2$s to be installed and active."
Expand All @@ -195,11 +204,11 @@ msgstr ""
msgid "WooCommerce"
msgstr ""

#: includes/Products.php:105
#: includes/Products.php:171
msgid "Add Variation Images"
msgstr ""

#: includes/functions.php:98
#: includes/functions.php:102 templates/product-image.php:75
msgid "Awaiting product image"
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c66c64c

Please sign in to comment.