Skip to content

Instantly share code, notes, and snippets.

@gjedeer
Created August 19, 2020 10:05
Show Gist options
  • Save gjedeer/9dc7482ee167bb773881a0df61524d13 to your computer and use it in GitHub Desktop.
Save gjedeer/9dc7482ee167bb773881a0df61524d13 to your computer and use it in GitHub Desktop.
diff --git a/admin/class-woo-related-products-admin.php b/admin/class-woo-related-products-admin.php
index 4db5c5e..9d97581 100644
--- a/admin/class-woo-related-products-admin.php
+++ b/admin/class-woo-related-products-admin.php
@@ -121,5 +121,6 @@ class Woo_Related_Products_Admin {
register_setting( 'woorelated-group', 'woorelated_basedon' );
register_setting( 'woorelated-group', 'woorelated_exclude' );
register_setting( 'woorelated-group', 'woorelated_slider' );
+ register_setting( 'woorelated-group', 'woorelated_display_automatically' );
}
}
diff --git a/woo-related-products.php b/woo-related-products.php
index a0a50d1..419067b 100644
--- a/woo-related-products.php
+++ b/woo-related-products.php
@@ -191,6 +191,34 @@ function admin_page()
} ?>
</select>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Display under products</th>
+ <td>
+ <?php
+ $display_automatically = array(
+ "Enabled" => 'Enabled',
+ "Disabled" => 'Disabled'
+ ); ?>
+ <select name="woorelated_display_automatically">
+ <?php if (esc_attr(get_option('woorelated_display_automatically')) != '')
+ { ?>
+ <option selected="<?php
+ echo esc_attr(get_option('woorelated_display_automatically')); ?>"><?php
+ echo esc_attr(get_option('woorelated_display_automatically')); ?></option>
+ <?php
+ } ?>
+ <?php
+ foreach($display_automatically as $display_automatically_value => $display_automatically_label)
+ { ?>
+ <option value="<?php
+ echo $display_automatically_value; ?>"><?php
+ echo $display_automatically_label; ?></option>
+ <?php
+ } ?>
+ </select>
+
</td>
</tr>
</table>
@@ -234,10 +262,6 @@ function wrprrdisplay($atts)
}
function wrprr_wp_taxonomy($basedonf, $atts)
{
- echo '<pre>';
- echo current_action();
- debug_print_backtrace();
- echo '</pre>';
global $post;
$started = '';
$sc = '';
@@ -470,7 +494,9 @@ if (!shortcode_exists('woo-related')) {
run_woo_related_products();
-add_action('woocommerce_after_single_product', 'wrprrdisplay');
+if(get_option('woorelated_display_automatically') == '' || get_option('woorelated_display_automatically') == 'Enabled') {
+ add_action('woocommerce_after_single_product', 'wrprrdisplay');
+}
add_filter('widget_text','do_shortcode'); //fix for themes without shortcode support on sidebar
//version 4.0 featured : Code refactor, more features.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment