Skip to content

Instantly share code, notes, and snippets.

@igorbenic
igorbenic / edit.js
Last active November 6, 2019 14:32
Gutenberg Components: ServerSideRender https://ibenic.com/gutenberg-components-server-side-render
/**
* WordPress dependencies
* https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/archives/edit.js
*/
// ... hidden code for tutorial purposes
import ServerSideRender from '@wordpress/server-side-render';
export default function ArchivesEdit( { attributes, setAttributes } ) {
const { showPostCounts, displayAsDropdown } = attributes;
@igorbenic
igorbenic / functions-2.php
Last active July 31, 2022 22:26
How to Move Payments on WooCommerce Checkout | https://www.ibenic.com/move-payments-woocommerce-checkout
<?php
/**
* Adding the payment fragment to the WC order review AJAX response
*/
add_filter( 'woocommerce_update_order_review_fragments', 'my_custom_payment_fragment' );
/**
* Adding our payment gateways to the fragment #checkout_payments so that this HTML is replaced with the updated one.
*/
function my_custom_payment_fragment( $fragments ) {
@igorbenic
igorbenic / Login.js
Last active September 5, 2019 09:10
Headless WordPress: Logging with Google and JWT | https://www.ibenic.com/headless-wordpress-google-jwt
import React from 'react';
import { TextControl, Button, Notice } from '@wordpress/components';
import LoginGoogle from './login/LoginGoogle'; //Adding Google Component
const axios = require('axios');
class Login extends React.Component {
constructor( props ) {
super( props );
// ... previous bindings are here.
// ...
.components-drop-zone__provider {
min-height: 100px;
height: auto;
width: 100%;
position: relative;
padding: 1em;
text-align: center;
background: rgba( 0, 0, 0, 0.05 );
// ...
import Dashboard from './components/Dashboard';
import AppNotices from './components/AppNotices';
import '@wordpress/notices';
function App() {
// ...
return (
<div className="App container">
/**
* Showing the general Profile view
*/
function Profile( { user }) {
return <div className="jumbotron">
Welcome { user.nickname }
<p>I think your name is { user.first_name } { user.last_name}</p>
</div>;
}
@import '~bootstrap/scss/bootstrap.scss';
@igorbenic
igorbenic / plugin-2.php
Last active February 21, 2024 21:34
How to create a Custom WooCommerce Product Type | https://www.ibenic.com/custom-woocommerce-product-type
<?php
// ...
class WC_Product_Type_Plugin {
/**
* Build the instance
*/
public function __construct() {
@igorbenic
igorbenic / App.js
Last active February 16, 2022 09:58
Gutenberg Components: Form Token Field (Tags Field) | https://www.ibenic.com/gutenberg-components-form-token-field
import MyFormTokenField from './components/FormTokenField';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
import { Button, Modal } from '@wordpress/components';
import { withState } from '@wordpress/compose';
const MyModal = withState( {
isOpen: false,
} )( ( { isOpen, setState } ) => (
<div>
<Button isDefault onClick={ () => setState( { isOpen: true } ) }>Open Modal</Button>
{ isOpen && (
<Modal