Skip to content

Commit

Permalink
version 2.4.0-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mototeam committed May 25, 2020
1 parent 12a936b commit 436b943
Show file tree
Hide file tree
Showing 50 changed files with 1,130 additions and 3,941 deletions.
1 change: 0 additions & 1 deletion admin/customers/overview.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
$customer = mprm_get_customer($id);
$customer_edit_role = apply_filters('mprm_edit_customers_role', 'edit_shop_payments');
$users = apply_filters('mprm_edit_users', get_users());;

if (isset($customer->user_id) && $customer->user_id > 0) :
Expand Down
4 changes: 2 additions & 2 deletions admin/metaboxes/order/order-purchased.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
echo mprm_text(array(
'name' => 'mprm-order-menu-item-amount',
'id' => 'mprm-order-menu-item-amount',
'label' => __('Item Price: ', 'mp-restaurant-menu'),
'label' => __('Price: ', 'mp-restaurant-menu'),
'class' => 'mprm-order-menu-item-price'
)
);
?>
</div>

<div class="actions mprm-columns <?php echo $column ?>">
<a href="" id="mprm-order-add-menu-item" class="button button-secondary"><?php printf(__('Add %s to Payment', 'mp-restaurant-menu'), mprm_get_label_singular()); ?></a>
<a href="" id="mprm-order-add-menu-item" class="button button-secondary"><?php _e('Add Item', 'mp-restaurant-menu'); ?></a>
</div>
</div>
<input type="hidden" name="mprm-order-menu-items-changed" id="mprm-payment-menu-items-changed" value=""/>
Expand Down
2 changes: 1 addition & 1 deletion admin/popups/add-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</div>


<div class="mprm-line stick" data-selector="data-line">
<div class="mprm-line" data-selector="data-line">
<input class="button button-primary button-large" type="button" data-selector="insert_shortcode" value="<?php _e('Insert shortcode', 'mp-restaurant-menu'); ?>"/>
</div>
</form>
2 changes: 1 addition & 1 deletion admin/popups/shortcode-mprm_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<input type="checkbox" name="ingredients" checked value="1" data-selector="form_data"/>
</div>
</div>
<?php if (mprm_get_option('enable_ecommerce')): ?>
<?php if ( mprm_ecommerce_enabled() ) : ?>
<div class="mprm-line" data-selector="data-line">
<div class="mprm-left-side"><?php _e('Show buy button', 'mp-restaurant-menu'); ?></div>
<div class="mprm-right-side">
Expand Down
7 changes: 3 additions & 4 deletions templates/settings.php → admin/settings/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
?>
</h2>
<?php if (!empty($sections)): ?>
<div>
<div class="mprm-clear">
<?php
$number_of_sections = count($sections);
$number = 0;
if ($number_of_sections > 1) {
echo '<div><ul class="subsubsub">';
echo '<ul class="subsubsub">';
foreach ($sections as $section_id => $section_name) {
echo '<li>';
$number++;
Expand All @@ -40,10 +40,9 @@
}
echo '</li>';
}
echo '</ul></div>';
echo '</ul>';
} ?>
</div>
<br class="mprm-clear">
<?php endif;
// Let's verify we have a 'main' section to show
ob_start();
Expand Down
46 changes: 10 additions & 36 deletions classes/class-capability.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public function add_roles() {
'read' => true,
'edit_posts' => true,
'delete_posts' => true,
'unfiltered_html' => true,
//'unfiltered_html' => true,
'upload_files' => true,
'export' => true,
'import' => true,
//'export' => true,
//'import' => true,
'delete_others_pages' => true,
'delete_others_posts' => true,
'delete_pages' => true,
Expand All @@ -70,7 +70,7 @@ public function add_roles() {
'publish_pages' => true,
'publish_posts' => true,
'read_private_pages' => true,
'read_private_posts' => true
'read_private_posts' => true,
));

add_role('mprm_customer', __('Restaurant Customer', 'mp-restaurant-menu'), array(
Expand All @@ -93,17 +93,16 @@ public function add_caps() {
}
}
if (is_object($wp_roles)) {
$wp_roles->add_cap('mprm_manager', 'manage_restaurant_settings');
$wp_roles->add_cap('mprm_manager', 'manage_restaurant_terms');
$wp_roles->add_cap('mprm_manager', 'manage_restaurant_menu');
$wp_roles->add_cap('mprm_manager', 'manage_options');
$wp_roles->add_cap('mprm_manager', 'manage_restaurant_terms');

$wp_roles->add_cap('administrator', 'manage_restaurant_menu');
$wp_roles->add_cap('administrator', 'manage_restaurant_settings');
$wp_roles->add_cap('administrator', 'manage_restaurant_terms');


// Add the main post type capabilities
$capabilities = $this->get_core_caps();

foreach ($capabilities as $cap_group) {
foreach ($cap_group as $cap) {
$wp_roles->add_cap('mprm_manager', $cap);
Expand Down Expand Up @@ -192,6 +191,7 @@ public function meta_caps($caps, $cap, $user_id, $args) {
* @return void
*/
public function remove_caps() {

global $wp_roles;

if (class_exists('WP_Roles')) {
Expand All @@ -203,45 +203,19 @@ public function remove_caps() {
if (is_object($wp_roles)) {

/** Shop Manager Capabilities */
$wp_roles->remove_cap('mprm_manager', 'view_shop_reports');
$wp_roles->remove_cap('mprm_manager', 'manage_restaurant_settings');
$wp_roles->remove_cap('mprm_manager', 'view_shop_sensitive_data');
$wp_roles->remove_cap('mprm_manager', 'export_shop_reports');
$wp_roles->remove_cap('mprm_manager', 'manage_shop_discounts');
$wp_roles->remove_cap('mprm_manager', 'manage_shop_settings');
$wp_roles->remove_cap('mprm_manager', 'manage_restaurant_menu');

/** Site Administrator Capabilities */
$wp_roles->remove_cap('administrator', 'view_shop_reports');
$wp_roles->remove_cap('administrator', 'view_shop_sensitive_data');
$wp_roles->remove_cap('administrator', 'export_shop_reports');
$wp_roles->remove_cap('administrator', 'manage_shop_discounts');
$wp_roles->remove_cap('administrator', 'manage_shop_settings');
$wp_roles->remove_cap('administrator', 'manage_restaurant_settings');
$wp_roles->remove_cap('administrator', 'manage_restaurant_menu');

/** Site Editor Capabilities */
$wp_roles->remove_cap('editor', 'view_shop_reports');
$wp_roles->remove_cap('editor', 'view_shop_sensitive_data');
$wp_roles->remove_cap('editor', 'export_shop_reports');
$wp_roles->remove_cap('editor', 'manage_shop_discounts');
$wp_roles->remove_cap('editor', 'manage_shop_settings');
$wp_roles->remove_cap('editor', 'manage_restaurant_settings');
$wp_roles->remove_cap('editor', 'manage_restaurant_menu');
$wp_roles->remove_cap('mprm_manager', 'manage_restaurant_terms');

/** Remove the Main Post Type Capabilities */

$capabilities = $this->get_core_caps();

foreach ($capabilities as $cap_group) {
foreach ($cap_group as $cap) {
$wp_roles->remove_cap('mprm_manager', $cap);
$wp_roles->remove_cap('administrator', $cap);
$wp_roles->remove_cap('editor', $cap);
}
}
$this->remove_roles(array('mprm_manager', 'mprm_customer', 'mprm_shop_manager', 'mprm_shop_accountant', 'mprm_shop_vendor', 'mprm_shop_worker'));

$this->remove_roles(array('mprm_manager', 'mprm_customer'));
delete_option('mprm_capabilities_version');
}
}
Expand Down
4 changes: 3 additions & 1 deletion classes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,11 @@ public function set_state($state) {
* Route plugin url
*/
public function wp_ajax_route_url() {

$controller = isset($_REQUEST[ "controller" ]) ? $_REQUEST[ "controller" ] : null;
$action = isset($_REQUEST[ "mprm_action" ]) ? $_REQUEST[ "mprm_action" ] : null;
if (!empty($action) && !empty($controller)) {

if ( !empty($action) && !empty($controller) ) {
// call controller
Preprocessor::get_instance()->call_controller($action, $controller);
die();
Expand Down
49 changes: 49 additions & 0 deletions classes/class-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ public function init() {
add_filter('mprm_settings_general', array($this, 'filter_options'), 10, 1);

add_action('wp_head', array($this, 'wpHeadFinished'), 999);
//add_filter( 'mprm_can_checkout', array( $this, 'checkout_check_open_hours' ));

// change order status
add_action( 'wp_ajax_mprm_mark_order_status', array($this, 'wp_ajax_mprm_mark_order_status') );
}

/**
Expand Down Expand Up @@ -1063,4 +1067,49 @@ public function filter_options($args) {

return $args;
}

/*
public function checkout_check_open_hours( $can_checkout ) {
if ( mprm_store_has_open_hours() === true ) {
$prevent_offline_checkout = boolval( mprm_get_option('prevent_offline_checkout', false) );
if ( mprm_store_is_open() == false && $prevent_offline_checkout == true ) {
$can_checkout = false;
add_action('mprm_cart_empty', array( $this, 'mprm_cart_empty_offline_message' ), 11);
}
}
return $can_checkout;
}
*/

/*
public function mprm_cart_empty_offline_message() {
echo '<span class="mprm_empty_cart">' . mprm_get_open_hours_offline_message() . '</span>';
}
*/

/**
* Mark an order with a status.
*/
public function wp_ajax_mprm_mark_order_status() {
if ( current_user_can( 'manage_restaurant_menu' ) &&
check_admin_referer( 'mprm-mark-order-status' ) && isset( $_GET['status'], $_GET['order_id'] ) ) {

$status = sanitize_text_field( wp_unslash( $_GET['status'] ) );
$order = new models\Order( absint( wp_unslash( $_GET['order_id'] ) ) );

if ( $order ) {

$order->update_status( $status );
}
}

wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'edit.php?post_type=mprm_order' ) );
exit;
}


}
Loading

0 comments on commit 436b943

Please sign in to comment.