Skip to content

Instantly share code, notes, and snippets.

View dhirenpatel22's full-sized avatar
🏠
Working from home

Dhiren Patel dhirenpatel22

🏠
Working from home
View GitHub Profile
@dhirenpatel22
dhirenpatel22 / create-order-line-item-meta-field.php
Created May 8, 2020 12:11
Create Order line item meta field in WooCommerce
<?php
/**
* Add a custom field to order line item
* @param $item_id
* @param $item
*/
function add_order_item_custom_field($item_id, $item ) {
// Targeting line items type only
if ($item->get_type() == 'line_item') {
@dhirenpatel22
dhirenpatel22 / hide-category-widget.php
Last active February 14, 2020 20:32
Hide categories from WordPress category widget
<?php
//Hide categories from WordPress category widget
function exclude_widget_categories($args){
$exclude = "1,4,8,57,80";
$args["exclude"] = $exclude;
return $args;
}
add_filter("widget_categories_args","exclude_widget_categories");
?>
@dhirenpatel22
dhirenpatel22 / acf-wp-search.php
Created September 20, 2019 11:33
Add ACF in default WordPress Search
<?php
// Define list of ACF fields you want to search through - do NOT include taxonomies here
function list_searcheable_acf(){
$list_searcheable_acf = array(
"main_title",
"buttons",
"section_title",
"policies",
"latest_press",
@dhirenpatel22
dhirenpatel22 / browser-specific-class.js
Last active September 16, 2019 13:37
Add Browser Specific Class to body
//IE-10
if (jQuery.browser.msie && jQuery.browser.version == 10) {
jQuery("html").addClass("ie10");
}
// IE 11
if(navigator.userAgent.match(/Trident.*rv:11\./)) {
jQuery('body').addClass('ie11');
}
@dhirenpatel22
dhirenpatel22 / console-print.php
Created August 21, 2019 12:07
Print PHP array in console
<?php echo "<script>console.log('" . json_encode($links) . "');</script>"; ?>
@dhirenpatel22
dhirenpatel22 / search-shortcode.php
Created August 20, 2019 10:38
Add shortcode for search form in WordPress
<?php
/*
* Add a shortcode for search form in WordPress
* @url
*/
function search_form_shortcode( ) {
get_search_form( );
}
add_shortcode('search_form', 'search_form_shortcode');
@dhirenpatel22
dhirenpatel22 / disable-wow.js
Created July 22, 2019 13:32
Disable Wow JS in mobile view
if(isMobile || isTablet) {
$('.wow').addClass('wow-removed').removeClass('wow');
} else {
$('.wow-removed').addClass('wow').removeClass('wow-removed');
}
@dhirenpatel22
dhirenpatel22 / disable-animate.css
Created July 22, 2019 13:31
Disable Animation effects of Visual Composer in Mobile
@media screen and (max-width: 767px) {
.wpb_animate_when_almost_visible {
opacity: 1;
filter: alpha(opacity=100);
-webkit-animation: none;
-moz-animation: none;
-o-animation: none;
animation: none;
}
}
@dhirenpatel22
dhirenpatel22 / draft-parent.php
Last active June 13, 2019 04:08
Allow Draft Pages and Private Pages as Parent page
function filter_attributes_dropdown_pages_args($dropdown_args) {
$dropdown_args['post_status'] = array('publish','draft', 'private');
return $dropdown_args;
}
add_filter('page_attributes_dropdown_pages_args', __NAMESPACE__ . '\\filter_attributes_dropdown_pages_args', 100, 1);
add_filter( 'quick_edit_dropdown_pages_args', __NAMESPACE__ . '\\filter_attributes_dropdown_pages_args', 100, 1);
@dhirenpatel22
dhirenpatel22 / redirect.txt
Created June 3, 2019 18:08
301 Redirections in OpenCart
First:
Here’s an example of what you need to use for a 301 Redirect in OpenCart .htaccess file:
Redirect 301 /the-old-file.htm http://www.yourdomain.com/new-product-url?
or
Redirect 301 /the-old-file.htm http://www.yourdomain.com/new-product-url/?
Second:
just add below line in .htaccess file:
RewriteRule ^the-old-file.htm$ http://www.yourdomain.com/new-product-url [R=301,L]