Skip to content

Instantly share code, notes, and snippets.

@igorbenic
igorbenic / class.php
Last active December 19, 2019 13:52
Extending Elementor: Custom Button Field & Skin | https://www.ibenic.com/extending-elementor-custom-button-field-skin
<?php
add_action( 'elementor/widget/before_render_content', 'custom_render_button' );
/**
* Adding a new attribute to our button
*
* @param \Elementor\Widget_Base $button
*/
function custom_render_button( $button ) {
@igorbenic
igorbenic / abstract.php
Last active December 18, 2017 12:38
How to enable WordPress Extensions in your Plugin | https://www.ibenic.com/wordpress-extensions-plugin
<?php
/**
* Abstract Extension Class from which all others should be done
*/
if( ! defined( 'ABSPATH' ) ) {
return;
}
@igorbenic
igorbenic / api.php
Last active February 20, 2025 05:36
How to use PHP Namespaces in WordPress Plugins | https://www.ibenic.com/php-namespaces-wordpress-plugins
<?php
namespace My_Plugin\API;
/**
* API Functions
*/
if( ! defined( 'ABSPATH' ) ) {
return;
}
@igorbenic
igorbenic / app-1.js
Last active February 21, 2024 21:34
Using React to Render Content from WP REST API | https://ibenic.com/react-render-content-wp-rest-api
class App extends React.Component {
render() {
return (
bla
)
}
}
const element = <App />
@igorbenic
igorbenic / package.json
Last active January 8, 2021 10:44
Powering the WordPress Search with React and REST API | https://www.ibenic.com/wordpress-react-search
{
"name": "wordpress-search-react",
"version": "1.0.0",
"description": "Powering WordPress Search with React and REST API",
"main": "assets/js/public.js",
"scripts": {
"build": "webpack",
"watch": "webpack --watch",
"test": "echo \"Error: no test specified\" && exit 1"
},
@igorbenic
igorbenic / block.js
Last active April 22, 2022 22:25
Gutenberg Select Post - Duplicate Controls
/**
* BLOCK: my-block
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './style.scss';
import './editor.scss';
@igorbenic
igorbenic / block-atts.js
Last active June 16, 2022 00:44
How to create a Gutenberg Block for Displaying a Post | https://www.ibenic.com/create-gutenberg-block-displaying-post/
registerBlockType( 'cgb/block-guten-load-post', {
// ...
keywords: [
__( 'my-block — CGB Block' ),
__( 'CGB Example' ),
__( 'create-guten-block' ),
],
attributes: {
content: {
@igorbenic
igorbenic / button.php
Last active February 23, 2018 14:46
Additional WooCommerce Settings Page for a Payment Gateway | https://www.ibenic.com/additional-woocommerce-settings-page-for-a-payment-gateway
<?php
class WC_Custom_PayPal extends WC_Gateway_Paypal {
/**
* Screen button Field
*/
public function generate_screen_button_html( $key, $value ) {
?>
<tr valign="top">
<td colspan="2" class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
@igorbenic
igorbenic / metaboxes.php
Last active March 19, 2018 14:56
WP Dispencary
<?php
/**
* The file that defines the metaboxes used by the various custom post types
*
* @link https://www.wpdispensary.com
* @since 1.0.0
*
* @package WP_Dispensary
* @subpackage WP_Dispensary/admin/post-types
*/
@igorbenic
igorbenic / cpt.php
Last active March 21, 2018 14:10
Building a Quiz with React and WordPress REST API: CPT and REST API Routes | https://ibenic.com/quiz-react-wordpress-rest-api-routes
<?php
// ... Rest of the code
class WPQR {
// ... Rest of the code
/**
* Load everything