first commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
=== Absolute Reviews ===
|
||||
Tags: reviews, rating, review, schema.org
|
||||
Requires at least: 4.0
|
||||
Tested up to: 6.0
|
||||
Requires PHP: 5.4
|
||||
Stable tag: 1.1.1
|
||||
Contributors: codesupplyco
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
== Description ==
|
||||
|
||||
Add beautiful responsive and modern review boxes with valid JSON-LD schema to your posts with the “Advanced Reviews” plugin.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.1.1 =
|
||||
* Added schema attributes to Review Block
|
||||
|
||||
= 1.1.0 =
|
||||
* Added compatibility with WordPress 5.9
|
||||
|
||||
= 1.0.9 =
|
||||
* Improved plugin security.
|
||||
|
||||
= 1.0.8 =
|
||||
* Improved the display of the panel in the admin
|
||||
|
||||
= 1.0.7 =
|
||||
* Compatibility fixes for WordPress 5.5
|
||||
|
||||
= 1.0.6 =
|
||||
* Improved google scheme.
|
||||
* Improved posts location.
|
||||
|
||||
= 1.0.5 =
|
||||
* Added support Post Views Counter.
|
||||
|
||||
= 1.0.4 =
|
||||
* Minor improvements.
|
||||
|
||||
= 1.0.3 =
|
||||
* Added css variables to styles.
|
||||
|
||||
= 1.0.2 =
|
||||
* Improve indicators.
|
||||
|
||||
= 1.0.1 =
|
||||
* Initial release.
|
||||
|
||||
= 1.0 =
|
||||
* Initial release.
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Absolute Reviews
|
||||
* Description: Add beautiful responsive and modern review boxes with valid JSON-LD schema to your posts with the "Advanced Reviews" plugin.
|
||||
* Version: 1.1.1
|
||||
* Author: Code Supply Co.
|
||||
* Author URI: https://codesupply.co
|
||||
* License: GPL-2.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
* Text Domain: absolute-reviews
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @package ABR
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variables
|
||||
*/
|
||||
define( 'ABR_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'ABR_PATH', plugin_dir_path( __FILE__ ) );
|
||||
|
||||
/**
|
||||
* Plugin Activation.
|
||||
*/
|
||||
function abr_activation() {
|
||||
do_action( 'abr_activation' );
|
||||
}
|
||||
register_activation_hook( __FILE__, 'abr_activation' );
|
||||
|
||||
/**
|
||||
* Plugin Deactivation.
|
||||
*/
|
||||
function abr_deactivation() {
|
||||
do_action( 'abr_deactivation' );
|
||||
}
|
||||
register_deactivation_hook( __FILE__, 'abr_deactivation' );
|
||||
|
||||
/**
|
||||
* The core plugin class that is used to define internationalization,
|
||||
* admin-specific hooks, and public-facing site hooks.
|
||||
*/
|
||||
require plugin_dir_path( __FILE__ ) . 'includes/class-absolute-reviews.php';
|
||||
|
||||
/**
|
||||
* Begins execution of the plugin.
|
||||
*
|
||||
* Since everything within the plugin is registered via hooks,
|
||||
* then kicking off the plugin from this point in the file does
|
||||
* not affect the page life cycle.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function abr_init() {
|
||||
|
||||
$plugin = new ABR();
|
||||
$plugin->run();
|
||||
|
||||
}
|
||||
abr_init();
|
||||
@@ -0,0 +1,922 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The admin-specific functionality of the plugin.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/admin
|
||||
*/
|
||||
|
||||
/**
|
||||
* The admin-specific functionality of the plugin.
|
||||
*
|
||||
* Defines the plugin name, version, and two examples hooks for how to
|
||||
* enqueue the admin-specific stylesheet and JavaScript.
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/admin
|
||||
*/
|
||||
class ABR_Admin {
|
||||
|
||||
/**
|
||||
* The ID of this plugin.
|
||||
|
||||
* @access private
|
||||
* @var string $abr The ID of this plugin.
|
||||
*/
|
||||
private $abr;
|
||||
|
||||
/**
|
||||
* The version of this plugin.
|
||||
|
||||
* @access private
|
||||
* @var string $version The current version of this plugin.
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Initialize the class and set its properties.
|
||||
*
|
||||
* @param string $abr The name of this plugin.
|
||||
* @param string $version The version of this plugin.
|
||||
*/
|
||||
public function __construct( $abr, $version ) {
|
||||
$this->abr = $abr;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_options_page() {
|
||||
add_options_page( esc_html__( 'Reviews', 'absolute-reviews' ), esc_html__( 'Reviews', 'absolute-reviews' ), 'manage_options', 'absolute-reviews', array( $this, 'build_options_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function build_options_page() {
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_die( esc_html__( 'You do not have sufficient rights to view this page.', 'absolute-reviews' ) );
|
||||
}
|
||||
|
||||
$indicators = abr_default_indicators();
|
||||
|
||||
$this->save_options_page();
|
||||
?>
|
||||
|
||||
<div class="wrap abr-wrap">
|
||||
<h2><?php esc_html_e( 'Reviews Settings', 'absolute-reviews' ); ?></h2>
|
||||
|
||||
<div class="abr-settings">
|
||||
<form method="post">
|
||||
<h3><?php esc_html_e( 'Indicators of the progress bar', 'absolute-reviews' ); ?></h3>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
for ( $index = 1; $index <= 10; $index++ ) {
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="abr_review_indicator_label_<?php echo esc_attr( $index ); ?>"><?php esc_html_e( 'Indicator', 'absolute-reviews' ); ?> <?php echo esc_attr( $index ); ?></label>
|
||||
<p class="description"><?php esc_html_e( 'Default:', 'absolute-reviews' ); ?> <?php echo esc_html( $indicators[ $index ]['name'] ); ?></p>
|
||||
</th>
|
||||
<td>
|
||||
<input class="regular-text" id="abr_review_indicator_label_<?php echo esc_attr( $index ); ?>" placeholder="<?php esc_html_e( 'Label', 'absolute-reviews' ); ?>" name="abr_review_indicator_label_<?php echo esc_attr( $index ); ?>" type="text" value="<?php echo esc_attr( get_option( "abr_review_indicator_label_{$index}", $indicators[ $index ]['name'] ) ); ?>"><br>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="abr_review_disable_indicators"><?php esc_html_e( 'Disable all indicators on the front end', 'absolute-reviews' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input class="regular-text" id="abr_review_disable_indicators" name="abr_review_disable_indicators[]" type="checkbox" value="true" <?php checked( (bool) get_option( 'abr_review_disable_indicators', false ) ); ?>>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><?php esc_html_e( 'Supported Post Types', 'absolute-reviews' ); ?></h3>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="abr_review_post_types"><?php esc_html_e( 'Enable reviews for the following post types', 'absolute-reviews' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
$post_types = get_post_types(
|
||||
array(
|
||||
'publicly_queryable' => 1,
|
||||
'_builtin' => false,
|
||||
)
|
||||
);
|
||||
|
||||
unset( $post_types['attachment'] );
|
||||
|
||||
// Merge post types.
|
||||
$post_types = array_merge( abr_default_post_types(), $post_types );
|
||||
|
||||
// Get types of option.
|
||||
$option_types = get_option( 'abr_review_post_types', abr_default_post_types() );
|
||||
|
||||
foreach ( $post_types as $post_type ) {
|
||||
?>
|
||||
<p>
|
||||
<label><input class="regular-text" id="abr_review_post_types" name="abr_review_post_types[]" type="checkbox" value="<?php echo esc_attr( $post_type ); ?>" <?php echo in_array( $post_type, $option_types, true ) ? 'checked' : ''; ?>> <?php echo esc_html( $post_type ); ?></label>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php wp_nonce_field(); ?>
|
||||
|
||||
<p class="submit"><input class="button button-primary" name="save_settings" type="submit" value="<?php esc_html_e( 'Save changes', 'absolute-reviews' ); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings save
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function save_options_page() {
|
||||
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['save_settings'] ) ) { // Input var ok.
|
||||
for ( $index = 1; $index <= 10; $index++ ) {
|
||||
if ( isset( $_POST[ 'abr_review_indicator_label_' . $index ] ) ) { // Input var ok.
|
||||
update_option( "abr_review_indicator_label_{$index}", sanitize_text_field( wp_unslash( $_POST[ 'abr_review_indicator_label_' . $index ] ) ) ); // Input var ok.
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_post_types'] ) ) { // Input var ok; sanitization ok.
|
||||
|
||||
$post_types = is_array( $_POST['abr_review_post_types'] ) ? $_POST['abr_review_post_types'] : array(); // Input var ok; sanitization ok.
|
||||
|
||||
update_option( 'abr_review_post_types', array_map( 'sanitize_text_field', $post_types ) );
|
||||
} else {
|
||||
update_option( 'abr_review_post_types', array() );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_disable_indicators'] ) ) { // Input var ok.
|
||||
update_option( 'abr_review_disable_indicators', true );
|
||||
} else {
|
||||
update_option( 'abr_review_disable_indicators', false );
|
||||
}
|
||||
|
||||
printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'absolute-reviews' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Addd new Meta Box for Review.
|
||||
*/
|
||||
public function metabox_review_register() {
|
||||
// Get types of option.
|
||||
$option_types = get_option( 'abr_review_post_types', abr_default_post_types() );
|
||||
|
||||
if ( $option_types ) {
|
||||
add_meta_box( 'abr_review_metabox', esc_html__( 'Review Options', 'absolute-reviews' ), array( $this, 'metabox_review_callback' ), $option_types, 'normal', 'high', null );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for Review Meta Box.
|
||||
*
|
||||
* @param object $post Object of post.
|
||||
*/
|
||||
public function metabox_review_callback( $post ) {
|
||||
|
||||
$review_settings = abr_get_post_metadata( $post->ID, '_abr_review_settings', true );
|
||||
$review_heading = abr_get_post_metadata( $post->ID, '_abr_review_heading', true );
|
||||
$review_desc = abr_get_post_metadata( $post->ID, '_abr_review_desc', true );
|
||||
$review_legend = abr_get_post_metadata( $post->ID, '_abr_review_legend', true );
|
||||
$review_type = abr_get_post_metadata( $post->ID, '_abr_review_type', true, 'percentage' );
|
||||
$review_items = abr_get_post_metadata( $post->ID, '_abr_review_items', true, array() );
|
||||
$review_main_scale = abr_get_post_metadata( $post->ID, '_abr_review_main_scale', true, true );
|
||||
$review_auto_score = abr_get_post_metadata( $post->ID, '_abr_review_auto_score', true, true );
|
||||
$review_total_score = abr_get_post_metadata( $post->ID, '_abr_review_total_score', true );
|
||||
$review_pros_heading = abr_get_post_metadata( $post->ID, '_abr_review_pros_heading', true );
|
||||
$review_pros_items = abr_get_post_metadata( $post->ID, '_abr_review_pros_items', true, array() );
|
||||
$review_cons_heading = abr_get_post_metadata( $post->ID, '_abr_review_cons_heading', true );
|
||||
$review_cons_items = abr_get_post_metadata( $post->ID, '_abr_review_cons_items', true, array() );
|
||||
$review_schema_heading = abr_get_post_metadata( $post->ID, '_abr_review_schema_heading', true );
|
||||
$review_schema_desc = abr_get_post_metadata( $post->ID, '_abr_review_schema_desc', true );
|
||||
$review_schema_author = abr_get_post_metadata( $post->ID, '_abr_review_schema_author', true );
|
||||
$review_schema_author_custom = abr_get_post_metadata( $post->ID, '_abr_review_schema_author_custom', true );
|
||||
?>
|
||||
<div class="abr-metabox-wrap review-wrap">
|
||||
<input type="hidden" name="abr_review_action" value="1">
|
||||
|
||||
<?php wp_nonce_field( 'abr_review_meta_nonce', 'abr_review_meta_nonce' ); ?>
|
||||
|
||||
<div class="abr-metabox-switcher">
|
||||
<input class="abr-metabox-checkbox" type="checkbox" name="abr_review_settings" value="1" <?php checked( $review_settings ); ?>>
|
||||
|
||||
<div class="abr-metabox-switch">
|
||||
<span class="abr-metabox-switch-on"></span>
|
||||
<span class="abr-metabox-switch-off"></span>
|
||||
<span class="abr-metabox-switch-slider"></span>
|
||||
</div>
|
||||
|
||||
<?php esc_html_e( 'Enable Review', 'absolute-reviews' ); ?>
|
||||
</div>
|
||||
|
||||
<div class="abr-metabox-tabs" <?php checked( $review_settings ); ?>>
|
||||
<ul class="abr-metabox-tabs-navigation">
|
||||
<li><a href="#review-tab-general"><?php esc_html_e( 'General', 'absolute-reviews' ); ?></a></li>
|
||||
<li><a href="#review-tab-criteria"><?php esc_html_e( 'Criteria', 'absolute-reviews' ); ?></a></li>
|
||||
<li><a href="#review-tab-pros-cons"><?php esc_html_e( 'Pros / Cons', 'absolute-reviews' ); ?></a></li>
|
||||
<li><a href="#review-tab-scheme"><?php esc_html_e( 'Schema Attributes', 'absolute-reviews' ); ?></a></li>
|
||||
</ul>
|
||||
<div class="abr-metabox-tabs-content">
|
||||
<div id="review-tab-general">
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_heading"><?php esc_html_e( 'Heading', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<input type="text" id="abr_review_heading" name="abr_review_heading" value="<?php echo esc_attr( $review_heading ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_desc"><?php esc_html_e( 'Description', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<textarea id="abr_review_desc" name="abr_review_desc" rows="6"><?php echo esc_html( $review_desc ); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_legend"><?php esc_html_e( 'Legend', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<textarea id="abr_review_legend" name="abr_review_legend" rows="3"><?php echo wp_kses_post( $review_legend ); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_type"><?php esc_html_e( 'Type', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<select id="abr_review_type" name="abr_review_type">
|
||||
<option value="percentage" <?php selected( $review_type, 'percentage' ); ?>><?php esc_html_e( 'Percentage (1-100%)', 'absolute-reviews' ); ?></option>
|
||||
<option value="point-5" <?php selected( $review_type, 'point-5' ); ?>><?php esc_html_e( 'Points (1-5)', 'absolute-reviews' ); ?></option>
|
||||
<option value="point-10" <?php selected( $review_type, 'point-10' ); ?>><?php esc_html_e( 'Points (1-10)', 'absolute-reviews' ); ?></option>
|
||||
<option value="star" <?php selected( $review_type, 'star' ); ?>><?php esc_html_e( 'Stars (1-5)', 'absolute-reviews' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_main_scale"><?php esc_html_e( 'Main Scale', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<label><input type="checkbox" id="abr_review_main_scale" name="abr_review_main_scale" value="1" <?php checked( $review_main_scale ); ?>></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field review-field-auto-score">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_auto_score"><?php esc_html_e( 'Auto Сalculate Total Score', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<label><input type="checkbox" id="abr_review_auto_score" name="abr_review_auto_score" value="1" <?php checked( $review_auto_score ); ?>></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field review-field-total-score" <?php checked( $review_auto_score ); ?>>
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_total_score"><?php esc_html_e( 'Total Score', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<input type="text" id="abr_review_total_score" name="abr_review_total_score" value="<?php echo esc_attr( $review_total_score ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="review-tab-criteria">
|
||||
<div class="abr-metabox-repeater">
|
||||
<table class="abr-metabox-repeater-table">
|
||||
<tbody>
|
||||
<tr class="row hidden">
|
||||
<td>
|
||||
<div class="row-content">
|
||||
<div class="row-topbar">
|
||||
<a href="#" class="btn-remove-row delete"><?php esc_html_e( 'Remove', 'absolute-reviews' ); ?></a>
|
||||
<div class="handlediv" title="<?php esc_html_e( 'Click to toggle', 'absolute-reviews' ); ?>"></div>
|
||||
<strong class="signature"><span><?php echo esc_html__( 'Criterion', 'absolute-reviews' ); ?></span></strong>
|
||||
</div>
|
||||
|
||||
<div class="row-fields">
|
||||
<div class="row-body review-field-grid">
|
||||
<p class="review-field-criterion-name">
|
||||
<label><?php esc_html_e( 'Name', 'absolute-reviews' ); ?>:<br>
|
||||
<input disabled type="text" class="attribute-name" name="abr_review_items[name][]" placeholder="<?php esc_html_e( 'Name', 'absolute-reviews' ); ?>" data-label="<?php esc_html_e( 'Criterion', 'absolute-reviews' ); ?>"></label>
|
||||
</p>
|
||||
|
||||
<p class="review-field-criterion-number">
|
||||
<label><?php esc_html_e( 'Value', 'absolute-reviews' ); ?>:<br>
|
||||
<input disabled type="number" name="abr_review_items[val][]" min="0" step="1"></label>
|
||||
</p>
|
||||
|
||||
<p class="review-field-criterion-desc">
|
||||
<label><?php esc_html_e( 'Description', 'absolute-reviews' ); ?>:<br>
|
||||
<textarea disabled name="abr_review_items[desc][]" placeholder="<?php esc_html_e( 'Description', 'absolute-reviews' ); ?>" row="4"></textarea>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if ( isset( $review_items['name'] ) && $review_items['name'] ) {
|
||||
foreach ( $review_items['name'] as $key => $name ) {
|
||||
?>
|
||||
<tr class="row">
|
||||
<td>
|
||||
<div class="row-content">
|
||||
<div class="row-topbar closed">
|
||||
<a href="#" class="btn-remove-row delete"><?php esc_html_e( 'Remove', 'absolute-reviews' ); ?></a>
|
||||
<div class="handlediv" title="<?php esc_html_e( 'Click to toggle', 'absolute-reviews' ); ?>"></div>
|
||||
<strong class="signature"><?php echo (string) $review_items['name'][ $key ] ? esc_html( $review_items['name'][ $key ] ) : '<span>' . esc_html__( 'Criterion', 'absolute-reviews' ) . '</span>'; ?></strong>
|
||||
</div>
|
||||
|
||||
<div class="row-fields" style="display:none">
|
||||
<div class="row-body review-field-grid">
|
||||
<p class="review-field-criterion-name">
|
||||
<label><?php esc_html_e( 'Name', 'absolute-reviews' ); ?>:<br>
|
||||
<input type="text" class="attribute-name" name="abr_review_items[name][]" placeholder="<?php esc_html_e( 'Name', 'absolute-reviews' ); ?>" data-label="<?php esc_html_e( 'Criterion', 'absolute-reviews' ); ?>" value="<?php echo esc_attr( $review_items['name'][ $key ] ); ?>"></label>
|
||||
</p>
|
||||
|
||||
<p class="review-field-criterion-number">
|
||||
<label><?php esc_html_e( 'Value', 'absolute-reviews' ); ?>:<br>
|
||||
<input type="number" name="abr_review_items[val][]" value="<?php echo esc_attr( $review_items['val'][ $key ] ); ?>" min="0" step="1"></label>
|
||||
</p>
|
||||
|
||||
<p class="review-field-criterion-desc">
|
||||
<label><?php esc_html_e( 'Description', 'absolute-reviews' ); ?>:<br>
|
||||
<textarea name="abr_review_items[desc][]" placeholder="<?php esc_html_e( 'Description', 'absolute-reviews' ); ?>" row="4"><?php echo esc_attr( $review_items['desc'][ $key ] ); ?></textarea>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<a class="btn-add-row button button-primary" href="#" data-event="btn-add-row"><?php esc_html_e( 'Add new criterion', 'absolute-reviews' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="review-tab-pros-cons">
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_pros_heading"><?php esc_html_e( 'Pros Heading', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<input type="text" id="abr_review_pros_heading" name="abr_review_pros_heading" placeholder="<?php esc_html_e( 'The Good', 'absolute-reviews' ); ?>" value="<?php echo esc_attr( $review_pros_heading ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_pros_heading"><?php esc_html_e( 'Pros List', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<div class="abr-metabox-repeater">
|
||||
<table class="abr-metabox-repeater-table review-repeater-simple">
|
||||
<tbody>
|
||||
<tr class="row hidden">
|
||||
<td>
|
||||
<div class="row-content">
|
||||
<div class="row-fields">
|
||||
<div class="row-body">
|
||||
<div class="row-handle">
|
||||
<span class="dashicons dashicons-menu-alt"></span>
|
||||
</div>
|
||||
|
||||
<input disabled type="text" class="attribute-name" name="abr_review_pros_items[name][]" placeholder="<?php esc_html_e( 'Name', 'absolute-reviews' ); ?>" data-label="<?php esc_html_e( 'Item', 'absolute-reviews' ); ?>">
|
||||
|
||||
<a href="#" class="btn-remove-row delete">
|
||||
<span class="dashicons dashicons-no-alt"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if ( isset( $review_pros_items['name'] ) && $review_pros_items['name'] ) {
|
||||
foreach ( $review_pros_items['name'] as $key => $name ) {
|
||||
?>
|
||||
<tr class="row">
|
||||
<td>
|
||||
<div class="row-content">
|
||||
<div class="row-fields">
|
||||
<div class="row-body">
|
||||
<div class="row-handle">
|
||||
<span class="dashicons dashicons-menu-alt"></span>
|
||||
</div>
|
||||
|
||||
<input type="text" class="attribute-name" name="abr_review_pros_items[name][]" placeholder="<?php esc_html_e( 'Name', 'absolute-reviews' ); ?>" data-label="<?php esc_html_e( 'Item', 'absolute-reviews' ); ?>" value="<?php echo esc_attr( $review_pros_items['name'][ $key ] ); ?>"></label>
|
||||
|
||||
<a href="#" class="btn-remove-row delete">
|
||||
<span class="dashicons dashicons-no-alt"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<a class="btn-add-row button button-primary" href="#" data-event="btn-add-row"><?php esc_html_e( 'Add new pros item', 'absolute-reviews' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br><hr><br>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_cons_heading"><?php esc_html_e( 'Cons Heading', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<input type="text" id="abr_review_cons_heading" name="abr_review_cons_heading" placeholder="<?php esc_html_e( 'The Bad', 'absolute-reviews' ); ?>" value="<?php echo esc_attr( $review_cons_heading ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_cons_heading"><?php esc_html_e( 'Cons List', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<div class="abr-metabox-repeater">
|
||||
<table class="abr-metabox-repeater-table review-repeater-simple">
|
||||
<tbody>
|
||||
<tr class="row hidden">
|
||||
<td>
|
||||
<div class="row-content">
|
||||
<div class="row-fields">
|
||||
<div class="row-body">
|
||||
<div class="row-handle">
|
||||
<span class="dashicons dashicons-menu-alt"></span>
|
||||
</div>
|
||||
|
||||
<input disabled type="text" class="attribute-name" name="abr_review_cons_items[name][]" placeholder="<?php esc_html_e( 'Name', 'absolute-reviews' ); ?>" data-label="<?php esc_html_e( 'Item', 'absolute-reviews' ); ?>">
|
||||
|
||||
<a href="#" class="btn-remove-row delete">
|
||||
<span class="dashicons dashicons-no-alt"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if ( isset( $review_cons_items['name'] ) && $review_cons_items['name'] ) {
|
||||
foreach ( $review_cons_items['name'] as $key => $name ) {
|
||||
?>
|
||||
<tr class="row">
|
||||
<td>
|
||||
<div class="row-content">
|
||||
<div class="row-fields">
|
||||
<div class="row-body">
|
||||
<div class="row-handle">
|
||||
<span class="dashicons dashicons-menu-alt"></span>
|
||||
</div>
|
||||
|
||||
<input type="text" class="attribute-name" name="abr_review_cons_items[name][]" placeholder="<?php esc_html_e( 'Name', 'absolute-reviews' ); ?>" data-label="<?php esc_html_e( 'Item', 'absolute-reviews' ); ?>" value="<?php echo esc_attr( $review_cons_items['name'][ $key ] ); ?>"></label>
|
||||
|
||||
<a href="#" class="btn-remove-row delete">
|
||||
<span class="dashicons dashicons-no-alt"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<a class="btn-add-row button button-primary" href="#" data-event="btn-add-row"><?php esc_html_e( 'Add new cons item', 'absolute-reviews' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="review-tab-scheme">
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_schema_heading"><?php esc_html_e( 'Item Reviewed', 'absolute-reviews' ); ?></label>
|
||||
<p class="description"><?php esc_html_e( 'Heading will be used if blank.', 'absolute-reviews' ); ?></p>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<input type="text" id="abr_review_schema_heading" name="abr_review_schema_heading" value="<?php echo esc_attr( $review_schema_heading ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_schema_desc"><?php esc_html_e( 'Review Text', 'absolute-reviews' ); ?></label>
|
||||
<p class="description"><?php esc_html_e( 'Description will be used if blank.', 'absolute-reviews' ); ?></p>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<textarea id="abr_review_schema_desc" name="abr_review_schema_desc" rows="6"><?php echo esc_html( $review_schema_desc ); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_schema_author"><?php esc_html_e( 'Review Author', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<select id="abr_review_schema_author" name="abr_review_schema_author">
|
||||
<?php
|
||||
$user = get_userdata( $post->post_author );
|
||||
|
||||
if ( $user->user_login ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $user->user_login ); ?>" <?php selected( $review_schema_author, $user->user_login ); ?>>
|
||||
<?php echo esc_html( $user->user_login ); ?>
|
||||
</option>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $user->first_name ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $user->first_name ); ?>" <?php selected( $review_schema_author, $user->first_name ); ?>>
|
||||
<?php echo esc_html( $user->first_name ); ?>
|
||||
</option>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $user->last_name ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $user->last_name ); ?>" <?php selected( $review_schema_author, $user->last_name ); ?>>
|
||||
<?php echo esc_html( $user->last_name ); ?>
|
||||
</option>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $user->first_name && $user->last_name ) {
|
||||
$user_var_once = $user->first_name . ' ' . $user->last_name;
|
||||
$user_var_second = $user->last_name . ' ' . $user->first_name;
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $user_var_once ); ?>" <?php selected( $review_schema_author, $user_var_once ); ?>>
|
||||
<?php echo esc_html( $user_var_once ); ?>
|
||||
</option>
|
||||
<option value="<?php echo esc_attr( $user_var_second ); ?>" <?php selected( $review_schema_author, $user_var_second ); ?>>
|
||||
<?php echo esc_html( $user_var_second ); ?>
|
||||
</option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<option value="custom" <?php selected( $review_schema_author, 'custom' ); ?>><?php esc_html_e( 'Custom', 'absolute-reviews' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="abr-metabox-field review-field-schema-author-custom" <?php checked( $review_schema_author, 'custom' ); ?>">
|
||||
<div class="abr-metabox-label">
|
||||
<label for="abr_review_schema_author_custom"><?php esc_html_e( 'Custom Author', 'absolute-reviews' ); ?></label>
|
||||
</div>
|
||||
<div class="abr-metabox-input">
|
||||
<input type="text" id="abr_review_schema_author_custom" name="abr_review_schema_author_custom" value="<?php echo esc_attr( $review_schema_author_custom ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta tags by post
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param object $post Post Object.
|
||||
*/
|
||||
public function metabox_review_save( $post_id, $post ) {
|
||||
|
||||
// Break if doing autosave.
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Break if current user can't edit this post.
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Break if this post revision.
|
||||
if ( wp_is_post_revision( $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $_POST['abr_review_meta_nonce'] ) || ! wp_verify_nonce( $_POST['abr_review_meta_nonce'], 'abr_review_meta_nonce' ) ) { // Input var ok; sanitization ok.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $_POST['abr_review_action'] ) || 1 !== (int) $_POST['abr_review_action'] ) { // Input var ok; sanitization ok.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_settings'] ) ) { // Input var ok; sanitization ok.
|
||||
update_post_meta( $post_id, '_abr_review_settings', 1 );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_abr_review_settings', '' );
|
||||
}
|
||||
|
||||
// Check Switch Metabox.
|
||||
if ( isset( $_POST['abr_review_settings'] ) ) { // Input var ok; sanitization ok.
|
||||
|
||||
$review_type = null;
|
||||
$review_items = null;
|
||||
|
||||
if ( isset( $_POST['abr_review_heading'] ) ) {
|
||||
$review_heading = sanitize_text_field( $_POST['abr_review_heading'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_heading', $review_heading );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_type'] ) ) {
|
||||
$review_type = sanitize_text_field( $_POST['abr_review_type'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_type', $review_type );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_items'] ) ) { // Input var ok; sanitization ok.
|
||||
$review_items = map_deep( $_POST['abr_review_items'], 'sanitize_text_field' ); // Input var ok; sanitization ok.
|
||||
|
||||
if ( isset( $_POST['abr_review_type'] ) && isset( $review_items['val'] ) ) { // Input var ok; sanitization ok.
|
||||
switch ( $_POST['abr_review_type'] ) { // Input var ok; sanitization ok.
|
||||
case 'percentage':
|
||||
$max = '100';
|
||||
break;
|
||||
case 'point-5':
|
||||
$max = '5';
|
||||
break;
|
||||
case 'point-10':
|
||||
$max = '10';
|
||||
break;
|
||||
case 'star':
|
||||
$max = '5';
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $review_items['val'] ) {
|
||||
foreach ( $review_items['val'] as $key => $value ) {
|
||||
if ( $value > $max ) {
|
||||
$review_items['val'][ $key ] = $max;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_items', $review_items );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_abr_review_items', array() );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_main_scale'] ) ) { // Input var ok; sanitization ok.
|
||||
update_post_meta( $post_id, '_abr_review_main_scale', 1 );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_abr_review_main_scale', '' );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_auto_score'] ) ) { // Input var ok; sanitization ok.
|
||||
update_post_meta( $post_id, '_abr_review_auto_score', 1 );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_abr_review_auto_score', '' );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_total_score'] ) ) {
|
||||
$review_total_score = sanitize_text_field( $_POST['abr_review_total_score'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_total_score', $review_total_score );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_desc'] ) ) { // Input var ok; sanitization ok.
|
||||
$review_desc = sanitize_text_field( $_POST['abr_review_desc'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_desc', $review_desc );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_pros_heading'] ) ) {
|
||||
$review_pros_heading = sanitize_text_field( $_POST['abr_review_pros_heading'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_pros_heading', $review_pros_heading );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_pros_items'] ) ) { // Input var ok; sanitization ok.
|
||||
$review_pros_items = map_deep( $_POST['abr_review_pros_items'], 'sanitize_text_field' ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_pros_items', $review_pros_items );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_abr_review_pros_items', array() );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_cons_heading'] ) ) {
|
||||
$review_cons_heading = sanitize_text_field( $_POST['abr_review_cons_heading'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_cons_heading', $review_cons_heading );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_cons_items'] ) ) { // Input var ok; sanitization ok.
|
||||
$review_cons_items = map_deep( $_POST['abr_review_cons_items'], 'sanitize_text_field' ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_cons_items', $review_cons_items );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_abr_review_cons_items', array() );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_legend'] ) ) { // Input var ok; sanitization ok.
|
||||
$review_legend = sanitize_text_field( $_POST['abr_review_legend'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_legend', $review_legend );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_schema_heading'] ) ) {
|
||||
$review_schema_heading = sanitize_text_field( $_POST['abr_review_schema_heading'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_schema_heading', $review_schema_heading );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_schema_desc'] ) ) {
|
||||
$review_schema_desc = sanitize_text_field( $_POST['abr_review_schema_desc'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_schema_desc', $review_schema_desc );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_schema_author'] ) ) {
|
||||
$review_schema_author = sanitize_text_field( $_POST['abr_review_schema_author'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_schema_author', $review_schema_author );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['abr_review_schema_author_custom'] ) ) {
|
||||
$review_schema_author_custom = sanitize_text_field( $_POST['abr_review_schema_author_custom'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_schema_author_custom', $review_schema_author_custom );
|
||||
}
|
||||
|
||||
// Review total score.
|
||||
$total_score = (float) $this->calc_review_total_score( $post_id, $review_type, $review_items );
|
||||
|
||||
/* ------------------------ */
|
||||
|
||||
// Save total score number.
|
||||
$review_type = abr_get_post_metadata( $post_id, '_abr_review_type', true, 'percentage' );
|
||||
|
||||
$review_auto_score = abr_get_post_metadata( $post_id, '_abr_review_auto_score', true, true );
|
||||
|
||||
if ( empty( $review_auto_score ) ) {
|
||||
$total_score = (float) abr_get_post_metadata( $post_id, '_abr_review_total_score', true );
|
||||
}
|
||||
|
||||
// Vars.
|
||||
switch ( $review_type ) {
|
||||
case 'percentage':
|
||||
$max = 100;
|
||||
break;
|
||||
case 'point-5':
|
||||
$max = 5;
|
||||
break;
|
||||
case 'point-10':
|
||||
$max = 10;
|
||||
break;
|
||||
case 'star':
|
||||
$max = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
// Validate value.
|
||||
switch ( $review_type ) {
|
||||
case 'percentage':
|
||||
case 'point-5':
|
||||
case 'point-10':
|
||||
$total_score = ( $total_score <= $max ) ? round( $total_score ) : $max;
|
||||
break;
|
||||
case 'star':
|
||||
$total_score = ( $total_score <= $max ) ? round( $total_score, 1 ) : $max;
|
||||
break;
|
||||
}
|
||||
|
||||
update_post_meta( $post_id, '_abr_review_total_score_number', (float) $total_score );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calc Total Score
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param string $review_type Type of review.
|
||||
* @param array $review_items Array list items.
|
||||
*/
|
||||
public function calc_review_total_score( $post_id, $review_type, $review_items ) {
|
||||
|
||||
/* Review Type */
|
||||
if ( $review_type ) {
|
||||
|
||||
/* Set Score */
|
||||
switch ( $review_type ) {
|
||||
case 'star':
|
||||
$stars_count = 5;
|
||||
break;
|
||||
case 'point-5':
|
||||
$points_count = 5;
|
||||
break;
|
||||
case 'point-10':
|
||||
$points_count = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( isset( $review_items['name'] ) && $review_items['name'] ) {
|
||||
$average = 0;
|
||||
|
||||
$review_items_count = 0;
|
||||
|
||||
foreach ( $review_items['name'] as $key => $item_name ) {
|
||||
|
||||
if ( ! $item_name ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item_value = floatval( $review_items['val'][ $key ] );
|
||||
|
||||
/* Get Item Value */
|
||||
switch ( $review_type ) {
|
||||
case 'star':
|
||||
$item_value = ( $item_value <= $stars_count ) ? $item_value : $stars_count;
|
||||
break;
|
||||
case 'point-5':
|
||||
case 'point-10':
|
||||
$item_value = ( $item_value <= $points_count ) ? $item_value : $points_count;
|
||||
break;
|
||||
}
|
||||
|
||||
$review_items_count++;
|
||||
|
||||
$average += floatval( $item_value );
|
||||
}
|
||||
|
||||
if ( $average > 0 ) {
|
||||
$average = $average / $review_items_count;
|
||||
|
||||
$average = round( $average, 1 );
|
||||
}
|
||||
|
||||
return $average;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets and JavaScript for the admin area.
|
||||
*
|
||||
* @param string $page Current page.
|
||||
*/
|
||||
public function admin_enqueue_scripts( $page ) {
|
||||
|
||||
// Styles.
|
||||
wp_enqueue_style( $this->abr, abr_style( plugin_dir_url( __FILE__ ) . 'css/absolute-reviews-admin.css' ), array(), $this->version, 'all' );
|
||||
|
||||
if ( in_array( $page, array( 'post.php', 'post-new.php' ), true ) ) {
|
||||
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_script( 'jquery-ui-tabs' );
|
||||
|
||||
// Scripts.
|
||||
wp_enqueue_script( $this->abr, plugin_dir_url( __FILE__ ) . 'js/absolute-reviews-admin.js', array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-sortable' ), $this->version, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,547 @@
|
||||
/**
|
||||
* All of the CSS for your admin-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
@font-face {
|
||||
font-family: 'absolute-reviews-icons';
|
||||
src: url("../../fonts/absolute-reviews-icons.woff") format("woff"), url("../../fonts/absolute-reviews-icons.ttf") format("truetype"), url("../../fonts/absolute-reviews-icons.svg") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
[class^="abr-icon-"],
|
||||
[class*=" abr-icon-"] {
|
||||
font-family: 'absolute-reviews-icons' !important;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.abr-icon-comment:before {
|
||||
content: "\e905";
|
||||
}
|
||||
|
||||
.abr-icon-eye:before {
|
||||
content: "\e903";
|
||||
}
|
||||
|
||||
.abr-icon-watch:before {
|
||||
content: "\e904";
|
||||
}
|
||||
|
||||
.abr-icon-funds-fill:before {
|
||||
content: "\e902";
|
||||
}
|
||||
|
||||
.abr-icon-x:before {
|
||||
content: "\e901";
|
||||
}
|
||||
|
||||
.abr-icon-check:before {
|
||||
content: "\e900";
|
||||
}
|
||||
|
||||
.abr-icon-star-half:before {
|
||||
content: "\e938";
|
||||
}
|
||||
|
||||
.abr-icon-star-full:before {
|
||||
content: "\e939";
|
||||
}
|
||||
|
||||
.abr-icon-star-empty:before {
|
||||
content: "\e93a";
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Basic -------------------------------------------------------------- */
|
||||
.abr-metabox-wrap .abr-metabox-tabs {
|
||||
background: none;
|
||||
border: none;
|
||||
display: flex;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: none;
|
||||
border-left: 1px solid #eee;
|
||||
background: #FAFAFA;
|
||||
flex: 0 0 200px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li {
|
||||
display: block;
|
||||
background: transparent;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
float: none;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li a {
|
||||
border: none;
|
||||
border-bottom: 1px solid #eee;
|
||||
position: relative;
|
||||
display: block;
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.25rem;
|
||||
padding: 0.625rem;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
color: #0073aa;
|
||||
float: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li a:hover {
|
||||
color: #00a0d2;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li.ui-tabs-active {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li.ui-tabs-active a {
|
||||
background-color: #eee;
|
||||
color: #555;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-content {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-content .ui-tabs-panel {
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.abr-metabox-wrap .abr-metabox-tabs {
|
||||
flex-direction: column;
|
||||
}
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field {
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-label {
|
||||
position: relative;
|
||||
flex: 0 0 100%;
|
||||
float: none;
|
||||
margin: 0;
|
||||
padding: 1rem 1rem 0.5rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-label label {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
margin: 0 0 3px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input {
|
||||
position: relative;
|
||||
flex: 0 0 100%;
|
||||
margin: 0;
|
||||
padding: 1rem 1rem 0.5rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="number"],
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="text"],
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input select,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="number"].short,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="text"].short,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input select.short,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input textarea.short {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.abr-metabox-wrap .abr-metabox-field {
|
||||
flex-direction: row;
|
||||
}
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-label {
|
||||
flex: 0 0 20%;
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input {
|
||||
flex: 0 0 80%;
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
top: -2rem;
|
||||
left: 1rem;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch {
|
||||
border: 2px solid #555d66;
|
||||
box-sizing: border-box;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
height: 1.75rem;
|
||||
height: 18px;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
width: 36px;
|
||||
margin-left: 0.5rem;
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch .abr-metabox-switch-on {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
z-index: 1;
|
||||
background: #6C7781;
|
||||
border-radius: 50%;
|
||||
transition: all 0s ease 0.25s;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch .abr-metabox-switch-off {
|
||||
border: 2px solid #6c7781;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
z-index: 1;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch .abr-metabox-switch-slider {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
z-index: 1;
|
||||
background: #6C7781;
|
||||
border-radius: 50%;
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch {
|
||||
border-color: #11A0D2;
|
||||
background: #11A0D2;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch .abr-metabox-switch-on {
|
||||
top: 4px;
|
||||
right: 6px;
|
||||
width: 2px;
|
||||
height: 6px;
|
||||
background: #FFFFFF;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch .abr-metabox-switch-off {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch .abr-metabox-switch-slider {
|
||||
background: #FFFFFF;
|
||||
top: 2px;
|
||||
right: calc(50% + 4px);
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table {
|
||||
width: 100%;
|
||||
border: none;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr {
|
||||
background: #FFFFFF;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr th {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr th,
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr td {
|
||||
border: none;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr.ui-sortable-helper {
|
||||
display: table;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr.ui-sortable-placeholder {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr.ui-state-highlight td {
|
||||
background: #F9F9F9;
|
||||
border: 1px dashed #D8D8D8;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .btn-add-row {
|
||||
margin: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-content input, .abr-metabox-wrap .abr-metabox-repeater .row-content textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-content input[type="number"] {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-content p {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar {
|
||||
position: relative;
|
||||
border-bottom: 1px solid #EFEFEF;
|
||||
padding: 1rem 1.25rem;
|
||||
zoom: 1;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .handlediv {
|
||||
display: block !important;
|
||||
background-position: 6px 5px;
|
||||
visibility: hidden;
|
||||
width: 27px;
|
||||
height: 26px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .handlediv:before {
|
||||
content: "\f142";
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font: 400 20px/1 Dashicons;
|
||||
line-height: .5;
|
||||
padding: 8px 10px;
|
||||
position: relative;
|
||||
left: 12px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar.closed .handlediv:before {
|
||||
content: "\f140";
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .delete {
|
||||
color: red;
|
||||
font-weight: 400;
|
||||
line-height: 26px;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
visibility: hidden;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .signature {
|
||||
display: inline-block;
|
||||
padding-left: 100px;
|
||||
line-height: 26px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .signature span {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar:hover .handlediv,
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar:hover .delete {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-fields {
|
||||
border-bottom: 1px solid #EFEFEF;
|
||||
background-color: #FDFDFD;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-body {
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
/* Reviews -------------------------------------------------------------- */
|
||||
#abr_review_metabox .handlediv {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .inside {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#abr_review_metabox .hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .handle-actions {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .postbox-header {
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
#abr_review_metabox .abr-metabox-tabs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .abr-metabox-tabs[checked="checked"] {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .row-fields {
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .row-body {
|
||||
position: relative;
|
||||
padding: 0.5rem 2rem;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .row-handle {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 0;
|
||||
transform: translateY(-50%);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .btn-remove-row {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
transform: translateY(-50%);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
color: #555d66;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .btn-remove-row:hover {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple + .btn-add-row {
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
#abr_review_metabox .review-field-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-name {
|
||||
flex: 1 0 70%;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-number {
|
||||
flex: 1 0 30%;
|
||||
padding-right: 2rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-number input {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-desc {
|
||||
flex: 1 0 100%;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-desc textarea {
|
||||
min-height: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Widget -------------------------------------------------------------- */
|
||||
.widget[id*="abr_reviews_posts_widget"] .widget-content fieldset {
|
||||
border: 1px solid #DDDDDD;
|
||||
margin-top: 0.5rem;
|
||||
padding: 0 0.75rem;
|
||||
}
|
||||
|
||||
.widget[id*="abr_reviews_posts_widget"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"] .abr-small-post {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-3"] .abr-simple-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-4"] .abr-simple-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-5"] .abr-simple-post {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-3"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-3"] .abr-small-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-4"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-4"] .abr-small-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-5"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-5"] .abr-small-post {
|
||||
display: block;
|
||||
}
|
||||
@@ -0,0 +1,547 @@
|
||||
/**
|
||||
* All of the CSS for your admin-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
@font-face {
|
||||
font-family: 'absolute-reviews-icons';
|
||||
src: url("../../fonts/absolute-reviews-icons.woff") format("woff"), url("../../fonts/absolute-reviews-icons.ttf") format("truetype"), url("../../fonts/absolute-reviews-icons.svg") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
[class^="abr-icon-"],
|
||||
[class*=" abr-icon-"] {
|
||||
font-family: 'absolute-reviews-icons' !important;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.abr-icon-comment:before {
|
||||
content: "\e905";
|
||||
}
|
||||
|
||||
.abr-icon-eye:before {
|
||||
content: "\e903";
|
||||
}
|
||||
|
||||
.abr-icon-watch:before {
|
||||
content: "\e904";
|
||||
}
|
||||
|
||||
.abr-icon-funds-fill:before {
|
||||
content: "\e902";
|
||||
}
|
||||
|
||||
.abr-icon-x:before {
|
||||
content: "\e901";
|
||||
}
|
||||
|
||||
.abr-icon-check:before {
|
||||
content: "\e900";
|
||||
}
|
||||
|
||||
.abr-icon-star-half:before {
|
||||
content: "\e938";
|
||||
}
|
||||
|
||||
.abr-icon-star-full:before {
|
||||
content: "\e939";
|
||||
}
|
||||
|
||||
.abr-icon-star-empty:before {
|
||||
content: "\e93a";
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Basic -------------------------------------------------------------- */
|
||||
.abr-metabox-wrap .abr-metabox-tabs {
|
||||
background: none;
|
||||
border: none;
|
||||
display: flex;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: none;
|
||||
border-right: 1px solid #eee;
|
||||
background: #FAFAFA;
|
||||
flex: 0 0 200px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li {
|
||||
display: block;
|
||||
background: transparent;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
float: none;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li a {
|
||||
border: none;
|
||||
border-bottom: 1px solid #eee;
|
||||
position: relative;
|
||||
display: block;
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.25rem;
|
||||
padding: 0.625rem;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
color: #0073aa;
|
||||
float: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li a:hover {
|
||||
color: #00a0d2;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li.ui-tabs-active {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation li.ui-tabs-active a {
|
||||
background-color: #eee;
|
||||
color: #555;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-content {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-content .ui-tabs-panel {
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.abr-metabox-wrap .abr-metabox-tabs {
|
||||
flex-direction: column;
|
||||
}
|
||||
.abr-metabox-wrap .abr-metabox-tabs > .abr-metabox-tabs-navigation {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field {
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-label {
|
||||
position: relative;
|
||||
flex: 0 0 100%;
|
||||
float: none;
|
||||
margin: 0;
|
||||
padding: 1rem 1rem 0.5rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-label label {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
margin: 0 0 3px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input {
|
||||
position: relative;
|
||||
flex: 0 0 100%;
|
||||
margin: 0;
|
||||
padding: 1rem 1rem 0.5rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="number"],
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="text"],
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input select,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="number"].short,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input input[type="text"].short,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input select.short,
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input textarea.short {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.abr-metabox-wrap .abr-metabox-field {
|
||||
flex-direction: row;
|
||||
}
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-label {
|
||||
flex: 0 0 20%;
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
.abr-metabox-wrap .abr-metabox-field .abr-metabox-input {
|
||||
flex: 0 0 80%;
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
top: -2rem;
|
||||
right: 1rem;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch {
|
||||
border: 2px solid #555d66;
|
||||
box-sizing: border-box;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
height: 1.75rem;
|
||||
height: 18px;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
width: 36px;
|
||||
margin-right: 0.5rem;
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch .abr-metabox-switch-on {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
z-index: 1;
|
||||
background: #6C7781;
|
||||
border-radius: 50%;
|
||||
transition: all 0s ease 0.25s;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch .abr-metabox-switch-off {
|
||||
border: 2px solid #6c7781;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
z-index: 1;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-switch .abr-metabox-switch-slider {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
z-index: 1;
|
||||
background: #6C7781;
|
||||
border-radius: 50%;
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch {
|
||||
border-color: #11A0D2;
|
||||
background: #11A0D2;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch .abr-metabox-switch-on {
|
||||
top: 4px;
|
||||
left: 6px;
|
||||
width: 2px;
|
||||
height: 6px;
|
||||
background: #FFFFFF;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch .abr-metabox-switch-off {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-switcher .abr-metabox-checkbox:checked + .abr-metabox-switch .abr-metabox-switch-slider {
|
||||
background: #FFFFFF;
|
||||
top: 2px;
|
||||
left: calc(50% + 4px);
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table {
|
||||
width: 100%;
|
||||
border: none;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr {
|
||||
background: #FFFFFF;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr th,
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr td {
|
||||
border: none;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr.ui-sortable-helper {
|
||||
display: table;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr.ui-sortable-placeholder {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater > table tr.ui-state-highlight td {
|
||||
background: #F9F9F9;
|
||||
border: 1px dashed #D8D8D8;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .btn-add-row {
|
||||
margin: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-content input, .abr-metabox-wrap .abr-metabox-repeater .row-content textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-content input[type="number"] {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-content p {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar {
|
||||
position: relative;
|
||||
border-bottom: 1px solid #EFEFEF;
|
||||
padding: 1rem 1.25rem;
|
||||
zoom: 1;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .handlediv {
|
||||
display: block !important;
|
||||
background-position: 6px 5px;
|
||||
visibility: hidden;
|
||||
width: 27px;
|
||||
height: 26px;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .handlediv:before {
|
||||
content: "\f142";
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font: 400 20px/1 Dashicons;
|
||||
line-height: .5;
|
||||
padding: 8px 10px;
|
||||
position: relative;
|
||||
right: 12px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar.closed .handlediv:before {
|
||||
content: "\f140";
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .delete {
|
||||
color: red;
|
||||
font-weight: 400;
|
||||
line-height: 26px;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
visibility: hidden;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .signature {
|
||||
display: inline-block;
|
||||
padding-right: 100px;
|
||||
line-height: 26px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar .signature span {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar:hover .handlediv,
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-topbar:hover .delete {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-fields {
|
||||
border-bottom: 1px solid #EFEFEF;
|
||||
background-color: #FDFDFD;
|
||||
}
|
||||
|
||||
.abr-metabox-wrap .abr-metabox-repeater .row-body {
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
/* Reviews -------------------------------------------------------------- */
|
||||
#abr_review_metabox .handlediv {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .inside {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#abr_review_metabox .hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .handle-actions {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .postbox-header {
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
#abr_review_metabox .abr-metabox-tabs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .abr-metabox-tabs[checked="checked"] {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .row-fields {
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .row-body {
|
||||
position: relative;
|
||||
padding: 0.5rem 2rem;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .row-handle {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
transform: translateY(-50%);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .btn-remove-row {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 0;
|
||||
transform: translateY(-50%);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
color: #555d66;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple .btn-remove-row:hover {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#abr_review_metabox .review-repeater-simple + .btn-add-row {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
#abr_review_metabox .review-field-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-name {
|
||||
flex: 1 0 70%;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-number {
|
||||
flex: 1 0 30%;
|
||||
padding-left: 2rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-number input {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-desc {
|
||||
flex: 1 0 100%;
|
||||
}
|
||||
#abr_review_metabox .review-field-grid .review-field-criterion-desc textarea {
|
||||
min-height: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Widget -------------------------------------------------------------- */
|
||||
.widget[id*="abr_reviews_posts_widget"] .widget-content fieldset {
|
||||
border: 1px solid #DDDDDD;
|
||||
margin-top: 0.5rem;
|
||||
padding: 0 0.75rem;
|
||||
}
|
||||
|
||||
.widget[id*="abr_reviews_posts_widget"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"] .abr-small-post {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-3"] .abr-simple-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-4"] .abr-simple-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-5"] .abr-simple-post {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-3"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-3"] .abr-small-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-4"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-4"] .abr-small-post, .widget[id*="abr_reviews_posts_widget"][template="reviews-5"] .abr-large-post,
|
||||
.widget[id*="abr_reviews_posts_widget"][template="reviews-5"] .abr-small-post {
|
||||
display: block;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
||||
@@ -0,0 +1,211 @@
|
||||
"use strict";
|
||||
|
||||
/* Basic -------------------------------------------------------------- */
|
||||
|
||||
(function($) {
|
||||
var abrMetabox = {};
|
||||
|
||||
( function() {
|
||||
var $this;
|
||||
|
||||
abrMetabox = {
|
||||
/*
|
||||
* Initialize
|
||||
*/
|
||||
init: function( e ) {
|
||||
$this = abrMetabox;
|
||||
|
||||
// Variables.
|
||||
$this.wrap = $( '.abr-metabox-wrap' );
|
||||
|
||||
// Init.
|
||||
$this.metaboxInit( e );
|
||||
|
||||
// Init events.
|
||||
$this.events( e );
|
||||
},
|
||||
|
||||
/*
|
||||
* Events
|
||||
*/
|
||||
events: function( e ) {
|
||||
|
||||
// Custom Events
|
||||
$this.wrap.on( 'click change keyup keydown', '.abr-metabox-repeater .attribute-name', $this.setSignature );
|
||||
$this.wrap.on( 'click', '.abr-metabox-repeater .row-topbar', $this.toggleItems );
|
||||
$this.wrap.on( 'click', '.abr-metabox-repeater .btn-remove-row', $this.removeRepeaterRow );
|
||||
$this.wrap.on( 'click', '.abr-metabox-repeater .btn-add-row', $this.addRepeaterRow );
|
||||
},
|
||||
|
||||
/*
|
||||
* Init metabox elements
|
||||
*/
|
||||
metaboxInit: function( e ) {
|
||||
// Add tabs for Meta Box (UI)
|
||||
$this.wrap.find( '.abr-metabox-tabs' ).tabs();
|
||||
|
||||
// Repeater sortable
|
||||
$this.wrap.find( '.abr-metabox-repeater tbody' ).sortable( {
|
||||
items: 'tr',
|
||||
placeholder: 'ui-state-highlight',
|
||||
handle: '.row-topbar, .row-handle',
|
||||
start: function( e, ui ) {
|
||||
ui.placeholder.height( ui.item.height() );
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/*
|
||||
* Toggle items
|
||||
*/
|
||||
toggleItems: function() {
|
||||
if ( $( this ).hasClass( 'closed' ) ) {
|
||||
$( this ).removeClass( 'closed' );
|
||||
|
||||
$( this ).siblings( '.row-fields' ).slideDown();
|
||||
} else {
|
||||
$( this ).addClass( 'closed' );
|
||||
|
||||
$( this ).siblings( '.row-fields' ).slideUp();
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Set signature
|
||||
*/
|
||||
setSignature: function() {
|
||||
|
||||
var label = '<span>' + $( this ).data( 'label' ) + '</span>';
|
||||
|
||||
var value = $( this ).val() ? $( this ).val() : label;
|
||||
|
||||
$( this ).parents( '.row-content' ).find( '.signature' ).html( value );
|
||||
},
|
||||
|
||||
/*
|
||||
* Add repeater row
|
||||
*/
|
||||
addRepeaterRow: function() {
|
||||
|
||||
var repeater = $( this ).siblings( '.abr-metabox-repeater-table' )
|
||||
|
||||
// Get html row.
|
||||
var html = repeater.find( 'tbody tr.hidden' ).html();
|
||||
|
||||
// Add new row.
|
||||
repeater.find( 'tbody' ).append( '<tr class="row">' + html + '</tr>' );
|
||||
|
||||
// Visible all input and textarea.
|
||||
repeater.find( 'tr' ).not( '.hidden' ).find( 'input, textarea' ).removeAttr( 'disabled' );
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/*
|
||||
* Remove repeater row
|
||||
*/
|
||||
removeRepeaterRow: function() {
|
||||
$( this ).parents( '.row' ).remove();
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} )();
|
||||
|
||||
// Initialize.
|
||||
$( function() {
|
||||
abrMetabox.init();
|
||||
} );
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/* Reviews -------------------------------------------------------------- */
|
||||
|
||||
(function($) {
|
||||
var abrReviews = {};
|
||||
|
||||
( function() {
|
||||
var $this;
|
||||
|
||||
abrReviews = {
|
||||
/*
|
||||
* Initialize
|
||||
*/
|
||||
init: function( e ) {
|
||||
$this = abrReviews;
|
||||
|
||||
// Variables.
|
||||
$this.wrap = $( '.review-wrap' );
|
||||
|
||||
// Init.
|
||||
$this.reviewsInit( e );
|
||||
|
||||
// Init events.
|
||||
$this.events( e );
|
||||
},
|
||||
|
||||
/*
|
||||
* Events
|
||||
*/
|
||||
events: function( e ) {
|
||||
// Custom Events
|
||||
$this.wrap.on( 'click', 'input[name="abr_review_settings"]', $this.toggleMetaBox );
|
||||
$this.wrap.on( 'click', 'input[name="abr_review_auto_score"]', $this.actionAutoScore );
|
||||
$this.wrap.on( 'change', 'select[name="abr_review_schema_author"]', $this.actionSchemaAuthor );
|
||||
},
|
||||
|
||||
/*
|
||||
* Init reviews elements
|
||||
*/
|
||||
reviewsInit: function( e ) {
|
||||
$this.actionAutoScore( 'input[name="abr_review_auto_score"]' );
|
||||
$this.actionSchemaAuthor( 'select[name="abr_review_schema_author"]' );
|
||||
},
|
||||
|
||||
/*
|
||||
* Toggle metabox view
|
||||
*/
|
||||
toggleMetaBox: function() {
|
||||
if ( $( this ).prop( 'checked' ) ) {
|
||||
$this.wrap.find( '.abr-metabox-tabs' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
$this.wrap.find( '.abr-metabox-tabs' ).removeAttr( 'checked' );
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Action auto score
|
||||
*/
|
||||
actionAutoScore: function( e ) {
|
||||
let checked = $( typeof e === 'string' ? e : this ).prop('checked');
|
||||
|
||||
if ( checked ) {
|
||||
$( '.review-field-total-score' ).addClass( 'hidden' );
|
||||
} else {
|
||||
$( '.review-field-total-score' ).removeClass( 'hidden' );
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Action schema author
|
||||
*/
|
||||
actionSchemaAuthor: function( e ) {
|
||||
let val = $( typeof e === 'string' ? e : this ).val();
|
||||
|
||||
if ( 'custom' !== val ) {
|
||||
$( '.review-field-schema-author-custom' ).addClass( 'hidden' );
|
||||
} else {
|
||||
$( '.review-field-schema-author-custom' ).removeClass( 'hidden' );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
} )();
|
||||
|
||||
// Initialize.
|
||||
$( function() {
|
||||
abrReviews.init();
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Generated by IcoMoon</metadata>
|
||||
<defs>
|
||||
<font id="absolute-reviews-icons" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " horiz-adv-x="512" d="" />
|
||||
<glyph unicode="" glyph-name="check" d="M823.168 712.832l-439.168-439.168-183.168 183.168c-16.683 16.683-43.691 16.683-60.331 0s-16.683-43.691 0-60.331l213.333-213.333c16.683-16.683 43.691-16.683 60.331 0l469.333 469.333c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0z" />
|
||||
<glyph unicode="" glyph-name="x" d="M225.835 652.502l225.835-225.835-225.835-225.835c-16.683-16.683-16.683-43.691 0-60.331s43.691-16.683 60.331 0l225.835 225.835 225.835-225.835c16.683-16.683 43.691-16.683 60.331 0s16.683 43.691 0 60.331l-225.835 225.835 225.835 225.835c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0l-225.835-225.835-225.835 225.835c-16.683 16.683-43.691 16.683-60.331 0s-16.683-43.691 0-60.331z" />
|
||||
<glyph unicode="" glyph-name="funds-fill" d="M97.127 147.968l200.192 200.192 144.845-144.794 234.035 233.984 91.801-91.75v256h-256l91.802-91.802-161.638-161.638-144.794 144.845-253.235-253.235c-29.188 65.535-44.226 136.489-44.135 208.23 0 282.778 229.223 512 512 512s512-229.222 512-512c0-282.778-229.222-512-512-512-164.316-0.107-318.673 78.757-414.873 211.968z" />
|
||||
<glyph unicode="" glyph-name="eye" d="M4.523 445.739c-5.803-11.691-6.229-25.728 0-38.144 0 0 16.896-33.664 47.787-78.635 19.243-27.989 44.288-61.099 74.965-94.635 38.144-41.771 85.504-84.779 141.611-119.467 68.053-42.069 149.589-72.192 243.115-72.192s175.061 30.123 243.115 72.192c56.107 34.688 103.467 77.696 141.611 119.467 30.635 33.536 55.723 66.645 74.965 94.635 30.891 44.971 47.787 78.635 47.787 78.635 5.803 11.691 6.229 25.728 0 38.144 0 0-16.896 33.664-47.787 78.635-19.243 27.989-44.288 61.099-74.965 94.635-38.144 41.771-85.504 84.779-141.611 119.467-68.053 42.069-149.589 72.192-243.115 72.192s-175.061-30.123-243.115-72.192c-56.107-34.688-103.467-77.696-141.611-119.467-30.677-33.536-55.723-66.603-74.965-94.635-30.891-44.971-47.787-78.635-47.787-78.635zM91.307 426.667c6.955 11.989 17.365 29.056 31.317 49.408 17.493 25.429 40.107 55.296 67.627 85.376 34.347 37.589 75.733 74.923 123.477 104.448 57.6 35.584 123.776 59.435 198.272 59.435s140.672-23.851 198.229-59.435c47.744-29.525 89.131-66.859 123.477-104.448 27.477-30.080 50.133-59.947 67.627-85.376 13.995-20.352 24.405-37.376 31.317-49.408-6.955-11.989-17.365-29.056-31.317-49.408-17.493-25.429-40.107-55.296-67.627-85.376-34.347-37.589-75.733-74.923-123.477-104.448-57.557-35.584-123.733-59.435-198.229-59.435s-140.672 23.851-198.229 59.435c-47.744 29.525-89.131 66.859-123.477 104.448-27.477 30.080-50.133 59.947-67.627 85.376-13.995 20.352-24.405 37.419-31.36 49.408zM682.667 426.667c0 47.104-19.157 89.856-50.005 120.661s-73.557 50.005-120.661 50.005-89.856-19.157-120.661-50.005-50.005-73.557-50.005-120.661 19.157-89.856 50.005-120.661 73.557-50.005 120.661-50.005 89.856 19.157 120.661 50.005 50.005 73.557 50.005 120.661zM597.333 426.667c0-23.595-9.515-44.843-25.003-60.331s-36.736-25.003-60.331-25.003-44.843 9.515-60.331 25.003-25.003 36.736-25.003 60.331 9.515 44.843 25.003 60.331 36.736 25.003 60.331 25.003 44.843-9.515 60.331-25.003 25.003-36.736 25.003-60.331z" />
|
||||
<glyph unicode="" glyph-name="watch" d="M469.333 554.667v-128c0-11.776 4.779-22.443 12.501-30.165l64-64c16.683-16.683 43.691-16.683 60.331 0s16.683 43.691 0 60.331l-51.499 51.499v110.336c0 23.552-19.115 42.667-42.667 42.667s-42.667-19.115-42.667-42.667zM654.080 116.224l-7.083-77.355c-1.024-11.349-6.272-21.12-14.208-28.075-7.68-6.784-17.707-10.795-28.587-10.795h-184.789c-11.52-0.043-21.76 4.267-29.44 11.477-7.467 6.997-12.416 16.597-13.397 27.435l-7.083 77.525c43.349-19.968 91.648-31.104 142.507-31.104 50.688 0 98.816 11.051 142.080 30.891zM349.312 624.342c44.245 36.48 100.864 58.325 162.688 58.325 70.699 0 134.656-28.587 181.035-74.965s74.965-110.336 74.965-181.035-28.587-134.656-74.965-181.035c-4.437-4.437-9.003-8.704-13.781-12.8-1.493-1.323-3.029-2.603-4.565-3.84-44.245-36.48-100.864-58.325-162.688-58.325-70.699 0-134.656 28.587-181.035 74.965s-74.965 110.336-74.965 181.035 28.587 134.656 74.965 181.035c4.437 4.437 9.003 8.704 13.781 12.8 1.493 1.323 3.029 2.603 4.565 3.84zM746.283 674.902l-13.44 147.413c-2.987 32.256-17.835 61.013-40.021 81.792-22.997 21.547-54.016 34.688-87.808 34.56h-185.771c-32.213-0.128-62.037-12.203-84.693-32.299-23.552-20.821-39.467-50.432-42.539-84.139l-13.397-146.475c-2.688-2.517-5.376-5.12-7.979-7.723-61.696-61.739-99.968-147.115-99.968-241.365s38.272-179.627 99.968-241.365c2.475-2.475 4.992-4.907 7.509-7.296l13.44-146.987c2.987-32.256 17.835-61.013 40.021-81.792 22.997-21.547 54.016-34.688 87.808-34.56h184.661c32.384-0.043 62.421 12.032 85.205 32.171 23.595 20.864 39.637 50.517 42.667 84.267l13.397 146.475c2.688 2.517 5.376 5.12 7.979 7.723 61.739 61.739 100.011 147.115 100.011 241.365s-38.272 179.627-99.968 241.365c-2.304 2.304-4.693 4.608-7.040 6.869zM369.92 737.11l7.083 77.355c1.024 11.307 6.272 21.077 14.123 28.032 7.637 6.784 17.579 10.795 28.459 10.837h185.429c11.52 0.043 21.76-4.267 29.44-11.477 7.467-6.997 12.416-16.597 13.397-27.435l7.083-77.696c-43.477 20.053-91.904 31.275-142.933 31.275-50.688 0-98.816-11.051-142.080-30.891z" />
|
||||
<glyph unicode="" glyph-name="comment" d="M938.667 298.667v426.667c0 35.328-14.379 67.413-37.504 90.496s-55.168 37.504-90.496 37.504h-597.333c-35.328 0-67.413-14.379-90.496-37.504s-37.504-55.168-37.504-90.496v-682.667c0-10.923 4.181-21.845 12.501-30.165 16.683-16.683 43.691-16.683 60.331 0l158.165 158.165h494.336c35.328 0 67.413 14.379 90.496 37.504s37.504 55.168 37.504 90.496zM853.333 298.667c0-11.776-4.736-22.4-12.501-30.165s-18.389-12.501-30.165-12.501h-512c-11.776 0-22.443-4.779-30.165-12.501l-97.835-97.835v579.669c0 11.776 4.736 22.4 12.501 30.165s18.389 12.501 30.165 12.501h597.333c11.776 0 22.4-4.736 30.165-12.501s12.501-18.389 12.501-30.165z" />
|
||||
<glyph unicode="" glyph-name="star-half" d="M1024 562.95l-353.78 51.408-158.22 320.582-158.216-320.582-353.784-51.408 256-249.538-60.432-352.352 316.432 166.358 316.432-166.358-60.434 352.352 256.002 249.538zM512 206.502l-0.942-0.496 0.942 570.768 111.736-226.396 249.836-36.304-180.788-176.222 42.678-248.83-223.462 117.48z" />
|
||||
<glyph unicode="" glyph-name="star-full" d="M1024 562.95l-353.78 51.408-158.22 320.582-158.216-320.582-353.784-51.408 256-249.538-60.432-352.352 316.432 166.358 316.432-166.358-60.434 352.352 256.002 249.538z" />
|
||||
<glyph unicode="" glyph-name="star-empty" d="M1024 562.95l-353.78 51.408-158.22 320.582-158.216-320.582-353.784-51.408 256-249.538-60.432-352.352 316.432 166.358 316.432-166.358-60.434 352.352 256.002 249.538zM512 206.502l-223.462-117.48 42.676 248.83-180.786 176.222 249.84 36.304 111.732 226.396 111.736-226.396 249.836-36.304-180.788-176.222 42.678-248.83-223.462 117.48z" />
|
||||
</font></defs></svg>
|
||||
|
After Width: | Height: | Size: 7.0 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality.
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
class ABR_i18n {
|
||||
|
||||
|
||||
/**
|
||||
* Load the plugin text domain for translation.
|
||||
*/
|
||||
public function load_plugin_textdomain() {
|
||||
|
||||
load_plugin_textdomain( 'absolute-reviews', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin.
|
||||
*
|
||||
* Maintain a list of all hooks that are registered throughout
|
||||
* the plugin, and register them with the WordPress API. Call the
|
||||
* run function to execute the list of actions and filters.
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
class ABR_Loader {
|
||||
|
||||
/**
|
||||
* The array of actions registered with WordPress.
|
||||
*
|
||||
* @access protected
|
||||
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $actions;
|
||||
|
||||
/**
|
||||
* The array of filters registered with WordPress.
|
||||
*
|
||||
* @access protected
|
||||
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $filters;
|
||||
|
||||
/**
|
||||
* Initialize the collections used to maintain the actions and filters.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->actions = array();
|
||||
$this->filters = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new action to the collection to be registered with WordPress.
|
||||
|
||||
* @param string $hook The name of the WordPress action that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the action is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
||||
*/
|
||||
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
||||
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new filter to the collection to be registered with WordPress.
|
||||
*
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
||||
*/
|
||||
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
||||
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility function that is used to register the actions and hooks into a single
|
||||
* collection.
|
||||
|
||||
* @access private
|
||||
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority The priority at which the function should be fired.
|
||||
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
||||
* @return array The collection of actions and filters registered with WordPress.
|
||||
*/
|
||||
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
||||
|
||||
$hooks[] = array(
|
||||
'hook' => $hook,
|
||||
'component' => $component,
|
||||
'callback' => $callback,
|
||||
'priority' => $priority,
|
||||
'accepted_args' => $accepted_args,
|
||||
);
|
||||
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the filters and actions with WordPress.
|
||||
*/
|
||||
public function run() {
|
||||
|
||||
foreach ( $this->filters as $hook ) {
|
||||
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
||||
}
|
||||
|
||||
foreach ( $this->actions as $hook ) {
|
||||
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The file that defines the core plugin class
|
||||
*
|
||||
* A class definition that includes attributes and functions used across both the
|
||||
* public-facing side of the site and the admin area.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* The core plugin class.
|
||||
*
|
||||
* This is used to define internationalization, admin-specific hooks, and
|
||||
* public-facing site hooks.
|
||||
*
|
||||
* Also maintains the unique identifier of this plugin as well as the current
|
||||
* version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
class ABR {
|
||||
|
||||
/**
|
||||
* The loader that's responsible for maintaining and registering all hooks that power
|
||||
* the plugin.
|
||||
*
|
||||
* @access protected
|
||||
* @var ABR_Loader $loader Maintains and registers all hooks for the plugin.
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* The unique identifier of this plugin.
|
||||
*
|
||||
* @access protected
|
||||
* @var string $abr The string used to uniquely identify this plugin.
|
||||
*/
|
||||
protected $abr;
|
||||
|
||||
/**
|
||||
* The current version of the plugin.
|
||||
*
|
||||
* @access protected
|
||||
* @var string $version The current version of the plugin.
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Define the core functionality of the plugin.
|
||||
*
|
||||
* Set the plugin name and the plugin version that can be used throughout the plugin.
|
||||
* Load the dependencies, define the locale, and set the hooks for the admin area and
|
||||
* the public-facing side of the site.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
// Get plugin data.
|
||||
$plugin_data = get_plugin_data( ABR_PATH . '/absolute-reviews.php' );
|
||||
|
||||
$this->version = $plugin_data['Version'];
|
||||
$this->abr = 'absolute-reviews';
|
||||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->define_admin_hooks();
|
||||
$this->define_public_hooks();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the required dependencies for this plugin.
|
||||
*
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - ABR_Loader. Orchestrates the hooks of the plugin.
|
||||
* - ABR_i18n. Defines internationalization functionality.
|
||||
* - ABR_Admin. Defines all hooks for the admin area.
|
||||
* - ABR_Public. Defines all hooks for the public side of the site.
|
||||
*
|
||||
* Create an instance of the loader which will be used to register the hooks
|
||||
* with WordPress.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function load_dependencies() {
|
||||
|
||||
/**
|
||||
* Helpers Functions for the plugin.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/helpers-absolute-reviews.php';
|
||||
|
||||
/**
|
||||
* Post Meta.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/post-meta.php';
|
||||
|
||||
/**
|
||||
* Posts Template.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/posts-template.php';
|
||||
|
||||
/**
|
||||
* Register widgets for the plugin.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-absolute-reviews-posts-widget.php';
|
||||
|
||||
/**
|
||||
* Register gutenberg blocks.
|
||||
*/
|
||||
if ( function_exists( 'register_block_type' ) ) {
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-absolute-reviews-block.php';
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-absolute-reviews-posts-block.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* The class responsible for orchestrating the actions and filters of the
|
||||
* core plugin.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-absolute-reviews-loader.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining internationalization functionality
|
||||
* of the plugin.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-absolute-reviews-i18n.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all actions that occur in the admin area.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-absolute-reviews-admin.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all actions that occur in the public-facing
|
||||
* side of the site.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-absolute-reviews-public.php';
|
||||
|
||||
$this->loader = new ABR_Loader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the locale for this plugin for internationalization.
|
||||
*
|
||||
* Uses the ABR_i18n class in order to set the domain and to register the hook
|
||||
* with WordPress.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function set_locale() {
|
||||
|
||||
$plugin_i18n = new ABR_i18n();
|
||||
|
||||
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all of the hooks related to the admin area functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function define_admin_hooks() {
|
||||
|
||||
$plugin_admin = new ABR_Admin( $this->get_abr(), $this->get_version() );
|
||||
|
||||
$this->loader->add_action( 'admin_menu', $plugin_admin, 'register_options_page' );
|
||||
$this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'metabox_review_register' );
|
||||
$this->loader->add_action( 'save_post', $plugin_admin, 'metabox_review_save', 10, 2 );
|
||||
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'admin_enqueue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all of the hooks related to the public-facing functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function define_public_hooks() {
|
||||
|
||||
$plugin_public = new ABR_Public( $this->get_abr(), $this->get_version() );
|
||||
|
||||
$this->loader->add_action( 'wp_head', $plugin_public, 'wp_head' );
|
||||
$this->loader->add_action( 'the_content', $plugin_public, 'the_content' );
|
||||
$this->loader->add_action( 'abr_reviews_posts_templates', $plugin_public, 'posts_templates' );
|
||||
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'wp_enqueue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the loader to execute all of the hooks with WordPress.
|
||||
*/
|
||||
public function run() {
|
||||
$this->loader->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the plugin used to uniquely identify it within the context of
|
||||
* WordPress and to define internationalization functionality.
|
||||
*
|
||||
* @return string The name of the plugin.
|
||||
*/
|
||||
public function get_abr() {
|
||||
return $this->abr;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference to the class that orchestrates the hooks with the plugin.
|
||||
*
|
||||
* @return ABR_Loader Orchestrates the hooks of the plugin.
|
||||
*/
|
||||
public function get_loader() {
|
||||
return $this->loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the version number of the plugin.
|
||||
*
|
||||
* @return string The version number of the plugin.
|
||||
*/
|
||||
public function get_version() {
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,886 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers Absolute Reviews
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'abr_style' ) ) {
|
||||
/**
|
||||
* Processing path of style.
|
||||
*
|
||||
* @param string $path URL to the stylesheet.
|
||||
*/
|
||||
function abr_style( $path ) {
|
||||
// Check RTL.
|
||||
if ( is_rtl() ) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
// Check Dev.
|
||||
$dev = ABR_PATH . 'public/css/absolute-reviews-public-dev.css';
|
||||
|
||||
if ( file_exists( $dev ) ) {
|
||||
return str_replace( '.css', '-dev.css', $path );
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_powerkit_module_enabled' ) ) {
|
||||
/**
|
||||
* Helper function to check the status of powerkit modules
|
||||
*
|
||||
* @param array $name Name of module.
|
||||
*/
|
||||
function abr_powerkit_module_enabled( $name ) {
|
||||
if ( function_exists( 'powerkit_module_enabled' ) && powerkit_module_enabled( $name ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_post_views_enabled' ) ) {
|
||||
/**
|
||||
* Check post views module.
|
||||
*
|
||||
* @return string Type.
|
||||
*/
|
||||
function abr_post_views_enabled() {
|
||||
|
||||
// Post Views Counter.
|
||||
if ( class_exists( 'Post_Views_Counter' ) ) {
|
||||
return 'post_views';
|
||||
}
|
||||
|
||||
// Powerkit Post Views.
|
||||
if ( abr_powerkit_module_enabled( 'post_views' ) ) {
|
||||
return 'pk_post_views';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_available_image_sizes' ) ) {
|
||||
/**
|
||||
* Get the available image sizes
|
||||
*/
|
||||
function abr_get_available_image_sizes() {
|
||||
$wais = & $GLOBALS['_wp_additional_image_sizes'];
|
||||
|
||||
$sizes = array();
|
||||
$image_sizes = get_intermediate_image_sizes();
|
||||
|
||||
if ( is_array( $image_sizes ) && $image_sizes ) {
|
||||
foreach ( $image_sizes as $size ) {
|
||||
if ( in_array( $size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
|
||||
$sizes[ $size ] = array(
|
||||
'width' => get_option( "{$size}_size_w" ),
|
||||
'height' => get_option( "{$size}_size_h" ),
|
||||
'crop' => (bool) get_option( "{$size}_crop" ),
|
||||
);
|
||||
} elseif ( isset( $wais[ $size ] ) ) {
|
||||
$sizes[ $size ] = array(
|
||||
'width' => $wais[ $size ]['width'],
|
||||
'height' => $wais[ $size ]['height'],
|
||||
'crop' => $wais[ $size ]['crop'],
|
||||
);
|
||||
}
|
||||
|
||||
// Size registered, but has 0 width and height.
|
||||
if ( 0 === (int) $sizes[ $size ]['width'] && 0 === (int) $sizes[ $size ]['height'] ) {
|
||||
unset( $sizes[ $size ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sizes;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_image_size' ) ) {
|
||||
/**
|
||||
* Gets the data of a specific image size.
|
||||
*
|
||||
* @param string $size Name of the size.
|
||||
*/
|
||||
function abr_get_image_size( $size ) {
|
||||
if ( ! is_string( $size ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sizes = abr_get_available_image_sizes();
|
||||
|
||||
return isset( $sizes[ $size ] ) ? $sizes[ $size ] : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_list_available_image_sizes' ) ) {
|
||||
/**
|
||||
* Get the list available image sizes
|
||||
*/
|
||||
function abr_get_list_available_image_sizes() {
|
||||
$intermediate_image_sizes = get_intermediate_image_sizes();
|
||||
|
||||
$image_sizes = array();
|
||||
|
||||
foreach ( $intermediate_image_sizes as $size ) {
|
||||
$image_sizes[ $size ] = $size;
|
||||
|
||||
$data = abr_get_image_size( $size );
|
||||
|
||||
if ( isset( $data['width'] ) || isset( $data['height'] ) ) {
|
||||
|
||||
$width = '~';
|
||||
$height = '~';
|
||||
|
||||
if ( isset( $data['width'] ) && $data['width'] ) {
|
||||
$width = $data['width'] . 'px';
|
||||
}
|
||||
if ( isset( $data['height'] ) && $data['height'] ) {
|
||||
$height = $data['height'] . 'px';
|
||||
}
|
||||
|
||||
$image_sizes[ $size ] .= sprintf( ' [%s, %s]', $width, $height );
|
||||
}
|
||||
}
|
||||
|
||||
$image_sizes = apply_filters( 'abr_list_available_image_sizes', $image_sizes );
|
||||
|
||||
return $image_sizes;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_post_metadata' ) ) {
|
||||
/**
|
||||
* Retrieves a post meta field for the given post ID.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param string $key Optional. The meta key to retrieve. By default, returns
|
||||
* data for all keys. Default empty.
|
||||
* @param bool $single Optional. If true, returns only the first value for the specified meta key.
|
||||
* This parameter has no effect if $key is not specified. Default false.
|
||||
* @param mixed $default Default value.
|
||||
* @return mixed Will be an array if $single is false. Will be value of the meta
|
||||
* field if $single is true.
|
||||
*/
|
||||
function abr_get_post_metadata( $post_id, $key = '', $single = false, $default = null ) {
|
||||
|
||||
if ( ! metadata_exists( 'post', $post_id, $key ) && $default ) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return get_metadata( 'post', $post_id, $key, $single );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_default_post_types' ) ) {
|
||||
/**
|
||||
* Return default post types.
|
||||
*/
|
||||
function abr_default_post_types() {
|
||||
$types = array(
|
||||
'post' => 'post',
|
||||
);
|
||||
|
||||
return apply_filters( 'abr_default_post_types', $types );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_default_indicators' ) ) {
|
||||
/**
|
||||
* Return default indicators.
|
||||
*/
|
||||
function abr_default_indicators() {
|
||||
$indicators = array(
|
||||
0 => array(
|
||||
'name' => 'None',
|
||||
),
|
||||
1 => array(
|
||||
'name' => 'Awfully',
|
||||
),
|
||||
2 => array(
|
||||
'name' => 'Very bad',
|
||||
),
|
||||
3 => array(
|
||||
'name' => 'Bad',
|
||||
),
|
||||
4 => array(
|
||||
'name' => 'Passably',
|
||||
),
|
||||
5 => array(
|
||||
'name' => 'Neutral',
|
||||
),
|
||||
6 => array(
|
||||
'name' => 'Normal',
|
||||
),
|
||||
7 => array(
|
||||
'name' => 'Good',
|
||||
),
|
||||
8 => array(
|
||||
'name' => 'Very good',
|
||||
),
|
||||
9 => array(
|
||||
'name' => 'Amazing',
|
||||
),
|
||||
10 => array(
|
||||
'name' => 'The best',
|
||||
),
|
||||
);
|
||||
|
||||
return apply_filters( 'abr_default_indicators', $indicators );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_list_indicators' ) ) {
|
||||
/**
|
||||
* Return list indicators.
|
||||
*/
|
||||
function abr_list_indicators() {
|
||||
$indicators = abr_default_indicators();
|
||||
|
||||
// Disable all indicators.
|
||||
if ( get_option( 'abr_review_disable_indicators', false ) ) {
|
||||
$indicators = array();
|
||||
}
|
||||
|
||||
// Set custom name for indicators.
|
||||
foreach ( $indicators as $index => $value ) {
|
||||
$indicators[ $index ]['name'] = get_option( "abr_review_indicator_label_{$index}", $indicators[ $index ]['name'] );
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_the_review' ) ) {
|
||||
/**
|
||||
* Post Review
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
*/
|
||||
function abr_the_review( $post_id = null ) {
|
||||
|
||||
if ( ! $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
|
||||
if ( ! $post_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_type = get_post_type( $post_id );
|
||||
|
||||
// Get types of option.
|
||||
$option_types = get_option( 'abr_review_post_types', abr_default_post_types() );
|
||||
|
||||
if ( ! in_array( $post_type, $option_types, true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check display.
|
||||
if ( ! abr_get_post_metadata( $post_id, '_abr_review_settings', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Params.
|
||||
$params = array(
|
||||
'type' => abr_get_post_metadata( $post_id, '_abr_review_type', true, 'percentage' ),
|
||||
'items' => abr_get_post_metadata( $post_id, '_abr_review_items', true, array() ),
|
||||
'heading' => abr_get_post_metadata( $post_id, '_abr_review_heading', true ),
|
||||
'desc' => abr_get_post_metadata( $post_id, '_abr_review_desc', true ),
|
||||
'main_scale' => abr_get_post_metadata( $post_id, '_abr_review_main_scale', true, true ),
|
||||
'total_score_number' => abr_get_post_metadata( $post_id, '_abr_review_total_score_number', true ),
|
||||
'pros_heading' => abr_get_post_metadata( $post_id, '_abr_review_pros_heading', true ),
|
||||
'pros_items' => abr_get_post_metadata( $post_id, '_abr_review_pros_items', true, array() ),
|
||||
'cons_heading' => abr_get_post_metadata( $post_id, '_abr_review_cons_heading', true ),
|
||||
'cons_items' => abr_get_post_metadata( $post_id, '_abr_review_cons_items', true, array() ),
|
||||
'legend' => abr_get_post_metadata( $post_id, '_abr_review_legend', true ),
|
||||
'schema_heading' => abr_get_post_metadata( $post_id, '_abr_review_schema_heading', true ),
|
||||
'schema_desc' => abr_get_post_metadata( $post_id, '_abr_review_schema_desc', true ),
|
||||
'schema_author' => abr_get_post_metadata( $post_id, '_abr_review_schema_author', true ),
|
||||
'schema_author_custom' => abr_get_post_metadata( $post_id, '_abr_review_schema_author_custom', true ),
|
||||
);
|
||||
|
||||
abr_review_display_block( $params );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_review' ) ) {
|
||||
/**
|
||||
* Get review of post
|
||||
*
|
||||
* @param bool $format Do you format the result?.
|
||||
* @param int $post_id Post ID.
|
||||
*/
|
||||
function abr_get_review( $format = false, $post_id = null ) {
|
||||
if ( ! $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
|
||||
if ( ! $post_id ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( ! abr_get_post_metadata( $post_id, '_abr_review_settings', true ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$review_type = abr_get_post_metadata( $post_id, '_abr_review_type', true, 'percentage' );
|
||||
|
||||
$total_score = (float) abr_get_post_metadata( $post_id, '_abr_review_total_score_number', true );
|
||||
|
||||
// Vars.
|
||||
switch ( $review_type ) {
|
||||
case 'percentage':
|
||||
$max = 100;
|
||||
break;
|
||||
case 'point-5':
|
||||
$max = 5;
|
||||
break;
|
||||
case 'point-10':
|
||||
$max = 10;
|
||||
break;
|
||||
case 'star':
|
||||
$max = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
// Formating value.
|
||||
if ( $total_score && $format ) {
|
||||
if ( 'percentage' === $review_type ) {
|
||||
$total_score = sprintf( '%s%%', $total_score );
|
||||
} else {
|
||||
$total_score = sprintf( '%s/%s', $total_score, $max );
|
||||
}
|
||||
}
|
||||
|
||||
return $total_score;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_review_get_val_index' ) ) {
|
||||
/**
|
||||
* Get value index for post review
|
||||
*
|
||||
* @param string $type The type of review.
|
||||
* @param float $value The value.
|
||||
*/
|
||||
function abr_review_get_val_index( $type, $value ) {
|
||||
$val_index = $value;
|
||||
|
||||
if ( 'star' === $type ) {
|
||||
$val_index = round( $value * 2 - 1 );
|
||||
}
|
||||
|
||||
if ( 'point-5' === $type ) {
|
||||
$val_index = round( $value * 2 - 1 );
|
||||
}
|
||||
|
||||
if ( 'percentage' === $type ) {
|
||||
$val_index = round( $value / 10 );
|
||||
}
|
||||
|
||||
return $val_index;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_review_get_type' ) ) {
|
||||
/**
|
||||
* Get type review of post
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param mixed $default Return default.
|
||||
*/
|
||||
function abr_review_get_type( $post_id = null, $default = false ) {
|
||||
|
||||
if ( ! $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
|
||||
if ( ! $post_id ) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return abr_get_post_metadata( $post_id, '_abr_review_type', true, $default );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_review_star_rating' ) ) {
|
||||
/**
|
||||
* Output a HTML element with a star rating for a given rating.
|
||||
*
|
||||
* @param array $args {
|
||||
* Optional. Array of star ratings arguments.
|
||||
*
|
||||
* @type int|float $rating The rating to display, expressed in either a 0.5 rating increment,
|
||||
* or percentage. Default 0.
|
||||
* @type string $type Format that the $rating is in. Valid values are 'rating' (default),
|
||||
* or, 'percent'. Default 'rating'.
|
||||
* @type int $number The number of ratings that makes up this rating. Default 0.
|
||||
* @type bool $echo Whether to echo the generated markup. False to return the markup instead
|
||||
* of echoing it. Default true.
|
||||
* }
|
||||
*/
|
||||
function abr_review_star_rating( $args = array() ) {
|
||||
$defaults = array(
|
||||
'rating' => 0,
|
||||
'type' => 'rating',
|
||||
'number' => 0,
|
||||
'echo' => true,
|
||||
);
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
// Non-English decimal places when the $rating is coming from a string.
|
||||
$rating = (float) str_replace( ',', '.', $r['rating'] );
|
||||
|
||||
// Convert Percentage to star rating, 0..5 in .5 increments.
|
||||
if ( 'percent' === $r['type'] ) {
|
||||
$rating = round( $rating / 10, 0 ) / 2;
|
||||
}
|
||||
|
||||
// Calculate the number of each type of star needed.
|
||||
$full_stars = floor( $rating );
|
||||
$half_stars = ceil( $rating - $full_stars );
|
||||
$empty_stars = 5 - $full_stars - $half_stars;
|
||||
|
||||
if ( $r['number'] ) {
|
||||
/* translators: 1: the rating, 2: the number of ratings */
|
||||
$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
|
||||
$title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
|
||||
} else {
|
||||
/* translators: %s: the rating */
|
||||
$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
|
||||
}
|
||||
|
||||
$output = '<div class="abr-star-rating">';
|
||||
$output .= '<span class="screen-reader-text">' . $title . '</span>';
|
||||
$output .= str_repeat( '<div class="abr-star abr-star-full" aria-hidden="true"></div>', $full_stars );
|
||||
$output .= str_repeat( '<div class="abr-star abr-star-half" aria-hidden="true"></div>', $half_stars );
|
||||
$output .= str_repeat( '<div class="abr-star abr-star-empty" aria-hidden="true"></div>', $empty_stars );
|
||||
$output .= '</div>';
|
||||
|
||||
if ( $r['echo'] ) {
|
||||
echo (string) $output; // XSS.
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_review_display_rating' ) ) {
|
||||
/**
|
||||
* Display review rating info
|
||||
*
|
||||
* @param string $type The type of review.
|
||||
* @param float $max The max value.
|
||||
* @param float $value The value.
|
||||
* @param string $name The name.
|
||||
* @param bool $label Display label.
|
||||
*/
|
||||
function abr_review_display_rating( $type, $max, $value, $name = null, $label = true ) {
|
||||
|
||||
switch ( $type ) {
|
||||
case 'star':
|
||||
$value = ( $value <= $max ) ? round( $value, 1 ) : $max;
|
||||
break;
|
||||
case 'point-5':
|
||||
case 'point-10':
|
||||
case 'percentage':
|
||||
$value = ( $value <= $max ) ? round( $value ) : $max;
|
||||
break;
|
||||
}
|
||||
|
||||
// Get indicators.
|
||||
$indicators = abr_list_indicators();
|
||||
|
||||
// Set value index.
|
||||
$val_index = abr_review_get_val_index( $type, $value );
|
||||
?>
|
||||
<div class="abr-review-data">
|
||||
<?php if ( $name ) { ?>
|
||||
<div class="abr-review-name">
|
||||
<?php echo esc_html( $name ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( 'star' === $type ) : ?>
|
||||
<div class="abr-review-stars">
|
||||
<?php
|
||||
abr_review_star_rating( array(
|
||||
'rating' => $value,
|
||||
'type' => 'rating',
|
||||
'number' => 0,
|
||||
) );
|
||||
?>
|
||||
</div>
|
||||
<?php elseif ( 'point-5' === $type || 'point-10' === $type ) : ?>
|
||||
<div class="abr-review-line">
|
||||
<?php
|
||||
$max_slice = 'point-5' === $type ? 5 : 10;
|
||||
|
||||
for ( $index = 1; $index <= $max_slice; $index++ ) {
|
||||
if ( $index <= $value ) {
|
||||
$class = 'abr-review-slice-active';
|
||||
} else {
|
||||
$class = 'abr-review-slice-no-active';
|
||||
}
|
||||
?>
|
||||
<span class="abr-review-slice <?php echo esc_attr( $class ); ?>"></span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php elseif ( 'percentage' === $type ) : ?>
|
||||
<div class="abr-review-progress">
|
||||
<div class="abr-review-progressbar abr-review-progressbar-<?php echo esc_attr( $val_index ); ?>"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $label ) { ?>
|
||||
<div class="abr-review-label">
|
||||
<span class="abr-review-text">
|
||||
<?php
|
||||
echo wp_kses_post( sprintf( '<span class="total">%s</span><span class="sep">/</span><span class="max">%s</span>', $value, $max ) );
|
||||
?>
|
||||
</span>
|
||||
|
||||
<?php if ( $indicators && $indicators[ $val_index ]['name'] ) { ?>
|
||||
<span class="abr-badge abr-badge-primary abr-review-badge-<?php echo esc_attr( $val_index ); ?>">
|
||||
<?php echo esc_html( $indicators[ $val_index ]['name'] ); ?>
|
||||
</span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_review_display_block' ) ) {
|
||||
/**
|
||||
* Display review rating
|
||||
*
|
||||
* @param array $params The params of review.
|
||||
*/
|
||||
function abr_review_display_block( $params ) {
|
||||
|
||||
$params = array_merge( array(
|
||||
'variant' => 'default',
|
||||
'type' => 'percentage',
|
||||
'items' => array(),
|
||||
'heading' => '',
|
||||
'desc' => '',
|
||||
'main_scale' => true,
|
||||
'total_label' => esc_html__( 'Total Score', 'absolute-reviews' ),
|
||||
'total_score_number' => '',
|
||||
'pros_heading' => '',
|
||||
'pros_items' => array(),
|
||||
'cons_heading' => '',
|
||||
'cons_items' => array(),
|
||||
'legend' => '',
|
||||
'schema_heading' => '',
|
||||
'schema_desc' => '',
|
||||
'schema_author' => '',
|
||||
'schema_author_custom' => '',
|
||||
), $params );
|
||||
|
||||
// Vars.
|
||||
switch ( $params['type'] ) {
|
||||
case 'percentage':
|
||||
$max = 100;
|
||||
break;
|
||||
case 'point-5':
|
||||
$max = 5;
|
||||
break;
|
||||
case 'point-10':
|
||||
$max = 10;
|
||||
break;
|
||||
case 'star':
|
||||
$max = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
// Get indicators.
|
||||
$indicators = abr_list_indicators();
|
||||
?>
|
||||
<div class="abr-post-review abr-review-<?php echo esc_attr( $params['variant'] ); ?> abr-review-<?php echo esc_attr( $params['type'] ); ?>" itemprop="reviews" itemscope itemtype="http://schema.org/Review">
|
||||
|
||||
<div class="abr-review-author" itemprop="author" itemscope itemtype="http://schema.org/Person">
|
||||
<span itemprop="name">
|
||||
<?php echo esc_html( 'custom' === $params['schema_author'] ? $params['schema_author_custom'] : $params['schema_author'] ); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Info -->
|
||||
<?php if ( $params['heading'] || $params['desc'] ) { ?>
|
||||
<div class="abr-review-info">
|
||||
|
||||
<div class="abr-review-heading" itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product">
|
||||
<?php
|
||||
// Review title.
|
||||
if ( $params['heading'] ) {
|
||||
?>
|
||||
<h3 class="abr-title abr-review-title"><?php echo esc_html( $params['heading'] ); ?></h3>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $params['heading'] || $params['schema_heading'] ) {
|
||||
$heading = $params['schema_heading'] ? $params['schema_heading'] : $params['heading'];
|
||||
?>
|
||||
<span class="abr-review-scheme-hidden" itemprop="name"><?php echo esc_html( $heading ); ?></span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="abr-review-scheme-hidden" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
|
||||
<span itemprop="ratingValue"><?php echo esc_html( $params['total_score_number'] ); ?></span>
|
||||
<span itemprop="bestRating"><?php echo esc_html( $max ); ?></span>
|
||||
<span itemprop="worstRating"><?php echo esc_html( 0 ); ?></span>
|
||||
<span itemprop="reviewCount"><?php echo esc_html( 1 ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// Review desc.
|
||||
if ( $params['desc'] ) {
|
||||
?>
|
||||
<div class="abr-review-description" itemprop="reviewBody"><?php echo wp_kses( $params['desc'], 'post' ); ?></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $params['desc'] || $params['schema_desc'] ) {
|
||||
$desc = $params['schema_desc'] ? $params['schema_desc'] : $params['desc'];
|
||||
?>
|
||||
<div class="abr-review-scheme-hidden" itemprop="reviewBody"><?php echo wp_kses( $desc, 'post' ); ?></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Review Total -->
|
||||
<div class="abr-review-total">
|
||||
<?php
|
||||
$total_score = (float) $params['total_score_number'];
|
||||
|
||||
if ( $total_score ) {
|
||||
if ( ! $params['main_scale'] && $params['items'] ) {
|
||||
?>
|
||||
<div class="abr-review-list">
|
||||
<ul>
|
||||
<?php
|
||||
if ( isset( $params['items']['name'] ) && $params['items']['name'] ) {
|
||||
foreach ( $params['items']['name'] as $key => $item_name ) {
|
||||
$item_desc = (string) $params['items']['desc'][ $key ];
|
||||
$item_value = (float) $params['items']['val'][ $key ];
|
||||
|
||||
if ( ! $item_name ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
?>
|
||||
<li class="abr-review-item">
|
||||
<?php abr_review_display_rating( $params['type'], $max, $item_value, $item_name ); ?>
|
||||
|
||||
<div class="abr-review-desc">
|
||||
<?php echo esc_html( $item_desc ); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $params['main_scale'] ) {
|
||||
abr_review_display_rating( $params['type'], $max, $total_score, null, false );
|
||||
}
|
||||
?>
|
||||
<div class="abr-review-score <?php echo esc_html( ! $params['total_label'] ? 'abr-review-score-row' : '' ); ?>" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
|
||||
<div class="abr-review-text">
|
||||
<?php
|
||||
echo wp_kses( sprintf( '<span class="total" itemprop="ratingValue">%s</span><span class="sep">/</span><span class="max" itemprop="bestRating">%s</span>', $total_score, $max ), array(
|
||||
'span' => array(
|
||||
'class' => true,
|
||||
'itemprop' => true,
|
||||
),
|
||||
) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if ( $params['total_label'] || $params['legend'] ) { ?>
|
||||
<div class="abr-review-subtext">
|
||||
<?php if ( $params['total_label'] ) { ?>
|
||||
<span class="abr-data-label"><?php echo esc_html( $params['total_label'] ); ?></span>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( $params['legend'] ) { ?>
|
||||
<span class="abr-data-info">i<span><?php echo wp_kses_post( $params['legend'] ); ?></span></span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Review Indicator -->
|
||||
<?php
|
||||
if ( 'block' === $params['variant'] ) {
|
||||
// Set value index.
|
||||
$val_index = abr_review_get_val_index( $params['type'], $total_score );
|
||||
|
||||
if ( $indicators && $indicators[ $val_index ]['name'] ) {
|
||||
?>
|
||||
<div class="abr-review-indicator">
|
||||
<span class="abr-badge abr-badge-primary abr-review-badge-<?php echo esc_attr( $val_index ); ?>">
|
||||
<?php echo esc_html( $indicators[ $val_index ]['name'] ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Items List -->
|
||||
<?php if ( $params['items'] && $params['main_scale'] ) { ?>
|
||||
<div class="abr-review-list">
|
||||
<ul>
|
||||
<?php
|
||||
if ( isset( $params['items']['name'] ) && $params['items']['name'] ) {
|
||||
foreach ( $params['items']['name'] as $key => $item_name ) {
|
||||
$item_desc = (string) $params['items']['desc'][ $key ];
|
||||
$item_value = (float) $params['items']['val'][ $key ];
|
||||
|
||||
if ( ! $item_name ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
?>
|
||||
<li class="abr-review-item">
|
||||
<?php abr_review_display_rating( $params['type'], $max, $item_value, $item_name ); ?>
|
||||
|
||||
<div class="abr-review-desc">
|
||||
<?php echo esc_html( $item_desc ); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Items Pros / Cons -->
|
||||
<?php if ( $params['pros_items'] || $params['cons_items'] ) { ?>
|
||||
<div class="abr-review-details">
|
||||
<?php
|
||||
if ( $params['pros_items'] ) {
|
||||
|
||||
$params['pros_heading'] = $params['pros_heading'] ? $params['pros_heading'] : esc_html__( 'The Good', 'absolute-reviews' );
|
||||
?>
|
||||
<div class="abr-review-items abr-review-pros">
|
||||
<div class="abr-review-title">
|
||||
<h3 class="abr-title"><?php echo esc_html( $params['pros_heading'] ); ?></h3>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
if ( isset( $params['pros_items']['name'] ) && $params['pros_items']['name'] ) {
|
||||
foreach ( $params['pros_items']['name'] as $key => $name ) {
|
||||
?>
|
||||
<li><?php echo esc_attr( $params['pros_items']['name'][ $key ] ); ?></li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( $params['cons_items'] ) {
|
||||
|
||||
$params['cons_heading'] = $params['cons_heading'] ? $params['cons_heading'] : esc_html__( 'The Bad', 'absolute-reviews' );
|
||||
?>
|
||||
<div class="abr-review-items abr-review-cons">
|
||||
<div class="abr-review-title">
|
||||
<h3 class="abr-title"><?php echo esc_html( $params['cons_heading'] ); ?></h3>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
if ( isset( $params['cons_items']['name'] ) && $params['cons_items']['name'] ) {
|
||||
foreach ( $params['cons_items']['name'] as $key => $name ) {
|
||||
?>
|
||||
<li class="abr-item"><?php echo esc_attr( $params['cons_items']['name'][ $key ] ); ?></li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_reviews_posts_widget_handler' ) ) {
|
||||
/**
|
||||
* Widget template handler
|
||||
*
|
||||
* @param string $name Specific template.
|
||||
* @param array $posts Array of posts.
|
||||
* @param array $params Array of params.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
function abr_reviews_posts_widget_handler( $name, $posts, $params, $instance ) {
|
||||
$templates = apply_filters( 'abr_reviews_posts_templates', array() );
|
||||
|
||||
if ( isset( $templates[ $name ] ) && function_exists( $templates[ $name ]['func'] ) ) {
|
||||
call_user_func( $templates[ $name ]['func'], $posts, $params, $instance );
|
||||
} else {
|
||||
call_user_func( 'abr_reviews_posts_template', $posts, $params, $instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Block Post Meta
|
||||
*
|
||||
* @param array $settings Settings of block.
|
||||
* @param string $prefix The prefix.
|
||||
*/
|
||||
function abr_block_convert_post_meta( $settings, $prefix ) {
|
||||
|
||||
$meta = array();
|
||||
|
||||
$list = array(
|
||||
'category' => 'showMetaCategory',
|
||||
'author' => 'showMetaAuthor',
|
||||
'date' => 'showMetaDate',
|
||||
'comments' => 'showMetaComments',
|
||||
'views' => 'showMetaViews',
|
||||
'reading_time' => 'showMetaReadingTime',
|
||||
);
|
||||
|
||||
$list = apply_filters( 'abr_convert_post_meta', $list, $settings, $prefix );
|
||||
|
||||
foreach ( $list as $key => $alt ) {
|
||||
if ( isset( $settings[ $prefix . '_' . $alt ] ) && $settings[ $prefix . '_' . $alt ] ) {
|
||||
$meta[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return $meta;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
||||
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
/**
|
||||
* Post Meta Helper Functions
|
||||
*
|
||||
* These helper functions return post meta.
|
||||
*
|
||||
* @package abr
|
||||
* @subpackage Core
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'abr_allowed_post_meta' ) ) {
|
||||
/**
|
||||
* Allowed Post Meta
|
||||
*
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
* @param array $exclude Exclude list.
|
||||
*/
|
||||
function abr_allowed_post_meta( $compact = false, $exclude = array() ) {
|
||||
$allowed = array(
|
||||
'category' => esc_html__( 'Category', 'canvas' ),
|
||||
'date' => esc_html__( 'Date', 'canvas' ),
|
||||
'author' => esc_html__( 'Author', 'canvas' ),
|
||||
'comments' => esc_html__( 'Comments count', 'canvas' ),
|
||||
);
|
||||
|
||||
if ( abr_post_views_enabled() ) {
|
||||
$allowed['views'] = esc_html__( 'Views', 'canvas' );
|
||||
}
|
||||
|
||||
if ( abr_powerkit_module_enabled( 'reading_time' ) ) {
|
||||
$allowed['reading_time'] = esc_html__( 'Reading time', 'canvas' );
|
||||
}
|
||||
|
||||
$allowed = apply_filters( 'abr_allowed_post_meta', $allowed );
|
||||
|
||||
// Computes the difference of arrays.
|
||||
$allowed = array_diff_key( $allowed, array_flip( (array) $exclude ) );
|
||||
|
||||
// If compact.
|
||||
if ( $compact ) {
|
||||
return array_keys( $allowed );
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_block_post_meta' ) ) {
|
||||
/**
|
||||
* Block Post Meta
|
||||
*
|
||||
* A wrapper function that returns all post meta types either
|
||||
* in an ordered list <ul> or as a single element <span>.
|
||||
*
|
||||
* @param array $settings Settings of block.
|
||||
* @param mixed $meta Contains post meta types.
|
||||
* @param bool $echo Echo or return.
|
||||
* @param bool $compact If meta compact.
|
||||
*/
|
||||
function abr_block_post_meta( $settings, $meta, $echo = true, $compact = false ) {
|
||||
|
||||
$func_handler = apply_filters( 'abr_get_block_post_meta_handler', false );
|
||||
|
||||
if ( $func_handler ) {
|
||||
return call_user_func( $func_handler, $settings, $meta, $echo, $compact );
|
||||
}
|
||||
|
||||
$allowed = array();
|
||||
|
||||
if ( isset( $settings['showMetaCategory'] ) && $settings['showMetaCategory'] ) {
|
||||
$allowed[] = 'category';
|
||||
}
|
||||
|
||||
if ( isset( $settings['showMetaAuthor'] ) && $settings['showMetaAuthor'] ) {
|
||||
$allowed[] = 'author';
|
||||
}
|
||||
|
||||
if ( isset( $settings['showMetaDate'] ) && $settings['showMetaDate'] ) {
|
||||
$allowed[] = 'date';
|
||||
}
|
||||
|
||||
if ( isset( $settings['showMetaComments'] ) && $settings['showMetaComments'] ) {
|
||||
$allowed[] = 'comments';
|
||||
}
|
||||
|
||||
if ( isset( $settings['showMetaViews'] ) && $settings['showMetaViews'] ) {
|
||||
$allowed[] = 'views';
|
||||
}
|
||||
|
||||
if ( isset( $settings['showMetaReadingTime'] ) && $settings['showMetaReadingTime'] ) {
|
||||
$allowed[] = 'reading_time';
|
||||
}
|
||||
|
||||
if ( isset( $settings['metaCompact'] ) && $settings['metaCompact'] ) {
|
||||
$compact = true;
|
||||
}
|
||||
|
||||
$allowed = apply_filters( 'abr_allowed_block_post_meta', $allowed, $settings, $meta, $echo, $compact );
|
||||
|
||||
if ( ! $allowed ) {
|
||||
return;
|
||||
}
|
||||
|
||||
abr_get_post_meta( $meta, $compact, $echo, $allowed );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_post_meta' ) ) {
|
||||
/**
|
||||
* Post Meta
|
||||
*
|
||||
* A wrapper function that returns all post meta types either
|
||||
* in an ordered list <ul> or as a single element <span>.
|
||||
*
|
||||
* @param mixed $meta Contains post meta types.
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
* @param bool $echo Echo or return.
|
||||
* @param array $allowed Allowed meta types.
|
||||
* @param array $settings The advanced settings.
|
||||
*/
|
||||
function abr_get_post_meta( $meta, $compact = false, $echo = true, $allowed = array(), $settings = array() ) {
|
||||
|
||||
$func_handler = apply_filters( 'abr_get_post_meta_handler', false );
|
||||
|
||||
if ( $func_handler ) {
|
||||
return call_user_func( $func_handler, $meta, $compact, $echo, $allowed, $settings );
|
||||
}
|
||||
|
||||
// Return if no post meta types provided.
|
||||
if ( ! $meta ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set default allowed post meta types.
|
||||
if ( ! $allowed ) {
|
||||
$allowed = abr_allowed_post_meta();
|
||||
}
|
||||
|
||||
if ( is_array( $meta ) ) {
|
||||
// Intersect provided and allowed meta types.
|
||||
$meta = array_intersect( $allowed, $meta );
|
||||
}
|
||||
|
||||
$output = null;
|
||||
|
||||
if ( $meta && is_array( $meta ) ) {
|
||||
|
||||
$output .= '<ul class="abr-post-meta post-meta">';
|
||||
|
||||
// Add normal meta types to the list.
|
||||
foreach ( $meta as $type ) {
|
||||
$function = "abr_get_meta_$type";
|
||||
|
||||
if ( function_exists( $function ) ) {
|
||||
$output .= $function( 'li', $compact );
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '</ul>';
|
||||
|
||||
} else {
|
||||
if ( in_array( $meta, $allowed, true ) ) {
|
||||
// Output single meta type.
|
||||
$function = "abr_get_meta_$meta";
|
||||
|
||||
if ( function_exists( $function ) ) {
|
||||
$output .= $function( 'div', $compact );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $echo ) {
|
||||
echo (string) $output; // XSS ok.
|
||||
} else {
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_meta_date' ) ) {
|
||||
/**
|
||||
* Post Date
|
||||
*
|
||||
* @param string $tag Element tag, i.e. div or span.
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
*/
|
||||
function abr_get_meta_date( $tag = 'span', $compact = false ) {
|
||||
|
||||
$output = '<' . esc_html( $tag ) . ' class="abr-meta-date meta-date">';
|
||||
|
||||
if ( false === $compact ) {
|
||||
$time_string = get_the_date();
|
||||
} else {
|
||||
$time_string = get_the_date( 'd.m.y' );
|
||||
}
|
||||
|
||||
$output .= apply_filters( 'abr_post_meta_date_output', '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' );
|
||||
|
||||
$output .= '</' . esc_html( $tag ) . '>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_meta_author' ) ) {
|
||||
/**
|
||||
* Post Author
|
||||
*
|
||||
* @param string $tag Element tag, i.e. div or span.
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
*/
|
||||
function abr_get_meta_author( $tag = 'span', $compact = false ) {
|
||||
|
||||
$authors = array( get_the_author_meta( 'ID' ) );
|
||||
|
||||
$output = '<' . esc_html( $tag ) . ' class="abr-meta-author meta-author">';
|
||||
|
||||
$output .= sprintf(
|
||||
'<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
|
||||
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
|
||||
/* translators: %s: author name */
|
||||
esc_attr( sprintf( __( 'View all posts by %s', 'absolute-reviews' ), get_the_author() ) ),
|
||||
// Author.
|
||||
get_the_author()
|
||||
);
|
||||
|
||||
$output .= '</' . esc_html( $tag ) . '>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_meta_category' ) ) {
|
||||
/**
|
||||
* Post Сategory
|
||||
*
|
||||
* @param string $tag Element tag, i.e. div or span.
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
* @param int $post_id Post ID.
|
||||
*/
|
||||
function abr_get_meta_category( $tag = 'span', $compact = false, $post_id = null ) {
|
||||
|
||||
if ( ! $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
|
||||
$output = '<' . esc_html( $tag ) . ' class="abr-meta-category meta-category">';
|
||||
|
||||
$output .= get_the_category_list( '', '', $post_id );
|
||||
|
||||
$output .= '</' . esc_html( $tag ) . '>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_meta_comments' ) ) {
|
||||
/**
|
||||
* Post Comments
|
||||
*
|
||||
* @param string $tag Element tag, i.e. div or span.
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
*/
|
||||
function abr_get_meta_comments( $tag = 'span', $compact = false ) {
|
||||
$output = '';
|
||||
|
||||
$output .= '<' . esc_html( $tag ) . ' class="abr-meta-comments meta-comments">';
|
||||
|
||||
if ( true === $compact ) {
|
||||
$output .= '<i class="abr-icon abr-icon-comment"></i>';
|
||||
ob_start();
|
||||
comments_popup_link( '0', '1', '%', 'comments-link', '' );
|
||||
$output .= ob_get_clean();
|
||||
} else {
|
||||
ob_start();
|
||||
comments_popup_link( esc_html__( 'No comments', 'absolute-reviews' ), esc_html__( 'One comment', 'absolute-reviews' ), '% ' . esc_html__( 'comments', 'absolute-reviews' ), 'comments-link', '' );
|
||||
$output .= ob_get_clean();
|
||||
}
|
||||
|
||||
$output .= '</' . esc_html( $tag ) . '>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_meta_reading_time' ) ) {
|
||||
/**
|
||||
* Post Reading Time
|
||||
*
|
||||
* @param string $tag Element tag, i.e. div or span.
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
*/
|
||||
function abr_get_meta_reading_time( $tag = 'span', $compact = false ) {
|
||||
|
||||
if ( ! function_exists( 'powerkit_module_enabled' ) || ! powerkit_module_enabled( 'reading_time' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$reading_time = powerkit_get_post_reading_time();
|
||||
|
||||
$output = '<' . esc_html( $tag ) . ' class="abr-meta-reading-time meta-reading-time">';
|
||||
|
||||
if ( true === $compact ) {
|
||||
$output .= '<i class="abr-icon abr-icon-watch"></i>' . intval( $reading_time ) . ' ' . esc_html( 'min', 'absolute-reviews' );
|
||||
} else {
|
||||
/* translators: %s number of minutes */
|
||||
$output .= esc_html( sprintf( _n( '%s minute read', '%s minute read', $reading_time, 'absolute-reviews' ), $reading_time ) );
|
||||
}
|
||||
|
||||
$output .= '</' . esc_html( $tag ) . '>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'abr_get_meta_views' ) ) {
|
||||
/**
|
||||
* Post Reading Time
|
||||
*
|
||||
* @param string $tag Element tag, i.e. div or span.
|
||||
* @param bool $compact If compact version shall be displayed.
|
||||
*/
|
||||
function abr_get_meta_views( $tag = 'span', $compact = false ) {
|
||||
|
||||
switch ( abr_post_views_enabled() ) {
|
||||
case 'post_views':
|
||||
$views = pvc_get_post_views();
|
||||
break;
|
||||
case 'pk_post_views':
|
||||
$views = powerkit_get_post_views( null, false );
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't display if minimum threshold is not met.
|
||||
if ( $views < apply_filters( 'abr_post_minimum_views', 1 ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$output = '<' . esc_html( $tag ) . ' class="abr-meta-views meta-views">';
|
||||
|
||||
$views_rounded = powerkit_get_round_number( $views );
|
||||
|
||||
if ( true === $compact ) {
|
||||
$output .= '<i class="abr-icon abr-icon-eye"></i>' . esc_html( $views_rounded );
|
||||
} else {
|
||||
/* translators: %s number of post views */
|
||||
$output .= esc_html( sprintf( _n( '%s view', '%s views', $views, 'absolute-reviews' ), $views_rounded ) );
|
||||
}
|
||||
|
||||
$output .= '</' . esc_html( $tag ) . '>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
||||
@@ -0,0 +1,464 @@
|
||||
# Copyright (C) 2022 absolute-reviews
|
||||
# This file is distributed under the same license as the absolute-reviews package.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: absolute-reviews\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language-Team: Code Supply Co. <hello@codesupply.co>\n"
|
||||
"Last-Translator: Code Supply Co. <hello@codesupply.co>\n"
|
||||
"Report-Msgid-Bugs-To: https://codesupply.co/contact/\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:57, admin/class-absolute-reviews-admin.php:57, public/class-absolute-reviews-block.php:51
|
||||
msgid "Reviews"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:68
|
||||
msgid "You do not have sufficient rights to view this page."
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:77
|
||||
msgid "Reviews Settings"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:81
|
||||
msgid "Indicators of the progress bar"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:89
|
||||
msgid "Indicator"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:90
|
||||
msgid "Default:"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:93
|
||||
msgid "Label"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:99
|
||||
msgid "Disable all indicators on the front end"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:108
|
||||
msgid "Supported Post Types"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:114
|
||||
msgid "Enable reviews for the following post types"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:148
|
||||
msgid "Save changes"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:187
|
||||
msgid "Settings saved."
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:199
|
||||
msgid "Review Options"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:242
|
||||
msgid "Enable Review"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:247
|
||||
msgid "General"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:248
|
||||
msgid "Criteria"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:249
|
||||
msgid "Pros / Cons"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:250, public/class-absolute-reviews-block.php:71
|
||||
msgid "Schema Attributes"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:256, public/class-absolute-reviews-block.php:162, public/class-absolute-reviews-posts-block.php:451
|
||||
msgid "Heading"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:264, admin/class-absolute-reviews-admin.php:342, admin/class-absolute-reviews-admin.php:343, admin/class-absolute-reviews-admin.php:378, admin/class-absolute-reviews-admin.php:379, public/class-absolute-reviews-block.php:169
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:272, public/class-absolute-reviews-block.php:176
|
||||
msgid "Legend"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:280
|
||||
msgid "Type"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:284, public/class-absolute-reviews-block.php:81, public/class-absolute-reviews-posts-block.php:255, public/class-absolute-reviews-posts-widget.php:248
|
||||
msgid "Percentage (1-100%)"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:285, public/class-absolute-reviews-block.php:101, public/class-absolute-reviews-posts-block.php:256, public/class-absolute-reviews-posts-widget.php:249
|
||||
msgid "Points (1-5)"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:286, public/class-absolute-reviews-block.php:121, public/class-absolute-reviews-posts-block.php:257, public/class-absolute-reviews-posts-widget.php:250
|
||||
msgid "Points (1-10)"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:287, public/class-absolute-reviews-block.php:140, public/class-absolute-reviews-posts-block.php:258, public/class-absolute-reviews-posts-widget.php:251
|
||||
msgid "Stars (1-5)"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:293
|
||||
msgid "Main Scale"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:301
|
||||
msgid "Auto Сalculate Total Score"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:309, includes/helpers-absolute-reviews.php:576, public/class-absolute-reviews-block.php:89, public/class-absolute-reviews-block.php:109, public/class-absolute-reviews-block.php:129, public/class-absolute-reviews-block.php:148, public/class-absolute-reviews-block.php:186
|
||||
msgid "Total Score"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:324, admin/class-absolute-reviews-admin.php:360
|
||||
msgid "Remove"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:325, admin/class-absolute-reviews-admin.php:361
|
||||
msgid "Click to toggle"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:326, admin/class-absolute-reviews-admin.php:333, admin/class-absolute-reviews-admin.php:362, admin/class-absolute-reviews-admin.php:369
|
||||
msgid "Criterion"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:332, admin/class-absolute-reviews-admin.php:333, admin/class-absolute-reviews-admin.php:368, admin/class-absolute-reviews-admin.php:369, admin/class-absolute-reviews-admin.php:422, admin/class-absolute-reviews-admin.php:446, admin/class-absolute-reviews-admin.php:492, admin/class-absolute-reviews-admin.php:516
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:337, admin/class-absolute-reviews-admin.php:373
|
||||
msgid "Value"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:393
|
||||
msgid "Add new criterion"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:399
|
||||
msgid "Pros Heading"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:402, includes/helpers-absolute-reviews.php:787
|
||||
msgid "The Good"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:407
|
||||
msgid "Pros List"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:422, admin/class-absolute-reviews-admin.php:446, admin/class-absolute-reviews-admin.php:492, admin/class-absolute-reviews-admin.php:516
|
||||
msgid "Item"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:462
|
||||
msgid "Add new pros item"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:469
|
||||
msgid "Cons Heading"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:472, includes/helpers-absolute-reviews.php:811
|
||||
msgid "The Bad"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:477
|
||||
msgid "Cons List"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:532
|
||||
msgid "Add new cons item"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:540
|
||||
msgid "Item Reviewed"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:541
|
||||
msgid "Heading will be used if blank."
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:549
|
||||
msgid "Review Text"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:550
|
||||
msgid "Description will be used if blank."
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:558
|
||||
msgid "Review Author"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:602
|
||||
msgid "Custom"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-absolute-reviews-admin.php:608, public/class-absolute-reviews-block.php:190
|
||||
msgid "Custom Author"
|
||||
msgstr ""
|
||||
|
||||
#. translators: %s: author name
|
||||
#: includes/post-meta.php:224
|
||||
msgid "View all posts by %s"
|
||||
msgstr ""
|
||||
|
||||
#: includes/post-meta.php:278
|
||||
msgid "No comments"
|
||||
msgstr ""
|
||||
|
||||
#: includes/post-meta.php:278
|
||||
msgid "One comment"
|
||||
msgstr ""
|
||||
|
||||
#: includes/post-meta.php:278
|
||||
msgid "comments"
|
||||
msgstr ""
|
||||
|
||||
#. translators: %s number of minutes
|
||||
#: includes/post-meta.php:309
|
||||
msgid "%s minute read"
|
||||
msgid_plural "%s minute read"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#. translators: %s number of post views
|
||||
#: includes/post-meta.php:351
|
||||
msgid "%s view"
|
||||
msgid_plural "%s views"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: public/class-absolute-reviews-block.php:52
|
||||
msgid "The block allows you to display images from your review account."
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-block.php:66, public/class-absolute-reviews-posts-block.php:202
|
||||
msgid "Block Settings"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-block.php:75, public/class-absolute-reviews-posts-block.php:219
|
||||
msgid "Typography Settings"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-block.php:183
|
||||
msgid "Total Score Label"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:137, public/class-absolute-reviews-public.php:92
|
||||
msgid "Reviews 1"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:139, public/class-absolute-reviews-public.php:96
|
||||
msgid "Reviews 2"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:141, public/class-absolute-reviews-public.php:100
|
||||
msgid "Reviews 3"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:143, public/class-absolute-reviews-public.php:104
|
||||
msgid "Reviews 4"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:145, public/class-absolute-reviews-public.php:108
|
||||
msgid "Reviews 5"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:147, public/class-absolute-reviews-public.php:112
|
||||
msgid "Reviews 6"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:149, public/class-absolute-reviews-public.php:116
|
||||
msgid "Reviews 7"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:151, public/class-absolute-reviews-public.php:120
|
||||
msgid "Reviews 8"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:207
|
||||
msgid "Large Post Meta Settings"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:211
|
||||
msgid "Small Post Meta Settings"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:215
|
||||
msgid "Thumbnail Settings"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:249
|
||||
msgid "Filter by Review Type"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:254, public/class-absolute-reviews-posts-widget.php:247
|
||||
msgid "All types"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:264
|
||||
msgid "Posts Count"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:273
|
||||
msgid "Image Size"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:298
|
||||
msgid "Large Post Image Size"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:325
|
||||
msgid "Small Post Image Size"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:353
|
||||
msgid "Heading Font Size"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:384
|
||||
msgid "Heading Post Large Font Size"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:417
|
||||
msgid "Heading Post Small Font Size"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:465
|
||||
msgid "Heading Hover"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:479
|
||||
msgid "Post Meta"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:493
|
||||
msgid "Post Meta Links"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-block.php:507
|
||||
msgid "Post Meta Links Hover"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:48
|
||||
msgid "Display a list of your reviews posts."
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:50
|
||||
msgid "Reviews Posts"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:219
|
||||
msgid "Title:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:227
|
||||
msgid "Template:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:240
|
||||
msgid "Number of posts:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:245
|
||||
msgid "Filter by Review Type:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:257
|
||||
msgid "Order by:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:259
|
||||
msgid "Date"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:260
|
||||
msgid "Comments"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:261
|
||||
msgid "Random"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:264
|
||||
msgid "Views"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:271
|
||||
msgid "Order"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:273
|
||||
msgid "Descending"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:274
|
||||
msgid "Ascending"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:279
|
||||
msgid "Time frame:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:280
|
||||
msgid "3 months"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:284
|
||||
msgid "Category:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:309, public/class-absolute-reviews-posts-widget.php:337, public/class-absolute-reviews-posts-widget.php:365
|
||||
msgid "Image size:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:320, public/class-absolute-reviews-posts-widget.php:348, public/class-absolute-reviews-posts-widget.php:376
|
||||
msgid "Post meta:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:328, public/class-absolute-reviews-posts-widget.php:356, public/class-absolute-reviews-posts-widget.php:384
|
||||
msgid "Compact post meta:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:330, public/class-absolute-reviews-posts-widget.php:358, public/class-absolute-reviews-posts-widget.php:386
|
||||
msgid "Display compact post meta"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:334
|
||||
msgid "Large Post"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:362
|
||||
msgid "Small Post"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:390
|
||||
msgid "Avoid duplicate posts:"
|
||||
msgstr ""
|
||||
|
||||
#: public/class-absolute-reviews-posts-widget.php:392
|
||||
msgid "Exclude duplicate posts"
|
||||
msgstr ""
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Review block template
|
||||
*
|
||||
* @var $attributes - block attributes
|
||||
* @var $options - layout options
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
|
||||
switch ( $attributes['layout'] ) {
|
||||
case 'percentage':
|
||||
$total_score = $options['total_score_percentage'];
|
||||
break;
|
||||
case 'point-5':
|
||||
$total_score = $options['total_score_point_5'];
|
||||
break;
|
||||
case 'point-10':
|
||||
$total_score = $options['total_score_point_10'];
|
||||
break;
|
||||
case 'star':
|
||||
$total_score = $options['total_score_star'];
|
||||
break;
|
||||
default:
|
||||
$total_score = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'variant' => 'block',
|
||||
'type' => $attributes['layout'],
|
||||
'heading' => $attributes['heading'],
|
||||
'desc' => $attributes['desc'],
|
||||
'legend' => $attributes['legend'],
|
||||
'total_label' => $attributes['total_score_label'],
|
||||
'total_score_number' => $total_score,
|
||||
'main_scale' => true,
|
||||
'auto_score' => false,
|
||||
);
|
||||
|
||||
$params['schema_author'] = get_post_meta( get_queried_object_id(), '_abr_review_schema_author', true );
|
||||
$params['schema_author_custom'] = get_post_meta( get_queried_object_id(), '_abr_review_schema_author_custom', true );
|
||||
|
||||
if ( isset( $attributes['schema_author_custom'] ) && $attributes['schema_author_custom'] ) {
|
||||
$params['schema_author'] = 'custom';
|
||||
$params['schema_author_custom'] = $attributes['schema_author_custom'];
|
||||
}
|
||||
|
||||
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>';
|
||||
|
||||
abr_review_display_block( $params );
|
||||
|
||||
echo '</div>';
|
||||
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
/**
|
||||
* The Gutenberg Block.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* The initialize block.
|
||||
*/
|
||||
class ABR_Review_Block {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'block' ) );
|
||||
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the block's assets for the editor.
|
||||
*/
|
||||
public function block() {
|
||||
// Styles.
|
||||
wp_register_style(
|
||||
'absolute-reviews-block-editor-style',
|
||||
ABR_URL . 'public/css/absolute-reviews-public.css',
|
||||
array( 'wp-edit-blocks' ),
|
||||
filemtime( ABR_PATH . 'public/css/absolute-reviews-public.css' )
|
||||
);
|
||||
|
||||
wp_style_add_data( 'absolute-reviews-block-editor-style', 'rtl', 'replace' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register block
|
||||
*
|
||||
* @param array $blocks all registered blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function register_block_type( $blocks ) {
|
||||
|
||||
// Add block.
|
||||
$blocks[] = array(
|
||||
'name' => 'canvas/absolute-reviews',
|
||||
'title' => esc_html__( 'Reviews', 'absolute-reviews' ),
|
||||
'description' => esc_html__( 'The block allows you to display images from your review account.', 'absolute-reviews' ),
|
||||
'category' => 'canvas',
|
||||
'keywords' => array(),
|
||||
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><rect x="0" fill="none" width="20" height="20"/><g><path d="M10 1l3 6 6 .75-4.12 4.62L16 19l-6-3-6 3 1.13-6.63L1 7.75 7 7z"/></g></svg>',
|
||||
'supports' => array(
|
||||
'className' => true,
|
||||
'anchor' => true,
|
||||
'html' => false,
|
||||
'canvasSpacings' => true,
|
||||
),
|
||||
'styles' => array(),
|
||||
'location' => array(),
|
||||
'sections' => array(
|
||||
'general' => array(
|
||||
'title' => esc_html__( 'Block Settings', 'absolute-reviews' ),
|
||||
'priority' => 5,
|
||||
'open' => true,
|
||||
),
|
||||
'schema_attrs' => array(
|
||||
'title' => esc_html__( 'Schema Attributes', 'absolute-reviews' ),
|
||||
'priority' => 10,
|
||||
),
|
||||
'typography' => array(
|
||||
'title' => esc_html__( 'Typography Settings', 'absolute-reviews' ),
|
||||
'priority' => 10,
|
||||
),
|
||||
),
|
||||
'layouts' => array(
|
||||
'percentage' => array(
|
||||
'name' => esc_html__( 'Percentage (1-100%)', 'absolute-reviews' ),
|
||||
'icon' => '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><path d="M19 19.429h18.286M19 16h24m-24-3.429h20.571M7 30.429h33.75M7 27h31.5M7 23.571h36" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/><path fill="#2D2D2D" d="M7 12h8v8H7z"/><path d="M13 19a1 1 0 110-2 1 1 0 010 2zm-4-4a1 1 0 110-2 1 1 0 010 2zm4.5-2l.5.5L8.5 19l-.5-.5 5.5-5.5z" fill="#FFF" fill-rule="nonzero"/></g></svg>',
|
||||
'location' => array(),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
'sections' => array(),
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'total_score_percentage',
|
||||
'label' => esc_html__( 'Total Score', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'step' => 1,
|
||||
'min' => 1,
|
||||
'max' => 100,
|
||||
'default' => 50,
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
'point-5' => array(
|
||||
'name' => esc_html__( 'Points (1-5)', 'absolute-reviews' ),
|
||||
'icon' => '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><g stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"><path d="M7 25.5h27m-27-4h36m-36-4h31M7 29.571h36"/></g><path fill="#2D2D2D" d="M7 12h5v2H7zM13 12h5v2h-5zM19 12h5v2h-5zM25 12h5v2h-5z"/><path fill="#C7C7C7" d="M31 12h5v2h-5zM37 12h5v2h-5z"/></g></svg>',
|
||||
'location' => array(),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
'sections' => array(),
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'total_score_point_5',
|
||||
'label' => esc_html__( 'Total Score', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'step' => 1,
|
||||
'min' => 1,
|
||||
'max' => 5,
|
||||
'default' => 1,
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
'point-10' => array(
|
||||
'name' => esc_html__( 'Points (1-10)', 'absolute-reviews' ),
|
||||
'icon' => '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><g stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"><path d="M7 25.5h27m-27-4h36m-36-4h31M7 29.571h36"/></g><path fill="#2D2D2D" d="M7 12h5v2H7zM13 12h5v2h-5zM19 12h5v2h-5zM25 12h5v2h-5z"/><path fill="#C7C7C7" d="M31 12h5v2h-5zM37 12h5v2h-5z"/></g></svg>',
|
||||
'location' => array(),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
'sections' => array(),
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'total_score_point_10',
|
||||
'label' => esc_html__( 'Total Score', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'step' => 1,
|
||||
'min' => 1,
|
||||
'max' => 10,
|
||||
'default' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
'star' => array(
|
||||
'name' => esc_html__( 'Stars (1-5)', 'absolute-reviews' ),
|
||||
'icon' => '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><path d="M19 19.429h18.286M19 16h24m-24-3.429h20.571M7 30.429h33.75M7 27h31.5M7 23.571h36" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/><path fill="#2D2D2D" d="M7 12h8v8H7z"/><path d="M11 13.143l.883 1.88 1.974.304-1.428 1.463.337 2.067L11 17.881l-1.766.976.337-2.067-1.428-1.463 1.974-.303z" fill="#FFF"/></g></svg>',
|
||||
'location' => array(),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
'sections' => array(),
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'total_score_star',
|
||||
'label' => esc_html__( 'Total Score', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'step' => 1,
|
||||
'min' => 1,
|
||||
'max' => 5,
|
||||
'default' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'heading',
|
||||
'label' => esc_html__( 'Heading', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'key' => 'desc',
|
||||
'label' => esc_html__( 'Description', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'key' => 'legend',
|
||||
'label' => esc_html__( 'Legend', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'key' => 'total_score_label',
|
||||
'label' => esc_html__( 'Total Score Label', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'text',
|
||||
'default' => esc_html__( 'Total Score', 'absolute-reviews' ),
|
||||
),
|
||||
array(
|
||||
'key' => 'schema_author_custom',
|
||||
'label' => esc_html__( 'Custom Author', 'absolute-reviews' ),
|
||||
'section' => 'schema_attrs',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
),
|
||||
// Typography.
|
||||
array(
|
||||
'key' => 'typographyDescription',
|
||||
'label' => esc_html__( 'Description Font Size', 'authentic' ),
|
||||
'section' => 'typography',
|
||||
'type' => 'dimension',
|
||||
'default' => '0.875rem',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-review-info .abr-review-description',
|
||||
'property' => 'font-size',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
'active_callback' => array(
|
||||
array(
|
||||
'field' => 'desc',
|
||||
'operator' => '!=',
|
||||
'value' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'typographyLegend',
|
||||
'label' => esc_html__( 'Legend Font Size', 'authentic' ),
|
||||
'section' => 'typography',
|
||||
'type' => 'dimension',
|
||||
'default' => '0.875rem',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-review-total .abr-review-subtext .abr-data-info > span',
|
||||
'property' => 'font-size',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
'active_callback' => array(
|
||||
array(
|
||||
'field' => 'legend',
|
||||
'operator' => '!=',
|
||||
'value' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'typographyTotal',
|
||||
'label' => esc_html__( 'Total Font Size', 'authentic' ),
|
||||
'section' => 'typography',
|
||||
'type' => 'dimension',
|
||||
'default' => '3rem',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-review-total .abr-review-score .abr-review-text',
|
||||
'property' => 'font-size',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
'editor_style' => 'absolute-reviews-block-editor-style',
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
}
|
||||
|
||||
new ABR_Review_Block();
|
||||
@@ -0,0 +1,630 @@
|
||||
<?php
|
||||
/**
|
||||
* Block Reviews Posts
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block Reviews Posts
|
||||
*/
|
||||
class ABR_Reviews_Posts_Block {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'canvas_block_layouts_canvas/posts', array( $this, 'register_layout' ), 99 );
|
||||
add_filter( 'canvas_block_posts_query_args', array( $this, 'change_query_args' ), 10, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields array for Meta
|
||||
*
|
||||
* @param array $settings The settings.
|
||||
*/
|
||||
public function get_meta_fields( $settings ) {
|
||||
|
||||
$settings = array_merge( array(
|
||||
'field_prefix' => 'reviews',
|
||||
'section_name' => '',
|
||||
'active_callback' => array(),
|
||||
), $settings );
|
||||
|
||||
// Set fields.
|
||||
$fields = array(
|
||||
array(
|
||||
'key' => $settings['field_prefix'] . '_showMetaCategory',
|
||||
'label' => esc_html__( 'Category', 'authentic' ),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
'active_callback' => $settings['active_callback'],
|
||||
),
|
||||
array(
|
||||
'key' => $settings['field_prefix'] . '_showMetaAuthor',
|
||||
'label' => esc_html__( 'Author', 'authentic' ),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
'active_callback' => $settings['active_callback'],
|
||||
),
|
||||
array(
|
||||
'key' => $settings['field_prefix'] . '_showMetaDate',
|
||||
'label' => esc_html__( 'Date', 'authentic' ),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
'active_callback' => $settings['active_callback'],
|
||||
),
|
||||
array(
|
||||
'key' => $settings['field_prefix'] . '_showMetaComments',
|
||||
'label' => esc_html__( 'Comments', 'authentic' ),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'toggle',
|
||||
'default' => false,
|
||||
'active_callback' => $settings['active_callback'],
|
||||
),
|
||||
abr_post_views_enabled() ? array(
|
||||
'key' => $settings['field_prefix'] . '_showMetaViews',
|
||||
'label' => esc_html__( 'Views', 'authentic' ),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'toggle',
|
||||
'default' => false,
|
||||
'active_callback' => $settings['active_callback'],
|
||||
) : array(),
|
||||
abr_powerkit_module_enabled( 'reading_time' ) ? array(
|
||||
'key' => $settings['field_prefix'] . '_showMetaReadingTime',
|
||||
'label' => esc_html__( 'Reading Time', 'authentic' ),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'toggle',
|
||||
'default' => false,
|
||||
'active_callback' => $settings['active_callback'],
|
||||
) : array(),
|
||||
array(
|
||||
'key' => uniqid(),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'separator',
|
||||
'active_callback' => $settings['active_callback'],
|
||||
),
|
||||
array(
|
||||
'key' => $settings['field_prefix'] . 'MetaCompact',
|
||||
'label' => esc_html__( 'Display compact post meta', 'authentic' ),
|
||||
'section' => $settings['section_name'],
|
||||
'type' => 'toggle',
|
||||
'default' => false,
|
||||
'active_callback' => $settings['active_callback'],
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get types of layout.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
public function get_types_of_layouts() {
|
||||
$types = array(
|
||||
'reviews-1' => 'reviews-1',
|
||||
'reviews-2' => 'reviews-2',
|
||||
'reviews-3' => 'reviews-3',
|
||||
'reviews-4' => 'reviews-4',
|
||||
'reviews-5' => 'reviews-5',
|
||||
'reviews-6' => 'reviews-6',
|
||||
'reviews-7' => 'reviews-7',
|
||||
'reviews-8' => 'reviews-8',
|
||||
);
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of layout by key.
|
||||
*
|
||||
* @param mixed $key The key.
|
||||
*/
|
||||
public function get_name_of_layout_by( $key ) {
|
||||
|
||||
switch ( $key ) {
|
||||
case 'reviews-1':
|
||||
return esc_html__( 'Reviews 1', 'absolute-reviews' );
|
||||
case 'reviews-2':
|
||||
return esc_html__( 'Reviews 2', 'absolute-reviews' );
|
||||
case 'reviews-3':
|
||||
return esc_html__( 'Reviews 3', 'absolute-reviews' );
|
||||
case 'reviews-4':
|
||||
return esc_html__( 'Reviews 4', 'absolute-reviews' );
|
||||
case 'reviews-5':
|
||||
return esc_html__( 'Reviews 5', 'absolute-reviews' );
|
||||
case 'reviews-6':
|
||||
return esc_html__( 'Reviews 6', 'absolute-reviews' );
|
||||
case 'reviews-7':
|
||||
return esc_html__( 'Reviews 7', 'absolute-reviews' );
|
||||
case 'reviews-8':
|
||||
return esc_html__( 'Reviews 8', 'absolute-reviews' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get icon of layout by key.
|
||||
*
|
||||
* @param mixed $key The key.
|
||||
*/
|
||||
public function get_icon_of_layout_by( $key ) {
|
||||
|
||||
switch ( $key ) {
|
||||
case 'reviews-1':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" stroke="#2D2D2D" fill="none" fill-rule="evenodd"><rect stroke-width="1.5" width="50" height="42" rx="3"/><g transform="translate(10 6)"><rect stroke-width="1.5" width="14" height="12" rx="1"/><path d="M18 4.625h12.278M18 7.625h8.273" stroke-linecap="round" stroke-linejoin="round"/></g><g transform="translate(10 24)"><rect stroke-width="1.5" width="14" height="12" rx="1"/><path d="M18 4.625h12.278M18 7.625h8.273" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>';
|
||||
case 'reviews-2':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><g transform="translate(10 24)"><rect stroke="#2D2D2D" stroke-width="1.5" width="14" height="12" rx="1"/><g transform="translate(18 9)"><rect fill="#C7C7C7" width="13" height="2" rx="1"/><rect fill="#2D2D2D" width="10" height="2" rx="1"/></g><path d="M18 2h12.278M18 5h8.273" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/></g><g transform="translate(10 6)"><rect stroke="#2D2D2D" stroke-width="1.5" width="14" height="12" rx="1"/><g transform="translate(18 9)"><rect fill="#C7C7C7" width="13" height="2" rx="1"/><rect fill="#2D2D2D" width="10" height="2" rx="1"/></g><path d="M18 2h12.278M18 5h8.273" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>';
|
||||
case 'reviews-3':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" stroke="#2D2D2D" fill="none" fill-rule="evenodd"><rect stroke-width="1.5" width="50" height="42" rx="3"/><rect x=".5" y=".5" width="24" height="16" rx="1" transform="translate(12 4)" stroke-width="1.5"/><g transform="translate(13 30)"><rect stroke-width="1.5" width="8" height="8" rx="1"/><path d="M11.361 2.5H23.64M11 5.5h8.667" stroke-linecap="round" stroke-linejoin="round"/></g><path d="M13.028 26.5H28.68m-15.652-3h22.666" stroke-linecap="round" stroke-linejoin="round"/></g></svg>';
|
||||
case 'reviews-4':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><rect x=".5" y=".5" width="24" height="16" rx="1" transform="translate(12 4)" stroke="#2D2D2D" stroke-width="1.5"/><rect stroke="#2D2D2D" stroke-width="1.5" x="13" y="30" width="8" height="8" rx="1"/><path d="M24.361 35.5h8.667m-8.667-3H36.64" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/><g transform="translate(12 24)"><rect fill="#C7C7C7" width="25" height="2" rx="1"/><rect fill="#2D2D2D" width="19" height="2" rx="1"/></g></g></svg>';
|
||||
case 'reviews-5':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><rect x=".5" y=".5" width="24" height="16" rx="1" transform="translate(12 4)" stroke="#2D2D2D" stroke-width="1.5"/><g transform="translate(13 30)" stroke="#2D2D2D"><rect stroke-width="1.5" width="8" height="8" rx="1"/><path d="M11.361 2.5H23.64M11 5.5h8.667" stroke-linecap="round" stroke-linejoin="round"/></g><path d="M12.722 26.5h10.212m-10.212-3H25" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/><text font-family="FuturaPT-Bold, Futura PT" font-size="5" font-weight="bold" fill="#2D2D2D"><tspan x="27" y="28">3/5</tspan></text></g></svg>';
|
||||
case 'reviews-6':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><g transform="translate(12 4)"><rect stroke="#2D2D2D" stroke-width="1.5" x=".5" y=".5" width="24" height="33" rx="1"/><g transform="translate(3 3)"><circle fill="#2D2D2D" cx="3" cy="3" r="3"/><path d="M4.333 5a.667.667 0 110-1.333.667.667 0 010 1.333zM1.667 2.333a.667.667 0 110-1.333.667.667 0 010 1.333zm3-1.333L5 1.333 1.333 5 1 4.667 4.666 1z" fill="#FFF" fill-rule="nonzero"/></g><path d="M3.528 26.5h17.944M3.44 29h11.416" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>';
|
||||
case 'reviews-7':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><g transform="translate(12 4)"><rect stroke="#2D2D2D" stroke-width="1.5" x=".5" y=".5" width="24" height="33" rx="1"/><path d="M3.57 29.758l1.172-1.173.849.848 1.371-1.37.538.537v-1.5H6l.538.538-.947.947-.849-.849L3.26 29.22a3 3 0 11.31.538z" fill="#2D2D2D" fill-rule="nonzero"/><path d="M3.528 19.5h17.944M3.44 22h11.416" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>';
|
||||
case 'reviews-8':
|
||||
return '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><g transform="translate(12 4)"><rect stroke="#2D2D2D" stroke-width="1.5" x=".5" y=".5" width="24" height="33" rx="1"/><path d="M3.57 7.758l1.172-1.173.849.848 1.371-1.37.538.537V5.1H6l.538.538-.947.947-.849-.849L3.26 7.22a3 3 0 11.31.538z" fill="#2D2D2D" fill-rule="nonzero"/><path d="M3.528 27.5h17.944M3.44 30h11.416" stroke="#2D2D2D" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register layout.
|
||||
*
|
||||
* @param array $layouts List of layouts.
|
||||
*/
|
||||
public function register_layout( $layouts = array() ) {
|
||||
|
||||
$image_sizes = abr_get_list_available_image_sizes();
|
||||
|
||||
$types = $this->get_types_of_layouts();
|
||||
|
||||
foreach ( $types as $type ) {
|
||||
|
||||
$layouts[ $type ] = array(
|
||||
'location' => array(),
|
||||
'name' => $this->get_name_of_layout_by( $type ),
|
||||
'template' => dirname( __FILE__ ) . '/posts-block.php',
|
||||
'icon' => $this->get_icon_of_layout_by( $type ),
|
||||
'sections' => array(
|
||||
'general' => array(
|
||||
'title' => esc_html__( 'Block Settings', 'absolute-reviews' ),
|
||||
'priority' => 5,
|
||||
'open' => true,
|
||||
),
|
||||
'reviewsLargeMeta' => array(
|
||||
'title' => esc_html__( 'Large Post Meta Settings', 'absolute-reviews' ),
|
||||
'priority' => 10,
|
||||
),
|
||||
'reviewsSmallMeta' => array(
|
||||
'title' => esc_html__( 'Small Post Meta Settings', 'absolute-reviews' ),
|
||||
'priority' => 20,
|
||||
),
|
||||
'reviewsThumbnail' => array(
|
||||
'title' => esc_html__( 'Thumbnail Settings', 'absolute-reviews' ),
|
||||
'priority' => 30,
|
||||
),
|
||||
'reviewsTypography' => array(
|
||||
'title' => esc_html__( 'Typography Settings', 'absolute-reviews' ),
|
||||
'priority' => 40,
|
||||
),
|
||||
),
|
||||
'hide_fields' => array(
|
||||
'showMetaCategory',
|
||||
'showMetaAuthor',
|
||||
'showMetaDate',
|
||||
'showMetaComments',
|
||||
'showMetaViews',
|
||||
'showMetaReadingTime',
|
||||
'showMetaShares',
|
||||
'showExcerpt',
|
||||
'showViewPostButton',
|
||||
'showPagination',
|
||||
'imageSize',
|
||||
'postsCount',
|
||||
'colorText',
|
||||
'colorHeading',
|
||||
'colorHeadingHover',
|
||||
'colorText',
|
||||
'colorMeta',
|
||||
'colorMetaHover',
|
||||
'colorMetaLinks',
|
||||
'colorMetaLinksHover',
|
||||
),
|
||||
'fields' => array_merge(
|
||||
array(
|
||||
array(
|
||||
'key' => 'reviewType',
|
||||
'label' => esc_html__( 'Filter by Review Type', 'absolute-reviews' ),
|
||||
'section' => 'query',
|
||||
'type' => 'select',
|
||||
'multiple' => false,
|
||||
'choices' => array(
|
||||
'all' => esc_html__( 'All types', 'absolute-reviews' ),
|
||||
'percentage' => esc_html__( 'Percentage (1-100%)', 'absolute-reviews' ),
|
||||
'point-5' => esc_html__( 'Points (1-5)', 'absolute-reviews' ),
|
||||
'point-10' => esc_html__( 'Points (1-10)', 'absolute-reviews' ),
|
||||
'star' => esc_html__( 'Stars (1-5)', 'absolute-reviews' ),
|
||||
),
|
||||
'default' => 'all',
|
||||
),
|
||||
array(
|
||||
'key' => 'reviewsPostsCount',
|
||||
'label' => esc_html__( 'Posts Count', 'absolute-reviews' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'default' => 5,
|
||||
'min' => 1,
|
||||
'max' => 100,
|
||||
),
|
||||
array(
|
||||
'key' => 'imageSize',
|
||||
'label' => esc_html__( 'Image Size', 'absolute-reviews' ),
|
||||
'section' => 'reviewsThumbnail',
|
||||
'type' => 'select',
|
||||
'default' => 'large',
|
||||
'choices' => $image_sizes,
|
||||
'active_callback' => array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'largeImageSize',
|
||||
'label' => esc_html__( 'Large Post Image Size', 'absolute-reviews' ),
|
||||
'section' => 'reviewsThumbnail',
|
||||
'type' => 'select',
|
||||
'default' => 'large',
|
||||
'choices' => $image_sizes,
|
||||
'active_callback' => array(
|
||||
array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'smallImageSize',
|
||||
'label' => esc_html__( 'Small Post Image Size', 'absolute-reviews' ),
|
||||
'section' => 'reviewsThumbnail',
|
||||
'type' => 'select',
|
||||
'default' => 'large',
|
||||
'choices' => $image_sizes,
|
||||
'active_callback' => array(
|
||||
array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Typography.
|
||||
array(
|
||||
'key' => 'typographyHeading',
|
||||
'label' => esc_html__( 'Heading Font Size', 'absolute-reviews' ),
|
||||
'section' => 'reviewsTypography',
|
||||
'type' => 'dimension',
|
||||
'default' => '1rem',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .entry-title a',
|
||||
'property' => 'font-size',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
'active_callback' => array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'typographyLargeHeading',
|
||||
'label' => esc_html__( 'Heading Post Large Font Size', 'absolute-reviews' ),
|
||||
'section' => 'reviewsTypography',
|
||||
'type' => 'dimension',
|
||||
'default' => '1.5rem',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-post-item:first-child .entry-title a',
|
||||
'property' => 'font-size',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
'active_callback' => array(
|
||||
array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'typographySmallHeading',
|
||||
'label' => esc_html__( 'Heading Post Small Font Size', 'absolute-reviews' ),
|
||||
'section' => 'reviewsTypography',
|
||||
'type' => 'dimension',
|
||||
'default' => '1rem',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-post-item:nth-child(n+2) .entry-title a',
|
||||
'property' => 'font-size',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
'active_callback' => array(
|
||||
array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Color Settings.
|
||||
array(
|
||||
'key' => 'colorHeading',
|
||||
'label' => esc_html__( 'Heading', 'absolute-reviews' ),
|
||||
'section' => 'color',
|
||||
'type' => 'color',
|
||||
'default' => '#000',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-variation-default .entry-title a',
|
||||
'property' => 'color',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'colorHeadingHover',
|
||||
'label' => esc_html__( 'Heading Hover', 'absolute-reviews' ),
|
||||
'section' => 'color',
|
||||
'type' => 'color',
|
||||
'default' => '#5a5a5a',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-variation-default .entry-title a:hover, $ .abr-variation-default .entry-title a:focus',
|
||||
'property' => 'color',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'colorMeta',
|
||||
'label' => esc_html__( 'Post Meta', 'absolute-reviews' ),
|
||||
'section' => 'color',
|
||||
'type' => 'color',
|
||||
'default' => '',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-variation-default .post-meta span, $ .abr-variation-default .post-categories span',
|
||||
'property' => 'color',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'colorMetaLinks',
|
||||
'label' => esc_html__( 'Post Meta Links', 'absolute-reviews' ),
|
||||
'section' => 'color',
|
||||
'type' => 'color',
|
||||
'default' => '',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-variation-default .post-meta a, $ .abr-variation-default .post-categories a',
|
||||
'property' => 'color',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'colorMetaLinksHover',
|
||||
'label' => esc_html__( 'Post Meta Links Hover', 'absolute-reviews' ),
|
||||
'section' => 'color',
|
||||
'type' => 'color',
|
||||
'default' => '',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .abr-variation-default .post-meta a:hover, $ .abr-variation-default .post-meta a:focus, $ .abr-variation-default .post-categories a:hover, $ .abr-variation-default .post-categories a:focus',
|
||||
'property' => 'color',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Meta Settings.
|
||||
$this->get_meta_fields(
|
||||
array(
|
||||
'field_prefix' => 'reviews',
|
||||
'section_name' => 'meta',
|
||||
'active_callback' => array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '!=',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
$this->get_meta_fields(
|
||||
array(
|
||||
'field_prefix' => 'reviewsLarge',
|
||||
'section_name' => 'reviewsLargeMeta',
|
||||
'active_callback' => array(
|
||||
array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
$this->get_meta_fields(
|
||||
array(
|
||||
'field_prefix' => 'reviewsSmall',
|
||||
'section_name' => 'reviewsSmallMeta',
|
||||
'active_callback' => array(
|
||||
array(
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-3',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-4',
|
||||
),
|
||||
array(
|
||||
'field' => 'layout',
|
||||
'operator' => '==',
|
||||
'value' => 'reviews-5',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $layouts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change post query attributes
|
||||
*
|
||||
* @param array $args Args for post query.
|
||||
* @param array $attributes Block attributes.
|
||||
* @param array $options Block options.
|
||||
*/
|
||||
public function change_query_args( $args, $attributes, $options ) {
|
||||
|
||||
// Review type.
|
||||
if ( isset( $options['reviewType'] ) && 'all' !== $options['reviewType'] ) {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => '_abr_review_type',
|
||||
'value' => $options['reviewType'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Posts count.
|
||||
if ( isset( $options['reviewsPostsCount'] ) && $options['reviewsPostsCount'] ) {
|
||||
$args['posts_per_page'] = $options['reviewsPostsCount'];
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
|
||||
new ABR_Reviews_Posts_Block();
|
||||
@@ -0,0 +1,454 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Reviews Posts
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget Reviews Posts
|
||||
*/
|
||||
class ABR_Reviews_Posts_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->default_settings = apply_filters(
|
||||
'abr_widget_posts_settings', array(
|
||||
'title' => '',
|
||||
'template' => 'list',
|
||||
'posts_per_page' => 5,
|
||||
'review_type' => 'all',
|
||||
'orderby' => 'date',
|
||||
'order' => 'desc',
|
||||
'time_frame' => '',
|
||||
'category' => false,
|
||||
'thumbnail' => 'large',
|
||||
'post_meta' => array( 'date' ),
|
||||
'post_meta_compact' => false,
|
||||
'thumbnail_large' => 'large',
|
||||
'post_meta_large' => array( 'date' ),
|
||||
'post_meta_large_compact' => false,
|
||||
'thumbnail_small' => 'large',
|
||||
'post_meta_small' => array( 'date' ),
|
||||
'post_meta_small_compact' => false,
|
||||
'avoid_duplicate' => false,
|
||||
'output' => 'widget',
|
||||
)
|
||||
);
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'abr_reviews_posts_widget',
|
||||
'description' => esc_html__( 'Display a list of your reviews posts.', 'absolute-reviews' ),
|
||||
);
|
||||
parent::__construct( 'abr_reviews_posts_widget', esc_html__( 'Reviews Posts', 'absolute-reviews' ), $widget_details );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the content for the current widget instance.
|
||||
*
|
||||
* @param array $args Display arguments including 'before_title', 'after_title',
|
||||
* 'before_widget', and 'after_widget'.
|
||||
* @param array $instance Settings for the current widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
global $abr_posts;
|
||||
global $wp_query;
|
||||
|
||||
if ( ! $abr_posts ) {
|
||||
$abr_posts = array();
|
||||
}
|
||||
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
$posts_args = array(
|
||||
'posts_per_page' => $params['posts_per_page'],
|
||||
'order' => $params['order'],
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'ignore_sticky_posts' => true,
|
||||
);
|
||||
|
||||
if ( $params['category'] ) {
|
||||
$category = $params['category'];
|
||||
$posts_args['cat'] = $category;
|
||||
}
|
||||
|
||||
// Avoid Duplicate.
|
||||
if ( $params['avoid_duplicate'] ) {
|
||||
$main_posts = array();
|
||||
|
||||
if ( isset( $wp_query->posts ) && $wp_query->posts ) {
|
||||
$main_posts = wp_list_pluck( $wp_query->posts, 'ID' );
|
||||
}
|
||||
|
||||
if ( $main_posts ) {
|
||||
$posts_args['post__not_in'] = array_merge( $main_posts, $abr_posts );
|
||||
} else {
|
||||
$posts_args['post__not_in'] = $abr_posts;
|
||||
}
|
||||
}
|
||||
|
||||
// Review type.
|
||||
if ( 'all' !== $params['review_type'] ) {
|
||||
$posts_args['meta_query'] = array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => '_abr_review_type',
|
||||
'value' => $params['review_type'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Post order.
|
||||
if ( class_exists( 'Post_Views_Counter' ) && 'meta_value_num' === $params['orderby'] ) {
|
||||
// Post Views.
|
||||
$posts_args['orderby'] = 'post_views';
|
||||
} else {
|
||||
$posts_args['orderby'] = $params['orderby'];
|
||||
}
|
||||
|
||||
if ( $params['time_frame'] ) {
|
||||
$posts_args['date_query'] = array(
|
||||
array(
|
||||
'column' => 'post_date_gmt',
|
||||
'after' => $params['time_frame'] . ' ago',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$posts = new WP_Query( apply_filters_ref_array( 'abr_reviews_posts_widget_args', array( $posts_args, & $params ) ) );
|
||||
|
||||
if ( $posts->have_posts() ) {
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS.
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $params['title'], $instance, $this->id_base ) . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
$review_id = get_the_ID();
|
||||
|
||||
// Class Template.
|
||||
$class = sprintf( 'abr-posts-template-%s', $params['template'] );
|
||||
|
||||
// Class Number of Posts.
|
||||
$class .= sprintf( ' abr-posts-per-page-%s', (int) $params['posts_per_page'] );
|
||||
?>
|
||||
|
||||
<div class="widget-body abr-reviews-posts <?php echo esc_html( $class ); ?>">
|
||||
<div class="abr-reviews-posts-list">
|
||||
<?php
|
||||
$params['counter'] = 0;
|
||||
|
||||
while ( $posts->have_posts() ) :
|
||||
$posts->the_post();
|
||||
|
||||
$abr_posts[] = $review_id;
|
||||
|
||||
$params['counter']++;
|
||||
?>
|
||||
<div class="abr-post-item">
|
||||
<?php abr_reviews_posts_widget_handler( $params['template'], $posts, $params, $instance ); ?>
|
||||
</div>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS.
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles updating settings for the current widget instance.
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via
|
||||
* WP_Widget::form().
|
||||
* @param array $old_instance Old settings for this instance.
|
||||
* @return array Settings to save or bool false to cancel saving.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = $new_instance;
|
||||
|
||||
// Post Meta.
|
||||
if ( ! isset( $instance['post_meta'] ) ) {
|
||||
$instance['post_meta'] = array();
|
||||
}
|
||||
|
||||
// Compact Post Meta.
|
||||
if ( ! isset( $instance['post_meta_compact'] ) ) {
|
||||
$instance['post_meta_compact'] = false;
|
||||
}
|
||||
|
||||
// Avoid duplicate posts.
|
||||
if ( ! isset( $instance['avoid_duplicate'] ) ) {
|
||||
$instance['avoid_duplicate'] = false;
|
||||
}
|
||||
|
||||
return apply_filters( 'abr_reviews_posts_widget_update', $instance );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
$allowed_post_meta = abr_allowed_post_meta();
|
||||
|
||||
$image_sizes = abr_get_list_available_image_sizes();
|
||||
|
||||
$templates = apply_filters( 'abr_reviews_posts_templates', array() );
|
||||
?>
|
||||
<!-- Title -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'absolute-reviews' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $params['title'] ); ?>" /></p>
|
||||
|
||||
<?php do_action( 'abr_reviews_posts_widget_form_before', $this, $params, $instance ); ?>
|
||||
|
||||
<!-- Template -->
|
||||
<?php if ( $templates ) { ?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"><?php esc_html_e( 'Template:', 'absolute-reviews' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>" class="widefat abr-template">
|
||||
<?php
|
||||
foreach ( $templates as $slug => $template ) {
|
||||
$name = isset( $template['name'] ) ? $template['name'] : $slug;
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $slug ); ?>" <?php selected( $params['template'], $slug ); ?>><?php echo esc_html( $name ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Number of Posts -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'posts_per_page' ) ); ?>"><?php esc_html_e( 'Number of posts:', 'absolute-reviews' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'posts_per_page' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'posts_per_page' ) ); ?>" type="number" value="<?php echo esc_attr( $params['posts_per_page'] ); ?>" /></p>
|
||||
|
||||
<!-- Filter by Review Type -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'review_type' ) ); ?>"><?php esc_html_e( 'Filter by Review Type:', 'absolute-reviews' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'review_type' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'review_type' ) ); ?>" class="widefat">
|
||||
<option value="all" <?php selected( $params['review_type'], 'all' ); ?>><?php esc_html_e( 'All types', 'absolute-reviews' ); ?></option>
|
||||
<option value="percentage" <?php selected( $params['review_type'], 'percentage' ); ?>><?php esc_html_e( 'Percentage (1-100%)', 'absolute-reviews' ); ?></option>
|
||||
<option value="point-5" <?php selected( $params['review_type'], 'point-5' ); ?>><?php esc_html_e( 'Points (1-5)', 'absolute-reviews' ); ?></option>
|
||||
<option value="point-10" <?php selected( $params['review_type'], 'point-10' ); ?>><?php esc_html_e( 'Points (1-10)', 'absolute-reviews' ); ?></option>
|
||||
<option value="star" <?php selected( $params['review_type'], 'star' ); ?>><?php esc_html_e( 'Stars (1-5)', 'absolute-reviews' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Order by -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Order by:', 'absolute-reviews' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat">
|
||||
<option value="date" <?php selected( $params['orderby'], 'date' ); ?>><?php esc_html_e( 'Date', 'absolute-reviews' ); ?></option>
|
||||
<option value="comment_count" <?php selected( $params['orderby'], 'comment_count' ); ?>><?php esc_html_e( 'Comments', 'absolute-reviews' ); ?></option>
|
||||
<option value="rand" <?php selected( $params['orderby'], 'rand' ); ?>><?php esc_html_e( 'Random', 'absolute-reviews' ); ?></option>
|
||||
|
||||
<?php if ( class_exists( 'Post_Views_Counter' ) ) { ?>
|
||||
<option value="meta_value_num" <?php selected( $params['orderby'], 'meta_value_num' ); ?>><?php esc_html_e( 'Views', 'absolute-reviews' ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Order -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order', 'absolute-reviews' ); ?>:</label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" class="widefat">
|
||||
<option value="desc" <?php selected( $params['order'], 'desc' ); ?>><?php esc_html_e( 'Descending', 'absolute-reviews' ); ?></option>
|
||||
<option value="asc" <?php selected( $params['order'], 'asc' ); ?>><?php esc_html_e( 'Ascending', 'absolute-reviews' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Time Frame -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'time_frame' ) ); ?>"><?php esc_html_e( 'Time frame:', 'absolute-reviews' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'time_frame' ) ); ?>" placeholder="<?php esc_html_e( '3 months', 'absolute-reviews' ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'time_frame' ) ); ?>" type="text" value="<?php echo esc_attr( $params['time_frame'] ); ?>" /></p>
|
||||
|
||||
<!-- Category -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php esc_html_e( 'Category:', 'absolute-reviews' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>[]" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" class="widefat" style="height: auto !important;" multiple="multiple" size="8">
|
||||
<?php
|
||||
$cat_args = array(
|
||||
'hide_empty' => 0,
|
||||
'hierarchical' => 1,
|
||||
'selected' => (array) $params['category'],
|
||||
'walker' => new ABR_Add_Posts_Categories_Tree_Walker(),
|
||||
);
|
||||
|
||||
$allowed_html = array(
|
||||
'option' => array(
|
||||
'class' => true,
|
||||
'value' => true,
|
||||
'selected' => true,
|
||||
),
|
||||
);
|
||||
|
||||
echo wp_kses( walk_category_dropdown_tree( get_categories( $cat_args ), 0, $cat_args ), $allowed_html );
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<fieldset class="abr-simple-post">
|
||||
<!-- Image size -->
|
||||
<h4><?php esc_html_e( 'Image size:', 'absolute-reviews' ); ?></h4>
|
||||
|
||||
<?php if ( $image_sizes ) { ?>
|
||||
<p><select name="<?php echo esc_attr( $this->get_field_name( 'thumbnail' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'thumbnail' ) ); ?>">
|
||||
<?php foreach ( $image_sizes as $key => $caption ) { ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $params['thumbnail'] ); ?>><?php echo esc_html( $caption ); ?></option>
|
||||
<?php } ?>
|
||||
</select></p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Post meta -->
|
||||
<h4><?php esc_html_e( 'Post meta:', 'absolute-reviews' ); ?></h4>
|
||||
|
||||
<?php foreach ( $allowed_post_meta as $key => $caption ) { ?>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta' ) ); ?>-<?php echo esc_attr( $key ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr( $key ); ?>" <?php checked( in_array( $key, (array) $params['post_meta'], true ) ? true : false ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta' ) ); ?>-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $caption ); ?></label></p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Compact post meta -->
|
||||
<h4><?php esc_html_e( 'Compact post meta:', 'absolute-reviews' ); ?></h4>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta_compact' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta_compact' ) ); ?>" type="checkbox" <?php checked( (bool) $params['post_meta_compact'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta_compact' ) ); ?>"><?php esc_html_e( 'Display compact post meta', 'absolute-reviews' ); ?></label></p>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="abr-large-post">
|
||||
<legend><?php esc_html_e( 'Large Post', 'absolute-reviews' ); ?></legend>
|
||||
|
||||
<!-- Image size -->
|
||||
<h4><?php esc_html_e( 'Image size:', 'absolute-reviews' ); ?></h4>
|
||||
|
||||
<?php if ( $image_sizes ) { ?>
|
||||
<p><select name="<?php echo esc_attr( $this->get_field_name( 'thumbnail_large' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'thumbnail_large' ) ); ?>-<?php echo esc_attr( $key ); ?>">
|
||||
<?php foreach ( $image_sizes as $key => $caption ) { ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $params['thumbnail_large'] ); ?>><?php echo esc_html( $caption ); ?></option>
|
||||
<?php } ?>
|
||||
</select></p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Post meta -->
|
||||
<h4><?php esc_html_e( 'Post meta:', 'absolute-reviews' ); ?></h4>
|
||||
|
||||
<?php foreach ( $allowed_post_meta as $key => $caption ) { ?>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta_large' ) ); ?>-<?php echo esc_attr( $key ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta_large' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr( $key ); ?>" <?php checked( in_array( $key, (array) $params['post_meta_large'], true ) ? true : false ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta_large' ) ); ?>-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $caption ); ?></label></p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Compact post meta -->
|
||||
<h4><?php esc_html_e( 'Compact post meta:', 'absolute-reviews' ); ?></h4>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta_large_compact' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta_large_compact' ) ); ?>" type="checkbox" <?php checked( (bool) $params['post_meta_large_compact'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta_large_compact' ) ); ?>"><?php esc_html_e( 'Display compact post meta', 'absolute-reviews' ); ?></label></p>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="abr-small-post">
|
||||
<legend><?php esc_html_e( 'Small Post', 'absolute-reviews' ); ?></legend>
|
||||
|
||||
<!-- Image size -->
|
||||
<h4><?php esc_html_e( 'Image size:', 'absolute-reviews' ); ?></h4>
|
||||
|
||||
<?php if ( $image_sizes ) { ?>
|
||||
<p><select name="<?php echo esc_attr( $this->get_field_name( 'thumbnail_small' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'thumbnail_small' ) ); ?>-<?php echo esc_attr( $key ); ?>">
|
||||
<?php foreach ( $image_sizes as $key => $caption ) { ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $params['thumbnail_small'] ); ?>><?php echo esc_html( $caption ); ?></option>
|
||||
<?php } ?>
|
||||
</select></p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Post meta -->
|
||||
<h4><?php esc_html_e( 'Post meta:', 'absolute-reviews' ); ?></h4>
|
||||
|
||||
<?php foreach ( $allowed_post_meta as $key => $caption ) { ?>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta_small' ) ); ?>-<?php echo esc_attr( $key ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta_small' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr( $key ); ?>" <?php checked( in_array( $key, (array) $params['post_meta_small'], true ) ? true : false ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta_small' ) ); ?>-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $caption ); ?></label></p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Compact Post Meta -->
|
||||
<h4><?php esc_html_e( 'Compact post meta:', 'absolute-reviews' ); ?></h4>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta_small_compact' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta_small_compact' ) ); ?>" type="checkbox" <?php checked( (bool) $params['post_meta_small_compact'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta_small_compact' ) ); ?>"><?php esc_html_e( 'Display compact post meta', 'absolute-reviews' ); ?></label></p>
|
||||
</fieldset>
|
||||
|
||||
<!-- Avoid duplicate posts -->
|
||||
<h4><?php esc_html_e( 'Avoid duplicate posts:', 'absolute-reviews' ); ?></h4>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'avoid_duplicate' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'avoid_duplicate' ) ); ?>" type="checkbox" <?php checked( (bool) $params['avoid_duplicate'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'avoid_duplicate' ) ); ?>"><?php esc_html_e( 'Exclude duplicate posts', 'absolute-reviews' ); ?></label></p>
|
||||
|
||||
<?php do_action( 'abr_reviews_posts_widget_form_after', $this, $params, $instance ); ?>
|
||||
|
||||
<script>
|
||||
(function($) {
|
||||
let objTemplate = $( '#<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>' );
|
||||
|
||||
$( objTemplate ).on( 'change', function() {
|
||||
$( this ).closest( '.widget' ).attr( 'template', $( this ).val() );
|
||||
});
|
||||
|
||||
$( objTemplate ).change();
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create HTML dropdown list of Categories.
|
||||
*/
|
||||
class ABR_Add_Posts_Categories_Tree_Walker extends Walker_CategoryDropdown {
|
||||
|
||||
/**
|
||||
* Starts the element output.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access public
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $category Category data object.
|
||||
* @param int $depth Depth of category. Used for padding.
|
||||
* @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist.
|
||||
* See wp_dropdown_categories().
|
||||
* @param int $id Optional. ID of the current category. Default 0 (unused).
|
||||
*/
|
||||
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
$pad = $depth > 0 ? '- ' . str_repeat( ' ', $depth * 3 ) : '';
|
||||
$selected = array_map( 'intval', $args['selected'] );
|
||||
$cat_name = apply_filters( 'list_cats', $category->name, $category );
|
||||
|
||||
$output .= sprintf(
|
||||
'<option class="level-%1$s" value="%2$s" %4$s>%3$s</option>',
|
||||
esc_attr( $depth ),
|
||||
esc_attr( $category->term_id ),
|
||||
esc_html( $pad . $cat_name ),
|
||||
selected( in_array( $category->term_id, $selected, true ), true )
|
||||
);
|
||||
$output .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function abr_reviews_posts_init() {
|
||||
register_widget( 'ABR_Reviews_Posts_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'abr_reviews_posts_init' );
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the plugin.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the plugin.
|
||||
*
|
||||
* Defines the plugin name, version, and two examples hooks for how to
|
||||
* enqueue the public-facing stylesheet and JavaScript.
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/public
|
||||
*/
|
||||
class ABR_Public {
|
||||
|
||||
/**
|
||||
* The ID of this plugin.
|
||||
|
||||
* @access private
|
||||
* @var string $abr The ID of this plugin.
|
||||
*/
|
||||
private $abr;
|
||||
|
||||
/**
|
||||
* The version of this plugin.
|
||||
|
||||
* @access private
|
||||
* @var string $version The current version of this plugin.
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Initialize the class and set its properties.
|
||||
*
|
||||
* @param string $abr The name of the plugin.
|
||||
* @param string $version The version of this plugin.
|
||||
*/
|
||||
public function __construct( $abr, $version ) {
|
||||
|
||||
$this->abr = $abr;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter output review in post content.
|
||||
*
|
||||
* @param string $content The content of post.
|
||||
*/
|
||||
public function the_content( $content ) {
|
||||
|
||||
// Check enabled.
|
||||
if ( ! apply_filters( 'abr_review_content_enabled', true ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Check AMP endpoint.
|
||||
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if ( is_singular() && ( is_single( get_the_ID() ) || is_page( get_the_ID() ) ) ) {
|
||||
ob_start();
|
||||
abr_the_review();
|
||||
$review = ob_get_clean();
|
||||
|
||||
// Concatenation.
|
||||
$content = $content . $review;
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Posts Templates
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $templates List of Templates.
|
||||
*/
|
||||
public function posts_templates( $templates = array() ) {
|
||||
$templates = array(
|
||||
'reviews-1' => array(
|
||||
'name' => esc_html__( 'Reviews 1', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
'reviews-2' => array(
|
||||
'name' => esc_html__( 'Reviews 2', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
'reviews-3' => array(
|
||||
'name' => esc_html__( 'Reviews 3', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
'reviews-4' => array(
|
||||
'name' => esc_html__( 'Reviews 4', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
'reviews-5' => array(
|
||||
'name' => esc_html__( 'Reviews 5', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
'reviews-6' => array(
|
||||
'name' => esc_html__( 'Reviews 6', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
'reviews-7' => array(
|
||||
'name' => esc_html__( 'Reviews 7', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
'reviews-8' => array(
|
||||
'name' => esc_html__( 'Reviews 8', 'absolute-reviews' ),
|
||||
'func' => 'abr_reviews_posts_template',
|
||||
),
|
||||
);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the wp_head action.
|
||||
*/
|
||||
public function wp_head() {
|
||||
?>
|
||||
<link rel="preload" href="<?php echo esc_url( ABR_URL . 'fonts/absolute-reviews-icons.woff' ); ?>" as="font" type="font/woff" crossorigin>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
|
||||
// Styles.
|
||||
wp_enqueue_style( $this->abr, abr_style( plugin_dir_url( __FILE__ ) . 'css/absolute-reviews-public.css' ), array(), $this->version, 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( $this->abr, 'rtl', 'replace' );
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Posts Block
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/public
|
||||
*/
|
||||
|
||||
// when layout is not selected, used list.php
|
||||
// but we don't need to print any html in this situation.
|
||||
if ( ! isset( $attributes['layout'] ) || ! $attributes['layout'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes['output'] = 'block';
|
||||
$attributes['template'] = $attributes['layout'];
|
||||
|
||||
// Set classes.
|
||||
$class_wrap = $attributes['canvasClassName'];
|
||||
|
||||
// Class Template.
|
||||
$class_block = sprintf( 'abr-posts-template-%s', $attributes['layout'] );
|
||||
|
||||
// Class Number of Posts.
|
||||
$class_block .= sprintf( ' abr-posts-per-page-%s', (int) $options['reviewsPostsCount'] );
|
||||
|
||||
if ( $posts->have_posts() ) {
|
||||
?>
|
||||
<div class="abr-block-reviews-posts <?php echo esc_attr( $class_wrap ); ?>">
|
||||
<div class="abr-reviews-posts <?php echo esc_attr( $class_block ); ?>">
|
||||
<div class="abr-reviews-posts-list">
|
||||
<?php
|
||||
$attributes['counter'] = 0;
|
||||
|
||||
// Check if there're enough posts in the query.
|
||||
while ( $posts->have_posts() ) {
|
||||
$posts->the_post();
|
||||
|
||||
$attributes['counter']++;
|
||||
|
||||
$attributes['post_meta_list'] = abr_block_convert_post_meta( $options, 'reviews' );
|
||||
$attributes['post_meta_compact'] = isset( $options['reviewsMetaCompact'] ) ? $options['reviewsMetaCompact'] : false;
|
||||
$attributes['thumbnail'] = isset( $options['imageSize'] ) ? $options['imageSize'] : 'large';
|
||||
|
||||
if ( in_array( $attributes['layout'], array( 'reviews-3', 'reviews-4', 'reviews-5' ), true ) ) {
|
||||
if ( 1 === $attributes['counter'] ) {
|
||||
$attributes['post_meta_list'] = abr_block_convert_post_meta( $options, 'reviewsLarge' );
|
||||
$attributes['post_meta_compact'] = isset( $options['reviewsLargeMetaCompact'] ) ? $options['reviewsLargeMetaCompact'] : false;
|
||||
$attributes['thumbnail'] = isset( $options['largeImageSize'] ) ? $options['largeImageSize'] : 'large';
|
||||
} else {
|
||||
$attributes['post_meta_list'] = abr_block_convert_post_meta( $options, 'reviewsSmall' );
|
||||
$attributes['post_meta_compact'] = isset( $options['reviewsSmallMetaCompact'] ) ? $options['reviewsSmallMetaCompact'] : false;
|
||||
$attributes['thumbnail'] = isset( $options['smallImageSize'] ) ? $options['smallImageSize'] : 'large';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="abr-post-item">
|
||||
<?php abr_reviews_posts_template( $posts, $attributes, null ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
cnvs_alert_warning( esc_html__( 'There aren\'t enough posts that match the filter criteria.', 'authentic' ) );
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* Posts Template
|
||||
*
|
||||
* @package ABR
|
||||
* @subpackage ABR/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Template
|
||||
*
|
||||
* @param array $posts Array of posts.
|
||||
* @param array $params Array of params.
|
||||
* @param array $instance Instance.
|
||||
*/
|
||||
function abr_reviews_posts_template( $posts, $params, $instance ) {
|
||||
|
||||
$review_id = get_the_ID();
|
||||
|
||||
$value = abr_get_review( false, $review_id );
|
||||
|
||||
// Get indicators.
|
||||
$indicators = abr_list_indicators();
|
||||
|
||||
// Get type.
|
||||
$type = abr_review_get_type( $review_id, 'none' );
|
||||
|
||||
// Set value index.
|
||||
$val_index = abr_review_get_val_index( $type, $value );
|
||||
|
||||
// Set mode.
|
||||
$mode = 'simple';
|
||||
|
||||
// Set variation.
|
||||
$variation = 'default';
|
||||
|
||||
if ( 'reviews-2' === $params['template'] || 'reviews-4' === $params['template'] ) {
|
||||
$mode = 'extended';
|
||||
}
|
||||
|
||||
// Badges.
|
||||
$badge_block = sprintf( 'abr-badge abr-badge-primary abr-review-badge-%s', $val_index );
|
||||
$badge_text = sprintf( 'abr-badge-text abr-badge-text-primary abr-review-badge-text-%s', $val_index );
|
||||
|
||||
// Set variation by template.
|
||||
if ( in_array( $params['template'], array( 'reviews-6', 'reviews-7', 'reviews-8' ), true ) ) {
|
||||
$variation = 'overlay';
|
||||
}
|
||||
|
||||
// Post Meta.
|
||||
if ( 'widget' === $params['output'] ) {
|
||||
$params['post_meta_list'] = $params['post_meta'];
|
||||
$params['post_meta_compact'] = $params['post_meta_compact'];
|
||||
$params['thumbnail'] = $params['thumbnail'];
|
||||
|
||||
if ( in_array( $params['template'], array( 'reviews-3', 'reviews-4', 'reviews-5' ), true ) ) {
|
||||
if ( 1 === $params['counter'] ) {
|
||||
$params['post_meta_list'] = $params['post_meta_large'];
|
||||
$params['post_meta_compact'] = $params['post_meta_large_compact'];
|
||||
$params['thumbnail'] = $params['thumbnail_large'];
|
||||
} else {
|
||||
$params['post_meta_list'] = $params['post_meta_small'];
|
||||
$params['post_meta_compact'] = $params['post_meta_small_compact'];
|
||||
$params['thumbnail'] = $params['thumbnail_small'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Class Type.
|
||||
$class = sprintf( 'abr-type-%s', $type );
|
||||
|
||||
// Class Variation.
|
||||
$class .= sprintf( ' abr-variation-%s', $variation );
|
||||
|
||||
// Classes.
|
||||
$class_caption = $badge_block;
|
||||
$class_number = null;
|
||||
|
||||
if ( 'reviews-1' === $params['template'] || 'reviews-3' === $params['template'] ) {
|
||||
$class_caption = $badge_text;
|
||||
$class_number = $badge_block;
|
||||
}
|
||||
|
||||
if ( 'percentage' === $type ) {
|
||||
$class_caption = $badge_block;
|
||||
$class_number = null;
|
||||
}
|
||||
|
||||
$meta_settings = array(
|
||||
'abr-params' => $params,
|
||||
);
|
||||
?>
|
||||
<article <?php post_class( $class ); ?>>
|
||||
<div class="abr-post-outer">
|
||||
|
||||
<?php if ( has_post_thumbnail() ) { ?>
|
||||
<div class="abr-post-inner abr-post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" class="post-thumbnail">
|
||||
<?php the_post_thumbnail( $params['thumbnail'] ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="abr-post-inner abr-post-data">
|
||||
|
||||
<?php if ( 'overlay' === $variation ) { ?>
|
||||
<a class="abr-post-link" href="<?php the_permalink(); ?>"></a>
|
||||
<?php } ?>
|
||||
|
||||
<div class="abr-post-headline">
|
||||
<?php
|
||||
abr_get_post_meta( 'category', (bool) $params['post_meta_compact'], true, $params['post_meta_list'], $meta_settings );
|
||||
?>
|
||||
|
||||
<?php
|
||||
$tag = apply_filters( 'abr_reviews_posts_title_tag', 'h5', $params, $instance );
|
||||
?>
|
||||
|
||||
<<?php echo esc_html( $tag ); ?> class="entry-title">
|
||||
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||
</<?php echo esc_html( $tag ); ?>>
|
||||
|
||||
<?php
|
||||
abr_get_post_meta( abr_allowed_post_meta( true, 'category' ), (bool) $params['post_meta_compact'], true, $params['post_meta_list'], $meta_settings );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if ( $value ) { ?>
|
||||
<?php if ( 'simple' === $mode ) { ?>
|
||||
<div class="abr-review-meta">
|
||||
<div class="abr-review-number <?php echo esc_attr( $class_number ); ?>">
|
||||
<?php
|
||||
echo abr_get_review( true, $review_id ); // XSS.
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if ( $indicators && $indicators[ $val_index ]['name'] ) { ?>
|
||||
<div class="abr-review-caption <?php echo esc_attr( $class_caption ); ?>">
|
||||
<?php echo esc_html( $indicators[ $val_index ]['name'] ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="abr-review-meta">
|
||||
<div class="abr-review-indicator abr-review-<?php echo esc_attr( $type ); ?>">
|
||||
<?php if ( 'star' === $type ) : ?>
|
||||
<div class="abr-review-stars">
|
||||
<?php
|
||||
abr_review_star_rating(
|
||||
array(
|
||||
'rating' => $value,
|
||||
'type' => 'rating',
|
||||
'number' => 0,
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php elseif ( 'point-5' === $type || 'point-10' === $type ) : ?>
|
||||
<div class="abr-review-line">
|
||||
<?php
|
||||
$max_slice = 'point-5' === $type ? 5 : 10;
|
||||
|
||||
for ( $index = 1; $index <= $max_slice; $index++ ) {
|
||||
if ( $index <= $value ) {
|
||||
$class = 'abr-review-slice-active';
|
||||
} else {
|
||||
$class = 'abr-review-slice-no-active';
|
||||
}
|
||||
?>
|
||||
<span class="abr-review-slice <?php echo esc_attr( $class ); ?>"></span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php elseif ( 'percentage' === $type ) : ?>
|
||||
<div class="abr-review-progress">
|
||||
<div class="abr-review-progressbar abr-review-progressbar-<?php echo esc_attr( $val_index ); ?>" style="width:<?php echo esc_attr( $value > 90 ? $value : 100 ); ?>%"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="abr-review-number <?php echo esc_attr( $class_number ); ?>">
|
||||
<?php
|
||||
echo abr_get_review( true, $review_id ); // XSS.
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Fired when the plugin is uninstalled.
|
||||
*
|
||||
* When populating this file, consider the following flow
|
||||
* of control:
|
||||
*
|
||||
* - This method should be static
|
||||
* - Check if the $_REQUEST content actually is the plugin name
|
||||
* - Run an admin referrer check to make sure it goes through authentication
|
||||
* - Verify the output of $_GET makes sense
|
||||
* - Repeat with other user roles. Best directly by using the links/query string parameters.
|
||||
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
|
||||
*
|
||||
* This file may be updated more in future version of the Boilerplate; however, this is the
|
||||
* general skeleton and outline for how the file should work.
|
||||
*
|
||||
* For more information, see the following discussion:
|
||||
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ABR
|
||||
*/
|
||||
|
||||
// If uninstall not called from WordPress, then exit.
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user