Skip to content

Instantly share code, notes, and snippets.

View djcowan's full-sized avatar

djcowan djcowan

View GitHub Profile
$dashicons = array(
'dashicons-menu',
'dashicons-dashboard',
'dashicons-admin-site',
'dashicons-admin-media',
'dashicons-admin-page',
'dashicons-admin-comments',
'dashicons-admin-appearance',
'dashicons-admin-plugins',
'dashicons-admin-users',
@corsonr
corsonr / functions.php
Created September 28, 2016 08:33
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
@igorbenic
igorbenic / code.php
Last active February 21, 2024 21:32
How to create WordPress Metaboxes with OOP
<?php
class IBenic_WordPress_Metabox extends WordPressSettings {
protected $title = '';
protected $slug = '';
protected $post_types = array();
@igorbenic
igorbenic / abstract.php
Last active February 21, 2024 21:32
How to add custom WordPress Profile Fields
<?php
abstract class WordPressSettings {
/**
* ID of the settings
* @var string
*/
public $settings_id = '';
/**
* Tabs for the settings page
@maxkostinevich
maxkostinevich / functions.php
Last active February 11, 2023 20:03
WordPress: Export custom data to CSV
<?php
/**
* Export Data to CSV file
* Could be used in WordPress plugin or theme
*/
// A sample link to Download CSV, could be placed somewhere in plugin settings page
?>
<a href="<?php echo admin_url( 'admin.php?page=myplugin-settings-page' ) ?>&action=download_csv&_wpnonce=<?php echo wp_create_nonce( 'download_csv' )?>" class="page-title-action"><?php _e('Export to CSV','my-plugin-slug');?></a>
@bfncs
bfncs / README.md
Last active May 25, 2016 01:34
Demo: Different page transitions based on clicked anchor with smoothState.js

Demo: Different page transitions based on clicked anchor with smoothState.js

This demo shows how to switch transitions based on initiating link with smoothState.js. This solution has been inspired by @pudgereyem's comment on smoothState.js #143.

You can view the demo here.

The demo implements a crude idea of viewports that are horizontally aligned to determine the needed animation: every anchor has a numeric data-target paramter that represents the needed viewport while every scene element provides a numeric data-viewport parameter that reprents the current viewport. If the viewport requested for the clicked target is larger then the current viewport, the scene element is moved to the left, else to the right.

The logic to determine the wanted ani

@mattclements
mattclements / function.php
Last active June 12, 2024 00:06
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@anderly
anderly / woocommerce-add-custom-product-data-tab.php
Last active June 8, 2023 20:30
WooCommerce - Add Custom Product Data Tab
// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'my_text_domain' ),
'target' => 'my_custom_product_data',
);
return $product_data_tabs;
}
@om4james
om4james / woocommerce-shop-archives.php
Created May 1, 2015 04:03
WooCommerce wrap product images in the loop (shop/archive pages)
<?php
/**
* Shop/archives: wrap the product image/thumbnail in a div.
*
* The product image itself is hooked in at priority 10 using woocommerce_template_loop_product_thumbnail(),
* so priority 9 and 11 are used to open and close the div.
*/
add_action( 'woocommerce_before_shop_loop_item_title', function(){
echo '<div class="imagewrapper">';
@milanaryal
milanaryal / schema-org-structured-data-markup-using-microdata.html
Last active November 4, 2023 13:45
An example of how to mark up a HTML5 webpage using the schema.org schemas and microdata.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Site Title</title>
<link rel="stylesheet" href="/assets/css/style.min.css">