Skip to content

Instantly share code, notes, and snippets.

Dinesh Kesarwani cyberwani

Block or report user

Report or block cyberwani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View WORDPRESS: Base64 Image to Wordpress Uploads directory
<?php
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';
@cyberwani
cyberwani / wordpress-upload-base64.php
Created Sep 13, 2019 — forked from CasperSchultz/wordpress-upload-base64.php
Upload a base64 string as image to the WordPress media library
View wordpress-upload-base64.php
<?php
/**
* Save the image on the server.
*/
function save_image( $base64_img, $title ) {
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
@cyberwani
cyberwani / gist:f0987fd98acc65e4193f519344538bf0
Created Sep 8, 2019 — forked from rolinger/gist:d6500d65128db95f004041c2b636753a
PHP => FCM Push notification tutorial for Android and iOS
View gist:f0987fd98acc65e4193f519344538bf0
Below is a full tutorial on how to setup and use Googles Firebase push notification API for both Android and iOS. It is based on this
earlier implementation of Googles GCM method: https://gist.github.com/prime31/5675017 - FCM is the new method and GCM will eventually be
retired.
## THE BELOW METHOD IS THE NEWER FCM METHOD:
Register your app in the FCM Console: https://console.firebase.google.com (add project)
1. Click on the newly added project, in the upper left menu is the "Overview" and Gear Settings.
2. Click on the GEAR settings icon, and then on "Project Settings"
3. In the main screen, click on "Cloud Messaging"
@cyberwani
cyberwani / gist:34d769e29f8a4f71f6fa015ce5e32eb4
Created Sep 8, 2019 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
View gist:34d769e29f8a4f71f6fa015ce5e32eb4
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@cyberwani
cyberwani / PushNotifications.php
Created Sep 8, 2019 — forked from joashp/PushNotifications.php
Simple PHP script to send Android Push Notification, iOS Push Notification and Windows Phone 8 Push Notification
View PushNotifications.php
<?php
// Server file
class PushNotifications {
// (Android)API access key from Google API's Console.
private static $API_ACCESS_KEY = 'AIzaSyDG3fYAj1uW7VB-wejaMJyJXiO5JagAsYI';
// (iOS) Private key's passphrase.
private static $passphrase = 'joashp';
// (Windows Phone 8) The name of our push channel.
private static $channelName = "joashp";
@cyberwani
cyberwani / babel.php
Created Sep 8, 2019 — forked from igorbenic/babel.php
How to create a WordPress Login Plugin with React | www.ibenic.com/create-wordpress-login-plugin-with-react
View babel.php
<?php
// ...
add_action('wp_footer', 'react_login_add_babel_script', 999);
function react_login_add_babel_script() {
?>
<script type="text/babel">
View get-theme-file-url-backwards-compatibility.php
<?php
if ( ! function_exists( 'get_theme_file_uri' ) ) {
function get_theme_file_uri( $file = '' ) {
$file = ltrim( $file, '/' );
if ( empty( $file ) ) {
$url = get_stylesheet_directory_uri();
} elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$url = get_stylesheet_directory_uri() . '/' . $file;
} else {
$url = get_template_directory_uri() . '/' . $file;
View wordpress-file-paths.php
File path for a pre WordPress 4.7 asset:
<img src="<?php echo get_template_directory_uri(); ?>/images/filename.png" />
File path for a WordPress 4.7 + asset:
<img src="<?php echo get_theme_file_uri( ‘/images/filename.png’ ); ?>" />
@cyberwani
cyberwani / functions.php
Created Aug 17, 2019 — forked from lukecav/functions.php
Get All orders IDs for a given product ID in WooCommerce
View functions.php
/**
* Get All orders IDs for a given product ID.
*
* @param integer $product_id (required)
* @param array $order_status (optional) Default is 'wc-completed'
*
* @return array
*/
function get_orders_ids_by_product_id( $product_id, $order_status = array( 'wc-completed' ) ){
global $wpdb;
@cyberwani
cyberwani / editorskit.php
Created Aug 8, 2019 — forked from phpbits/editorskit.php
Using EditorsKit Utility Classes Filter
View editorskit.php
<?php
/**
* Add Support for EditorsKit Plugin
*
* @package Jarvis
* @subpackage EditorsKit
* @author Jeffrey Carandang <jeffreycarandang.com>
* @link https://editorskit.com/
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
*/
You can’t perform that action at this time.