Skip to content

Instantly share code, notes, and snippets.

<?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
$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
$blogs = $wpdb->get_results( "
SELECT
`blog_id`
FROM
" . $wpdb->blogs . "
" );
foreach( $blogs AS $blog )
{
@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%'
@Clorith
Clorith / functions.php
Last active April 9, 2024 01:35
WordPress filter for adding responsive wrapper to embedded content
<?php
/**
* Filter for adding wrappers around embedded objects
*/
function responsive_embeds( $content ) {
$content = preg_replace( "/<object/Si", '<div class="embed-container"><object', $content );
$content = preg_replace( "/<\/object>/Si", '</object></div>', $content );
/**
* Added iframe filtering, iframes are bad.
@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,
$("#portofolio").isotope({
itemSelector : '.latest-work',
layoutMode : 'fitRows'
});
$(".filters").click(function (e) {
$("#portofolio").isotope({
filter: $(this).attr('data-filter')
});
e.preventDefault();
@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', '');
@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;
<?php
if ( ( strpos( $current_user->adi_description, 'Support' ) !== false ) || ( $current_user->login_user == 'support' ) ) {