Changeset 2952022
- Timestamp:
- 08/11/2023 07:35:01 AM (3 years ago)
- Location:
- woo-advanced-product-information/trunk
- Files:
-
- 10 edited
-
CHANGELOG.txt (modified) (1 diff)
-
admin/settings.php (modified) (7 diffs)
-
frontend/instock.php (modified) (1 diff)
-
frontend/orders.php (modified) (2 diffs)
-
frontend/rank.php (modified) (1 diff)
-
frontend/recent.php (modified) (4 diffs)
-
includes/data.php (modified) (1 diff)
-
includes/support.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
woo-advanced-product-information.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-advanced-product-information/trunk/CHANGELOG.txt
r2760148 r2952022 1 /*1.1.0 - 2023.08.11*/ 2 - Updated: Compatible with WooCommerce HPOS 3 1 4 /*1.0.10 - 2022.07.22*/ 2 5 - Updated: VillaTheme_Support -
woo-advanced-product-information/trunk/admin/settings.php
r2760148 r2952022 300 300 <tr> 301 301 <th> 302 <label for="review-include-category"><?php esc_html_e( 'Include categor ys', 'woocommerce-advanced-category-information' ); ?></label>302 <label for="review-include-category"><?php esc_html_e( 'Include categories', 'woocommerce-advanced-category-information' ); ?></label> 303 303 </th> 304 304 <td> … … 656 656 <tr> 657 657 <th> 658 <label for="instock-include-category"><?php esc_html_e( 'Include categor ys', 'woocommerce-advanced-category-information' ); ?></label>658 <label for="instock-include-category"><?php esc_html_e( 'Include categories', 'woocommerce-advanced-category-information' ); ?></label> 659 659 </th> 660 660 <td> … … 906 906 <tr> 907 907 <th> 908 <label for="sale-include-category"><?php esc_html_e( 'Include categor ys', 'woocommerce-advanced-category-information' ); ?></label>908 <label for="sale-include-category"><?php esc_html_e( 'Include categories', 'woocommerce-advanced-category-information' ); ?></label> 909 909 </th> 910 910 <td> … … 1184 1184 <tr> 1185 1185 <th> 1186 <label for="countdown-include-category"><?php esc_html_e( 'Include categor ys', 'woocommerce-advanced-category-information' ); ?></label>1186 <label for="countdown-include-category"><?php esc_html_e( 'Include categories', 'woocommerce-advanced-category-information' ); ?></label> 1187 1187 </th> 1188 1188 <td> … … 1470 1470 <tr> 1471 1471 <th> 1472 <label for="recent-include-category"><?php esc_html_e( 'Include categor ys', 'woocommerce-advanced-category-information' ); ?></label>1472 <label for="recent-include-category"><?php esc_html_e( 'Include categories', 'woocommerce-advanced-category-information' ); ?></label> 1473 1473 </th> 1474 1474 <td> … … 1754 1754 <tr> 1755 1755 <th> 1756 <label for="rank-include-category"><?php esc_html_e( 'Include categor ys', 'woocommerce-advanced-category-information' ); ?></label>1756 <label for="rank-include-category"><?php esc_html_e( 'Include categories', 'woocommerce-advanced-category-information' ); ?></label> 1757 1757 </th> 1758 1758 <td> … … 2598 2598 <tr> 2599 2599 <th> 2600 <label for="orders-include-category"><?php esc_html_e( 'Include categor ys', 'woocommerce-advanced-category-information' ); ?></label>2600 <label for="orders-include-category"><?php esc_html_e( 'Include categories', 'woocommerce-advanced-category-information' ); ?></label> 2601 2601 </th> 2602 2602 <td> -
woo-advanced-product-information/trunk/frontend/instock.php
r2760148 r2952022 157 157 $today = strtotime( 'today' ); 158 158 $product_id = $product->get_id(); 159 if ( get_post_meta( $product_id, '_wapi_fake_stock', true ) && get_post_meta( $product_id, '_wapi_fake_stock', true )['day'] == $today ) { 160 $product_left_fake = absint( get_post_meta( $product_id, '_wapi_fake_stock', true )['amount'] ); 161 } else { 162 $product_left_fake = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) ); 163 update_post_meta( $product_id, '_wapi_fake_stock', array( 164 'day' => $today, 165 'amount' => $product_left_fake, 166 'barwidth' => $this->barwidth, 167 ) ); 168 } 169 if ( 1 == $this->settings['fake'] ) { 170 if ( $product->get_manage_stock() ) { 171 if ( $product->is_in_stock() ) { 172 $product_left = $product->get_stock_quantity(); 173 } else { 174 return; 159 if (!empty($this->settings['fake'])){ 160 if ($product->is_in_stock()){ 161 $fake_stock = $product->get_meta('_wapi_fake_stock'); 162 if ($fake_stock && 163 isset($fake_stock['day'],$fake_stock['amount'],$fake_stock['min'],$fake_stock['max']) && 164 $fake_stock['day'] == $today && $fake_stock['min'] == $this->settings['minrand'] && $fake_stock['max'] != $this->settings['maxrand']){ 165 $product_left_fake = absint( $fake_stock['amount'] ); 166 }else{ 167 $product_left_fake = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) ); 168 $product->add_meta_data( 169 '_wapi_fake_stock', 170 array( 171 'day' => $today, 172 'amount' => $product_left_fake, 173 'barwidth' => $this->barwidth, 174 'min' => $this->settings['minrand'], 175 'max' => $this->settings['maxrand'], 176 ), 177 true); 175 178 } 176 } elseif ( $product->is_in_stock() ) {177 179 $product_left = $product_left_fake; 178 } else{180 }else{ 179 181 return; 180 182 } 181 182 183 } elseif ( $product->get_type() == 'simple' && $product->is_in_stock() ) { 183 }elseif ( $product->get_type() == 'simple' && $product->is_in_stock() ) { 184 184 185 185 $product_left = $product->get_stock_quantity(); 186 186 187 187 } 188 // if ( get_post_meta( $product_id, '_wapi_fake_stock', true ) && get_post_meta( $product_id, '_wapi_fake_stock', true )['day'] == $today ) { 189 // $product_left_fake = absint( get_post_meta( $product_id, '_wapi_fake_stock', true )['amount'] ); 190 // } else { 191 // $product_left_fake = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) ); 192 // update_post_meta( $product_id, '_wapi_fake_stock', array( 193 // 'day' => $today, 194 // 'amount' => $product_left_fake, 195 // 'barwidth' => $this->barwidth, 196 // ) ); 197 // } 198 // if ( 1 == $this->settings['fake'] ) { 199 // if ( $product->get_manage_stock() ) { 200 // if ( $product->is_in_stock() ) { 201 // $product_left = $product->get_stock_quantity(); 202 // } 203 // } elseif ( $product->is_in_stock() ) { 204 // $product_left = $product_left_fake; 205 // } 206 // 207 // 208 // } elseif ( $product->get_type() == 'simple' && $product->is_in_stock() ) { 209 // 210 // $product_left = $product->get_stock_quantity(); 211 // 212 // } 188 213 if ( $product_left < 1 ) { 189 214 return; -
woo-advanced-product-information/trunk/frontend/orders.php
r2363640 r2952022 127 127 $product_id = $product->get_id(); 128 128 $order_status = array( 'wc-processing', 'wc-completed' ); 129 $results = $wpdb->get_col( " 130 SELECT order_items.order_id 131 FROM {$wpdb->prefix}woocommerce_order_items as order_items 132 LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id 133 LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID 134 WHERE posts.post_type = 'shop_order' 135 AND posts.post_status IN ( '" . implode( "','", $order_status ) . "' ) 136 AND order_items.order_item_type = 'line_item' 137 AND order_item_meta.meta_key = '_product_id' 138 AND order_item_meta.meta_value = '$product_id' 139 ORDER BY posts.ID DESC 140 LIMIT $limit" ); 129 130 if ( class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) && \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled() ) { 131 $query = "SELECT order_items.order_id 132 FROM {$wpdb->prefix}woocommerce_order_items as order_items 133 LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id 134 LEFT JOIN {$wpdb->prefix}wc_orders AS posts ON order_items.order_id = posts.id 135 WHERE posts.type = 'shop_order' 136 AND posts.status IN ( '" . implode( "','", $order_status ) . "' ) 137 AND order_items.order_item_type = 'line_item' 138 AND order_item_meta.meta_key = '_product_id' 139 AND order_item_meta.meta_value = '$product_id' 140 ORDER BY posts.id DESC 141 LIMIT $limit"; 142 } else { 143 $query = "SELECT order_items.order_id 144 FROM {$wpdb->prefix}woocommerce_order_items as order_items 145 LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id 146 LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID 147 WHERE posts.post_type = 'shop_order' 148 AND posts.post_status IN ( '" . implode( "','", $order_status ) . "' ) 149 AND order_items.order_item_type = 'line_item' 150 AND order_item_meta.meta_key = '_product_id' 151 AND order_item_meta.meta_value = '$product_id' 152 ORDER BY posts.ID DESC 153 LIMIT $limit"; 154 } 155 156 $results = $wpdb->get_col( $query ); 157 141 158 if ( count( $results ) ) { 142 159 $customers = array(); … … 176 193 $product_id = $product->get_id(); 177 194 $order_status = array( 'wc-processing', 'wc-completed' ); 178 $results = $wpdb->get_col( " 179 SELECT order_items.order_id 180 FROM {$wpdb->prefix}woocommerce_order_items as order_items 181 LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id 182 LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID 183 WHERE posts.post_type = 'shop_order' 184 AND posts.post_status IN ( '" . implode( "','", $order_status ) . "' ) 185 AND order_items.order_item_type = 'line_item' 186 AND order_item_meta.meta_key = '_product_id' 187 AND order_item_meta.meta_value = '$product_id' 188 ORDER BY posts.ID DESC 189 LIMIT $limit" ); 195 196 if ( class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) && \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled() ) { 197 $query = "SELECT order_items.order_id 198 FROM {$wpdb->prefix}woocommerce_order_items as order_items 199 LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id 200 LEFT JOIN {$wpdb->prefix}wc_orders AS posts ON order_items.order_id = posts.id 201 WHERE posts.type = 'shop_order' 202 AND posts.status IN ( '" . implode( "','", $order_status ) . "' ) 203 AND order_items.order_item_type = 'line_item' 204 AND order_item_meta.meta_key = '_product_id' 205 AND order_item_meta.meta_value = '$product_id' 206 ORDER BY posts.id DESC 207 LIMIT $limit"; 208 } else { 209 $query = "SELECT order_items.order_id 210 FROM {$wpdb->prefix}woocommerce_order_items as order_items 211 LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id 212 LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID 213 WHERE posts.post_type = 'shop_order' 214 AND posts.post_status IN ( '" . implode( "','", $order_status ) . "' ) 215 AND order_items.order_item_type = 'line_item' 216 AND order_item_meta.meta_key = '_product_id' 217 AND order_item_meta.meta_value = '$product_id' 218 ORDER BY posts.ID DESC 219 LIMIT $limit"; 220 } 221 222 $results = $wpdb->get_col( $query ); 223 190 224 if ( count( $results ) ) { 191 225 $customers = array(); -
woo-advanced-product-information/trunk/frontend/rank.php
r2363640 r2952022 538 538 ) 539 539 ); 540 $orders = array(); 541 $query = new WP_Query( $args ); 542 if ( $query->have_posts() ) { 543 while ( $query->have_posts() ) { 544 $query->the_post(); 545 $orders[] = get_the_ID(); 546 } 547 wp_reset_postdata(); 548 } 549 if ( count( $orders ) ) { 550 foreach ( $orders as $order1 ) { 551 $order = wc_get_order( $order1 ); 552 //if product is in the order, increase the quantity 540 541 $orders = wc_get_orders( $args ); 542 543 if ( ! empty( $orders ) ) { 544 foreach ( $orders as $order ) { 553 545 foreach ( $order->get_items() as $item_data ) { 554 546 if ( $product_id == $item_data->get_product_id() ) { -
woo-advanced-product-information/trunk/frontend/recent.php
r2363640 r2952022 107 107 } 108 108 wp_add_inline_style( 'wapinfo-frontend-recent-style', $css ); 109 109 110 switch ( $this->settings['position'] ) { 110 111 case 'before_cart': … … 130 131 131 132 if ( 1 === $this->settings['fake'] ) { 132 if ( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true ) && get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['day'] == $today ) { 133 $qty = absint( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['amount'] ); 133 $fake = $product->get_meta( '_wapi_recent_quantity_virtual' ); 134 if ( $fake && 135 isset( $fake['day'], $fake['amount'], $fake['min'], $fake['max'] ) && 136 $fake['day'] == $today && $fake['min'] == $this->settings['minrand'] && $fake['max'] != $this->settings['maxrand'] ) { 137 $qty = absint( $fake['amount'] ); 134 138 } else { 135 139 $qty = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) ); 136 update_post_meta( $product_id, '_wapi_recent_quantity_virtual', array( 137 'day' => $today, 138 'amount' => $qty 139 ) ); 140 } 140 $product->add_meta_data( 141 '_wapi_recent_quantity_virtual', 142 array( 143 'day' => $today, 144 'amount' => $qty, 145 'min' => $this->settings['minrand'], 146 'max' => $this->settings['maxrand'], 147 ), 148 true ); 149 } 150 // if ( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true ) && get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['day'] == $today ) { 151 // $qty = absint( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['amount'] ); 152 // } else { 153 // $qty = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) ); 154 // update_post_meta( $product_id, '_wapi_recent_quantity_virtual', array( 155 // 'day' => $today, 156 // 'amount' => $qty 157 // ) ); 158 // } 159 } else { 160 $from = $today - $range * 24 * 3600; 161 $recent_quantity = get_post_meta( $product_id, '_wapi_recent_quantity', true ); 162 163 if ( ! $recent_quantity || $recent_quantity['day'] != $today ) { 164 $qty = self::sold_quantity( $product_id, $from, $today ); 165 update_post_meta( $product_id, '_wapi_recent_quantity', array( 'day' => $today, 'amount' => $qty ) ); 166 } else { 167 $qty = $recent_quantity['amount']; 168 } 169 } 170 if ( $qty > 0 ) { 171 $text = $this->settings['text']; 172 $text = str_replace( '{recent_quantity}', '<span class="wapinfo-recent-qty">' . $qty . '</span>', $text ); 173 $text = str_replace( '{recent_range}', '<span class="wapinfo-recent-range">' . $range . '</span>', $text ); 174 echo '<div class="wapinfo-recent-order">' . do_shortcode( $text ) . '</div>'; 175 } 176 } 177 178 public function recent_meta( $template_name ) { 179 if ( $template_name !== 'single-product/meta.php' ) { 180 return; 181 } 182 global $product; 183 $product_id = $product->get_id(); 184 $range = $this->settings['range']; 185 $qty = 0; 186 $today = strtotime( 'today' ); 187 188 if ( 1 === $this->settings['fake'] ) { 189 $fake = $product->get_meta( '_wapi_recent_quantity_virtual' ); 190 if ( $fake && 191 isset( $fake['day'], $fake['amount'], $fake['min'], $fake['max'] ) && 192 $fake['day'] == $today && $fake['min'] == $this->settings['minrand'] && $fake['max'] != $this->settings['maxrand'] ) { 193 $qty = absint( $fake['amount'] ); 194 } else { 195 $qty = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) ); 196 $product->add_meta_data( 197 '_wapi_recent_quantity_virtual', 198 array( 199 'day' => $today, 200 'amount' => $qty, 201 'min' => $this->settings['minrand'], 202 'max' => $this->settings['maxrand'], 203 ), 204 true ); 205 } 206 // if ( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true ) && get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['day'] == $today ) { 207 // $qty = absint( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['amount'] ); 208 // } else { 209 // $qty = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) ); 210 // update_post_meta( $product_id, '_wapi_recent_quantity_virtual', array( 211 // 'day' => $today, 212 // 'amount' => $qty 213 // ) ); 214 // } 141 215 } else { 142 216 $from = $today - $range * 24 * 3600; … … 157 231 } 158 232 159 public function recent_meta( $template_name ) {160 if ( $template_name !== 'single-product/meta.php' ) {161 return;162 }163 global $product;164 $product_id = $product->get_id();165 $range = $this->settings['range'];166 $qty = 0;167 $today = strtotime( 'today' );168 169 if ( 1 === $this->settings['fake'] ) {170 if ( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true ) && get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['day'] == $today ) {171 $qty = absint( get_post_meta( $product_id, '_wapi_recent_quantity_virtual', true )['amount'] );172 } else {173 $qty = rand( absint( $this->settings['minrand'] ), absint( $this->settings['maxrand'] ) );174 update_post_meta( $product_id, '_wapi_recent_quantity_virtual', array(175 'day' => $today,176 'amount' => $qty177 ) );178 }179 } else {180 $from = $today - $range * 24 * 3600;181 $recent_quantity = get_post_meta( $product_id, '_wapi_recent_quantity', true );182 if ( ! $recent_quantity || $recent_quantity['day'] != $today ) {183 $qty = self::sold_quantity( $product_id, $from, $today );184 update_post_meta( $product_id, '_wapi_recent_quantity', array( 'day' => $today, 'amount' => $qty ) );185 } else {186 $qty = $recent_quantity['amount'];187 }188 }189 if ( $qty > 0 ) {190 $text = $this->settings['text'];191 $text = str_replace( '{recent_quantity}', '<span class="wapinfo-recent-qty">' . $qty . '</span>', $text );192 $text = str_replace( '{recent_range}', '<span class="wapinfo-recent-range">' . $range . '</span>', $text );193 echo '<div class="wapinfo-recent-order">' . do_shortcode( $text ) . '</div>';194 }195 }196 197 233 public static function sold_quantity( $product_id, $from, $to ) { 198 $qty = 0;199 $args = array(234 $qty = 0; 235 $args = array( 200 236 'post_type' => 'shop_order', 201 237 'post_status' => array( 'wc-on-hold', 'wc-completed', 'wc-processing' ), … … 209 245 ) 210 246 ); 211 $orders = array(); 212 $query = new WP_Query( $args ); 213 if ( $query->have_posts() ) { 214 while ( $query->have_posts() ) { 215 $query->the_post(); 216 $orders[] = get_the_ID(); 217 } 218 wp_reset_postdata(); 219 } 220 foreach ( $orders as $order1 ) { 221 $order = wc_get_order( $order1 ); 222 //if product is in the order, increase the quantity 223 foreach ( $order->get_items() as $item_data ) { 224 if ( $product_id == $item_data->get_product_id() ) { 225 $qty += $item_data->get_quantity(); 226 } 227 }; 247 248 $orders = wc_get_orders( $args ); 249 250 if ( ! empty( $orders ) ) { 251 foreach ( $orders as $order ) { 252 foreach ( $order->get_items() as $item_data ) { 253 if ( $product_id == $item_data->get_product_id() ) { 254 $qty += $item_data->get_quantity(); 255 } 256 }; 257 } 228 258 } 229 259 -
woo-advanced-product-information/trunk/includes/data.php
r2548789 r2952022 12 12 */ 13 13 public function __construct() { 14 15 14 global $wapi_settings; 16 15 if ( ! $wapi_settings ) { -
woo-advanced-product-information/trunk/includes/support.php
r2819414 r2952022 8 8 /** 9 9 * Class VillaTheme_Support 10 * 1.1. 710 * 1.1.8 11 11 */ 12 12 class VillaTheme_Support { 13 13 protected $plugin_base_name; 14 14 protected $ads_data; 15 protected $version = '1.1.7'; 15 protected $version = '1.1.8'; 16 protected $data = []; 16 17 17 18 public function __construct( $data ) { … … 702 703 $wp_admin_bar->add_node( array( 703 704 'id' => 'villatheme_hide_toolbar', 704 'title' => '<span style="font-family:dashicons"class="dashicons dashicons-dismiss"></span><span class="villatheme-hide-toolbar-button-title">Hide VillaTheme toolbar</span>',705 'title' => '<span class="dashicons dashicons-dismiss"></span><span class="villatheme-hide-toolbar-button-title">Hide VillaTheme toolbar</span>', 705 706 'parent' => 'villatheme', 706 707 'href' => add_query_arg( array( '_villatheme_nonce' => wp_create_nonce( 'villatheme_hide_toolbar' ) ) ), … … 941 942 } 942 943 } 944 945 if ( ! class_exists( 'VillaTheme_Require_Environment' ) ) { 946 class VillaTheme_Require_Environment { 947 948 protected $args; 949 protected $plugin_name; 950 protected $notices = []; 951 952 public function __construct( $args ) { 953 if ( ! did_action( 'plugins_loaded' ) ) { 954 _doing_it_wrong( 'VillaTheme_Require_Environment', sprintf( 955 /* translators: %s: plugins_loaded */ 956 __( 'VillaTheme_Require_Environment should not be run before the %s hook.' ), 957 '<code>plugins_loaded</code>' 958 ), '6.2.0' ); 959 } 960 961 $args = wp_parse_args( $args, [ 962 'plugin_name' => '', 963 'php_version' => '', 964 'wp_version' => '', 965 'wc_verison' => '', 966 'require_plugins' => [], 967 ] ); 968 969 $this->plugin_name = $args['plugin_name']; 970 971 $this->check( $args ); 972 973 add_action( 'admin_notices', [ $this, 'notice' ] ); 974 } 975 976 protected function check( $args ) { 977 if ( ! function_exists( 'install_plugin_install_status' ) ) { 978 require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; 979 } 980 981 if ( ! function_exists( 'is_plugin_active' ) ) { 982 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 983 } 984 985 if ( ! empty( $args['php_version'] ) ) { 986 $compatible_php = is_php_version_compatible( $args['php_version'] ); 987 if ( ! $compatible_php ) { 988 $this->notices[] = sprintf( "PHP version at least %s.", esc_html( $args['php_version'] ) ); 989 } 990 } 991 992 if ( ! empty( $args['wp_version'] ) ) { 993 $compatible_wp = is_wp_version_compatible( $args['wp_version'] ); 994 if ( ! $compatible_wp ) { 995 $this->notices[] = sprintf( "WordPress version at least %s.", esc_html( $args['wp_version'] ) ); 996 } 997 } 998 999 if ( ! empty( $args['require_plugins'] ) ) { 1000 foreach ( $args['require_plugins'] as $plugin ) { 1001 if ( empty( $plugin['version'] ) ) { 1002 $plugin['version'] = ''; 1003 } 1004 1005 $status = install_plugin_install_status( $plugin ); 1006 $require_plugin_name = $plugin['name'] ?? ''; 1007 1008 $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null; 1009 $requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null; 1010 1011 $compatible_php = is_php_version_compatible( $requires_php ); 1012 $compatible_wp = is_wp_version_compatible( $requires_wp ); 1013 1014 if ( ! $compatible_php || ! $compatible_wp ) { 1015 continue; 1016 } 1017 1018 switch ( $status['status'] ) { 1019 1020 case 'install': 1021 $this->notices[] = sprintf( "%s to be installed. <br><a href='%s' target='_blank' class='button button-primary' style='vertical-align: middle; margin-top: 5px;'>Install %s</a>", 1022 esc_html( $require_plugin_name ), 1023 esc_url( ! empty( $status['url'] ) ? $status['url'] : '#' ), 1024 esc_html( $require_plugin_name ) ); 1025 1026 break; 1027 1028 default: 1029 1030 if ( ! is_plugin_active( $status['file'] ) && current_user_can( 'activate_plugin', $status['file'] ) ) { 1031 $activate_url = add_query_arg( 1032 [ 1033 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ), 1034 'action' => 'activate', 1035 'plugin' => $status['file'], 1036 ], 1037 network_admin_url( 'plugins.php' ) 1038 ); 1039 1040 $this->notices[] = sprintf( "%s is installed and activated. <br> <a href='%s' target='_blank' class='button button-primary' style='vertical-align: middle; margin-top: 5px;'>Active %s</a>", 1041 esc_html( $require_plugin_name ), 1042 esc_url( $activate_url ), 1043 esc_html( $require_plugin_name ) ); 1044 1045 } 1046 1047 if ( $plugin['slug'] == 'woocommerce' && ! empty( $args['wc_version'] ) && is_plugin_active( $status['file'] ) ) { 1048 $wc_current_version = get_option( 'woocommerce_version' ); 1049 if ( ! version_compare( $wc_current_version, $args['wc_version'], '>=' ) ) { 1050 $this->notices[] = sprintf( "WooCommerce version at least %s.", esc_html( $args['wc_version'] ) ); 1051 } 1052 } 1053 1054 break; 1055 } 1056 } 1057 } 1058 } 1059 1060 public function notice() { 1061 $screen = get_current_screen(); 1062 1063 if ( ! current_user_can( 'manage_options' ) || $screen->id === 'update' ) { 1064 return; 1065 } 1066 1067 if ( ! empty( $this->notices ) ) { 1068 ?> 1069 <div class="error"> 1070 <?php 1071 if ( count( $this->notices ) > 1 ) { 1072 printf( "<p>%s requires:</p>", esc_html( $this->plugin_name ) ); 1073 ?> 1074 <ol> 1075 <?php 1076 foreach ( $this->notices as $notice ) { 1077 printf( "<li>%s</li>", wp_kses_post( $notice ) ); 1078 } 1079 ?> 1080 </ol> 1081 <?php 1082 } else { 1083 printf( "<p>%s requires %s</p>", esc_html( $this->plugin_name ), wp_kses_post( current( $this->notices ) ) ); 1084 } 1085 ?> 1086 </div> 1087 <?php 1088 } 1089 } 1090 1091 public function has_error() { 1092 return ! empty( $this->notices ); 1093 } 1094 } 1095 } -
woo-advanced-product-information/trunk/readme.txt
r2819414 r2952022 4 4 Tags: sales, triggers, sales countdown, rank of category, rank of product, product icon box, freeship 5 5 Requires at least: 5.0 6 Tested up to: 6. 16 Tested up to: 6.3 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 72 72 ### MAY BE YOU NEED 73 73 74 [SUBRE – Product Subscription for WooCommerce](https://bit.ly/subre-product-subscription-for-woo): Convert WooCommerce simple products(physical or downloadable/virtual) to subscription products and allow recurring payments 75 76 [Clear Autoptimize Cache Automatically](https://bit.ly/clear-autoptimize-cache-automatically): Clear Autoptimize cache automatically by cache amount or by time interval 77 74 78 [FEWC – WooCommerce Extra Checkout Fields](https://bit.ly/fewc-extra-checkout-fields-for-woocommerce): Manage checkout fields using WordPress Customizer 75 79 … … 164 168 165 169 == Changelog == 170 171 /*1.1.0 - 2023.08.11*/ 172 - Updated: Compatible with WooCommerce HPOS 173 166 174 /*1.0.10 - 2022.07.22*/ 167 175 - Updated: VillaTheme_Support -
woo-advanced-product-information/trunk/woo-advanced-product-information.php
r2819414 r2952022 4 4 * Plugin URI: https://villatheme.com/extensions/ 5 5 * Description: More attractive information of products to make customers eager to buy them 6 * Version: 1. 0.106 * Version: 1.1.0 7 7 * Author: VillaTheme 8 8 * Author URI: http://villatheme.com 9 * Copyright 2018-202 2VillaTheme.com. All rights reserved.10 * Tested up to: 6. 111 * WC tested up to: 6.79 * Copyright 2018-2023 VillaTheme.com. All rights reserved. 10 * Tested up to: 6.3 11 * WC tested up to: 8.0 12 12 * Requires PHP: 7.0 13 13 */ 14 14 15 if ( ! defined( 'ABSPATH' ) ) { 15 16 exit; 16 17 } 17 define( 'VI_WC_ADVANCED_PRODUCT_INFORMATION_VERSION', '1.0.10' ); 18 /** 19 * Detect plugin. For use on Front End only. 20 */ 21 22 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 23 if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { 24 $init_file = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . "woo-advanced-product-information" . DIRECTORY_SEPARATOR . "includes" . DIRECTORY_SEPARATOR . "define.php"; 25 require_once $init_file; 26 } 18 define( 'VI_WC_ADVANCED_PRODUCT_INFORMATION_VERSION', '1.1.0' ); 27 19 28 20 /** … … 32 24 public function __construct() { 33 25 register_activation_hook( __FILE__, array( $this, 'install' ) ); 34 add_action( 'admin_notices', array( $this, 'global_note' ) ); 35 } 36 37 /** 38 * Notify if WooCommerce is not activated 39 */ 40 function global_note() { 41 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { 42 ?> 43 <div id="message" class="error"> 44 <p><?php esc_html_e( 'Please install and activate WooCommerce. Advanced Product Information for WooCommerce is going to working.', 'woo-advanced-product-information' ); ?></p> 45 </div> 46 <?php 47 } 26 add_action( 'before_woocommerce_init', [ $this, 'custom_order_tables_declare_compatibility' ] ); 27 add_action( 'plugins_loaded', [ $this, 'init' ], 20 ); 28 } 29 30 public function init() { 31 if ( ! class_exists( 'VillaTheme_Require_Environment' ) ) { 32 include_once plugin_dir_path( __FILE__ ) . 'includes/support.php'; 33 } 34 35 $environment = new \VillaTheme_Require_Environment( [ 36 'plugin_name' => 'Advanced Product Information for WooCommerce', 37 'php_version' => '7.0', 38 'wp_version' => '5.0', 39 'wc_version' => '6.0', 40 ] 41 ); 42 43 if ( $environment->has_error() ) { 44 return; 45 } 46 47 require_once plugin_dir_path( __FILE__ ) . 'includes/define.php'; 48 48 } 49 49 … … 52 52 */ 53 53 public static function install() { 54 global $wp_version;55 if ( version_compare( $wp_version, "5.0", "<" ) ) {56 deactivate_plugins( basename( __FILE__ ) ); // Deactivate our plugin57 wp_die( "This plugin requires WordPress version 4.4 or higher." );58 }59 54 if ( ! get_option( '_wapi_settings', '' ) ) { 60 55 $wapi_settings_args = array( … … 261 256 } 262 257 } 258 259 public function custom_order_tables_declare_compatibility() { 260 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 261 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 262 } 263 } 263 264 } 264 265
Note: See TracChangeset
for help on using the changeset viewer.