Plugin Directory

Changeset 2143286


Ignore:
Timestamp:
08/21/2019 05:12:31 PM (7 years ago)
Author:
krishna121
Message:

updated version

Location:
wp-rate-and-review/trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-rate-and-review/trunk/readme.txt

    r2142261 r2143286  
    44Tags: woocommerce, woocommerce rating, woocommerce review, woocommerce rating progress bar, rating progress bar
    55Requires at least: 5.2
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.1
    77Requires PHP: 5.6
    88Tested up to: 5.2
     
    4141== Changelog ==
    4242
     43
     44= 1.0.1 =
     45* Auto disable plugin if woocommerce not installed.
     46* New Feature - Exclude Products to show summary.
     47
    4348= 1.0.0 =
    4449* Initial version
  • wp-rate-and-review/trunk/wp-rate-and-review-products.php

    r2142261 r2143286  
    33 * Plugin Name: WP Rate And Review
    44 * Description: A WooCommerce Add-on which provides complete feature to show your rating and review with progressbar.
    5  * Version: 1.0.0
     5 * Version: 1.0.1
    66 * Author: K.Kumar
    77 * Author URI: https://profiles.wordpress.org/krishna121/
     
    2121
    2222        function __construct(){
    23             $this->wcrr_setup_plugin();
     23
     24
     25            $check_wooEnable = $this->wcrr_check_woo_enable();
     26
     27            if($check_wooEnable){
     28                $this->wcrr_setup_plugin();
     29            }else{
     30                add_action( 'admin_notices', array( $this, 'wcrr_required_woocommerce' ) );
     31            }
     32        }
     33
     34        function wcrr_check_woo_enable(){
     35
     36            $enable= false;
     37
     38            $enable = in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) );
     39            if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
     40                require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
     41            }
     42
     43            if(is_multisite()){
     44                $enable = (is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) ? true : false;
     45            }
     46            return $enable;
     47
     48        }
     49
     50        function wcrr_required_woocommerce(){
     51
     52            ?>
     53                <div class="notice notice-error">
     54                <p><?php esc_html_e( 'WooCommerce is required for WP Rate and Review  plugin. Please install and configure woocommerce first.', 'wp-rate-and-review-products' ); ?></p>
     55                </div>
     56            <?php
    2457        }
    2558
     
    98131                    $settings['wp_enable_progress_bar'] = (!empty( $_POST['wp_enable_progress_bar'])) ? sanitize_text_field( wp_unslash( $_POST['wp_enable_progress_bar'] ) ) : '';
    99132
     133                    $settings['wphp_exclude_products'] = (!empty($_POST['wphp_exclude_products'])) ? (array)$_POST['wphp_exclude_products'] :array();
     134
     135
    100136                    $settings['wp_pbar_bg_color'] = (!empty($_POST['wp_pbar_bg_color'])) ? sanitize_text_field( wp_unslash( $_POST['wp_pbar_bg_color'] ) ) : ''; 
    101137                    $settings['wp_pbar_fill_color'] = (!empty($_POST['wp_pbar_fill_color'])) ? sanitize_text_field( wp_unslash( $_POST['wp_pbar_fill_color'] ) ) : ''; 
     
    111147         if($hook=='toplevel_page_wp_rate_overview' || $hook=='wp-rate-and-review_page_wcr_rate_review_settings'){
    112148
    113 
    114149                wp_enqueue_style( 'wp-color-picker' );
    115150                wp_enqueue_scripts( 'wp-color-picker' );
    116151                wp_enqueue_style( 'wpic-admin-css', plugin_dir_url( __FILE__ ).'/assets/css/wpic-admin.css');
    117                 wp_enqueue_style( 'select2-css', plugin_dir_url( __FILE__ ).'/assets/css//select2.css');
    118                 wp_enqueue_script( 'select2-full-js', plugin_dir_url( __FILE__ ).'/assets/js/select2.full.js');
     152                wp_enqueue_style( 'select2-min-css', plugin_dir_url( __FILE__ ).'/assets/css/select2.min.css');
     153                wp_enqueue_script( 'select2-min-js', plugin_dir_url( __FILE__ ).'/assets/js/select2.min.js');
    119154                wp_enqueue_script( 'wpic-admin-js', plugin_dir_url( __FILE__ ).'/assets/js/wpic-admin.js',array( 'wp-color-picker' ), false, true);
    120155
     
    235270                                </div>
    236271                            </div> 
     272
     273                            <div class="wpic-group">
     274                                <div class="wpic-row">
     275                                    <div class="wpic-cd-4">
     276                                        <div class="wpic-label">
     277                                            <label><?php echo esc_html__('Exclude Products to show summary','wp-rate-and-review-products'); ?> </label>
     278                                        </div>
     279                                    </div>
     280                                    <div class="wpic-cd-4">
     281                                        <select name="wphp_exclude_products[]" class="wpic_select2 wpic-form-control" multiple="multiple">
     282                                        <?php
     283                                        $next_args = array(
     284                                                'post_type' => 'product',
     285                                                'post_status' => 'publish',
     286                                                'posts_per_page'=>-1,
     287                                                'order'=>'DESC',
     288                                                'orderby'=>'ID',
     289                                                );
     290                                        $next_the_query = new WP_Query( $next_args );
     291                                        if ( $next_the_query->have_posts() ) {
     292                                            while ( $next_the_query->have_posts() ) {
     293                                                $next_the_query->the_post();
     294                                                $id =  $next_the_query->post->ID;
     295                                                $title = get_the_title($id);
     296                                                $title = substr($title, 0, 40);
     297                                                $selected = (in_array($id, $plugin_settings['wphp_exclude_products']))?'selected': ''; ?>
     298                                                <option <?php echo $selected; ?> value="<?php echo $id; ?>"><?php echo $title; ?></option>
     299                                                <?php
     300                                            }
     301                                        }
     302                                        wp_reset_postdata(); ?>
     303                                        </select>
     304                                    </div>
     305                                </div>
     306                        </div>
     307
     308
    237309                            <input type="hidden" name="wcr_nonce" value="<?php echo wp_create_nonce("wcr"); ?>"/>
    238310                            <input type="submit" name="setting-name" class="button button-primary button-large" value="Save" />
     
    269341                $plugin_settings = maybe_unserialize(get_option('wcr_options_group'));
    270342
    271                  if(empty($plugin_settings['wp_enable_rate_review']))
     343                if(empty($plugin_settings['wp_enable_rate_review']))
    272344                    return;
    273345
    274                 $wp_enable_progress_bar = (!empty($plugin_settings['wp_enable_progress_bar'])) ?true:false;
    275                 $wp_enable_number_rating = (!empty($plugin_settings['wp_enable_number_rating'])) ?true:false;
     346                if(!($wp_enable_progress_bar) && !($wp_enable_number_rating) )
     347                    return;
     348
     349                $is_product_single = ($post->post_type =='product' && is_single()) ? true : false;
     350
     351                if(!$is_product_single)
     352                    return;
     353
     354               if(!empty($plugin_settings['wphp_exclude_products']) &&  in_array($post->ID, $plugin_settings['wphp_exclude_products']))
     355                  return;
     356
     357
     358                $wp_enable_progress_bar = (!empty($plugin_settings['wp_enable_progress_bar'])) ? true:false;
     359                $wp_enable_number_rating = (!empty($plugin_settings['wp_enable_number_rating'])) ? true:false;
    276360                $wp_pbar_bg_color = (!empty($plugin_settings['wp_pbar_bg_color'])) ?$plugin_settings['wp_pbar_bg_color']:'';
    277361                $wp_pbar_fill_color = (!empty($plugin_settings['wp_pbar_fill_color'])) ?$plugin_settings['wp_pbar_fill_color']:'';
    278362               
    279                 if(!($wp_enable_progress_bar) && !($wp_enable_number_rating) )
    280                     return;
    281 
    282                 $is_product_single = ($post->post_type =='product' && is_single()) ? true : false;
    283 
    284                 if(!$is_product_single)
    285                     return;
    286363
    287364                $total_review_count = $product->get_review_count();
Note: See TracChangeset for help on using the changeset viewer.