Skip to content

Instantly share code, notes, and snippets.

import { addFilter, addAction } from '@wordpress/hooks';
import {Button } from '@wordpress/components'
addFilter( 'WPTReactPluginTestButtonText', 'WPRactPluginTestHook', (arg )=>{
return arg + ' Please'
}, 10 )
addFilter( 'WPTReactPluginTestButtonText', 'WPRactPluginTestHook', (arg)=>{
return arg + ' Here'
}, 9 )
@codearryaas
codearryaas / index.js
Created August 7, 2020 16:35
Start Point for react.
import { render } from '@wordpress/element'
import domReady from '@wordpress/dom-ready';
const App = () => {
return <>Welcome to WP react Tuts</>
}
domReady(function () {
if ('undefined' !== typeof document.getElementById('wp-react-plugin-test-app') && null !== document.getElementById('wp-react-plugin-test-app')) {
render(<App />, document.getElementById('wp-react-plugin-test-app'));
@codearryaas
codearryaas / wp-react-plugin-test-addon-const.php
Last active August 7, 2020 15:59
WP React Plugin Test Addon Files
<?php
/**
* Plugin Name: WP React Plugin Test Addon
* Plugin URI: https://racase.com.np/
* Description: A test plugin addon to teach React on WordPress.
* Version: 1.0.0
* Author: Rakesh Lawaju
* Author URI: https://racase.com.np/
* Text Domain: wp-react-plugin-test
* Domain Path: /i18n/languages/
@codearryaas
codearryaas / wp-react-plugin-test-add-scripts.php
Last active August 8, 2020 04:25
Steps to create wp-react-plugin-test.php
<?php
/**
* Plugin Name: WP React Plugin Test
* Plugin URI: https://racase.com.np/
* Description: A test pluing to teach React on WordPress
* Version: 1.0.0
* Author: Rakesh Lawaju
* Author URI: https://racase.com.np/
* Text Domain: wp-react-plugin-test
* Domain Path: /i18n/languages/
@codearryaas
codearryaas / webpack.config.js
Created July 31, 2020 15:57
wp-react-plugin-test - webpack.config.js - step 1
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
const path = require('path');
module.exports = {
...defaultConfig,
entry: {
'admin': [
'./app/src/admin/index.js'
@codearryaas
codearryaas / functions.php
Created November 21, 2019 16:25
WordPress: Remove admin bar in front-end: 3
function your_theme_admin_bar(){
global $post;
if ( 231 === $post->ID ) {
return false;
}
}
add_filter( 'show_admin_bar' , 'your_theme_admin_bar');
@codearryaas
codearryaas / functions.php
Created November 21, 2019 16:10
WordPress: Remove admin bar in front-end: Part 2
function your_theme_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'your_theme_admin_bar');
@codearryaas
codearryaas / functions.php
Created November 21, 2019 16:05
WordPress: Remove admin bar in front-end: Part 1
add_filter( 'show_admin_bar', '__return_false' );
@codearryaas
codearryaas / detect-ios.js
Created November 17, 2019 17:00
JavaScript: How to detect if device is iOS?
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if (isIOS) {
console.log('This is a IOS device');
} else {
console.log('This is Not a IOS device');
}
@codearryaas
codearryaas / stripe-checkout.html
Created September 5, 2016 05:40 — forked from ziadoz/stripe-checkout.html
Custom Stripe Checkout Button
<form action="." method="post">
<noscript>You must <a href="http://www.enable-javascript.com" target="_blank">enable JavaScript</a> in your web browser in order to pay via Stripe.</noscript>
<input
type="submit"
value="Pay with Card"
data-key="PUBLISHABLE STRIPE KEY"
data-amount="500"
data-currency="cad"
data-name="Example Company Inc"