Skip to content

Instantly share code, notes, and snippets.

Igor Benić igorbenic

Block or report user

Report or block igorbenic

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 edit.js
/**
* 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;
View functions-2.php
<?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 Sep 5, 2019
Headless WordPress: Logging with Google and JWT | https://www.ibenic.com/headless-wordpress-google-jwt
View Login.js
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.
View App.scss
// ...
.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 );
View App.js
// ...
import Dashboard from './components/Dashboard';
import AppNotices from './components/AppNotices';
import '@wordpress/notices';
function App() {
// ...
return (
<div className="App container">
View dashboard-2.js
/**
* 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>;
}
View App.scss
@import '~bootstrap/scss/bootstrap.scss';
@igorbenic
igorbenic / plugin-2.php
Last active May 29, 2019
How to create a Custom WooCommerce Product Type | https://www.ibenic.com/custom-woocommerce-product-type
View plugin-2.php
<?php
// ...
class WC_Product_Type_Plugin {
/**
* Build the instance
*/
public function __construct() {
@igorbenic
igorbenic / App.js
Last active Mar 29, 2019
Gutenberg Components: Form Token Field (Tags Field) | https://www.ibenic.com/gutenberg-components-form-token-field
View App.js
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" />
View example.js
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
You can’t perform that action at this time.