Skip to content

Instantly share code, notes, and snippets.

@cliffordp
cliffordp / style.css
Last active May 26, 2018 04:26
Always center SmugMug oEmbeds
/**
* SmugMug oEmbed centering
* From https://tourkick.com/advice-tips-howto/smugmug-custom-domain-oembed-wordpress/
*/
img[src*="https://media.tourkick.com"], /* Single Image from custom domain URL */
img[src*="https://photos.smugmug.com"], /* Single Image from smugmug.com URL */
iframe[src*="https://api.smugmug.com"]{ /* Videos and Slideshows (multiple images) regardless of custom domain URL or smugmug.com URL */
display: block;
margin: 0 auto;
}
@cliffordp
cliffordp / functions.php
Last active August 29, 2015 14:10
Adding custom SmugMug domain to oEmbed whitelist in WordPress (full regex version)
<?php
// From http://tourkick.com/2014/smugmug-custom-domain-oembed-wordpress/
// This version is based on the SmugMug code from wp-includes/class-oembed.php
// Even if you set both WWW and non-WWW versions as CNAMEs in your DNS settings, an oEmbed attempt to the wrong custom SmugMug domain (e.g. WWW if the custom domain in your SmugMug settings is non-WWW) will not work, which is why (www\.)? is not in the regex
// for a custom SmugMug subdomain like http://media.mydomain.com (notice the "backslash-dot" after the subdomain)
wp_oembed_add_provider( '#https?://?media\.mydomain\.com/.*#i', 'http://api.smugmug.com/services/oembed/', true );
// for a custom SmugMug domain like http://mydomain.com:
<?php
// From http://www.pagelinestheme.com/dms-editor-only-specified-admins/
// If not defined all users with edit_theme_options capability have access to the DMS Editor.
// Example 1, only allow username 'admin' to use DMS Editor
define( 'PL_EDITOR_LOCK', 'admin' );
// Example 2, allow 3 users to use DMS Editor
define( 'PL_EDITOR_LOCK', 'bobadmin,simonadmin,sallyadmin' );
// From http://www.pagelinestheme.com/disable-dms-regions-per-page/
//body[class*=" template-landing-"]:not(.logged-in) { //do not hide for logged in users
body[class*=" template-landing-"] { //e.g. template-landing-snowremoval
#fixed-top,
.fixed-top-pusher,
header,
footer {
//display:none; // no longer needed now that it is done via functions.php
}
<?php
// From http://www.pagelinestheme.com/disable-dms-regions-per-page/
//Disable Fixed, Header, and Footer on all these Page IDs
add_filter( 'pl_setting-region_disable_fixed', 'customize_templates_by_page' );
add_filter( 'pl_setting-region_disable_header', 'customize_templates_by_page' );
add_filter( 'pl_setting-region_disable_footer', 'customize_templates_by_page' );
function customize_templates_by_page() {
//could choose to still show for Admins (e.g. copy content from footer to template)
//if( current_user_can('edit_theme_options') ) { return false; }
<?php
//from http://www.pagelinestheme.com/all-the-dynamic-dms-page-handling-you-want/
add_filter( 'pl_breaker_type', 'custom_breakers');
function custom_breakers( $type ) {
$prepend = '* ';
if(is_tax('jetpack-portfolio-type')) {
$type = $prepend . get_query_var( 'taxonomy');
}
return $type;
<?php
//from http://www.pagelinestheme.com/all-the-dynamic-dms-page-handling-you-want/
add_filter( 'pl_breaker_type', 'custom_breakers');
function custom_breakers( $type ) {
$prepend = '* ';
//each custom taxonomy is its own type
if(is_tax()) {
$type = $prepend . get_query_var( 'taxonomy');
}
<?php
//from http://www.pagelinestheme.com/all-the-dynamic-dms-page-handling-you-want/
add_filter( 'pl_breaker_type', 'custom_breakers');
function custom_breakers( $type ) {
$prepend = '* ';
//each post category is its own type
if(is_category()) {
$type = $prepend . get_category(get_query_var('cat'))->slug;
}
@cliffordp
cliffordp / rcp-wp-admin-table-widths.php
Created July 4, 2015 13:57
make Restrict Content Pro wp-admin table column widths nicer
<?php
// Condense information on Restrict Content Pro wp-admin tables (avoid "too tall" table rows)
// override .widefat * { word-wrap: break-word; } and table.fixed { table-layout: fixed; }
// RCP pages with tables: /wp-admin/admin.php?page= ... rcp-members, rcp-member-levels, rcp-discounts, rcp-payments, or rcp-logs
// there are some columns we may NOT want to make AUTO width: https://github.com/pippinsplugins/Restrict-Content-Pro/blob/master/includes/css/admin-styles.css#L31
add_action('admin_head','my_rcp_tables_not_too_tall');
function my_rcp_tables_not_too_tall() {
$current_screen = get_current_screen();
if( !is_object($current_screen) ) {
@cliffordp
cliffordp / shortcode_ui_editor_one_click_insert_buttons.php
Last active August 29, 2015 14:26
Add One-Click Empty buttons via Shortcake by adding 'add_button' => true when registering Shortcode UI arguments -- can also use 'add_button' => 'icon_only' -- requires https://wordpress.org/plugins/shortcode-ui/ be installed and activated
<?php
add_action( 'media_buttons', 'shortcode_ui_editor_one_click_insert_buttons', 200 ); // higher priority adds it to the right side of all the other buttons (Add Media, Gravity Forms, etc.)
// adapted from https://github.com/fusioneng/Shortcake/issues/94#issuecomment-68020127
function shortcode_ui_editor_one_click_insert_buttons( $editor_id = '' ) { // without $editor_id = '', 'content' gets printed before the button
// Check if Shortcake is installed and activated
if( ! method_exists( 'Shortcode_UI', 'get_instance' ) ) {
return false;