Changeset 2965611
- Timestamp:
- 09/12/2023 04:03:24 AM (18 months ago)
- Location:
- jcwp-add-quote-button-in-product-page
- Files:
-
- 28 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
jcwp-add-quote-button-in-product-page/trunk/jcwp-add-quote-button-in-product-page.php
r2858684 r2965611 4 4 * Plugin URI: https://jcwpplugins.com/jcwp-add-quote-button-in-product-page/ 5 5 * Description: A plugin that adds a WhatsApp quote button on the WooCommerce product and shop page. 6 * Version: 1.0. 16 * Version: 1.0.2 7 7 * Author: JcwpPlugins 8 8 * Author URI: https://jcwpplugins.com … … 82 82 <td><input type="text" name="jcwp_quote_option_field_message_text" value="<?php echo esc_attr( get_option('jcwp_quote_option_field_message_text') ); ?>" /></td> 83 83 </tr> 84 </table> 85 <h1><?php echo __( 'Display Options', 'jcwp-add-quote-button-in-product-page' ); ?></h1> 86 <table class="form-table"> 84 87 <tr valign="top"> 85 88 <th scope="row"><?php echo __( 'Show button on product page', 'jcwp-add-quote-button-in-product-page' ); ?></th> … … 91 94 </tr> 92 95 </table> 96 <table class="form-table" style="border: solid 1px #3313;padding: 10px;display: block;width: auto;"> 97 <tr valign="top"> 98 <th scope="row"><?php echo __( 'Show only in these categories:', 'jcwp-add-quote-button-in-product-page' ); ?></th> 99 <td><input type="text" placeholder="music,tshirts" name="jcwp_quote_option_field_show_on_categories" value="<?php echo esc_attr( get_option('jcwp_quote_option_field_show_on_categories') ); ?>" /></td> 100 </tr> 101 </table> 102 <pre style="margin: 0;padding:0;"><?php echo __( 'Add the slugs of the categories separated by comma', 'jcwp-add-quote-button-in-product-page' ); ?></pre> 103 93 104 <?php submit_button(); ?> 94 105 </form> … … 104 115 register_setting( 'jcwp-quote-plugin-settings-group', 'jcwp_quote_option_field_show_on_product_page' ); 105 116 register_setting( 'jcwp-quote-plugin-settings-group', 'jcwp_quote_option_field_show_on_shop_page' ); 117 register_setting( 'jcwp-quote-plugin-settings-group', 'jcwp_quote_option_field_show_on_categories' ); 106 118 } 107 119 … … 112 124 } 113 125 $quote_link = "https://wa.me/{$this->phone_number}?text=" . urlencode( "{$this->message_text} {$product->get_title()}: {$product->get_permalink()}" ); 114 ?> 115 <a href="<?php echo esc_attr($quote_link); ?>" class="button jcwp-quote-button" target="_blank"> 116 <img src="<?php echo esc_attr($this->img_src); ?>"> 117 <?php echo esc_attr($this->button_text); ?> 118 </a> 119 <?php 126 $category_slugs = wp_get_post_terms($product->get_id(), 'product_cat', array('fields' => 'slugs')); 127 $show_categories = get_option('jcwp_quote_option_field_show_on_categories'); 128 $show_categories = str_replace(' ', '', $show_categories); 129 if(!empty($show_categories)){ 130 $show_categories = explode(',', $show_categories); 131 $common_elements = array_intersect($category_slugs, $show_categories); 132 if(!empty($common_elements)){ 133 ?> 134 <a href="<?php echo esc_attr($quote_link); ?>" class="button jcwp-quote-button" target="_blank"> 135 <img src="<?php echo esc_attr($this->img_src); ?>"> 136 <?php echo esc_attr($this->button_text); ?> 137 </a> 138 <?php 139 } 140 }else{ 141 ?> 142 <a href="<?php echo esc_attr($quote_link); ?>" class="button jcwp-quote-button" target="_blank"> 143 <img src="<?php echo esc_attr($this->img_src); ?>"> 144 <?php echo esc_attr($this->button_text); ?> 145 </a> 146 <?php 147 } 120 148 } 121 149 … … 126 154 } 127 155 $quote_link = "https://wa.me/{$this->phone_number}?text=" . urlencode( "{$this->message_text} {$product->get_title()}: {$product->get_permalink()}" ); 128 ?> 129 <a href="<?php echo esc_attr($quote_link); ?>" class="button jcwp-quote-button" target="_blank"> 130 <img src="<?php echo esc_attr($this->img_src); ?>"> 131 <?php echo esc_attr($this->button_text); ?> 132 </a> 133 <?php 156 $category_slugs = wp_get_post_terms($product->get_id(), 'product_cat', array('fields' => 'slugs')); 157 $show_categories = get_option( 'jcwp_quote_option_field_show_on_categories' ); 158 $show_categories = str_replace(' ', '', $show_categories); 159 if(!empty($show_categories)){ 160 $show_categories = explode(',', $show_categories); 161 $common_elements = array_intersect($category_slugs, $show_categories); 162 if(!empty($common_elements)){ 163 ?> 164 <a href="<?php echo esc_attr($quote_link); ?>" class="button jcwp-quote-button" target="_blank"> 165 <img src="<?php echo esc_attr($this->img_src); ?>"> 166 <?php echo esc_attr($this->button_text); ?> 167 </a> 168 <?php 169 } 170 }else{ 171 ?> 172 <a href="<?php echo esc_attr($quote_link); ?>" class="button jcwp-quote-button" target="_blank"> 173 <img src="<?php echo esc_attr($this->img_src); ?>"> 174 <?php echo esc_attr($this->button_text); ?> 175 </a> 176 <?php 177 } 134 178 } 135 179 -
jcwp-add-quote-button-in-product-page/trunk/readme.txt
r2858684 r2965611 5 5 Requires at least: 4.0 6 6 Tested up to: 6.1 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 44 44 3. Button result on shop page 45 45 4. Button Result Example 46 5. Show button only on products that belong to a specific category 46 47 47 48 == Changelog == 49 = 1.0.2 = 50 * New configuration option is added to show button only on products that belong to a specific category 48 51 = 1.0.1 = 49 52 * Add Settings link on plugins page
Note: See TracChangeset
for help on using the changeset viewer.