Plugin Directory

Changeset 2719869


Ignore:
Timestamp:
05/07/2022 12:32:25 PM (4 years ago)
Author:
krishna121
Message:

version 1.0.8

Location:
wp-rate-and-review
Files:
45 added
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • wp-rate-and-review/trunk/assets/css/slick.css

    r2178050 r2719869  
    124124.slick-loading .slick-list
    125125{
    126     background: #fff url('../../ajax-loader.gif') center center no-repeat;
     126    background: #fff url('../../images/ajax-loader.gif') center center no-repeat;
    127127}
    128128
  • wp-rate-and-review/trunk/assets/css/wpic-admin.css

    r2570508 r2719869  
    15871587    width: 24px;
    15881588    height: 24px;
    1589     background: url('../images/iconfinder_15_Tick_16x16_173960.png');
     1589    background: url("../../images/iconfinder_15_Tick_16x16_173960.png");
    15901590    margin: 0 auto;
    15911591    text-align: center;
  • wp-rate-and-review/trunk/readme.txt

    r2570645 r2719869  
    44Tags: woocommerce, woocommerce rating, woocommerce review, woocommerce rating progress bar, rating progress bar
    55Requires at least: 5.8
    6 Stable tag: 1.0.7
     6Stable tag: 1.0.8
    77Requires PHP: 5.6
    88Tested up to: 5.8
     
    4343== Changelog ==
    4444
     45= 1.0.8 =
     46* Compatible to latest Wordpress and WooCommerce
     47
    4548= 1.0.7 =
    4649* Compatible to latest Wordpress and WooCommerce
  • wp-rate-and-review/trunk/wp-rate-and-review.php

    r2570508 r2719869  
    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.7
     5 * Version: 1.0.8
    66 * Author: K.Kumar
    77 * Author URI: https://profiles.wordpress.org/krishna121/
     
    1515}
    1616
     17/**
     18 * WCRR_Rate_Review main class
     19 * @package wp-rate-and-review
     20 * @author Krishna
     21 */
     22
    1723if ( ! class_exists('WCRR_Rate_Review') ) {
    1824   
    1925    class WCRR_Rate_Review{
    2026
     27
     28
     29        /**
     30         * Current plugin version
     31         * @var $version
     32         */
     33        public  $version = '1.0.8';
     34
     35        /**
     36         * Instance of plugin
     37         * @var $instance
     38         */
     39        private static $instance;
     40
     41        /**
     42         * @var array
     43         */
    2144        public $result = array();
    22 
     45       
     46        /**
     47         * Constructor of class
     48         */
    2349        function __construct(){
    2450
     
    5177
    5278        function wcrr_required_woocommerce(){
    53 
    5479            ?>
    5580                <div class="notice notice-error">
    56                 <p><?php esc_html_e( 'WooCommerce is required for WP Rate and Review  plugin. Please install and configure woocommerce first.', 'wp-rate-and-review' ); ?></p>
     81                    <p><?php esc_html_e( 'WooCommerce is required for WP Rate and Review  plugin. Please install and configure woocommerce first.', 'wp-rate-and-review' ); ?></p>
    5782                </div>
    5883            <?php
    5984        }
    6085
     86        /**
     87         * Setup plugin
     88         * @since 1.0.0
     89         * @return void
     90         */
    6191        function wcrr_setup_plugin(){
     92
     93            $this->wcrr_define_constant();
     94            $this->wcrr_load_files();
     95            $this->wcrr_hooks();
     96               
     97        }
     98
     99
     100        /**
     101         *
     102         * Define constact of plugin
     103         * @since 1.0.8
     104         *
     105         */
     106
     107        function wcrr_define_constant(){
     108
     109            $this->wcrr_define('WCRR_VERSION',$this->version);
     110            $this->wcrr_define('WCRR_FILE',__FILE__);
     111            $this->wcrr_define('WCRR_PATH',dirname(WCRR_FILE));
     112            $this->wcrr_define('WCRR_INCLUDES',WCRR_PATH . '/includes');
     113            $this->wcrr_define('WCRR_URL', plugins_url('', WCRR_FILE));
     114            $this->wcrr_define('WCRR_ASSETS',WCRR_URL  . '/assets');
     115            $this->wcrr_define('WCRR_VIEWS',WCRR_PATH  . '/views');
     116            $this->wcrr_define('WCRR_TEMPLATES',WCRR_PATH  . '/templates/');
     117            $this->wcrr_define('WCRR_CSS',WCRR_URL. '/assets/css/');
     118            $this->wcrr_define('WCRR_JS',WCRR_URL. '/assets/js/');
     119            $this->wcrr_define('WCRR_IMAGES',WCRR_URL. '/assets/images/');
     120
     121        }
     122
     123          /**
     124         * Define constant if not already set.
     125         *
     126         * @param string      $name
     127         * @param string|bool $value
     128         */
     129        function wcrr_define( $name, $value ) {
     130            if ( ! defined( $name ) ) {
     131                define( $name, $value );
     132            }
     133        }
     134
     135
     136        function wcrr_load_files(){
     137
     138            if(is_admin()){
     139                require_once WCRR_INCLUDES  . '/class-wcrr-admin-menu.php';
     140                $this->wcrr_admin = new WCRR_Admin_Menu();
     141            }
     142        }
     143
     144        /**
     145         * Actual function for load hooks
     146         */
     147        function wcrr_hooks(){
    62148
    63149            add_action( 'wp_ajax_nopriv_wcrr_ajax_call', array($this,'wcrr_ajax_call' ));
    64150            add_action( 'wp_ajax_wcrr_ajax_call', array($this,'wcrr_ajax_call' ));
    65151
    66 
    67             if(is_admin()){
    68                 $this->wcrr_backend_hook();
    69             }else{
     152            // Check admin
     153            if(!is_admin()){   
    70154                $this->wcrr_frontend_hook();
    71155            }
     
    73157        }
    74158
     159        /**
     160         * Ajax call handler
     161         * @since 1.0.0
     162         *
     163         */
    75164        function wcrr_ajax_call(){
    76 
    77165            if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    78                
    79166                if (isset($_POST['nonce']) && !wp_verify_nonce( $_POST['nonce'], 'wcrr_nonce_value' ) )
    80167                die ( 'Busted!');
    81 
    82168                $ajax_handler = isset($_POST['ajax_handler']) ? $_POST['ajax_handler'] :'';
    83169                $response = $this->$ajax_handler($_POST);
     
    85171                exit;
    86172            }
    87     }
    88 
     173        }
     174        /**
     175         * Regiter hooks which worked into site frontend
     176         * @since 1.0.0
     177         *
     178         *
     179         */
    89180        function wcrr_frontend_hook(){
     181            // Register comment
    90182            add_filter( 'comments_template', array( $this, 'wcrr_enhance_review_rating' ) );
    91             add_action( 'wp_enqueue_scripts', array($this,'wcrr_theme_name_scripts' ));
    92             add_shortcode('wp_rate_review', array($this,'wcrr_review_markup_via_shortcode'));
    93            add_filter( 'woocommerce_my_account_my_orders_actions', array($this,'wcrr_show_review_actions' ),10,2);
    94 
     183           
     184            // Load css and js frontend files
     185            add_action( 'wp_enqueue_scripts', array($this,'wcrr_load_css_js' ));
    95186           
    96         }
    97 
    98         function wcrr_backend_hook(){
    99             add_action( 'admin_menu', array($this,'wcrr_plugin_menu' ));
    100             add_action( 'admin_enqueue_scripts', array($this,'wcrr_enqueue_admin_script' ));
    101             add_action( 'admin_init', array($this,'wcrr_plugin_settings' ));
    102         }
    103 
     187            // Register shortcode of plugin
     188            add_shortcode('wp_rate_review', array($this,'wcrr_review_markup_via_shortcode'));
     189           
     190            // Register new order actions on my-account's orders listing
     191            add_filter( 'woocommerce_my_account_my_orders_actions', array($this,'wcrr_show_review_actions' ),10,2);
     192        }
     193       
     194
     195        /**
     196         * Register new order action button
     197         */
    104198        function wcrr_show_review_actions($actions,$order){
    105199
     
    110204                'url'=>get_home_url(),
    111205                'name'=>esc_html__('Review','wp-rate-and-review')
    112 
    113206                );
    114 
    115207            }
    116208            return $actions;
    117209        }
    118210
    119         function wcrr_theme_name_scripts(){
     211
     212        /**
     213         * Load css and js files
     214         * @since 1.0.0
     215         */
     216        function wcrr_load_css_js(){
    120217
    121218            wp_enqueue_style( 'wpic-wcprogressbar-css', plugin_dir_url( __FILE__ ).'assets/css/wphp-progressbar.css');
     
    126223
    127224            $selected_tempalte = (!empty($plugin_settings['review_template'])) ?$plugin_settings['review_template']:'singlecolor';
    128 
    129 
    130225            $custom_css = "
    131226                .w3-light-grey{background-color: {$wp_pbar_bg_color} !important;}
     
    181276        }
    182277
    183         function wcrr_plugin_menu(){
    184 
    185             add_menu_page(
    186                 __('WP Rate And Review ', 'wp-rate-and-review' ),
    187                 __('WP Rate And Review','wp-rate-and-review'),
    188                 'manage_options',
    189                 'wp_rate_overview',
    190                 array($this,'wcrr_plugin_overview'),
    191                 'dashicons-welcome-widgets-menus');
    192 
    193 
    194             add_submenu_page( 'wp_rate_overview',
    195              __('Settings','wp-rate-and-review'),
    196              __('Settings','wp-rate-and-review'),
    197             'manage_options',
    198             'wcr_rate_review_settings',
    199             array($this,'wcrr_setting_page'));
    200         }
    201 
    202         function wcrr_plugin_settings(){
    203 
    204 
    205            $settings = array();
    206            register_setting( 'wcr_options_group','wcr_options_group');
    207 
    208            if(isset($_POST) && isset($_POST['action']) && ( sanitize_text_field( wp_unslash($_POST['action']))=="rating-form")  ){
    209            
    210             if ( isset( $_POST['wcr_nonce'] ) ) {
    211                 $nonce = sanitize_text_field( wp_unslash( $_POST['wcr_nonce'] ) );
    212             }
    213             $checknonce = wp_verify_nonce($nonce,'wcr');
    214                 if($checknonce){
    215                     $error=false;
    216                     if(!$error){
    217 
    218                         $settings['wp_enable_rate_review'] = (!empty( $_POST['wp_enable_rate_review'])) ? sanitize_text_field( wp_unslash( $_POST['wp_enable_rate_review'] ) ) : '';
    219                         $settings['wphp_exclude_products'] = (!empty($_POST['wphp_exclude_products'])) ? (array)$_POST['wphp_exclude_products'] :array();
    220                         $settings['wp_pbar_bg_color'] = (!empty($_POST['wp_pbar_bg_color'])) ? sanitize_text_field( wp_unslash( $_POST['wp_pbar_bg_color'] ) ) : ''; 
    221                         $settings['wp_pbar_fill_color'] = (!empty($_POST['wp_pbar_fill_color'])) ? sanitize_text_field( wp_unslash( $_POST['wp_pbar_fill_color'] ) ) : ''; 
    222                         $settings['review_template'] = (!empty($_POST['review_template'])) ? sanitize_text_field( wp_unslash( $_POST['review_template'] ) ) : ''; 
    223                         $settings['wp_progress_bar_height'] = (!empty($_POST['wp_progress_bar_height'])) ? sanitize_text_field( wp_unslash( $_POST['wp_progress_bar_height'] ) ) : ''; 
    224                         update_option('wcr_options_group',$settings);
    225                         $this->result['success'] = esc_html__('Settings Saved Successfully.','wp-rate-and-review');
    226                     }
    227                 }else{
    228                     wp_die('Cheating');
    229                 }
    230            }
    231         }
    232 
    233        function wcrr_enqueue_admin_script($hook){
    234 
    235          if($hook=='toplevel_page_wp_rate_overview' || $hook=='wp-rate-and-review_page_wcr_rate_review_settings'){
    236                 $plugin_settings = maybe_unserialize(get_option('wcr_options_group'));
    237 
    238                 wp_enqueue_style( 'wp-color-picker' );
    239                 wp_enqueue_style( 'wpic-slick-css', plugin_dir_url( __FILE__ ).'/assets/css/slick.css');
    240                 wp_enqueue_style( 'wpic-admin-css', plugin_dir_url( __FILE__ ).'/assets/css/wpic-admin.css',array(),rand(10,100));
    241                 wp_enqueue_style( 'select2-min-css', plugin_dir_url( __FILE__ ).'/assets/css/select2.min.css');
    242                 wp_enqueue_script( 'select2-min-js', plugin_dir_url( __FILE__ ).'/assets/js/select2.min.js');
    243                 wp_enqueue_script( 'silk-min-js', plugin_dir_url( __FILE__ ).'/assets/js/slick.min.js');
    244                 wp_enqueue_script( 'wpic-admin-js', plugin_dir_url( __FILE__ ).'/assets/js/wpic-admin.js',array( 'wp-color-picker' ), rand(10,100), true);
    245 
    246                 wp_localize_script( 'wpic-admin-js', 'wcrr_ajax_obj', array(
    247                     'ajax_url' => admin_url('admin-ajax.php'),
    248                     'nonce'=> wp_create_nonce('wcrr_nonce_value'),
    249                     'active_template'=>$plugin_settings['review_template']             
    250                 ));
    251 
    252          }
    253 
    254         }
     278       
     279
     280
     281
    255282
    256283        function wcrr_update_template_name($data){
     
    262289        }
    263290
    264         function wcrr_plugin_overview(){
    265             ob_start();
    266             require_once(plugin_dir_path( __FILE__ )."/include/view/welcome.php");
    267             $welcome = ob_get_contents();
    268             ob_clean();
    269             echo $welcome;
    270         }
    271 
    272 
    273         function wcrr_setting_page(){
    274 
    275             if(!empty($this->result) && array_key_exists('error',$this->result) ){
    276                     echo "<div class='error notice is-dismissible'><p><strong>".$this->result['error']."</strong></p><button type='button' class='notice-dismiss'><span class='screen-reader-text'>Dismiss this notice.</span></button></div>";
    277             }else if(!empty($this->result) &&  array_key_exists('success',$this->result)){
    278                     echo "<div class='updated published'><p>".$this->result['success']."</p></div>";
    279             }
    280             $plugin_setting_markup = '';
    281             ob_start();
    282             require_once(plugin_dir_path( __FILE__ )."/include/settings/settings.php");
    283             $plugin_setting_markup .= ob_get_contents();
    284             ob_clean();
    285             echo $plugin_setting_markup;
    286         }
     291
    287292
    288293        function wcrr_review_markup_via_shortcode($atts){
     
    299304        }
    300305
     306        /**
     307         * Get Number of ratings of rating status of current products
     308         * @param int $rating_number rating number of product like- 5*,4*,3*,2*
     309         * @param int $product_id product id
     310         * @return int
     311         */
    301312        function wcrr_get_number_ratings($rating_number,$product_id){
    302313
     
    321332        function wcrr_prepare_review_markup($product_id){
    322333
     334
    323335                $plugin_settings = maybe_unserialize(get_option('wcr_options_group'));
    324336
     
    326338                    return;
    327339
    328                if(!empty($plugin_settings['wphp_exclude_products']) && in_array($post->ID, $plugin_settings['wphp_exclude_products'])) 
     340               if(!empty($plugin_settings['wphp_exclude_products']) && in_array($product_id, $plugin_settings['wphp_exclude_products']))   
    329341                  return;
    330342
     
    377389                                        </div>
    378390                                    </div>';
    379 
    380 
    381391                                    }
    382 
    383 
    384 
    385 
    386392
    387393                                    $html.='<div class="wcrr_total_review_rating">';
     
    402408        }
    403409       
     410        /**
     411         * Show Rating markup on product page
     412         *
     413         * @param html @html
     414         */
    404415        function wcrr_enhance_review_rating($html){
    405 
    406416                global $product,$post;
    407 
    408417                $is_product_single = ($post->post_type =='product' && is_single()) ? true : false;
    409 
    410418                if(!$is_product_single)
    411419                    return;
     
    415423        }
    416424
     425        /**
     426         * Main WCRR_Rate_Review Instance       
     427         *
     428         * @since 1.0.0
     429         * @see instance()
     430         * @return instance
     431         */
     432
     433        public static function instance()
     434        {
     435            if (is_null(self::$instance)) {
     436                self::$instance = new self();
     437            }
     438            return self::$instance;
     439        }
     440
     441        /**
     442         * Initializes the extension.
     443         *
     444         * @since 1.0.0
     445         * @return Object Instance of extension.
     446
     447         */
     448
     449        public static function wcrr_init()
     450        {
     451
     452            $GLOBALS['wcrr_rate_review'] = WCRR_Rate_Review::instance();
     453        }
     454
     455
     456        /**
     457         * Entry point of plugin
     458         *
     459         * @since 1.0.0
     460         */
     461        public static function init()
     462        {
     463            add_action('plugins_loaded', array(__CLASS__, 'wcrr_init'));
     464
     465
     466        }
     467
    417468    }
    418     return new WCRR_Rate_Review();
    419 
     469
     470    WCRR_Rate_Review::init();
    420471}
Note: See TracChangeset for help on using the changeset viewer.