Skip to content

Instantly share code, notes, and snippets.

@igorbenic
igorbenic / cpt.php
Last active October 26, 2016 21:42
MailChimp WordPress Plugin with React: Settings & Custom Post Type | http://www.ibenic.com/mailchimp-wordpress-plugin-with-react-settings-custom-post-type
<?php
// Register Custom Post Type
function mwp_cpt_form() {
$labels = array(
'name' => _x( 'Forms', 'Post Type General Name', 'mwp' ),
'singular_name' => _x( 'Form', 'Post Type Singular Name', 'mwp' ),
'menu_name' => __( 'MWP Form', 'mwp' ),
'name_admin_bar' => __( 'Form', 'mwp' ),
@igorbenic
igorbenic / class.php
Last active November 2, 2016 22:55
MailChimp WordPress Plugin with React: Metabox & MailChimp Lists | http://www.ibenic.com/mailchimp-wordpress-plugin-with-react-metabox-mailchimp-lists
<?php
// Class MWP
/**
* Includes that are essential for this plugin
*/
public function includes(){
/** Core **/
@igorbenic
igorbenic / form.php
Last active November 24, 2016 14:45
MailChimp WordPress Plugin with React: The Form and Form Submission | http://www.ibenic.com/mailchimp-wordpress-plugin-with-react-form-subscription
<?php
/**
* Functions for handling everything about the forms
*/
/**
* Add Form error
* @param numeric $form_id POST ID of the form
* @param string $message Message
@igorbenic
igorbenic / forms.php
Last active November 17, 2016 19:14
MailChimp WordPress Plugin with React: MailChimp Widget | http://www.ibenic.com/mailchimp-wordpress-plugin-react-mailchimp-widget
<?php
/**
* Get forms from database
* @return array Array of Form Post Types
*/
function mwp_get_all_forms() {
$args = array(
'post_type' => 'mwp_form',
@igorbenic
igorbenic / enqueue.php
Last active November 24, 2016 16:56
MailChimp WordPress Plugin with React: React & AJAX | www.ibenic.com/mailchimp-wordpress-plugin-with-react-ajax-react
<?php
// wp-mailchimp-plugin.php
/**
* Enqueueing the scripts needed for MWP
* @return void
*/
public function enqueue() {
@igorbenic
igorbenic / array.php
Last active October 22, 2022 13:47
How to use the Starter Content in your WordPress Theme | http://www.ibenic.com/create-starter-content-wordpress-theme/
<?php
add_theme_support( 'starter-content', array(
// Content Section for Widgets
'widgets' => array(
// Sidebar
'sidebar-1' => array(
// Widget ID
'my_text' => array(
// Widget $id -> set when creating a Widget Class
@igorbenic
igorbenic / control.css
Last active January 14, 2019 21:15
WordPress Customizer Flexible List Control | http://www.ibenic.com/wordpress-customizer-flexible-list-control
.removeInput {
position: absolute;
right: 15px;
z-index: 999;
background-color: white;
display: block;
border-radius: 10px;
font-size: 10px;
line-height: 20px;
width: 20px;
@igorbenic
igorbenic / plugin.css
Last active February 10, 2021 09:17
How to Create a WordPress Rating Plugin for Your Content | http://www.ibenic.com/wordpress-rating-plugin-content
#contentRating {
position: fixed;
bottom:0;
right: 10px;
overflow: hidden;
text-align: center;
}
#toggleRating {
background:#333;
@igorbenic
igorbenic / plugin.php
Last active February 3, 2020 09:22
Controlling BuddyPress Private Messages
<?php
/**
* Plugin Name: Control Private Messages in BuddyPress
* Author: Igor Benic
* Author URI: http://www.ibenic.com
* Version: 1.0
*/
if( ! defined( 'ABSPATH' ) ) {
@igorbenic
igorbenic / hook.php
Created January 26, 2017 12:31
WooCommerce Stock Management with other Services | http://www.ibenic.com/woocommerce-stock-management-services
<?php
// woocommerce/includes/abstracts/abstract-wc-product.php
/**
* Returns number of items available for sale.
*
* @return int
*/
public function get_stock_quantity() {