Changeset 2298285
- Timestamp:
- 05/05/2020 08:24:30 AM (4 years ago)
- Location:
- front-end-product-edit-for-woocommerce/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
front-end-product-edit-for-woocommerce/trunk/forntend-product-edit.php
r2222021 r2298285 3 3 Plugin Name: Front End Product Edit For Woocommerce 4 4 Description: Front End Product Edit for Woocommerce will help you to edit or update the product in frontend. 5 Plugin URI: https:// www.code4webs.com6 Version: 1. 0.05 Plugin URI: https:// 6 Version: 1..0 7 7 Author: Mehedi Hasan 8 Author URI: https:// www.facebook.com/mehedicsit8 Author URI: https:// 9 9 License: GPL-2.0+ 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 23 23 require 'inc/fpde-media-upload.php'; 24 24 //Init action 25 add_action('init', array($this, 'fpde_init') );25 add_action('init', array($this, 'fpde_init')); 26 26 //Product update 27 add_action('wp_ajax_fpde_popup_submit', array( $this, 'fpde_popup_submit'));27 add_action('wp_ajax_fpde_popup_submit', array(); 28 28 // use ajax to query product by id to popup 29 add_action('wp_ajax_nopriv_fpde_get_product_by_id', array( $this, 'fpde_get_product_by_id'));30 add_action('wp_ajax_fpde_get_product_by_id', array( $this, 'fpde_get_product_by_id'));29 add_action('wp_ajax_nopriv_fpde_get_product_by_id', array(); 30 add_action('wp_ajax_fpde_get_product_by_id', array(); 31 31 } 32 32 33 public function fpde_init() {33 public function fpde_init(){ 34 34 if( current_user_can('edit_posts') ) { 35 35 //Enqueue css and js … … 38 38 add_action('wp_footer', array($this, 'fpde_ajax_data_render_popup')); 39 39 //Adding edit button 40 add_action('woocommerce_before_shop_loop_item', array( $this, 'fpde_product_edit_btn'));40 add_action('woocommerce_before_shop_loop_item', array($this, 'fpde_product_edit_btn')); 41 41 } 42 42 } 43 43 44 44 // enqueue scripts 45 public function fpde_scripts_register() {45 public function fpde_scripts_register(){ 46 46 wp_enqueue_style( 'fpde_custom_css', plugins_url('assets/css/fpde-ajax-popup.css', __FILE__) ); 47 wp_enqueue_script( 'fpde_popup_js', plugins_url('assets/js/fpde-ajax-popup.js', __FILE__), array('jquery'), null,true);47 wp_enqueue_script( 'fpde_popup_js', plugins_url('assets/js/fpde-ajax-popup.js', __FILE__), array('jquery'),); 48 48 wp_localize_script( 'fpde_popup_js', 'fpde_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_nonce' => wp_create_nonce('fpde_ajax_nonce') ) ); 49 49 wp_enqueue_editor(); … … 74 74 } 75 75 76 public function fpde_get_product_by_id() {76 public function fpde_get_product_by_id(){ 77 77 78 78 $fpdepid = sanitize_text_field($_POST['fpdepid']); … … 86 86 87 87 //Ajax loading 88 public function fpde_ajax_data_render_popup() {88 public function fpde_ajax_data_render_popup(){ 89 89 ?> 90 90 <div id="fpde-popup-wrapper"></div> … … 93 93 } 94 94 95 public function fpde_product_edit_btn() {95 public function fpde_product_edit_btn(){ 96 96 ?> 97 97 <a class="fpde-popup-trigger" fpde-pid="<?php the_id(); ?>" href="#"><span class="dashicons dashicons-edit"></span></a> … … 108 108 } 109 109 else{ 110 add_action('admin_notices', function() {110 add_action('admin_notices', function(){ 111 111 echo '<div class="notice notice-error"><p>'.esc_html__('Front End Product Edit For Woocommerce requires WooCommerce to be installed and active. You can download', 'fpde').' <a href="https://woocommerce.com/" target="_blank">WooCommerce</a> '.esc_html__('here.','fpde').'</p></div>'; 112 112 }); -
front-end-product-edit-for-woocommerce/trunk/inc/fpde-popup.php
r2222021 r2298285 14 14 <p id="fde-update-featured-image"><span class="dashicons dashicons-edit"></span></p> 15 15 <?php 16 $fpde_p_img = !empty( wp_get_attachment_url( $product->get_image_id() )) ? wp_get_attachment_url( $product->get_image_id() ) : plugins_url('../assets/woocommerce-placeholder-300x300.png', __FILE__);16 $fpde_p_img = !empty() ? wp_get_attachment_url( $product->get_image_id() ) : plugins_url('../assets/woocommerce-placeholder-300x300.png', __FILE__); 17 17 ?> 18 18 <img src="<?php echo esc_attr($fpde_p_img); ?>" alt="Image" /> … … 79 79 $top_term_tax = $category->taxonomy; 80 80 81 $term_children = get_term_children( $category->term_id, 'product_cat');81 $term_children = get_term_children($category->term_id, 'product_cat'); 82 82 ?> 83 83 <li> 84 <input type="checkbox" name="fpde-categories" id="fpde-category-<?php echo esc_attr( $category->term_id ) ?>" class="fpde-catageory" value="<?php echo esc_attr( $category->term_id ) ?>" <?php if( in_array( $category->term_id, $termsids) ){ echo 'checked'; } ?>> <label for="fpde-category-<?php echo esc_attr( $category->term_id ) ?>"><?php echo esc_html( $category->name ); ?></label>84 <input type="checkbox" name="fpde-categories" id="fpde-category-<?php echo esc_attr( $category->term_id ) ?>" class="fpde-catageory" value="<?php echo esc_attr( $category->term_id ) ?>" <?php if( in_array() ){ echo 'checked'; } ?>> <label for="fpde-category-<?php echo esc_attr( $category->term_id ) ?>"><?php echo esc_html( $category->name ); ?></label> 85 85 86 86 <?php … … 97 97 echo '<ul class="second-level-terms">'; 98 98 99 foreach ( $second_level_terms as $second_level_term) {99 foreach () { 100 100 101 101 echo '<li>'; 102 102 ?> 103 <input type="checkbox" id="fpde-category-<?php echo esc_attr( $second_level_term->term_id ) ?>" name="fpde-categories" class="fpde-catageory fpde-child" value="<?php echo esc_html( $second_level_term->term_id ) ?>" <?php if( in_array( $second_level_term->term_id, $termsids) ){ echo 'checked'; } ?>> <label for="fpde-category-<?php echo esc_attr( $second_level_term->term_id ) ?>"><?php echo esc_html( $second_level_term->name ); ?></label>103 <input type="checkbox" id="fpde-category-<?php echo esc_attr( $second_level_term->term_id ) ?>" name="fpde-categories" class="fpde-catageory fpde-child" value="<?php echo esc_html( $second_level_term->term_id ) ?>" <?php if( in_array() ){ echo 'checked'; } ?>> <label for="fpde-category-<?php echo esc_attr( $second_level_term->term_id ) ?>"><?php echo esc_html( $second_level_term->name ); ?></label> 104 104 <?php 105 105 echo '</li>'; … … 122 122 <div class="form-field"> 123 123 <label for="fpde_sku"><span class="fpde-title"><?php echo esc_html('SKU'); ?></span> 124 <input type="text" class="short" name="_sku" id="fpde_sku" value="<?php echo esc_attr( $product->get_sku()); ?>">124 <input type="text" class="short" name="_sku" id="fpde_sku" value="<?php echo esc_attr(); ?>"> 125 125 </label> 126 126 </div> … … 129 129 <?php 130 130 $manageStock = $product->get_manage_stock(); 131 if( $manageStock == 1){131 if(){ 132 132 133 133 $manageStock = "checked"; … … 140 140 } 141 141 ?> 142 <input type="checkbox" class="fpde-checkbox" name="_manage_stock" id="fpde_manage_stock" value="<?php echo esc_attr($manageStock); ?>" <?php echo esc_attr( $manageStock); ?>> <label for="fpde_manage_stock"><?php echo esc_html('Manage stock?'); ?></label>142 <input type="checkbox" class="fpde-checkbox" name="_manage_stock" id="fpde_manage_stock" value="<?php echo esc_attr($manageStock); ?>" <?php echo esc_attr(); ?>> <label for="fpde_manage_stock"><?php echo esc_html('Manage stock?'); ?></label> 143 143 </div> 144 144 … … 167 167 'tabindex' => 4, 168 168 ); 169 wp_editor( $product->get_short_description(), $short_desc_id,$settings);169 wp_editor( $product->get_short_description(),); 170 170 ?> 171 171 </label> … … 181 181 'tabindex' => 4, 182 182 ); 183 wp_editor( $product->get_description(), $long_desc_id,$settings);183 wp_editor( $product->get_description(),); 184 184 ?> 185 185 </label> -
front-end-product-edit-for-woocommerce/trunk/inc/fpde-product-update.php
r2222021 r2298285 4 4 } 5 5 6 if( isset($_POST['productTitle'])){7 $productTitle = sanitize_text_field( $_POST['productTitle']);8 $product_update->set_name( $productTitle);6 if({ 7 $productTitle = sanitize_text_field(); 8 $product_update->set_name(); 9 9 } 10 if( isset($_POST['productRegPrice'])){11 $product_Reg_Price = sanitize_text_field( $_POST['productRegPrice']);12 $product_update->set_regular_price( $product_Reg_Price);10 if({ 11 $product_Reg_Price = sanitize_text_field(); 12 $product_update->set_regular_price(); 13 13 } 14 if( isset($_POST['productSalePrice'])){15 $product_Sale_Price = sanitize_text_field( $_POST['productSalePrice']);16 $product_update->set_sale_price( $product_Sale_Price);14 if({ 15 $product_Sale_Price = sanitize_text_field(); 16 $product_update->set_sale_price(); 17 17 } 18 if(isset( $_POST['productShortDesc'])){19 $productShortDesc = wp_kses_post( $_POST['productShortDesc']);20 $product_update->set_short_description( $productShortDesc);18 if(isset({ 19 $productShortDesc = wp_kses_post(); 20 $product_update->set_short_description(); 21 21 } 22 if(isset( $_POST['productLongDesc'])){23 $productLongDesc = wp_kses_post( $_POST['productLongDesc']);24 $product_update->set_description( $productLongDesc);22 if(isset({ 23 $productLongDesc = wp_kses_post(); 24 $product_update->set_description(); 25 25 } 26 if( isset($_POST['productSku'])){27 $productSku = sanitize_text_field( $_POST['productSku']);28 $product_update->set_sku( $productSku);26 if({ 27 $productSku = sanitize_text_field(); 28 $product_update->set_sku(); 29 29 } 30 if(isset( $_POST['manageStock'])){31 $enable_stock = sanitize_text_field( $_POST['manageStock']);32 $product_update->set_manage_stock( $enable_stock);30 if(isset({ 31 $enable_stock = sanitize_text_field(); 32 $product_update->set_manage_stock(); 33 33 } 34 if( $_POST['manageStock'] == 1){35 if( isset($_POST['stockQuantity'])){36 $stock_quantity = sanitize_text_field( $_POST['stockQuantity']);37 $product_update->set_stock_quantity( $stock_quantity);34 if({ 35 if({ 36 $stock_quantity = sanitize_text_field(); 37 $product_update->set_stock_quantity(); 38 38 } 39 39 } 40 if( isset($_POST['stockStatus'])){41 $stock_status = sanitize_text_field( $_POST['stockStatus']);42 $product_update->set_stock_status( $stock_status);40 if({ 41 $stock_status = sanitize_text_field(); 42 $product_update->set_stock_status(); 43 43 } 44 if( isset($_POST['catIds'])){44 if({ 45 45 $product_cat_ids = array_map( 'sanitize_text_field', wp_unslash( $_POST['catIds'] ) ); 46 $product_update->set_category_ids( $product_cat_ids);46 $product_update->set_category_ids(); 47 47 } 48 if( !empty(trim($_POST['attachmentID']))){49 $popup_attachment_ID = sanitize_text_field( $_POST['attachmentID']);50 $product_update->set_image_id( $popup_attachment_ID);48 if({ 49 $popup_attachment_ID = sanitize_text_field(); 50 $product_update->set_image_id(); 51 51 } 52 if( isset($_POST['galleryIds'])) {52 if() { 53 53 $gallery_ids = array_map( 'sanitize_text_field', wp_unslash( $_POST['galleryIds'] ) ); 54 $product_update->set_gallery_image_ids( $gallery_ids);54 $product_update->set_gallery_image_ids(); 55 55 56 56 } -
front-end-product-edit-for-woocommerce/trunk/readme.txt
r2222041 r2298285 1 1 === Front End Product Edit For Woocommerce === 2 Contributors: mehedi_csit, raihan143 3 Tags: woocommerce product edit, frontend product edit, woocommerce, edit, product, add product, update product, update, popup edit, ajax edit 2 Contributors: mehedi_csit 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ANJRBFTXBUE8Q&source=url 4 Tags: woocommerce,product manager, product edit, frontend edit, woocommerce, edit, product, add product, update product, update, popup edit, ajax edit 4 5 Requires at least: 4.2 5 Tested up to: 5. 2.46 Requires PHP: 5. 46 Tested up to: 5. 7 Requires PHP: 5. 7 8 Stable tag: 1.0.0 8 9 License: GPL-2.0+
Note: See TracChangeset
for help on using the changeset viewer.