Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sanzeeb3's full-sized avatar
🚩
You are here!

Sanzeeb Aryal sanzeeb3

🚩
You are here!
View GitHub Profile
@sanzeeb3
sanzeeb3 / functions.php
Created September 12, 2018 15:06
Make 100% width for only wedocs documentation page
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
}
@sanzeeb3
sanzeeb3 / learning.js
Created December 27, 2018 02:40
Self Learning REACT JS
let a = 30;
console.log(a);
if( true ) {
let b = 40;
}
console.log(b); // Undefined.
@sanzeeb3
sanzeeb3 / all-posts.php
Last active February 13, 2019 15:02
List all posts in a specific page?
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();

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 / serve-side-block.js
Created May 4, 2019 16:33 — 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.
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: {
<?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 / custom-tab.php
Last active May 17, 2019 04:01
Add additional custom tab in WooCommerce myaccount page
<?php
/**
*
* Class for adding new custom tab in WooCommerce myaccount page.
*
* @class WooCommerce_Myaccount_Tab
*/
Class WooCommerce_Myaccount_Tab {
/**
@sanzeeb3
sanzeeb3 / hide_admin_notices.php
Last active July 22, 2019 06:51
Hides all admin notices in WooCommerce settings page.
<?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 / wpvulndb-api-request.php
Last active August 13, 2019 04:14
Get all of the vulnerabilities that affect a particular plugin
<?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 / covid-19.php
Last active March 27, 2020 08:43
Display covid-19 data with the shortcode.
/**
* 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.