Skip to content

Instantly share code, notes, and snippets.

View ashokdhaduk's full-sized avatar
♻️
Full Stack Developer

Ashok ashokdhaduk

♻️
Full Stack Developer
View GitHub Profile
@ashokdhaduk
ashokdhaduk / Media queries css
Last active June 19, 2019 06:02
Media queries
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
@ashokdhaduk
ashokdhaduk / function.php
Created May 28, 2018 04:45 — forked from tanmay27vats/function.php
Show "Stock Out" if all variations are stock out.
function wc_show_variable_product_stock_out()
{
global $product;
if( $product->is_type( 'variable' ) )
{
$args = array(
'post_type' => 'product_variation',
'post_status' => array( 'private', 'publish' ),
'numberposts' => -1,
'orderby' => 'menu_order',
@ashokdhaduk
ashokdhaduk / function.php
Created May 28, 2018 04:44 — forked from tanmay27vats/function.php
Enable SVG support in Wordpress. How to upload/enable SVG images on wordpress.
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
function fix_svg_thumb_display() {
echo '<style type="text/css">
td.media-icon img[src$=".svg"], img[src$=".svg"].attachment-post-thumbnail {
width: 100% !important;
@ashokdhaduk
ashokdhaduk / function.php
Created May 28, 2018 04:44 — forked from tanmay27vats/function.php
Get product's default variation ID, variation price or variation object without plugin.
function tv_find_matching_product_variation( $product, $attributes )
{
foreach( $attributes as $key => $value )
{
if( strpos( $key, 'attribute_' ) === 0 )
{
continue;
}
unset( $attributes[ $key ] );
@ashokdhaduk
ashokdhaduk / function.php
Created May 28, 2018 04:44 — forked from tanmay27vats/function.php
WordPress: Rename the default label “Posts” to “News” OR something else...
function tv_change_post_label()
{
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News Tags';
}
function tv_change_post_object()
@ashokdhaduk
ashokdhaduk / .htaccess
Created May 28, 2018 04:44 — forked from tanmay27vats/.htaccess
Wordpress: How to use live images on localhost?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# custom rules for loading server images or any other uploaded media files locally.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^localhost$
RewriteRule ^.*/uploads/(.*)$ http://livesiteurl.com/wp-content/uploads/$1 [L,R=301,NC]
# default WordPress rules
@ashokdhaduk
ashokdhaduk / function.php
Created May 28, 2018 04:44 — forked from tanmay27vats/function.php
Woocommerce: Remove Cross Sell From Cart Page
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
@ashokdhaduk
ashokdhaduk / wizard.php
Created May 28, 2018 04:43 — forked from tanmay27vats/wizard.php
Change collation to utf8 of all tables of database
$dbname=’db’; //your database name
$username=’userrname’; // your database user name
$password=’password’; //your database user password
$db = mysql_connect($dbname,$username,$password);
if (!$db) {
echo "Cannot connect to the database – incorrect details";
} else {
mysql_select_db(‘pm’);
$result = mysql_query(‘show tables’);
@ashokdhaduk
ashokdhaduk / function.php
Created May 28, 2018 04:43 — forked from tanmay27vats/function.php
How to upload local file on the FTP/SFTP server - PHP
// connect and login to FTP server
$ftp_server = "ftp.domain.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
//$ftp_conn = ftp_ssl_connect($ftp_server);// for SSL-FTP connection instead of ftp_connect
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$file = "local-file.jpg";
// upload file
if (ftp_put($ftp_conn, "server-file.jpg", $file, FTP_ASCII)) {
@ashokdhaduk
ashokdhaduk / PushNotifications.php
Created May 28, 2018 04:43 — forked from tanmay27vats/PushNotifications.php
Apple Push Notifications Service (APNS) in PHP
//$vHost = 'gateway.sandbox.push.apple.com';
$vHost = 'gateway.push.apple.com';
$vPort = 2195;
$vCert = APPPATH.'../assets/certificates/Certificates-Production.pem';
$vPassphrase = 'password to your pem file';
$vToken = $data['token'];
$vAlert = array(