Skip to content

Instantly share code, notes, and snippets.

Avatar
🚩
You are here!

Sanzeeb Aryal sanzeeb3

🚩
You are here!
View GitHub Profile
@sanzeeb3
sanzeeb3 / covid-19.php
Last active Mar 27, 2020
Display covid-19 data with the shortcode.
View covid-19.php
/**
* Display covid-19 data with the shortcode.
*
* Usage [covid19_data country="all"]
*
* @see http://sanjeebaryal.com.np/display-covid-19-data-in-your-site-without-plugin/.
*
* @param array $atts Attributes to the shortcode.
*
* @return string.
@sanzeeb3
sanzeeb3 / wpvulndb-api-request.php
Last active Aug 13, 2019
Get all of the vulnerabilities that affect a particular plugin
View wpvulndb-api-request.php
<?php
/**
* Get all of the vulnerabilities that affect a particular plugin
* @see https://wpvulndb.com/api
*
* @return void.
*/
function wpvul_api_call() {
$api_call = 'https://wpvulndb.com/api/v3/plugins/plugin-slug';
$header = array(
@sanzeeb3
sanzeeb3 / hide_admin_notices.php
Last active Jul 22, 2019
Hides all admin notices in WooCommerce settings page.
View hide_admin_notices.php
<?php
add_action( 'admin_print_scripts', 'hide_admin_notices' );
function hide_admin_notices() {
global $wp_filter;
if ( empty( $_REQUEST['page'] ) || 'wc-settings' !== $_REQUEST['page'] ) {
return;
}
foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $wp_notice ) {
@sanzeeb3
sanzeeb3 / custom-tab.php
Last active May 17, 2019
Add additional custom tab in WooCommerce myaccount page
View custom-tab.php
<?php
/**
*
* Class for adding new custom tab in WooCommerce myaccount page.
*
* @class WooCommerce_Myaccount_Tab
*/
Class WooCommerce_Myaccount_Tab {
/**
View flush-cache.php
<?php
/**
* Flush cache created by some popular WordPress plugins in a specific page.
*
* @return void.
*/
function sa_flush_cache() {
$post_id = get_the_ID();
// Flush already set cache by w3total cache plugin.
@sanzeeb3
sanzeeb3 / serve-side-block.js
Created May 4, 2019 — forked from Shelob9/serve-side-block.js
Example Gutenberg block with server-side rendering. Gutenberg edit() block creates interface. Gutenberg saves settings automatically, the PHP function passed as `render_callback` to `register_block_type` is used to create HTML for front-end rendering of block.
View serve-side-block.js
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const el = wp.element.createElement;
registerBlockType( 'hiRoy/serverSide', {
title: __( 'Server Side Block', 'text-domain' ),
icon: 'networking',
category: 'common',
attributes: {
View README.md

Custom Gutenberg Block

This is a basic custom Gutenberg block. Files explained below.

  • block.js — We register Custom Gutenberg block here.
  • editor.css _ Block CSS for the editor.
  • style.css — Block CSS for the front end.
  • index.php — Enqueue block's assets for editor and the front end.
@sanzeeb3
sanzeeb3 / learning.js
Created Dec 27, 2018
Self Learning REACT JS
View learning.js
let a = 30;
console.log(a);
if( true ) {
let b = 40;
}
console.log(b); // Undefined.
@sanzeeb3
sanzeeb3 / all-posts.php
Last active Feb 13, 2019
List all posts in a specific page?
View all-posts.php
function fu_list_all_posts() {
global $post;
// Return if the current post type is not page or the page is not blog.
if( $post->post_name !== 'blog' || $post->post_type !== 'page' ) {
return;
}
// Get all posts.
$all_posts = get_posts();
@sanzeeb3
sanzeeb3 / functions.php
Created Sep 12, 2018
Make 100% width for only wedocs documentation page
View functions.php
add_action( 'wp_footer', 'add_wedocs_100_percent' );
function add_wedocs_100_percent() {
?>
<script>
jQuery('.wedocs-single-wrap').parent().parent().css("width","100%");
</script>
<?php
}
You can’t perform that action at this time.