Skip to content

Instantly share code, notes, and snippets.

Dinesh Kesarwani cyberwani

View GitHub Profile
cyberwani / Youtube_Regex_Grab_Video-Playlist_ID_With_Time.php Best regex pattern to get youtube video/playlist id with/without time from any youtube link and generate embed code. This regex works with 1) youtube & 2) http/https 3) with/without www.
View Youtube_Regex_Grab_Video-Playlist_ID_With_Time.php
* @gist Regex to get youtube video/playlist id with/without time & generate embed code
* @license UNLICENSE (
$youtube_url = array(
cyberwani / .editorconfig
Created Feb 17, 2020 — forked from salcode/.editorconfig
WordPress .editorconfig - modified version of the WordPress coding standards
View .editorconfig
# EditorConfig helps keep your project formatting consistent.
# See
# This is a modified version of the WordPress coding standards.
# Author: Sal Ferrarello (@salcode)
# You can download this file directly
# to your project from the command-line with
cyberwani / sendmail in wamp
Created Feb 11, 2020 — forked from abdullahbutt/sendmail in wamp
how to send email from wamp using sendmail
View sendmail in wamp
Install Fake Sendmail ( Then configure C:\wamp\sendmail\sendmail.ini:
The above will work against a Gmail account. And then configure php.ini:
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Now, restart Apache, and that is basically all you need to do.
cyberwani / is_localhost
Created Feb 10, 2020 — forked from troutacular/is_localhost
PHP - Check if localhost
View is_localhost
// Check if we are in a local environment
function is_localhost() {
// set the array for testing the local environment
$whitelist = array( '', '::1' );
// check if the server is in the array
if ( in_array( $_SERVER['REMOTE_ADDR'], $whitelist ) ) {
cyberwani / sample-admin-notice.php
Created Jan 8, 2020 — forked from glueckpress/sample-admin-notice.php
[WordPress] Sample Admin Notices
View sample-admin-notice.php
defined( 'ABSPATH' ) or die( 'Poop.' );
* Plugin Name: _Sample Admin Notice
* Description: Displays a sample admin notice once for admins. (Requires PHP 5.3+.)
* Version: 0.1
* Author: Caspar Hübinger
* Plugin URI:
* Author URI:
* License: GNU General Public License v3
cyberwani / gist:13b58596ba7782a7d7aac8b55c534452
Created Dec 10, 2019 — forked from danielbachhuber/gist:7684646
How to integrate WordPress Core updates with your custom Plugin or Theme
View gist:13b58596ba7782a7d7aac8b55c534452
* How to integrate WordPress Core updates with your custom Plugin or Theme
* Filter the `update_plugins` transient to report your plugin as out of date.
* Themes have a similar transient you can filter.
add_filter( 'site_transient_update_plugins', 'wprp_extend_filter_update_plugins' );
add_filter( 'transient_update_plugins', 'wprp_extend_filter_update_plugins' );
function wprp_extend_filter_update_plugins( $update_plugins ) {
cyberwani / installed-plugin-details.php
Created Dec 10, 2019 — forked from bradyvercher/installed-plugin-details.php
WordPress Plugin: Show a "Details" link for installed plugins to view information from the plugin directory.
View installed-plugin-details.php
* Plugin Name: Installed Plugin Details
* Description: Show a "Details" link for installed plugins to view information from the plugin directory.
* Version: 1.0.0
* Author: Blazer Six
* Author URI:
* License: GPL-2.0+
* License URI:
cyberwani / upload-a-file.MD
Created Dec 4, 2019 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API
View upload-a-file.MD

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

cyberwani / gist:47005097c9e74100bfab92bb72dc6d12
Created Oct 24, 2019 — forked from mikejolley/gist:1604009
WooCommerce - Add a special field to the checkout, order emails and user/order meta
View gist:47005097c9e74100bfab92bb72dc6d12
* Add the field to the checkout
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
View WORDPRESS: Base64 Image to Wordpress Uploads directory
function tattoo_submit() {
if ( isset( $_POST['addtattoo'] ) ) {
$title = 'tattoo';
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
$img_type = 'jpeg';
You can’t perform that action at this time.