Skip to content

Instantly share code, notes, and snippets.

@Clorith
Clorith / gist:9321698
Created March 3, 2014 09:52
Quick filtering concept
<?php
$searcharg = array();
global $searcharg;
add_action( 'init', 'check_form' );
add_action( 'pre_get_posts', 'make_fancy_query' );
function check_form() {
if ( isset( $_GET['Checkme'] ) ) {
global $searcharg;
@Clorith
Clorith / gist:9503789
Created March 12, 2014 09:41
Use the WordPress media modal to add gallery shortcodes to custom meta boxes
jQuery(document).ready(function ($) {
// Set the original handler, since we override Core, we need to fall back to core if we're not doing stuff our selves
var _custom_media = true,
_orig_wp_media_insert = wp.media.editor.insert;
// Any input field wit hthe class 'theme_custom_media' will trigger our custom behavior
$(".theme_custom_media").click(function (e) {
var button = $(this);
var id = button.attr('id').replace('_button', '');
$("#portofolio").isotope({
itemSelector : '.latest-work',
layoutMode : 'fitRows'
});
$(".filters").click(function (e) {
$("#portofolio").isotope({
filter: $(this).attr('data-filter')
});
e.preventDefault();
@Clorith
Clorith / style.css
Last active August 29, 2015 13:57
Responsive embedded content (CSS)
.embed-container {
float: left;
width: 100%;
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.embed-container object,
@Clorith
Clorith / functions.php
Last active August 29, 2015 14:00
Make WordPress embeds of local content responsive
<?php
/**
* Filter function, converts fixed width to '100%' width
*/
function responsive_wp_video_shortcode( $html, $atts, $video, $post_id, $library ) {
$replace_value = array(
'width: ' . $atts['width'] . 'px'
);
$replace_with = array(
'width: 100%'
<?php
$blogs = $wpdb->get_results( "
SELECT
`blog_id`
FROM
" . $wpdb->blogs . "
" );
foreach( $blogs AS $blog )
{
<?php
$css->add(
'theme_primary', // Customize name (must be unique)
'color', // Customize type, (section or whatever you want, only section has a custom use at this point)
array(
'label' => __( 'Main color' ), // Label for the option
'object' => 'html, body', // The css DOM object to style
'selector' => 'color', // The css attribute to style
'default' => '#000000', // The default value
'type' => 'color', // The controller type
<?php
function wrap_sub_nav( $nav ) {
return preg_replace( '%<ul class="sub-menu">(.+\n)</ul>%s', '<div class="menu-form"><ul class="sub-menu">$1</ul></div>', $nav );
}
add_action( 'wp_nav_menu_items', 'wrap_sub_nav ');
<?php
function set_page_for_post( $query ) {
/*
* Only run our query modifications if;
* This is the main query (not a custom WP_Query or similar)
* We are not on the admin screen
* It's a single post entry
* The post type is 'post'
*/
if ( $query->is_main_query() & ! is_admin() && is_single() && 'post' == get_post_type() ) {
ASCII GS ( L pL pH m fn # # 1 1
Decimal 29 40 76 6 0 48 69 35 35 49 49