Skip to content

Instantly share code, notes, and snippets.

<?php
class KnowitTelltale
{
public function hooks(): void
{
add_action(
'rest_api_init',
\Closure::fromCallable([$this, 'registerRestRoutes'])
);
@ville6000
ville6000 / blocks.php
Last active May 29, 2020 12:51
blocks.php
<?php
public function allowed_block_types( $allowed_blocks, $post ) {
$blocks = [
'core/block' => [],
'core/template' => [],
'core/heading' => [],
'core/paragraph' => [],
'core/image' => [
'post_types' => [
@ville6000
ville6000 / sync_posts.php
Last active January 11, 2019 13:09
Copy and synchronize WordPress posts programmatically with Polylang
<?php
$pll = new PLL_Admin( PLL()->links_model );
$pll->add_filters();
$pll_pro = new Polylang_Pro();
$pll_pro->load_modules( $pll );
global $wpdb;
$post_type = 'your-post-type';
@ville6000
ville6000 / functions.php
Created January 8, 2019 10:23
WooCommerce remove product tabs
<?php
/**
* Remove product data tabs
*
* @param array $tabs Array of product tabs.
*
* @return array
*/
function theme_remove_product_tabs( $tabs ) {
unset( $tabs['description'] );
@ville6000
ville6000 / functions.php
Created January 7, 2019 14:03
Remove breadcrumbs from WooCommerce
<?php
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
@ville6000
ville6000 / functions.php
Created January 7, 2019 14:01
Remove WooCommerce product meta from single product page
<?php
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
@ville6000
ville6000 / functions.php
Created October 16, 2018 07:03
How to add fields to WooCommerce products general tab
<?php
add_action( 'woocommerce_product_options_general_product_data', 'add_my_custom_data' );
public function add_my_custom_data() {
global $post;
?>
<div class="options_group">
<?php
woocommerce_wp_text_input( [
@ville6000
ville6000 / functions.php
Last active November 26, 2018 01:44
Change Yoast SEO default image size
<?php
function theme_yoastseo_opengraph_image_size() {
return 'large';
}
add_filter( 'wpseo_opengraph_image_size', 'theme_yoastseo_opengraph_image_size', 10 );
function theme_yoastseo_twitter_image_size() {
return 'large';
@ville6000
ville6000 / mmarmy-org-streaks.js
Created June 6, 2018 11:29
MMArmy longest streaks
var record = {
loss: 0,
win: 0
};
var lastResult = false;
var currentStreak = 0;
jQuery('.record').find('tr').each(function(idx, el) {
if (idx > 0) {
@ville6000
ville6000 / mmarmy-org-record-breakdown.js
Created June 5, 2018 13:43
MMArmy record breakdown
var record = {};
jQuery('.record').find('tr').each(function(idx, el) {
var row = jQuery(el);
var key = (row.find('td:first-child').hasClass('win') || row.find('td:first-child').hasClass('winTitle')) ? 'wins' : 'losses';
var result = row.find('td').eq(5).text();
var result_key = 'ko';
if (idx > 0) {
if (result.indexOf('Decision') >= 0) {
result_key = 'decision';