Skip to content

Instantly share code, notes, and snippets.

View sharazghouri's full-sized avatar
🎯
Focusing

Sharaz Shahid sharazghouri

🎯
Focusing
View GitHub Profile
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
@sharazghouri
sharazghouri / gist:19ac267a82805bcc58f357faeb376068
Created August 29, 2020 10:54 — forked from mikejolley/gist:2176823
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
@sharazghouri
sharazghouri / jquery-phone-number-validation.js
Last active April 1, 2020 05:19
Phone number validation in jQuery with masking
//Only integer allowed
jQuery.fn.inputFilter = function(inputFilter) {
return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function() {
if (inputFilter(this.value)) {
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
this.oldSelectionEnd = this.selectionEnd;
} else if (this.hasOwnProperty("oldValue")) {
this.value = this.oldValue;
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
@sharazghouri
sharazghouri / Remove action hook with function name
Last active March 25, 2020 11:57
You can remove WordPress hooks action with function name. if you are not able to remove action using remove_action() core function.
<?php
function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) {
global $wp_filter;
// Take only filters on right hook name and priority
if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
return false;
}
// Loop on filters registered
foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) {
// Test if filter is an array ! (always for class/method)
.gform_wrapper {
form .gform_body .ginput_complex input[type=text] {
width:100% !important;
}
input, input[type=text], select, textarea {
width:100% !important;
@include box-sizing(border-box);
}
}
import { Button } from '@wordpress/components';
import { MediaUpload, MediaUploadCheck } from '@wordpress/editor';
const ALLOWED_MEDIA_TYPES = [ 'audio' ];
function MyMediaUploader() {
return (
// will check user have permission to upload media
<MediaUploadCheck>
<MediaUpload
@sharazghouri
sharazghouri / media-query.css
Created October 23, 2018 12:15 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@sharazghouri
sharazghouri / 0-links.md
Created February 18, 2018 14:44 — forked from Shelob9/0-links.md
Install create-guten-block and use it to create a plugin with a block (and optionally eject from cgb-scripts)
@sharazghouri
sharazghouri / README.md
Created January 16, 2018 06:05 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@sharazghouri
sharazghouri / my-corn.php
Created December 24, 2017 17:08
Cron task plugin ( event schedule when plugin active and unschedule when decactive [ use WP Crontrol to see scheduled event ] )
<?php
/*
Plugin Name: My WP-Cron Test
*/
//activation of job
register_activation_hook(__FILE__, 'my_activation');
add_action('hourly_job', 'do_hourly_job');