Skip to content

Instantly share code, notes, and snippets.

View widget-post-save.js
jQuery(document).ajaxSuccess(function(e, xhr, settings) {
var widget_id_base = 'mywidget';
if(settings.data.search('action=save-widget') != -1 && settings.data.search('id_base=' + widget_id_base) != -1) {
alert('yay!');
// do other stuff
}
});
View link_inside_archive_and_category_widget.php
View shortcodes-exist.php
<?php
/**
* Loop through an array of shortcodes and check for their existence
* @author Gabe Shackle <gabe@hereswhatidid.com>
* @param array $shortcodes An array of shortcode strings
* @param boolean $match_all Whether to check for the existence of ALL the shortcodes, or just ANY of them
* @return mixed The results will either be an array of the found shortcodes or boolean false
*/
function shortcodes_exist( $shortcodes = array(), $match_all = false ) {
$found_shortcodes = array();
View customizer-controls-40
function prefix_customizer_register( $wp_customize ) {
$wp_customize->add_panel( 'panel_id', array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Example Panel', 'textdomain' ),
'description' => __( 'Description of what this panel does.', 'textdomain' ),
) );
View Custom language menu for WPML.php
/* Pierre de la Martinière
*
* display all languages avalaible for a Wordpress Theme using WPML
* directly echo something like "en fr it ru" ...
*
* more info at http://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/
*
*/
//[wpml_lang_selector]
View supposition.js
/*
* Supposition v0.3a - an optional enhancer for Superfish jQuery menu widget
*
* Copyright (c) 2013 Joel Birch - based on work by Jesse Klaasse - credit goes largely to him.
* Special thanks to Karl Swedberg for valuable input.
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
View dimox_breadcrumbs.php
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2015.09.14
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
@krishna19
krishna19 / expanded_alowed_tags
Created Oct 25, 2015 — forked from adamsilverstein/expanded_alowed_tags
WordPress expanded allowed tags for wp_kses with iframe, forms, etc.
View expanded_alowed_tags
function expanded_alowed_tags() {
$my_allowed = wp_kses_allowed_html( 'post' );
// iframe
$my_allowed['iframe'] = array(
'src' => array(),
'height' => array(),
'width' => array(),
'frameborder' => array(),
'allowfullscreen' => array(),
);
@krishna19
krishna19 / gist:07e1e79aa1d742dc4c32
Created Nov 1, 2015 — forked from mikejolley/gist:2044101
WooCommerce - Show number of items in cart and total
View gist:07e1e79aa1d742dc4c32
<a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@krishna19
krishna19 / changes_to_functions.php
Created Nov 22, 2015 — forked from carlynorama/changes_to_functions.php
Create a more tag when it doesn't exist in a Wordpress Twenty Eleven Theme
View changes_to_functions.php
<?PHP
//functions that need to be in the functions.php
//for this to work
//more tag detection
function has_more()
{
global $post;
if ( empty( $post ) ) return;