WP init
This commit is contained in:
+66
@@ -0,0 +1,66 @@
|
||||
jQuery(window).on("elementor:init", (function() {
|
||||
"use strict";
|
||||
|
||||
var wprAjaxSelect2 = elementor.modules.controls.BaseData.extend({
|
||||
onReady: function() {
|
||||
var $this = this,
|
||||
$select = $this.ui.select,
|
||||
restUrl = $select.attr("data-rest-url"),
|
||||
nonce = window.wpApiSettings.nonce;
|
||||
|
||||
var querySlug = '' !== $select.attr('data-query-slug') ? $select.attr('data-query-slug') : '';
|
||||
|
||||
$select.select2({
|
||||
ajax: {
|
||||
url: restUrl,
|
||||
dataType: "json",
|
||||
headers: {
|
||||
"X-WP-Nonce": nonce
|
||||
},
|
||||
data: function(response) {
|
||||
return {
|
||||
s: response.term,
|
||||
query_slug: querySlug
|
||||
}
|
||||
}
|
||||
},
|
||||
cache: !0
|
||||
});
|
||||
|
||||
var controlValue = void 0 !== $this.getControlValue() ? $this.getControlValue() : "";
|
||||
|
||||
controlValue.isArray && (controlValue = $this.getControlValue().join()), jQuery.ajax({
|
||||
url: restUrl,
|
||||
dataType: "json",
|
||||
headers: {
|
||||
"X-WP-Nonce": nonce
|
||||
},
|
||||
data: {
|
||||
ids: String(controlValue),
|
||||
query_slug: querySlug
|
||||
}
|
||||
}).then((function(response) {
|
||||
if ( '' !== controlValue ) {
|
||||
null !== response && response.results.length > 0 && (jQuery.each(response.results, (function(index, element) {
|
||||
var option = new Option(element.text, element.id, !0, !0);
|
||||
$select.append(option);
|
||||
$select.append(option).trigger('change.select2');
|
||||
$select.val(controlValue).trigger('change.select2');
|
||||
|
||||
})), $select.trigger({
|
||||
type: "select2:select",
|
||||
params: {
|
||||
data: response
|
||||
}
|
||||
}))
|
||||
}
|
||||
}))
|
||||
},
|
||||
|
||||
onBeforeDestroy: function() {
|
||||
this.ui.select.data("select2") && this.ui.select.select2("destroy"), this.el.remove()
|
||||
}
|
||||
});
|
||||
|
||||
elementor.addControlView("wpr-ajax-select2", wprAjaxSelect2)
|
||||
}));
|
||||
+426
@@ -0,0 +1,426 @@
|
||||
<?php
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
class Wpr_Control_Ajax_Select2_Api {
|
||||
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function init() {
|
||||
add_action( 'rest_api_init', function() {
|
||||
register_rest_route(
|
||||
'wpraddons/v1/ajaxselect2',
|
||||
'/(?P<action>\w+)/',
|
||||
[
|
||||
'methods' => 'GET',
|
||||
'callback' => [$this, 'callback'],
|
||||
'permission_callback' => '__return_true'
|
||||
]
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
public function callback( $request ) {
|
||||
return $this->{$request['action']}( $request );
|
||||
}
|
||||
|
||||
public function get_elementor_templates( $request ) {
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = [
|
||||
'post_type' => 'elementor_library',
|
||||
'post_status' => 'publish',
|
||||
'meta_key' => '_elementor_template_type',
|
||||
'meta_value' => ['page', 'section', 'container'],
|
||||
'numberposts' => 15
|
||||
];
|
||||
|
||||
if ( isset( $request['s'] ) ) {
|
||||
$args['s'] = $request['s'];
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$query = new \WP_Query( $args );
|
||||
|
||||
if ( $query->have_posts() ) {
|
||||
while ( $query->have_posts() ) {
|
||||
$query->the_post();
|
||||
$options[] = [
|
||||
'id' => get_the_ID(),
|
||||
'text' => html_entity_decode(get_the_title()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return [ 'results' => $options ];
|
||||
}
|
||||
|
||||
public function get_posts_by_post_type( $request ) {
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_type = isset($request['query_slug']) ? $request['query_slug'] : '';
|
||||
|
||||
$args = [
|
||||
'post_type' => $post_type,
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 15,
|
||||
];
|
||||
|
||||
if ( isset( $request['ids'] ) ) {
|
||||
$ids = explode( ',', $request['ids'] );
|
||||
$args['post__in'] = $ids;
|
||||
}
|
||||
|
||||
if ( isset( $request['s'] ) ) {
|
||||
$args['s'] = $request['s'];
|
||||
}
|
||||
|
||||
if ( 'attachment' === $post_type ) {
|
||||
$args['post_status'] = 'any';
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$query = new \WP_Query( $args );
|
||||
|
||||
if ( $query->have_posts() ) {
|
||||
while ( $query->have_posts() ) {
|
||||
$query->the_post();
|
||||
$options[] = [
|
||||
'id' => get_the_ID(),
|
||||
'text' => html_entity_decode(get_the_title()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return [ 'results' => $options ];
|
||||
}
|
||||
|
||||
public function get_taxonomies( $request ) {
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = [
|
||||
'orderby' => 'name',
|
||||
'order' => 'DESC',
|
||||
'hide_empty' => true,
|
||||
'number' => 10,
|
||||
];
|
||||
|
||||
$tax = isset($request['query_slug']) ? $request['query_slug'] : '';
|
||||
|
||||
if ( isset( $request['ids'] ) ) {
|
||||
$request['ids'] = ('' !== $request['ids']) ? $request['ids'] : '99999999'; // Query Hack
|
||||
$ids = explode( ',', $request['ids'] );
|
||||
$args['include'] = $ids;
|
||||
}
|
||||
|
||||
if ( isset( $request['s'] ) ) {
|
||||
$args['name__like'] = $request['s'];
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$terms = get_terms( $tax, $args );
|
||||
|
||||
if ( ! empty($terms) ) {
|
||||
foreach ( $terms as $term ) {
|
||||
$options[] = [
|
||||
'id' => $term->term_id,
|
||||
'text' => $term->name,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return [ 'results' => $options ];
|
||||
}
|
||||
|
||||
public function get_users( $request ) {
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = [
|
||||
'number' => '15',
|
||||
'blog_id' => 0
|
||||
];
|
||||
|
||||
if ( isset( $request['ids'] ) ) {
|
||||
$ids = array_map('intval', explode(',', $request['ids'] ));
|
||||
$args['include'] = $ids;
|
||||
}
|
||||
|
||||
if ( isset( $request['s'] ) ) {
|
||||
$args['search'] = '*'. $request['s'] .'*';
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$user_query = new \WP_User_Query( $args );
|
||||
|
||||
if ( ! empty( $user_query->get_results() ) ) {
|
||||
foreach ( $user_query->get_results() as $user ) {
|
||||
$options[] = [
|
||||
'id' => $user->ID,
|
||||
'text' => $user->display_name,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return [ 'results' => $options ];
|
||||
}
|
||||
|
||||
public function get_post_type_taxonomies( $request ) {
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_type = isset($request['query_slug']) ? $request['query_slug'] : '';
|
||||
|
||||
$args = [
|
||||
'orderby' => 'name',
|
||||
'order' => 'DESC',
|
||||
'hide_empty' => true,
|
||||
'number' => -1,
|
||||
];
|
||||
|
||||
if ( isset( $request['ids'] ) ) {
|
||||
$request['ids'] = ('' !== $request['ids']) ? $request['ids'] : '99999999'; // Query Hack
|
||||
$ids = explode( ',', $request['ids'] );
|
||||
$args['include'] = $ids;
|
||||
}
|
||||
|
||||
if ( isset( $request['s'] ) ) {
|
||||
$args['name__like'] = $request['s'];
|
||||
}
|
||||
|
||||
$options = [];
|
||||
$taxonomies = get_object_taxonomies( $post_type, 'objects' );
|
||||
|
||||
if ( ! empty($taxonomies) ) {
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$options[] = [
|
||||
'id' => $taxonomy->name,
|
||||
'text' => $taxonomy->label,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return [ 'results' => $options ];
|
||||
}
|
||||
|
||||
/**
|
||||
** Get Custom Meta Keys
|
||||
*/
|
||||
public function get_custom_meta_keys( $request ) {
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$options = [];
|
||||
$merged_meta_keys = [];
|
||||
$post_types = Utilities::get_custom_types_of( 'post', false );
|
||||
|
||||
foreach ( $post_types as $post_type_slug => $post_type_name ) {
|
||||
$data[ $post_type_slug ] = [];
|
||||
$posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] );
|
||||
|
||||
foreach ( $posts as $key => $post ) {
|
||||
$meta_keys = get_post_custom_keys( $post->ID );
|
||||
|
||||
if ( ! empty($meta_keys) ) {
|
||||
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
|
||||
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
|
||||
array_push( $data[$post_type_slug], $meta_keys[$i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] );
|
||||
}
|
||||
|
||||
foreach ( $data as $array ) {
|
||||
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
|
||||
}
|
||||
|
||||
// Rekey
|
||||
$merged_meta_keys = array_values($merged_meta_keys);
|
||||
|
||||
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
|
||||
// Add a search condition here
|
||||
if ( ! isset( $request['s'] ) || strpos( $merged_meta_keys[$i], $request['s'] ) !== false ) {
|
||||
$options[] = [
|
||||
'id' => $merged_meta_keys[$i],
|
||||
'text' => $merged_meta_keys[$i],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [ 'results' => $options ];
|
||||
}
|
||||
|
||||
/**
|
||||
** Get Custom Meta Keys Product
|
||||
*/
|
||||
public function get_custom_meta_keys_product( $request ) {
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$options = [];
|
||||
$merged_meta_keys = [];
|
||||
$post_types = Utilities::get_custom_types_of( 'post', false );
|
||||
|
||||
foreach ( $post_types as $post_type_slug => $post_type_name ) {
|
||||
$data[ $post_type_slug ] = [];
|
||||
$posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] );
|
||||
|
||||
foreach ( $posts as $key => $post ) {
|
||||
$meta_keys = get_post_custom_keys( $post->ID );
|
||||
|
||||
if ( ! empty($meta_keys) ) {
|
||||
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
|
||||
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
|
||||
array_push( $data[$post_type_slug], $meta_keys[$i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] );
|
||||
}
|
||||
|
||||
foreach ( $data as $array ) {
|
||||
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
|
||||
}
|
||||
|
||||
// Rekey
|
||||
$merged_meta_keys = array_values($merged_meta_keys);
|
||||
|
||||
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
|
||||
// Add a search condition here
|
||||
if ( ! isset( $request['s'] ) || strpos( $merged_meta_keys[$i], $request['s'] ) !== false ) {
|
||||
$options[] = [
|
||||
'id' => $merged_meta_keys[$i],
|
||||
'text' => $merged_meta_keys[$i],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Get a list of all product attributes used by products
|
||||
$product_attributes = array();
|
||||
|
||||
// Query for all products of the "product" post type
|
||||
$args = array(
|
||||
'post_type' => 'product', // Change to the correct post type if needed
|
||||
'posts_per_page' => -1, // Retrieve all products
|
||||
);
|
||||
|
||||
$products_query = new \WP_Query($args);
|
||||
|
||||
if ($products_query->have_posts()) {
|
||||
while ($products_query->have_posts()) {
|
||||
$products_query->the_post();
|
||||
|
||||
// Get the product object
|
||||
$product = wc_get_product(get_the_ID());
|
||||
|
||||
// Get product attributes
|
||||
$attributes = $product->get_attributes();
|
||||
|
||||
// Loop through attributes and add them to the master list
|
||||
foreach ($attributes as $attribute) {
|
||||
$product_attributes[$attribute->get_name()] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset post data
|
||||
wp_reset_postdata();
|
||||
|
||||
// Extract attribute names from the master list
|
||||
$attribute_names = array_keys($product_attributes);
|
||||
|
||||
// Initialize an empty array
|
||||
$attributes_array = [];
|
||||
|
||||
// Iterate through the original array and set both key and value to be the same
|
||||
foreach ($attribute_names as $value) {
|
||||
$attributes_array[] = [
|
||||
'id' => $value,
|
||||
'text' => $value,
|
||||
];
|
||||
}
|
||||
|
||||
$options = array_merge($options, $attributes_array);
|
||||
}
|
||||
|
||||
return [ 'results' => $options ];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** Get Custom Meta Keys Data
|
||||
*/
|
||||
public function get_custom_meta_keys_data() { // TODO
|
||||
if ( ! current_user_can( 'edit_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$options = [];
|
||||
$merged_meta_keys = [];
|
||||
$post_types = Utilities::get_custom_types_of( 'post', false );
|
||||
|
||||
foreach ( $post_types as $post_type_slug => $post_type_name ) {
|
||||
$data[ $post_type_slug ] = [];
|
||||
$posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] );
|
||||
|
||||
foreach ( $posts as $key => $post ) {
|
||||
$meta_keys = get_post_custom_keys( $post->ID );
|
||||
|
||||
if ( ! empty($meta_keys) ) {
|
||||
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
|
||||
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
|
||||
array_push( $data[$post_type_slug], $meta_keys[$i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] );
|
||||
}
|
||||
|
||||
foreach ( $data as $array ) {
|
||||
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
|
||||
}
|
||||
|
||||
// Rekey
|
||||
$merged_meta_keys = array_values($merged_meta_keys);
|
||||
|
||||
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
|
||||
$options[ $merged_meta_keys[$i] ] = $merged_meta_keys[$i];
|
||||
}
|
||||
|
||||
// return [ $data, $options ];
|
||||
return [ 'results' => $data ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new Wpr_Control_Ajax_Select2_Api();
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace WprAddons\Includes\Controls\WprAjaxSelect2;
|
||||
|
||||
use Elementor\Base_Data_Control;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
|
||||
class WPR_Control_Ajax_Select2 extends Base_Data_Control {
|
||||
public function get_type() {
|
||||
return 'wpr-ajax-select2';
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
wp_register_script( 'wpr-control-ajax-select2', WPR_ADDONS_URL . 'includes/controls/wpr-ajax-select2/js/wpr-control-ajax-select2.js' );
|
||||
wp_enqueue_script( 'wpr-control-ajax-select2' );
|
||||
}
|
||||
|
||||
protected function get_default_settings() {
|
||||
return [
|
||||
'options' => [],
|
||||
'multiple' => false,
|
||||
'select2options' => [],
|
||||
'query_slug' => '',
|
||||
];
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
$control_uid = $this->get_control_uid();
|
||||
?>
|
||||
<div class="elementor-control-field">
|
||||
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
|
||||
<div class="elementor-control-input-wrapper">
|
||||
<# var multiple = ( data.multiple ) ? 'multiple' : ''; #>
|
||||
<select id="<?php echo esc_attr($control_uid); ?>" class="elementor-control-type-wpr-ajaxselect2" {{ multiple }} data-query-slug="{{data.query_slug}}" data-setting="{{ data.name }}" data-rest-url="<?php echo esc_attr( get_rest_url(). 'wpraddons/v1' . '/{{data.options}}/' ); ?>">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
+310
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
namespace WprAddons\Includes\Controls;
|
||||
|
||||
use Elementor\Base_Data_Control;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Animation Control for Elements.
|
||||
*
|
||||
* A base control for creating entrance animation control. Displays a select box
|
||||
* with the available entrance animation effects @see WPR_Control_Animations::get_animations() .
|
||||
*/
|
||||
class WPR_Control_Animations extends Base_Data_Control {
|
||||
|
||||
/**
|
||||
* List of animations.
|
||||
*/
|
||||
private static $_animations;
|
||||
|
||||
/**
|
||||
* Get control type.
|
||||
*/
|
||||
public function get_type() {
|
||||
return 'wpr-animations';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get animations list.
|
||||
* Retrieve the list of all the available animations.
|
||||
*/
|
||||
public static function get_animations() {
|
||||
|
||||
if ( is_null( self::$_animations ) ) {
|
||||
self::$_animations = [
|
||||
'Fade' => [
|
||||
'fade-in' => 'Fade In',
|
||||
'fade-out' => 'Fade Out',
|
||||
],
|
||||
'Slide' => [
|
||||
'pro-sltp' => 'Top (Pro)',
|
||||
'pro-slrt' => 'Right (Pro)',
|
||||
'pro-slxrt' => 'X Right (Pro)',
|
||||
'pro-slbt' => 'Bottom (Pro)',
|
||||
'pro-sllt' => 'Left (Pro)',
|
||||
'pro-slxlt' => 'X Left (Pro)',
|
||||
],
|
||||
'Skew' => [
|
||||
'pro-sktp' => 'Top (Pro)',
|
||||
'pro-skrt' => 'Right (Pro)',
|
||||
'pro-skbt' => 'Bottom (Pro)',
|
||||
'pro-sklt' => 'Left (Pro)',
|
||||
],
|
||||
'Scale' => [
|
||||
'pro-scup' => 'Up (Pro)',
|
||||
'pro-scdn' => 'Down (Pro)',
|
||||
],
|
||||
'Roll' => [
|
||||
'pro-rllt' => 'Left (Pro)',
|
||||
'pro-rlrt' => 'Right (Pro)',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
self::$_animations = \WprAddonsPro\Includes\Controls\WPR_Control_Animations_Pro::wpr_animations();
|
||||
}
|
||||
|
||||
return self::$_animations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render animations control template.
|
||||
*
|
||||
* Used to generate the control HTML in the editor using Underscore JS
|
||||
* template. The variables for the class are available using `data` JS
|
||||
* object.
|
||||
*/
|
||||
public function content_template() {
|
||||
$control_uid = $this->get_control_uid();
|
||||
?>
|
||||
<div class="elementor-control-field">
|
||||
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
|
||||
<div class="elementor-control-input-wrapper">
|
||||
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
|
||||
<option value="none"><?php echo esc_html__( 'None', 'wpr-addons' ); ?></option>
|
||||
<?php foreach ( self::get_animations() as $animations_group_name => $animations_group ) : ?>
|
||||
<optgroup label="<?php echo esc_attr($animations_group_name); ?>">
|
||||
<?php foreach ( $animations_group as $animation_name => $animation_title ) : ?>
|
||||
<option value="<?php echo esc_attr($animation_name); ?>"><?php echo esc_html($animation_title); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Animation Control for Overlays.
|
||||
*
|
||||
* A base control for creating entrance animation control. Displays a select box
|
||||
* with the available entrance animation effects @see WPR_Control_Animations::get_animations() .
|
||||
*/
|
||||
class WPR_Control_Animations_Alt extends WPR_Control_Animations {
|
||||
|
||||
/**
|
||||
* Get control type.
|
||||
*/
|
||||
public function get_type() {
|
||||
return 'wpr-animations-alt';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render animations control template.
|
||||
*
|
||||
* Used to generate the control HTML in the editor using Underscore JS
|
||||
* template. The variables for the class are available using `data` JS
|
||||
* object.
|
||||
*/
|
||||
public function content_template() {
|
||||
$animations = self::get_animations();
|
||||
$control_uid = $this->get_control_uid();
|
||||
|
||||
// Remove Extra
|
||||
unset($animations['Slide']['slide-x-right']);
|
||||
unset($animations['Slide']['slide-x-left']);
|
||||
?>
|
||||
<div class="elementor-control-field">
|
||||
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
|
||||
<div class="elementor-control-input-wrapper">
|
||||
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
|
||||
<option value="none"><?php echo esc_html__( 'None', 'wpr-addons' ); ?></option>
|
||||
<?php foreach ( $animations as $animations_group_name => $animations_group ) : ?>
|
||||
<optgroup label="<?php echo esc_attr($animations_group_name); ?>">
|
||||
<?php foreach ( $animations_group as $animation_name => $animation_title ) : ?>
|
||||
<option value="<?php echo esc_attr($animation_name); ?>"><?php echo esc_html($animation_title); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Animation Control for Buttons.
|
||||
*
|
||||
* A base control for creating button animation control. Displays a select box
|
||||
* with the available button animation effects @see WPR_Control_Button_Animations::get_animations() .
|
||||
*/
|
||||
class WPR_Control_Button_Animations extends Base_Data_Control {
|
||||
|
||||
/**
|
||||
* List of animations.
|
||||
*/
|
||||
private static $_animations;
|
||||
|
||||
/**
|
||||
* Get control type.
|
||||
*/
|
||||
public function get_type() {
|
||||
return 'wpr-button-animations';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get animations list.
|
||||
* Retrieve the list of all the available animations.
|
||||
*/
|
||||
public static function get_animations() {
|
||||
if ( is_null( self::$_animations ) ) {
|
||||
self::$_animations = [
|
||||
'Animations' => [
|
||||
'wpr-button-none' => esc_html__( 'None', 'wpr-addons' ),
|
||||
'pro-wnt' => esc_html__( 'Winona + Text (Pro)', 'wpr-addons' ),
|
||||
'pro-rlt' => esc_html__( 'Ray Left + Text (Pro)', 'wpr-addons' ),
|
||||
'pro-rrt' => esc_html__( 'Ray Right + Text (Pro)', 'wpr-addons' ),
|
||||
'wpr-button-wayra-left' => esc_html__( 'Wayra Left', 'wpr-addons' ),
|
||||
'wpr-button-wayra-right' => esc_html__( 'Wayra Right', 'wpr-addons' ),
|
||||
'wpr-button-isi-left' => esc_html__( 'Isi Left', 'wpr-addons' ),
|
||||
'wpr-button-isi-right' => esc_html__( 'Isi Right', 'wpr-addons' ),
|
||||
'wpr-button-aylen' => esc_html__( 'Aylen', 'wpr-addons' ),
|
||||
'wpr-button-antiman' => esc_html__( 'Antiman', 'wpr-addons' ),
|
||||
],
|
||||
'2D Animations' => [
|
||||
'elementor-animation-grow' => esc_html__( 'Grow', 'wpr-addons' ),
|
||||
'elementor-animation-shrink' => esc_html__( 'Shrink', 'wpr-addons' ),
|
||||
'elementor-animation-pulse' => esc_html__( 'Pulse', 'wpr-addons' ),
|
||||
'elementor-animation-pulse-grow' => esc_html__( 'Pulse Grow', 'wpr-addons' ),
|
||||
'elementor-animation-pulse-shrink' => esc_html__( 'Pulse Shrink', 'wpr-addons' ),
|
||||
'elementor-animation-push' => esc_html__( 'Push', 'wpr-addons' ),
|
||||
'elementor-animation-pop' => esc_html__( 'Pop', 'wpr-addons' ),
|
||||
'elementor-animation-bounce-in' => esc_html__( 'Bounce In', 'wpr-addons' ),
|
||||
'elementor-animation-bounce-out' => esc_html__( 'Bounce Out', 'wpr-addons' ),
|
||||
'elementor-animation-rotate' => esc_html__( 'Rotate', 'wpr-addons' ),
|
||||
'elementor-animation-grow-rotate' => esc_html__( 'Grow Rotate', 'wpr-addons' ),
|
||||
'elementor-animation-float' => esc_html__( 'Float', 'wpr-addons' ),
|
||||
'elementor-animation-sink' => esc_html__( 'Sink', 'wpr-addons' ),
|
||||
'elementor-animation-bob' => esc_html__( 'Bob', 'wpr-addons' ),
|
||||
'elementor-animation-hang' => esc_html__( 'Hang', 'wpr-addons' ),
|
||||
'elementor-animation-skew' => esc_html__( 'Skew', 'wpr-addons' ),
|
||||
'elementor-animation-skew-forward' => esc_html__( 'Skew Forward', 'wpr-addons' ),
|
||||
'elementor-animation-skew-backward' => esc_html__( 'Skew Backward', 'wpr-addons' ),
|
||||
'elementor-animation-wobble-horizontal' => esc_html__( 'Wobble Horizontal', 'wpr-addons' ),
|
||||
'elementor-animation-wobble-vertical' => esc_html__( 'Wobble Vertical', 'wpr-addons' ),
|
||||
'elementor-animation-wobble-to-bottom-right' => esc_html__( 'Wobble To Bottom Right', 'wpr-addons' ),
|
||||
'elementor-animation-wobble-to-top-right' => esc_html__( 'Wobble To Top Right', 'wpr-addons' ),
|
||||
'elementor-animation-wobble-top' => esc_html__( 'Wobble Top', 'wpr-addons' ),
|
||||
'elementor-animation-wobble-bottom' => esc_html__( 'Wobble Bottom', 'wpr-addons' ),
|
||||
'elementor-animation-wobble-skew' => esc_html__( 'Wobble Skew', 'wpr-addons' ),
|
||||
'elementor-animation-buzz' => esc_html__( 'Buzz', 'wpr-addons' ),
|
||||
'elementor-animation-buzz-out' => esc_html__( 'Buzz Out', 'wpr-addons' ),
|
||||
'elementor-animation-forward' => esc_html__( 'Forward', 'wpr-addons' ),
|
||||
'elementor-animation-backward' => esc_html__( 'Backward', 'wpr-addons' ),
|
||||
],
|
||||
'Background Animations' => [
|
||||
'wpr-button-back-pulse' => esc_html__( 'Back Pulse', 'wpr-addons' ),
|
||||
'wpr-button-sweep-to-right' => esc_html__( 'Sweep To Right', 'wpr-addons' ),
|
||||
'wpr-button-sweep-to-left' => esc_html__( 'Sweep To Left', 'wpr-addons' ),
|
||||
'wpr-button-sweep-to-bottom' => esc_html__( 'Sweep To Bottom', 'wpr-addons' ),
|
||||
'wpr-button-sweep-to-top' => esc_html__( 'Sweep To top', 'wpr-addons' ),
|
||||
'wpr-button-bounce-to-right' => esc_html__( 'Bounce To Right', 'wpr-addons' ),
|
||||
'wpr-button-bounce-to-left' => esc_html__( 'Bounce To Left', 'wpr-addons' ),
|
||||
'wpr-button-bounce-to-bottom' => esc_html__( 'Bounce To Bottom', 'wpr-addons' ),
|
||||
'wpr-button-bounce-to-top' => esc_html__( 'Bounce To Top', 'wpr-addons' ),
|
||||
'wpr-button-radial-out' => esc_html__( 'Radial Out', 'wpr-addons' ),
|
||||
'wpr-button-radial-in' => esc_html__( 'Radial In', 'wpr-addons' ),
|
||||
'wpr-button-rectangle-in' => esc_html__( 'Rectangle In', 'wpr-addons' ),
|
||||
'wpr-button-rectangle-out' => esc_html__( 'Rectangle Out', 'wpr-addons' ),
|
||||
'wpr-button-shutter-in-horizontal' => esc_html__( 'Shutter In Horizontal', 'wpr-addons' ),
|
||||
'wpr-button-shutter-out-horizontal' => esc_html__( 'Shutter Out Horizontal', 'wpr-addons' ),
|
||||
'wpr-button-shutter-in-vertical' => esc_html__( 'Shutter In Vertical', 'wpr-addons' ),
|
||||
'wpr-button-shutter-out-vertical' => esc_html__( 'Shutter Out Vertical', 'wpr-addons' ),
|
||||
'wpr-button-underline-from-left' => esc_html__( 'Underline From Left', 'wpr-addons' ),
|
||||
'wpr-button-underline-from-center' => esc_html__( 'Underline From Center', 'wpr-addons' ),
|
||||
'wpr-button-underline-from-right' => esc_html__( 'Underline From Right', 'wpr-addons' ),
|
||||
'wpr-button-underline-reveal' => esc_html__( 'Underline Reveal', 'wpr-addons' ),
|
||||
'wpr-button-overline-reveal' => esc_html__( 'Overline Reveal', 'wpr-addons' ),
|
||||
'wpr-button-overline-from-left' => esc_html__( 'Overline From Left', 'wpr-addons' ),
|
||||
'wpr-button-overline-from-center' => esc_html__( 'Overline From Center', 'wpr-addons' ),
|
||||
'wpr-button-overline-from-right' => esc_html__( 'Overline From Right', 'wpr-addons' ),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
self::$_animations = \WprAddonsPro\Includes\Controls\WPR_Control_Animations_Pro::wpr_button_animations();
|
||||
}
|
||||
|
||||
return self::$_animations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render animations control template.
|
||||
*
|
||||
* Used to generate the control HTML in the editor using Underscore JS
|
||||
* template. The variables for the class are available using `data` JS
|
||||
* object.
|
||||
*/
|
||||
public function content_template() {
|
||||
$control_uid = $this->get_control_uid();
|
||||
?>
|
||||
<div class="elementor-control-field">
|
||||
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
|
||||
<div class="elementor-control-input-wrapper">
|
||||
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
|
||||
<?php foreach ( self::get_animations() as $animations_group_name => $animations_group ) : ?>
|
||||
<optgroup label="<?php echo esc_attr($animations_group_name); ?>">
|
||||
<?php foreach ( $animations_group as $animation_name => $animation_title ) : ?>
|
||||
<option value="<?php echo esc_attr($animation_name); ?>"><?php echo esc_html($animation_title); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function get_assets( $setting ) {
|
||||
if ( ! $setting || 'none' === $setting || !str_contains($setting, 'elementor-animation') ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'styles' => [ 'e-animation-' . str_replace('elementor-animation-', '', $setting) ],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace WprAddons\Includes\Controls;
|
||||
|
||||
use Elementor\Base_Data_Control;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
|
||||
class WPR_Control_Arrow_Icons extends Base_Data_Control {
|
||||
private static $_arrow_icons;
|
||||
|
||||
public function get_type() {
|
||||
return 'wpr-arrow-icons';
|
||||
}
|
||||
|
||||
public static function get_arrow_icons() {
|
||||
if ( is_null( self::$_arrow_icons ) ) {
|
||||
self::$_arrow_icons = [
|
||||
'Font Awesome' => [
|
||||
'fas fa-angle' => esc_html__( 'Angle', 'wpr-addons' ),
|
||||
'fas fa-angle-double' => esc_html__( 'Angle Double', 'wpr-addons' ),
|
||||
'fas fa-arrow' => esc_html__( 'Arrow', 'wpr-addons' ),
|
||||
'fas fa-arrow-alt-circle' => esc_html__( 'Arrow Circle', 'wpr-addons' ),
|
||||
'far fa-arrow-alt-circle' => esc_html__( 'Arrow Circle Alt', 'wpr-addons' ),
|
||||
'fas fa-long-arrow-alt' => esc_html__( 'Long Arrow', 'wpr-addons' ),
|
||||
'fas fa-chevron' => esc_html__( 'Chevron', 'wpr-addons' ),
|
||||
],
|
||||
'Svg' => Utilities::get_svg_icons_array( 'arrows', [] ),
|
||||
];
|
||||
}
|
||||
|
||||
return self::$_arrow_icons;
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
$control_uid = $this->get_control_uid();
|
||||
?>
|
||||
<div class="elementor-control-field">
|
||||
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
|
||||
<div class="elementor-control-input-wrapper">
|
||||
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
|
||||
<option value="none"><?php echo esc_html__( 'None', 'wpr-addons' ); ?></option>
|
||||
<?php foreach ( self::get_arrow_icons() as $arrow_icons_group_name => $arrow_icons_group ) : ?>
|
||||
<optgroup label="<?php echo esc_attr($arrow_icons_group_name); ?>">
|
||||
<?php foreach ( $arrow_icons_group as $arrow_icon_name => $arrow_icon_title ) : ?>
|
||||
<option value="<?php echo esc_attr($arrow_icon_name); ?>"><?php echo esc_html($arrow_icon_title); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace WprAddons;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
final class Manager {
|
||||
|
||||
public function __construct() {
|
||||
$modules = Utilities::get_available_modules( Utilities::get_registered_modules() );
|
||||
|
||||
if ( empty(Utilities::get_available_modules( Utilities::get_registered_modules() )) && false === get_option('wpr-element-toggle-all') ) {
|
||||
$modules = Utilities::get_registered_modules();
|
||||
}
|
||||
|
||||
foreach ( $modules as $data ) {
|
||||
$module = $data[0];
|
||||
|
||||
$class_name = str_replace( '-', ' ', $module );
|
||||
$class_name = str_replace( ' ', '', ucwords( $class_name ) );
|
||||
$class_name = __NAMESPACE__ .'\\Modules\\'. $class_name .'\Module';
|
||||
|
||||
$class_name::instance();
|
||||
}
|
||||
|
||||
// Theme Builder Modules
|
||||
$theme_builder_modules = Utilities::get_available_modules( Utilities::get_theme_builder_modules() );
|
||||
|
||||
if ( empty(Utilities::get_available_modules( Utilities::get_theme_builder_modules() )) && false === get_option('wpr-element-toggle-all') ) {
|
||||
$theme_builder_modules = Utilities::get_theme_builder_modules();
|
||||
}
|
||||
|
||||
foreach ( $theme_builder_modules as $data ) {
|
||||
$module = $data[0];
|
||||
|
||||
$class_name = str_replace( '-', ' ', $module );
|
||||
$class_name = str_replace( ' ', '', ucwords( $class_name ) );
|
||||
$class_name = __NAMESPACE__ .'\\Modules\\ThemeBuilder\\'. $class_name .'\Module';
|
||||
|
||||
$class_name::instance();
|
||||
}
|
||||
|
||||
// Woocommerce Builder Modules
|
||||
if ( class_exists( 'woocommerce' ) ) {
|
||||
$woocommerce_builder_modules = Utilities::get_available_modules( Utilities::get_woocommerce_builder_modules() );
|
||||
|
||||
if ( empty(Utilities::get_available_modules( Utilities::get_woocommerce_builder_modules() )) && false === get_option('wpr-element-toggle-all') ) {
|
||||
$woocommerce_builder_modules = Utilities::get_woocommerce_builder_modules();
|
||||
}
|
||||
|
||||
|
||||
foreach ( $woocommerce_builder_modules as $data ) {
|
||||
$module = $data[0];
|
||||
|
||||
$class_name = str_replace( '-', ' ', $module );
|
||||
$class_name = str_replace( ' ', '', ucwords( $class_name ) );
|
||||
$class_name = __NAMESPACE__ . '\\Modules\\ThemeBuilder\\Woocommerce\\' . $class_name . '\Module';
|
||||
|
||||
$class_name::instance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* Cart Page
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce\Templates
|
||||
* @version 10.1.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
do_action( 'woocommerce_before_cart' ); ?>
|
||||
|
||||
|
||||
<form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
|
||||
<?php do_action( 'woocommerce_before_cart_table' ); ?>
|
||||
|
||||
<table class="wpr-shop-table shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="product-remove"> </th>
|
||||
<th class="product-thumbnail"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
|
||||
<th class="product-name"> </th>
|
||||
<th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
|
||||
<th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
|
||||
<th class="product-subtotal"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php do_action( 'woocommerce_before_cart_contents' ); ?>
|
||||
|
||||
<?php
|
||||
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
|
||||
|
||||
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
||||
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
|
||||
?>
|
||||
<tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
||||
|
||||
<td class="product-remove">
|
||||
<?php
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'woocommerce_cart_item_remove_link',
|
||||
sprintf(
|
||||
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">×</a>',
|
||||
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
|
||||
esc_html__( 'Remove this item', 'woocommerce' ),
|
||||
esc_attr( $product_id ),
|
||||
esc_attr( $_product->get_sku() )
|
||||
),
|
||||
$cart_item_key
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td class="product-thumbnail">
|
||||
<?php
|
||||
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
|
||||
|
||||
if ( ! $product_permalink ) {
|
||||
echo $thumbnail; // PHPCS: XSS ok.
|
||||
} else {
|
||||
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
if ( ! $product_permalink ) {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' ' );
|
||||
} else {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
|
||||
|
||||
// Meta data.
|
||||
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
|
||||
|
||||
// Backorder notification.
|
||||
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>', $product_id ) );
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
if ( $_product->is_sold_individually() ) {
|
||||
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
|
||||
} else {
|
||||
$product_quantity = woocommerce_quantity_input(
|
||||
array(
|
||||
'input_name' => "cart[{$cart_item_key}][qty]",
|
||||
'input_value' => $cart_item['quantity'],
|
||||
'max_value' => $_product->get_max_purchase_quantity(),
|
||||
'min_value' => '0',
|
||||
'product_name' => $_product->get_name(),
|
||||
),
|
||||
$_product,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>">
|
||||
<?php
|
||||
echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php do_action( 'woocommerce_cart_contents' ); ?>
|
||||
|
||||
<tr>
|
||||
<td colspan="6" class="actions">
|
||||
|
||||
<?php if ( wc_coupons_enabled() ) { ?>
|
||||
<div class="coupon">
|
||||
<label for="coupon_code"><?php esc_html_e( 'Coupon:', 'woocommerce' ); ?></label> <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'wpr-addons' ); ?>" /> <button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?></button>
|
||||
<?php do_action( 'woocommerce_cart_coupon' ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<button type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>"><?php esc_html_e( 'Update cart', 'woocommerce' ); ?></button>
|
||||
|
||||
<?php do_action( 'woocommerce_cart_actions' ); ?>
|
||||
|
||||
<?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php do_action( 'woocommerce_after_cart_contents' ); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php do_action( 'woocommerce_after_cart_table' ); ?>
|
||||
</form>
|
||||
|
||||
<?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
|
||||
|
||||
<div class="cart-collaterals">
|
||||
<?php
|
||||
/**
|
||||
* Cart collaterals hook.
|
||||
*
|
||||
* @hooked woocommerce_cross_sell_display
|
||||
* @hooked woocommerce_cart_totals - 10
|
||||
*/
|
||||
do_action( 'woocommerce_cart_collaterals' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_after_cart' ); ?>
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Mini-cart
|
||||
*
|
||||
* Contains the markup for the mini-cart, used by the cart widget.
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/cart/mini-cart.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce\Templates
|
||||
* @version 10.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
do_action( 'woocommerce_before_mini_cart' );
|
||||
?>
|
||||
|
||||
|
||||
<?php if ( ! WC()->cart->is_empty() ) : ?>
|
||||
|
||||
<ul class="wpr-woo-mini-cart woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">
|
||||
<?php
|
||||
do_action( 'woocommerce_before_mini_cart_contents' );
|
||||
|
||||
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
|
||||
|
||||
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
||||
$product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
|
||||
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
|
||||
$product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
|
||||
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
|
||||
?>
|
||||
<li class="woocommerce-mini-cart-item <?php echo esc_attr( apply_filters( 'woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key ) ); ?>">
|
||||
<?php if ( empty( $product_permalink ) ) : ?>
|
||||
<div class="wpr-mini-cart-image">
|
||||
<?php echo $thumbnail; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<div class="wpr-mini-cart-name-and-quantity">
|
||||
<div class="wpr-mini-cart-product-name">
|
||||
<?php echo'<span class="wpr-product-name">' . wp_kses_post( $product_name ) . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="wpr-mini-cart-image">
|
||||
<a href="<?php echo esc_url( $product_permalink ); ?>">
|
||||
<?php echo $thumbnail; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="wpr-mini-cart-name-and-quantity">
|
||||
<div class="wpr-mini-cart-product-name">
|
||||
<a href="<?php echo esc_url( $product_permalink ); ?>">
|
||||
<?php echo'<span class="wpr-mini-cart-name">' . wp_kses_post( $product_name ) . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<div class="wpr-mini-cart-quantity"><span class="quantity">' . sprintf( '%s × %s', $cart_item['quantity'], $product_price ) . '</span></div></div>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'woocommerce_cart_item_remove_link',
|
||||
sprintf(
|
||||
'<div class="wpr-mini-cart-remove"><a href="%s" class="wpr-remove-item-from-mini-cart remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="%s">×</a></div>',
|
||||
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
|
||||
esc_attr__( 'Remove this item', 'woocommerce' ),
|
||||
esc_attr( $product_id ),
|
||||
esc_attr( $cart_item_key ),
|
||||
esc_attr( $_product->get_sku() )
|
||||
),
|
||||
$cart_item_key
|
||||
);
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_mini_cart_contents' );
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<div class="wpr-mini-cart-separator"></div>
|
||||
|
||||
<p class="woocommerce-mini-cart__total total">
|
||||
<?php
|
||||
/**
|
||||
* Hook: woocommerce_widget_shopping_cart_total.
|
||||
*
|
||||
* @hooked woocommerce_widget_shopping_cart_subtotal - 10
|
||||
*/
|
||||
do_action( 'woocommerce_widget_shopping_cart_total' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?>
|
||||
|
||||
<p class="woocommerce-mini-cart__buttons buttons"><?php do_action( 'woocommerce_widget_shopping_cart_buttons' ); ?></p>
|
||||
|
||||
<?php do_action( 'woocommerce_widget_shopping_cart_after_buttons' ); ?>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<p class="woocommerce-mini-cart__empty-message"><?php esc_html_e( 'No products in the cart.', 'woocommerce' ); ?></p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_after_mini_cart' ); ?>
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Show error messages
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/error.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce\Templates
|
||||
* @version 8.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! $notices ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<ul class="woocommerce-error" role="alert">
|
||||
<?php foreach ( $notices as $notice ) : ?>
|
||||
<li<?php echo wc_get_notice_data_attr( $notice ); ?>>
|
||||
<?php
|
||||
if ( strpos( $notice['notice'], '</a>') !== false ) {
|
||||
$notice['notice'] = str_replace(substr($notice['notice'], strpos($notice['notice'], '</a>') + 4), '<p>' . substr($notice['notice'], strpos($notice['notice'], '</a>') + 4) . '</p>', $notice['notice']);
|
||||
}
|
||||
|
||||
echo wc_kses_notice( $notice['notice'] );
|
||||
?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Show messages
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/notice.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce\Templates
|
||||
* @version 10.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! $notices ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php foreach ( $notices as $notice ) : ?>
|
||||
<div class="woocommerce-info"<?php echo wc_get_notice_data_attr( $notice ); ?>>
|
||||
<?php
|
||||
if ( strpos( $notice['notice'], '</a>') !== false ) {
|
||||
$notice['notice'] = str_replace(substr($notice['notice'], strpos($notice['notice'], '</a>') + 4), '<p>' . substr($notice['notice'], strpos($notice['notice'], '</a>') + 4) . '</p>', $notice['notice']);
|
||||
}
|
||||
|
||||
echo wc_kses_notice( $notice['notice'] );
|
||||
?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Show messages
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/success.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce\Templates
|
||||
* @version 8.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! $notices ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php foreach ( $notices as $notice ) : ?>
|
||||
<div class="woocommerce-message"<?php echo wc_get_notice_data_attr( $notice ); ?> role="alert">
|
||||
<?php
|
||||
if ( strpos( $notice['notice'], '</a>') !== false ) {
|
||||
$notice['notice'] = str_replace(substr($notice['notice'], strpos($notice['notice'], '</a>') + 4), '<p>' . substr($notice['notice'], strpos($notice['notice'], '</a>') + 4) . '</p>', $notice['notice']);
|
||||
}
|
||||
|
||||
echo wc_kses_notice( $notice['notice'] );
|
||||
?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
class WPR_WooCommerce_Config {
|
||||
|
||||
public function __construct() {
|
||||
add_action('wp_ajax_wpr_addons_add_cart_single_product', [$this, 'add_cart_single_product_ajax']);
|
||||
add_action('wp_ajax_nopriv_wpr_addons_add_cart_single_product', [$this, 'add_cart_single_product_ajax']);
|
||||
|
||||
if ( 'on' == get_option('wpr_enable_woo_flexslider_navigation', 'on') ) {
|
||||
add_filter('woocommerce_single_product_carousel_options', [$this, 'wpr_update_woo_flexslider_options']);
|
||||
}
|
||||
|
||||
if ( 'on' !== get_option('wpr_enable_product_image_zoom', 'on') ) {
|
||||
add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
|
||||
}
|
||||
|
||||
if ( 'on' !== get_option('wpr_remove_wc_default_lightbox', 'on') ) {
|
||||
add_action( 'wp',[$this, 'wpr_remove_wc_lightbox'], 99 );
|
||||
// add_filter( 'body_class', [$this, 'wpr_remove_elementor_lightbox'] ); //: TODO condition
|
||||
}
|
||||
|
||||
// Change number of products that are displayed per page (shop page)
|
||||
add_filter( 'loop_shop_per_page', [$this, 'shop_products_per_page'], 20 );
|
||||
|
||||
// Rewrite WC Default Templates
|
||||
add_filter( 'wc_get_template', [ $this, 'rewrite_default_wc_templates' ], 10, 3 );
|
||||
|
||||
|
||||
// Mini-cart template
|
||||
if ( 'on' === get_option('wpr_override_woo_mini_cart', 'on') ) {
|
||||
add_filter( 'woocommerce_add_to_cart_fragments', [$this, 'wc_refresh_mini_cart_count']);
|
||||
}
|
||||
|
||||
// Fix Theme Builder issues
|
||||
if ( !is_admin() ) {
|
||||
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_init_cart' ] );
|
||||
add_action( 'init', [ $this, 'register_wc_hooks' ], 5 );
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
$template = isset($_GET['post']) ? sanitize_text_field(wp_unslash($_GET['post'])) : '';
|
||||
|
||||
if ( $template_type = Utilities::get_wpr_template_type($template) ) {
|
||||
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_init_cart' ] );
|
||||
add_action( 'init', [ $this, 'register_wc_hooks' ], 5 );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'init', [$this, 'add_wishlist_endpoint'] );
|
||||
|
||||
if ( 'on' == get_option('wpr_add_wishlist_to_my_account', 'on') && defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->is_plan( 'expert' ) ) {
|
||||
add_filter( 'woocommerce_account_menu_items', [$this, 'add_wishlist_to_my_account'] );
|
||||
}
|
||||
|
||||
add_action( 'woocommerce_after_register_post_type', [$this, 'remove_deleted_products_from_compare_and_wishlist'] );
|
||||
//TODO: GOGA - max & min issue
|
||||
// add_filter( 'woocommerce_quantity_input_args', [$this, 'wpr_custom_quantity_step'], 10, 2 );
|
||||
}
|
||||
|
||||
function add_wishlist_endpoint() {
|
||||
add_rewrite_endpoint( 'wishlist', EP_ROOT | EP_PAGES );
|
||||
}
|
||||
|
||||
function wpr_custom_quantity_step( $args, $product ) {
|
||||
if ( $args['input_value'] < 8 ) {
|
||||
$args['input_value'] = 8; // Start from this value
|
||||
}
|
||||
|
||||
// $args['max_value'] = 80; // Maximum value
|
||||
$args['min_value'] = 8; // Minimum value
|
||||
$args['step'] = 8; // Increment/decrement by this value
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
function add_wishlist_to_my_account( $items ) {
|
||||
$items['wishlist'] = __( 'Wishlist', 'wpr-addons' );
|
||||
return $items;
|
||||
}
|
||||
|
||||
function remove_deleted_products_from_compare_and_wishlist() {
|
||||
$compare = get_user_meta( get_current_user_id(), 'wpr_compare', true );
|
||||
if ( ! $compare ) {
|
||||
$compare = array();
|
||||
}
|
||||
foreach ( $compare as $key => $value ) {
|
||||
$product = wc_get_product( $value );
|
||||
if ( ! $product || 'trash' === get_post_status( $value ) ) {
|
||||
$compare = array_diff( $compare, array( $value ) );
|
||||
}
|
||||
}
|
||||
update_user_meta( get_current_user_id(), 'wpr_compare', $compare );
|
||||
|
||||
|
||||
$wishlist = get_user_meta( get_current_user_id(), 'wpr_wishlist', true );
|
||||
if ( ! $wishlist ) {
|
||||
$wishlist = array();
|
||||
}
|
||||
foreach ( $wishlist as $key => $value ) {
|
||||
$product = wc_get_product( $value );
|
||||
if ( ! $product || 'trash' === get_post_status( $value ) ) {
|
||||
$wishlist = array_diff( $wishlist, array( $value ) );
|
||||
}
|
||||
}
|
||||
update_user_meta( get_current_user_id(), 'wpr_wishlist', $wishlist );
|
||||
}
|
||||
|
||||
function wpr_remove_elementor_lightbox( $classes ) {
|
||||
$classes[] = 'wpr-no-lightbox';
|
||||
|
||||
// Return classes
|
||||
return $classes;
|
||||
}
|
||||
|
||||
function wpr_remove_wc_lightbox() {
|
||||
remove_theme_support( 'wc-product-gallery-lightbox' );
|
||||
}
|
||||
|
||||
function wc_refresh_mini_cart_count($fragments) {
|
||||
ob_start();
|
||||
$items_count = WC()->cart->get_cart_contents_count();
|
||||
?>
|
||||
<span class="wpr-mini-cart-icon-count <?php echo $items_count ? '' : 'wpr-mini-cart-icon-count-hidden'; ?>"><span><?php echo $items_count ? $items_count : '0'; ?></span></span>
|
||||
<?php
|
||||
$fragments['.wpr-mini-cart-icon-count'] = ob_get_clean();
|
||||
|
||||
ob_start();
|
||||
$sub_total = WC()->cart->get_cart_subtotal();
|
||||
?>
|
||||
<span class="wpr-mini-cart-btn-price">
|
||||
<?php
|
||||
echo $sub_total;
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
$fragments['.wpr-mini-cart-btn-price'] = ob_get_clean();
|
||||
|
||||
return $fragments;
|
||||
}
|
||||
|
||||
public function add_cart_single_product_ajax() {
|
||||
add_action( 'wp_loaded', [ 'WC_Form_Handler', 'add_to_cart_action' ], 20 );
|
||||
|
||||
if ( is_callable( [ 'WC_AJAX', 'get_refreshed_fragments' ] ) ) {
|
||||
WC_AJAX::get_refreshed_fragments();
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
public function wpr_update_woo_flexslider_options( $options ) {
|
||||
$options['directionNav'] = true;
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function shop_products_per_page( $cols ) {
|
||||
return get_option('wpr_woo_shop_ppp', 9);
|
||||
}
|
||||
|
||||
public function rewrite_default_wc_templates( $located, $template_name ) {
|
||||
// GOGA: needs separate conditions
|
||||
// Cart template
|
||||
if ( $template_name === 'cart/cart.php' && 'on' === get_option('wpr_override_woo_cart', 'on') ) {
|
||||
$located = WPR_ADDONS_PATH .'includes/woocommerce/templates/cart/cart.php';
|
||||
}
|
||||
|
||||
// Mini-cart template
|
||||
if ( $template_name === 'cart/mini-cart.php' && 'on' === get_option('wpr_override_woo_mini_cart', 'on') ) {
|
||||
$located = WPR_ADDONS_PATH .'includes/woocommerce/templates/cart/mini-cart.php';
|
||||
}
|
||||
|
||||
if ( 'on' === get_option('wpr_override_woo_mini_cart', 'on') ) {
|
||||
|
||||
if ( $template_name === 'notices/success.php' ) {
|
||||
$located = WPR_ADDONS_PATH .'includes/woocommerce/templates/notices/success.php';
|
||||
}
|
||||
|
||||
if ( $template_name === 'notices/error.php' ) {
|
||||
$located = WPR_ADDONS_PATH .'includes/woocommerce/templates/notices/error.php';
|
||||
}
|
||||
|
||||
if ( $template_name === 'notices/notice.php' ) {
|
||||
$located = WPR_ADDONS_PATH .'includes/woocommerce/templates/notices/notice.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if ( $template_name === 'cart/cart-empty.php' ) {
|
||||
|
||||
// }
|
||||
|
||||
// if ( $template_name === 'checkout/form-checkout.php' ) {
|
||||
|
||||
// }
|
||||
|
||||
return $located;
|
||||
}
|
||||
|
||||
public function register_wc_hooks() {
|
||||
wc()->frontend_includes();
|
||||
}
|
||||
|
||||
public function maybe_init_cart() {
|
||||
$has_cart = is_a( WC()->cart, 'WC_Cart' );
|
||||
|
||||
if ( ! $has_cart ) {
|
||||
$session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
|
||||
WC()->session = new $session_class();
|
||||
WC()->session->init();
|
||||
WC()->cart = new \WC_Cart();
|
||||
WC()->customer = new \WC_Customer( get_current_user_id(), true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new WPR_WooCommerce_Config();
|
||||
Reference in New Issue
Block a user