Skip to content

Instantly share code, notes, and snippets.

View cristianstan's full-sized avatar
🎯
Focusing

Cristian Stan cristianstan

🎯
Focusing
View GitHub Profile
@cristianstan
cristianstan / CMB2 repeatable fields.php
Created October 9, 2019 13:23
CMB2 repeatable fields.php
<?php
add_action( 'cmb2_admin_init', 'yourprefix_register_repeatable_group_field_metabox' );
/**
* Hook in and add a metabox to demonstrate repeatable grouped fields
*/
function yourprefix_register_repeatable_group_field_metabox() {
/**
* Repeatable Field Groups
@cristianstan
cristianstan / class-tgm-plugin-activation.php
Last active October 10, 2019 08:59 — forked from al5dy/class-tgm-plugin-activation.php
TGM 'Warning: sprintf(): Too few arguments...' bugfix
/**
* Sets install skin strings for each individual plugin.
*
* Checks to see if the automatic activation flag is set and uses the
* the proper strings accordingly.
*
* @since 2.2.0
*/
public function add_strings() {
if ( 'update' === $this->options['install_type'] ) {
@cristianstan
cristianstan / minicart not working on cart, checkout pages.php
Created February 13, 2019 11:34
Minicart not working on cart, checkout pages WooCommerce.php
<?php
add_filter( 'woocommerce_widget_cart_is_hidden', 'fuskowp_always_show_cart', 40, 0 );
function fuskowp_always_show_cart() {
return false;
}
@cristianstan
cristianstan / Welcome to the Gutenberg Editor.html
Created January 9, 2019 15:09
Welcome to the Gutenberg Editor
<!-- wp:cover {"url":"http://tijuana.modeltheme.com/wp-content/uploads/2018/11/roman_coliseum_evening-1.jpg","align":"wide","id":78} -->
<div class="wp-block-cover has-background-dim alignwide" style="background-image:url(http://tijuana.modeltheme.com/wp-content/uploads/2018/11/roman_coliseum_evening-1.jpg)"><p class="wp-block-cover-text">Of Mountains &amp; Printing Presses</p></div>
<!-- /wp:cover -->
<!-- wp:paragraph -->
<p>The goal of this new editor is to make adding rich content to WordPress simple and enjoyable. This whole post is composed of <em>pieces of content</em>???somewhat similar to LEGO bricks???that you can move around and interact with. Move your cursor around and you???ll notice the different blocks light up with outlines and arrows. Press the arrows to reposition blocks quickly, without fearing about losing things in the process of copying and pasting.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>What you are reading now is a <strong>text block</strong> the most basic block of all
@cristianstan
cristianstan / gutenberg-demo-content.html
Last active October 3, 2023 09:32
Gutenberg Demo Data for Testing Purposes - WordPress v5.0
<!-- wp:cover {"url":"https://cldup.com/Fz-ASbo2s3.jpg","align":"wide"} -->
<div class="wp-block-cover has-background-dim alignwide" style="background-image:url(https://cldup.com/Fz-ASbo2s3.jpg)"><p class="wp-block-cover-text">Of Mountains &amp; Printing Presses</p></div>
<!-- /wp:cover -->
<!-- wp:paragraph -->
<p>The goal of this new editor is to make adding rich content to WordPress simple and enjoyable. This whole post is composed of <em>pieces of content</em>—somewhat similar to LEGO bricks—that you can move around and interact with. Move your cursor around and you’ll notice the different blocks light up with outlines and arrows. Press the arrows to reposition blocks quickly, without fearing about losing things in the process of copying and pasting.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>What you are reading now is a <strong>text block</strong> the most basic block of all. The text block has its own controls to be moved freely around the post...</p>
@cristianstan
cristianstan / comments-example.php
Created December 5, 2018 15:02 — forked from chrisguitarguy/comments-example.php
How to add custom fields to WordPress comments
<?php
/*
Plugin Name: Add Extra Comment Fields
Plugin URI: http://pmg.co/category/wordpress
Description: An example of how to add, save and edit extra comment fields in WordPress
Version: n/a
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: MIT
*/
@cristianstan
cristianstan / WordPress Gutenberg-Styling-Custom-Fonts.php
Created October 25, 2018 11:56
WordPress Gutenberg-Styling-Custom-Fonts.php
<?php
/* 1. Gutenberg editor styling for frontend */
if (function_exists('the_gutenberg_project')) {
wp_enqueue_style( "rodberg-gutenberg-frontend", get_template_directory_uri().'/css/gutenberg-frontend.css' );
}
// 2. Add backend styles for Gutenberg.
add_action( 'enqueue_block_editor_assets', 'rodberg_add_gutenberg_assets' );
<?php
$cmb->add_field( array(
'name' => __( 'Postive numbers', 'theme-domain' ),
'desc' => __( 'Numbers only', 'msft-newscenter' ),
'id' => $prefix . 'number',
'type' => 'text',
'attributes' => array(
'type' => 'number',
'pattern' => '\d*',
@cristianstan
cristianstan / Visual comoposer with param_group
Created September 26, 2018 19:43 — forked from hasanm95/Visual comoposer with param_group
Create visual composer with param_group
//Backend visual composer add-on code
vc_map(array(
'name' => 'Accordions',
'base' => 'maxima_accordion',
'category' => 'Maxima',
'params' => array(
array(
'type' => 'textfield',
'name' => __('Title', 'rrf-maxima'),
@cristianstan
cristianstan / wordpress_while_loop.php
Created August 21, 2018 11:32 — forked from joedajigalo/wordpress_while_loop.php
Create a WordPress While Loop
<?php
/* Create a WordPress While Loop
-------------------------------------------------- */
$wordpress_loop_argument = array(
'post_type' => 'custom_post_type',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'ASC'
);