diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..4bf99f7 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": [ "plugin:@wordpress/eslint-plugin/recommended" ] +} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..1c2addd --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @eduardovillao diff --git a/.gitignore b/.gitignore index 270de8f..72d66af 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ composer.lock *.sql *.tar.gz *.zip +style.bundle.js diff --git a/README.txt b/README.txt index 2a37f2c..e7dbb3d 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ === Order on Mobile for Wocoommerce === Contributors: evcode Donate link: https://eduardovillao.me/ -Tags: woocommerce, whatsapp, products, order, woocommerce whatsapp, whatsapp order woocommerce, woocommerce mobile +Tags: woocommerce, whatsapp, order on whatsapp Requires at least: 5.5 Tested up to: 6.7 Stable tag: 2.3.4 diff --git a/assets/css/admin/admin-style.css b/assets/css/admin/admin-style.css deleted file mode 100644 index 42bb758..0000000 --- a/assets/css/admin/admin-style.css +++ /dev/null @@ -1,15 +0,0 @@ -.myd-tabs-content { - display: none; -} - -.myd-tabs-content--active { - display: block; -} - -.owm-pro-tag { - background: red; - border-radius: 4px; - padding: 2px 5px; - color: #fff; - font-size: 12px; -} \ No newline at end of file diff --git a/assets/css/admin/admin-style.min.css b/assets/css/admin/admin-style.min.css new file mode 100644 index 0000000..70ceea7 --- /dev/null +++ b/assets/css/admin/admin-style.min.css @@ -0,0 +1 @@ +.myd-tabs-content{display:none}.myd-tabs-content--active{display:block}.owm-pro-tag{background:red;border-radius:4px;color:#fff;font-size:12px;padding:2px 5px;text-decoration:none;transition:all .3s ease;white-space:nowrap}.owm-pro-tag:hover{background:red;color:#fff;opacity:.8}p.omw-description{color:#7d7d7d!important;font-size:13px!important} \ No newline at end of file diff --git a/assets/css/style.min.css b/assets/css/style.min.css new file mode 100644 index 0000000..51eb965 --- /dev/null +++ b/assets/css/style.min.css @@ -0,0 +1 @@ +.div_evowap_btn{margin:20px 0}.div_evowap_btn .evowap_btn{align-items:center;background:#25d366;border-radius:5px;box-shadow:0 2px 2px 0 rgba(45,62,79,.3)!important;color:#fff;display:inline-flex;font-size:16px;padding:12px 30px;position:relative;transition:all .3s!important;width:auto}.evowap_btn:hover{background:#21bd5b;box-shadow:0 8px 25px -5px rgba(45,62,79,.3)!important;color:#fff!important;transform:translateY(-3px)}#svg_wapp_evowap{margin-right:10px!important}.wowa-thankyou{background:#efefef;margin-bottom:20px;padding:30px;text-align:center}.wowa-thankyou h2{font-family:inherit;font-size:35px;margin-bottom:5px}.wowa-thankyou h3{font-family:inherit;font-size:18px;font-weight:400} \ No newline at end of file diff --git a/assets/js/admin/admin-settings.min.js b/assets/js/admin/admin-settings.min.js new file mode 100644 index 0000000..69eb993 --- /dev/null +++ b/assets/js/admin/admin-settings.min.js @@ -0,0 +1 @@ +window.mydChangeTab=function(t){t.preventDefault();let e=document.querySelectorAll(".myd-tab"),a=document.querySelectorAll(".myd-tabs-content"),c=t.target;e.forEach((t=>{t.classList.remove("nav-tab-active")})),a.forEach((t=>{t.classList.remove("myd-tabs-content--active")})),c.classList.add("nav-tab-active"),document.getElementById(c.id+"-content").classList.add("myd-tabs-content--active")}; \ No newline at end of file diff --git a/assets/js/front-js.min.js b/assets/js/front-js.min.js new file mode 100644 index 0000000..965b88f --- /dev/null +++ b/assets/js/front-js.min.js @@ -0,0 +1 @@ +jQuery(document).ready((function(a){"use strict";a("input.variation_id").change((function(){if(""!=a("input.variation_id").val()){var t=a("#woapp_message").val(),e=a("#woapp_name").val(),i=a("#woapp_link").val(),r=a("#woapp_number").val(),n="https://wa.me/"+r+"?text="+t+"%0D%0A%0D%0A"+e+"%0D%0A"+a(".variations_form.cart .amount").text()+"%0D%0A"+i;a(".evowap_btn").attr("href",n)}if(""!=a("input.variation_id").val()&&""==a(".woocommerce-variation-price").text()){var o="https://wa.me/"+r+"?text="+t+"%0D%0A%0D%0A"+e+"%0D%0A"+a("#woapp_reg_price").val()+"%0D%0A"+i;a(".evowap_btn").attr("href",o)}}))})); \ No newline at end of file diff --git a/includes/class-admin.php b/includes/class-admin.php index 6068721..22ea7a3 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -1,7 +1,7 @@ option_group = 'evwapp-settings-group'; - $this->plugin_name = 'Order Mobile for WooCommerce'; - $this->page_title = 'Order on Mobile for WooCommerce Options'; - $this->page_options_slug = 'order-on-mobile-for-woocommerce-config'; - $this->settings = [ - 'evwapp_opiton_phone_number' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_message' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_message_cart' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_text_button' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_text_button_cart' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_target' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_show_cart' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_remove_btn' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_remove_cart_btn' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_remove_price' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_text_btn_thank' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_message_thank' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_title_thank' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_show_btn_single' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ], - 'evwapp_opiton_cart_button_target' => [ - 'option_group' => $this->option_group, - 'args' => [ - 'sanitize_callback' => 'sanitize_text_field', - ] - ] - ]; - - $this->templates = [ - 'general' => OMW_PLUGIN_PATH . 'templates/admin/tab-general.php', - 'checkout' => OMW_PLUGIN_PATH . 'templates/admin/tab-checkout.php', - 'single_product' => OMW_PLUGIN_PATH . 'templates/admin/tab-single-product.php', - 'cart' => OMW_PLUGIN_PATH . 'templates/admin/tab-cart.php', - 'support' => OMW_PLUGIN_PATH . 'templates/admin/tab-support.php', - ]; - } - - ///'evwapp_opiton_phone_number' intval - - /** - * Undocumented function - * - * @since 2.8 - * @return void - */ - public function add_admin_page() { - - add_menu_page( - apply_filters( 'omw_admin_page_title', $this->page_title ), - apply_filters( 'omw_admin_page_name', $this->plugin_name ), - 'manage_options', - apply_filters( 'omw_admin_page_slug', $this->page_options_slug ), - [ $this, 'create_admin_page' ], - OMW_PLUGN_URL . 'assets/img/whatsapp.png', - 56 - ); - } - - /** - * Register settings - * - * @since 2.8 - * @return void - */ - public function register_settings() { - - /** - * Action to implement more admin settings. - */ - $settings = apply_filters( 'omw_before_register_admin_settings', $this->settings ); - - foreach( $settings as $setting_name => $data ) { - - register_setting( - $data['option_group'], - $setting_name, - $data['args'] - ); - } - } - - /** - * Admin page - * - * @since 2.8 - * @return void - */ - public function create_admin_page() { - - /** - * Action to edit/extende admin page templates. - */ - $templates = apply_filters( 'omw_after_output_templates', $this->templates ); - - include_once OMW_PLUGIN_PATH . 'templates/admin/tab-header.php'; - foreach( $templates as $template ) { - include_once $template; - } - include_once OMW_PLUGIN_PATH . 'templates/admin/tab-footer.php'; - } + /** + * Settings option group + * + * @since 2.8 + */ + public $option_group; + + /** + * Plugin name + * + * @since 2.8 + */ + public $plugin_name; + + /** + * Page options slug + * + * @since 2.8 + */ + public $page_options_slug; + + /** + * Page title + * + * @since 2.0 + */ + public $page_title; + + /** + * Settings + * + * @since 2.8 + */ + public $settings = []; + + /** + * Page templates + * + * @since 2.0 + */ + public $templates = []; + + /** + * Construct the class + * + * @since 2.8 + */ + public function __construct() { + + $this->option_group = 'evwapp-settings-group'; + $this->plugin_name = 'Order Mobile for WooCommerce'; + $this->page_title = 'Order on Mobile for WooCommerce Options'; + $this->page_options_slug = 'order-on-mobile-for-woocommerce-config'; + $this->settings = [ + 'evwapp_opiton_phone_number' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_message' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_message_cart' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_text_button' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_text_button_cart' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_target' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_show_cart' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_remove_btn' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_remove_cart_btn' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_remove_price' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_text_btn_thank' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_message_thank' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_title_thank' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_show_btn_single' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ], + 'evwapp_opiton_cart_button_target' => [ + 'option_group' => $this->option_group, + 'args' => [ + 'sanitize_callback' => 'sanitize_text_field', + ] + ] + ]; + + $this->templates = [ + 'general' => OMW_PLUGIN_PATH . 'templates/admin/tab-general.php', + 'checkout' => OMW_PLUGIN_PATH . 'templates/admin/tab-checkout.php', + 'single_product' => OMW_PLUGIN_PATH . 'templates/admin/tab-single-product.php', + 'cart' => OMW_PLUGIN_PATH . 'templates/admin/tab-cart.php', + 'support' => OMW_PLUGIN_PATH . 'templates/admin/tab-support.php', + ]; + } + + ///'evwapp_opiton_phone_number' intval + + /** + * Undocumented function + * + * @since 2.8 + * @return void + */ + public function add_admin_page() { + + add_menu_page( + apply_filters( 'omw_admin_page_title', $this->page_title ), + apply_filters( 'omw_admin_page_name', $this->plugin_name ), + 'manage_options', + apply_filters( 'omw_admin_page_slug', $this->page_options_slug ), + [ $this, 'create_admin_page' ], + OMW_PLUGN_URL . 'assets/img/whatsapp.png', + 56 + ); + } + + /** + * Register settings + * + * @since 2.8 + * @return void + */ + public function register_settings() { + + /** + * Action to implement more admin settings. + */ + $settings = apply_filters( 'omw_before_register_admin_settings', $this->settings ); + + foreach( $settings as $setting_name => $data ) { + + register_setting( + $data['option_group'], + $setting_name, + $data['args'] + ); + } + } + + /** + * Admin page + * + * @since 2.8 + * @return void + */ + public function create_admin_page() { + + /** + * Action to edit/extende admin page templates. + */ + $templates = apply_filters( 'omw_after_output_templates', $this->templates ); + + include_once OMW_PLUGIN_PATH . 'templates/admin/tab-header.php'; + foreach( $templates as $template ) { + include_once $template; + } + include_once OMW_PLUGIN_PATH . 'templates/admin/tab-footer.php'; + } } diff --git a/includes/class-button-cart.php b/includes/class-button-cart.php index 57043ca..8f5262c 100644 --- a/includes/class-button-cart.php +++ b/includes/class-button-cart.php @@ -1,7 +1,7 @@ button_custom_message = get_option( 'evwapp_opiton_message_cart' ); - $this->button_text = get_option( 'evwapp_opiton_text_button_cart' ); - $this->target = get_option( 'evwapp_opiton_cart_button_target' ); - } + /** + * Construct the class + * + * @since 2.8 + */ + public function __construct() { + $this->button_custom_message = get_option( 'evwapp_opiton_message_cart' ); + $this->button_text = get_option( 'evwapp_opiton_text_button_cart' ); + $this->target = get_option( 'evwapp_opiton_cart_button_target' ); + } - /** - * Output button - * - * @since 2.8 - * @return void - */ - public function output_btn() { - if ( is_cart() ) { - $this->cart_items = WC()->cart->get_cart_contents(); - $shared_text = $this->create_shared_text(); - $whatsapp_link = $this->create_whatsapp_link( $shared_text ); - $this->create_button( $whatsapp_link, $this->target, $this->button_text ); - } - } + /** + * Output button + * + * @since 2.8 + * @return void + */ + public function output_btn() { + if ( is_cart() ) { + $this->cart_items = WC()->cart->get_cart_contents(); + $shared_text = $this->create_shared_text(); + $whatsapp_link = $this->create_whatsapp_link( $shared_text ); + $this->create_button( $whatsapp_link, $this->target, $this->button_text ); + } + } /** * Create shared text @@ -92,13 +92,13 @@ public function get_cart_items() { return $items; } - /** - * Get formated cart total - * - * @since 2.8 - */ - public function get_formated_cart_total() { - $cart_total = WC()->cart->get_cart_contents_total(); - return OMW_Utils::format_price( $cart_total ); - } + /** + * Get formated cart total + * + * @since 2.8 + */ + public function get_formated_cart_total() { + $cart_total = WC()->cart->get_cart_contents_total(); + return OMW_Utils::format_price( $cart_total ); + } } diff --git a/includes/class-button-product-page.php b/includes/class-button-product-page.php index 3425142..0ca57ff 100644 --- a/includes/class-button-product-page.php +++ b/includes/class-button-product-page.php @@ -1,7 +1,7 @@ product = wc_get_product(); - $shared_text = $this->create_shared_text(); - $whatsapp_link = $this->create_whatsapp_link( $shared_text ); + $shared_text = $this->create_shared_text(); + $whatsapp_link = $this->create_whatsapp_link( $shared_text ); return $this->create_button( $whatsapp_link, $this->target, $this->button_text ); } else { @@ -81,7 +81,7 @@ public function output_btn() { */ public function create_shared_text() { - $product = $this->product; + $product = $this->product; return sprintf( '%1$s%2$s%3$s%4$s%5$s%6$s%7$s', diff --git a/includes/class-omw-plugin.php b/includes/class-omw-plugin.php index def4523..50d348e 100644 --- a/includes/class-omw-plugin.php +++ b/includes/class-omw-plugin.php @@ -1,7 +1,7 @@ button_in_product_page = get_option( 'evwapp_opiton_show_btn_single'); $this->button_in_cart_page = get_option( 'evwapp_opiton_show_cart' ); $this->phone_number = get_option( 'evwapp_opiton_phone_number' ); - /** - * Do action for pro version check loaded - * - * @since 2.0 - */ - do_action( 'omw_plugin_loaded' ); - - // Init plugin - add_action( 'plugins_loaded', [ $this, 'init' ] ); + /** + * Do action for pro version check loaded + * + * @since 2.0 + */ + do_action( 'omw_plugin_loaded' ); + add_action( 'plugins_loaded', [ $this, 'init' ] ); } /** @@ -108,26 +104,21 @@ private function __construct() { * @access public */ public function init() { - - /** - * Check if WooCommerce is activated - */ if( ! $this->plugin_is_active( 'woocommerce/woocommerce.php' ) ) { - add_action( 'admin_notcies', [ $this, 'notice_woo_inactived' ] ); return; } - /** - * Do action for init other extensions - * - * @since 2.0 - */ - do_action( 'omw_plugin_init' ); + /** + * Do action for init other extensions + * + * @since 2.0 + */ + do_action( 'omw_plugin_init' ); - /** - * Include initial required files - */ + /** + * Include initial required files + */ include_once OMW_PLUGIN_PATH . 'includes/class-utils.php'; include_once OMW_PLUGIN_PATH . 'includes/abstract-class-button.php'; @@ -139,22 +130,20 @@ public function init() { * Include admin class */ if( is_admin() ) { - include_once OMW_PLUGIN_PATH . 'includes/class-admin.php'; - $admin = new OMW_Admin; - add_action( 'admin_init', [ $admin, 'register_settings' ] ); - add_action( 'admin_menu', [ $admin, 'add_admin_page' ] ); + $admin = new OMW_Admin; + add_action( 'admin_init', [ $admin, 'register_settings' ] ); + add_action( 'admin_menu', [ $admin, 'add_admin_page' ] ); } /** * Check option and include product page btn class */ if( $this->button_in_product_page === 'yes' ) { - include_once OMW_PLUGIN_PATH . 'includes/class-button-product-page.php'; - $button_product_page = new OMW_Button_Product_Page; + $button_product_page = new OMW_Button_Product_Page; add_action( 'wp_head', [ $button_product_page, 'hide_woo_elements' ] ); add_action( 'woocommerce_after_add_to_cart_form', [ $button_product_page, 'output_btn' ] ); add_shortcode( 'woo-order-on-whatsapp', [ $button_product_page, 'output_btn' ] ); @@ -164,16 +153,12 @@ public function init() { * Check option and include car page btn class */ if( $this->button_in_cart_page === 'yes' ) { - include_once OMW_PLUGIN_PATH . 'includes/class-button-cart.php'; - $button_cart = new OMW_Button_Cart; + $button_cart = new OMW_Button_Cart; add_action('woocommerce_after_cart_table', [ $button_cart, 'output_btn' ] ); } - /** - * Enqueue styles and scripts - */ add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_plugin_css' ] ); add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_plugin_js' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_plugin_css' ] ); @@ -190,7 +175,6 @@ public function init() { * @access public */ public function notice_woo_inactived() { - $message = sprintf( esc_html__( '%1$s requires WooCommerce to be installed and activated.', 'woo-order-on-whatsapp' ), 'Order on WhatsApp for WooCommerce' @@ -211,8 +195,7 @@ public function notice_woo_inactived() { * @access public */ public function enqueue_plugin_css() { - - wp_enqueue_style( 'omw_style', OMW_PLUGN_URL . '/assets/css/style.css', array(), OMW_VERSION ); + wp_enqueue_style( 'omw_style', OMW_PLUGN_URL . '/assets/css/style.min.css', array(), OMW_VERSION ); } /** @@ -225,8 +208,7 @@ public function enqueue_plugin_css() { * @access public */ public function enqueue_plugin_js() { - - wp_enqueue_script( 'omw_script', OMW_PLUGN_URL . '/assets/js/front-js.js', array('jquery'), OMW_VERSION, true ); + wp_enqueue_script( 'omw_script', OMW_PLUGN_URL . '/assets/js/front-js.min.js', array('jquery'), OMW_VERSION, true ); } /** @@ -239,8 +221,7 @@ public function enqueue_plugin_js() { * @access public */ public function enqueue_admin_plugin_css() { - - wp_enqueue_style( 'omw_admin_style', OMW_PLUGN_URL . '/assets/css/admin/admin-style.css', array(), OMW_VERSION ); + wp_enqueue_style( 'omw_admin_style', OMW_PLUGN_URL . '/assets/css/admin/admin-style.min.css', array(), OMW_VERSION ); } /** @@ -253,8 +234,7 @@ public function enqueue_admin_plugin_css() { * @access public */ public function enqueue_admin_plugin_js() { - - wp_enqueue_script( 'omw_admin_script', OMW_PLUGN_URL . '/assets/js/admin/admin-settings.js', [], OMW_VERSION, true ); + wp_enqueue_script( 'omw_admin_script', OMW_PLUGN_URL . '/assets/js/admin/admin-settings.min.js', [], OMW_VERSION, true ); } /** @@ -265,7 +245,6 @@ public function enqueue_admin_plugin_js() { * @param string $plugin */ public function plugin_is_active( $plugin ) { - return function_exists( 'is_plugin_active' ) ? is_plugin_active( $plugin ) : in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ); } } diff --git a/includes/class-utils.php b/includes/class-utils.php index b64736f..87f5ca7 100644 --- a/includes/class-utils.php +++ b/includes/class-utils.php @@ -1,7 +1,7 @@ ' . esc_html__( 'Only on Pro', 'woo-order-on-whatsapp' ) . ''; + echo '' . esc_html__( 'Only on Pro', 'woo-order-on-whatsapp' ) . ''; } } diff --git a/package.json b/package.json index f2685ed..a5c5475 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,18 @@ "private": true, "description": "Receive orders requests direct on your phone from buttons on your woocommerce product page, cart page and after the checkout.", "scripts": { - "start-dev": "npm install && composer install && ./vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/ && ./vendor/bin/phpcs --config-set default_standard WordPress" + "start-dev": "npm install && composer install && ./vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/ && ./vendor/bin/phpcs --config-set default_standard WordPress", + "build": "webpack --mode=production" }, "author": "EduardoVillao", "license": "ISC", - "devDependencies": {} + "devDependencies": { + "@wordpress/eslint-plugin": "^18.0.0", + "css-loader": "^7.1.2", + "css-minimizer-webpack-plugin": "^7.0.0", + "esbuild-loader": "^4.1.0", + "mini-css-extract-plugin": "^2.9.0", + "webpack": "^5.91.0", + "webpack-cli": "^5.1.4" + } } diff --git a/ruleset.xml b/ruleset.xml new file mode 100644 index 0000000..8b7a9ac --- /dev/null +++ b/ruleset.xml @@ -0,0 +1,31 @@ + + + Order on Mobile for WooCommerce Coding Standards. + + node_modules/* + vendor/* + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/css/admin/admin-style.css b/src/css/admin/admin-style.css new file mode 100644 index 0000000..1ad6c7f --- /dev/null +++ b/src/css/admin/admin-style.css @@ -0,0 +1,29 @@ +.myd-tabs-content { + display: none; +} + +.myd-tabs-content--active { + display: block; +} + +.owm-pro-tag { + background: red; + border-radius: 4px; + padding: 2px 5px; + color: #fff; + font-size: 12px; + text-decoration: none; + transition: all 0.3s ease; + white-space: nowrap; +} + +.owm-pro-tag:hover { + background: #ff0000; + color: #fff; + opacity: 0.8; +} + +p.omw-description { + font-size: 13px !important; + color: #7d7d7d !important; +} diff --git a/assets/css/style.css b/src/css/style.css similarity index 89% rename from assets/css/style.css rename to src/css/style.css index 20b873d..ce25d2e 100644 --- a/assets/css/style.css +++ b/src/css/style.css @@ -29,12 +29,6 @@ margin-right: 10px !important; } -/**.woocommerce-checkout #evowap_btn { - width: 100%; - display: flex; - justify-content: center; -}**/ - .wowa-thankyou { text-align: center; background: #efefef; @@ -52,4 +46,4 @@ font-size: 18px; font-family: inherit; font-weight: 400; -} \ No newline at end of file +} diff --git a/assets/js/admin/admin-settings.js b/src/js/admin/admin-settings.js similarity index 82% rename from assets/js/admin/admin-settings.js rename to src/js/admin/admin-settings.js index c9a0246..2036213 100644 --- a/assets/js/admin/admin-settings.js +++ b/src/js/admin/admin-settings.js @@ -4,12 +4,14 @@ function mydChangeTab(e) { tabContent = document.querySelectorAll('.myd-tabs-content'), clicked = e.target; - tabs.forEach(item => { + tabs.forEach(item => { item.classList.remove('nav-tab-active'); }); - tabContent.forEach(item => { + tabContent.forEach(item => { item.classList.remove('myd-tabs-content--active'); }); clicked.classList.add('nav-tab-active'); document.getElementById(clicked.id + '-content').classList.add('myd-tabs-content--active'); -} \ No newline at end of file +} + +window.mydChangeTab = mydChangeTab; diff --git a/assets/js/front-js.js b/src/js/front-js.js similarity index 88% rename from assets/js/front-js.js rename to src/js/front-js.js index e257829..c25f2b8 100644 --- a/assets/js/front-js.js +++ b/src/js/front-js.js @@ -8,12 +8,12 @@ jQuery(document).ready(function($) { var var_phone = $('#woapp_number').val(); var variable_price = $('.variations_form.cart .amount').text(); var var_href = 'https://wa.me/' + var_phone + '?text=' + var_message + '%0D%0A%0D%0A' + var_name + '%0D%0A' + variable_price + '%0D%0A' + var_link; - $(".evowap_btn").attr("href", var_href); + $(".evowap_btn").attr("href", var_href); } if( '' != $('input.variation_id').val() && '' == $('.woocommerce-variation-price').text() ) { var regular_price = $('#woapp_reg_price').val(); var var_href2 = 'https://wa.me/' + var_phone + '?text=' + var_message + '%0D%0A%0D%0A' + var_name + '%0D%0A' + regular_price + '%0D%0A' + var_link; - $(".evowap_btn").attr("href", var_href2); + $(".evowap_btn").attr("href", var_href2); } }); -}); \ No newline at end of file +}); diff --git a/templates/admin/tab-advanced.php b/templates/admin/tab-advanced.php index f977787..b5dd392 100644 --- a/templates/admin/tab-advanced.php +++ b/templates/admin/tab-advanced.php @@ -1,26 +1,24 @@
- -

-

- - - - - - - - -
- - - -

CHANGE.

-
+

-
\ No newline at end of file + + + + + + + +
+ + + +

CHANGE.

+
+ + diff --git a/templates/admin/tab-cart.php b/templates/admin/tab-cart.php index d6abccb..5f304d0 100644 --- a/templates/admin/tab-cart.php +++ b/templates/admin/tab-cart.php @@ -1,42 +1,41 @@
- -

-

- - - - - - - - - - - - +

+ +
- - - -
- - - -
+ + + + + + + + + + - - - - - -
+ + + +
+ + + +
- - - >
-
-
\ No newline at end of file + + + + + + >
+ + + + + diff --git a/templates/admin/tab-checkout.php b/templates/admin/tab-checkout.php index 02ab17c..92b7627 100644 --- a/templates/admin/tab-checkout.php +++ b/templates/admin/tab-checkout.php @@ -1,61 +1,59 @@
- -

-

- -
-

-

2 -

-

2 -

-
- -

-

- - - - - -
-

-

-
- -

-

- - - - - -
\ No newline at end of file +

+ +
+

+

2 -

+

2 -

+
+ +

+

+ + + + + +
+

+

+
+ +

+

+ + + + + + diff --git a/templates/admin/tab-footer.php b/templates/admin/tab-footer.php index d545a6a..1a497c7 100644 --- a/templates/admin/tab-footer.php +++ b/templates/admin/tab-footer.php @@ -1,11 +1,11 @@ -

- -

- - \ No newline at end of file +

+ +

+ + diff --git a/templates/admin/tab-general.php b/templates/admin/tab-general.php index d7d9a70..6d779a0 100644 --- a/templates/admin/tab-general.php +++ b/templates/admin/tab-general.php @@ -1,58 +1,55 @@
+

+ + + + + + + + + + + + + + -

-

- -
+ + + +

+
+ + + > +

+
+ + + > +

+
- - - - - - - - - - - - - + + + + + +
- - - -

-
- - - > -

-
- - - > -

-
+ + + > +

+
- - - - - - > -

- - - - - -
-

-

PRO version has a Widget for Elemento! You can use that in all pages, and select wath product the button get and redirect information for WhatsApp. Open Elementor editor and search for: "Order on WhatsApp Button".', 'woo-order-on-whatsapp' ) );?>

-
-
\ No newline at end of file +
+

+

PRO version has a Widget for Elemento! You can use that in all pages, and select wath product the button get and redirect information for WhatsApp. Open Elementor editor and search for: "Order on WhatsApp Button".', 'woo-order-on-whatsapp' ) );?>

+
+ diff --git a/templates/admin/tab-header.php b/templates/admin/tab-header.php index 8d0d5cf..c040cfe 100644 --- a/templates/admin/tab-header.php +++ b/templates/admin/tab-header.php @@ -1,21 +1,21 @@
- -

- - +

+ -
- \ No newline at end of file + + + + diff --git a/templates/admin/tab-single-product.php b/templates/admin/tab-single-product.php index c9a05ac..52e1ca0 100644 --- a/templates/admin/tab-single-product.php +++ b/templates/admin/tab-single-product.php @@ -1,70 +1,67 @@
+

-

-

+ + + + + + -
+ + + +
- - - - - - - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - -
- - - -
- - - -
+ + + +
- - - >
-
+ + + >
+
- - - >
-
+ + + >
+
- - - >
-
+ + + >
+
- - - >
-
- -
\ No newline at end of file + + + + + + >
+ + + + +
diff --git a/templates/admin/tab-support.php b/templates/admin/tab-support.php index ba8d752..d24be4b 100644 --- a/templates/admin/tab-support.php +++ b/templates/admin/tab-support.php @@ -1,16 +1,15 @@
- -

+

-
-

-

.

-
+
+

+

.

+
-
\ No newline at end of file + diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..a130a94 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,127 @@ +const path = require('path'); +const fs = require('fs'); +const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); + +const srcJsAdminDirectory = path.resolve(__dirname, 'src/js/admin'); +const adminEntries = fs.readdirSync(srcJsAdminDirectory).reduce((entries, file) => { + if (file.endsWith('.js')) { + const entryKey = file.replace('.js', ''); + entries[entryKey] = path.resolve(srcJsAdminDirectory, file); + } + return entries; + }, {}); + +const adminJs = { + mode: 'production', + entry: adminEntries, + output: { + filename: '[name].min.js', + path: path.resolve(__dirname, 'assets/js/admin'), + }, + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: 'esbuild-loader', + options: { + loader: 'js', + target: 'es2016', + }, + }, + }, + ], + }, +}; + +const srcJsGeneralDirectory = path.resolve(__dirname, 'src/js/'); +const generalEntries = fs.readdirSync(srcJsGeneralDirectory).reduce((entries, file) => { + if (file.endsWith('.js')) { + const entryKey = file.replace('.js', ''); + entries[entryKey] = path.resolve(srcJsGeneralDirectory, file); + } + return entries; + }, {}); + +const generalJs = { + mode: 'production', + entry: generalEntries, + output: { + filename: '[name].min.js', + path: path.resolve(__dirname, 'assets/js'), + }, + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: 'esbuild-loader', + options: { + loader: 'js', + target: 'es2016', + }, + }, + }, + ], + }, +}; + +const generalCSS = { + mode: 'production', + entry: './src/css/style.css', + output: { + filename: 'style.bundle.js', + path: path.resolve(__dirname, 'assets/css/'), + }, + module: { + rules: [ + { + test: /\.css$/, + use: [MiniCssExtractPlugin.loader, 'css-loader'], + }, + ], + }, + optimization: { + minimizer: [new CssMinimizerPlugin()], + }, + plugins: [ + new MiniCssExtractPlugin({ + filename: 'style.min.css', + }), + ], +}; + +const adminCSS = { + mode: 'production', + entry: './src/css/admin/admin-style.css', + output: { + filename: 'style.bundle.js', + path: path.resolve(__dirname, 'assets/css/admin'), + }, + module: { + rules: [ + { + test: /\.css$/, + use: [MiniCssExtractPlugin.loader, 'css-loader'], + }, + ], + }, + optimization: { + minimizer: [new CssMinimizerPlugin()], + }, + plugins: [ + new MiniCssExtractPlugin({ + filename: 'admin-style.min.css', + }), + ], +}; + +module.exports = [ + adminJs, + generalJs, + generalCSS, + adminCSS, +]; diff --git a/woo-order-on-whatsapp.php b/woo-order-on-whatsapp.php index dae03ed..33c4bf6 100644 --- a/woo-order-on-whatsapp.php +++ b/woo-order-on-whatsapp.php @@ -11,6 +11,7 @@ * Text Domain: woo-order-on-whatsapp * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt + * Requires Plugins: woocommerce */ if ( ! defined( 'ABSPATH' ) ) {