Skip to content

Instantly share code, notes, and snippets.

View sabbiseaan's full-sized avatar
🕷️
I may be slow to respond.

sabbiseaan

🕷️
I may be slow to respond.
View GitHub Profile
<?php
$terms = get_terms('publicationyear','order=ASC');
//
function cmp($a, $b) {
return $b < $a;
}
usort($terms, "cmp");
@sabbiseaan
sabbiseaan / wp_pag.php
Created December 22, 2017 10:19 — forked from merli129/wp_pag.php
Wordpress Pagination
<?php
/**
* WordPress Bootstrap Pagination
*/
function wp_bootstrap_pagination( $args = array() ) {
$defaults = array(
'range' => 4,
'custom_query' => FALSE,
'previous_string' => __( 'Previous', 'text-domain' ),
@sabbiseaan
sabbiseaan / wp-comments
Created February 15, 2018 11:43 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
@sabbiseaan
sabbiseaan / repeatable-fields-metabox.php
Created May 12, 2018 11:11 — forked from helen/repeatable-fields-metabox.php
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@sabbiseaan
sabbiseaan / wp-chosen-tax-metabox.php
Created May 12, 2018 11:13 — forked from helen/wp-chosen-tax-metabox.php
Use Chosen for a replacement WordPress taxonomy metabox
<?php
/**
* WordPress Chosen Taxonomy Metabox
* Author: Helen Hou-Sandi
*
* Use Chosen for a replacement taxonomy metabox in WordPress
* Useful for taxonomies that aren't changed much on the fly and are
* non-hierarchical in nature, as Chosen is for flat selection only.
* You can always use the taxonomy admin screen to add/edit taxonomy terms.
* Categories need slightly different treatment from the rest in order to
<?php
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
add_meta_box( 'repeatable-fields', 'Audio Playlist', 'repeatable_meta_box_display', 'post', 'normal', 'high');
}
function repeatable_meta_box_display() {
global $post;
@sabbiseaan
sabbiseaan / wordpress
Created May 12, 2018 11:24
Repeated sortable metabox
<?php
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
add_meta_box( 'repeatable-fields', 'Product List', 'repeatable_meta_box_display', 'post', 'normal', 'high');
}
function get_product($value, $isHidden = false) {
return '
@sabbiseaan
sabbiseaan / widget.php
Created May 12, 2018 13:46 — forked from drrobotnik/widget.php
widget w/repeater field
<?php
class Nama_Widget_Classes extends WP_Widget {
/*--------------------------------------------------*/
/* Constructor
/*--------------------------------------------------*/
/**
* Specifies the classname and description, instantiates the widget,
@sabbiseaan
sabbiseaan / wp-autoloader.php
Created May 14, 2018 09:08 — forked from drrobotnik/wp-autoloader.php
wp plugin autoloader
<?php /*
Plugin Name: WP Plugin Autoloader
Plugin URI: http://www.caavadesign.com
Description: Proposed usage of a WP autoloader
Version: 0.0.1
Author: Brandon Lavigne
*/
# Plugin Autoloader
private function generate_icon_array() {
$icons = get_option( 'fa_icons' );
if ( ! $icons ) {
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before\s+{\s*content:\s*"(.+)";\s+}/';
$subject = file_get_contents( FA_DIR . 'css/font-awesome/css/font-awesome.css' );
preg_match_all( $pattern, $subject, $matches, PREG_SET_ORDER );
$icons = array();
foreach ( $matches as $match ) {
$icons[] = array( 'css' => $match[2], 'class' => stripslashes( $match[1] ) );
}