original_string: public function get_plugin_rating( $slug, $ratings = null ) {
  
  		$ratings = $ratings ?: [
  			1 => 0,
  			2 => 0,
  			3 => 0,
  			4 => 0,
  			5 => 1,
  		];
  
  		$plugins_url = Component::WP_Plugin_Rating()->getOption(
  			'url',
  			'wp-plugins'
  		);
  
  		$url = $plugins_url . $slug . '/reviews/#new-post';
  
  		$data['plugin-url-review'] = $url;
  
  		if ( Plugin::exists( 'WP_Plugin_Info' ) ) {
  			$info    = Plugin::WP_Plugin_Info()->getControllerInstance( 'Main' );
  			$rating  = $info->get( 'ratings', $slug );
  			$ratings = ( false !== $rating ) ? $rating : $ratings;
  		}
  
  		$total = 0;
  
  		$voters = array_sum( $ratings );
  
  		foreach ( $ratings as $stars => $votes ) {
  			$total += $stars * $votes;
  		}
  
  		$rating = $total ? $total / $voters : 0;
  
  		$data['stars'] = $this->prepare_stars( $rating );
  
  		$this->render( $data );
  	}
code: public function get_plugin_rating( $slug, $ratings = null ) {
  
  		$ratings = $ratings ?: [
  			1 => 0,
  			2 => 0,
  			3 => 0,
  			4 => 0,
  			5 => 1,
  		];
  
  		$plugins_url = Component::WP_Plugin_Rating()->getOption(
  			'url',
  			'wp-plugins'
  		);
  
  		$url = $plugins_url . $slug . '/reviews/#new-post';
  
  		$data['plugin-url-review'] = $url;
  
  		if ( Plugin::exists( 'WP_Plugin_Info' ) ) {
  			$info    = Plugin::WP_Plugin_Info()->getControllerInstance( 'Main' );
  			$rating  = $info->get( 'ratings', $slug );
  			$ratings = ( false !== $rating ) ? $rating : $ratings;
  		}
  
  		$total = 0;
  
  		$voters = array_sum( $ratings );
  
  		foreach ( $ratings as $stars => $votes ) {
  			$total += $stars * $votes;
  		}
  
  		$rating = $total ? $total / $voters : 0;
  
  		$data['stars'] = $this->prepare_stars( $rating );
  
  		$this->render( $data );
  	}
code_tokens: public function get_plugin_rating ( $ slug , $ ratings = null ) { $ ratings = $ ratings ? : [ 1 => 0 , 2 => 0 , 3 => 0 , 4 => 0 , 5 => 1 , ] ; $ plugins_url = Component :: WP_Plugin_Rating ( ) -> getOption ( 'url' , 'wp-plugins' ) ; $ url = $ plugins_url . $ slug . '/reviews/#new-post' ; $ data [ 'plugin-url-review' ] = $ url ; if ( Plugin :: exists ( 'WP_Plugin_Info' ) ) { $ info = Plugin :: WP_Plugin_Info ( ) -> getControllerInstance ( 'Main' ) ; $ rating = $ info -> get ( 'ratings' , $ slug ) ; $ ratings = ( false !== $ rating ) ? $ rating : $ ratings ; } $ total = 0 ; $ voters = array_sum ( $ ratings ) ; foreach ( $ ratings as $ stars => $ votes ) { $ total += $ stars * $ votes ; } $ rating = $ total ? $ total / $ voters : 0 ; $ data [ 'stars' ] = $ this -> prepare_stars ( $ rating ) ; $ this -> render ( $ data ) ; }
docstring: Get plugin Rating.
  
  @param string $slug    → WordPress plugin slug.
  @param array  $ratings → default ratings if plugin not exists.
docstring_tokens: Get plugin Rating .