Skip to content

Instantly share code, notes, and snippets.

@atsea
atsea / divi-functions.php
Last active May 5, 2017 14:49 — forked from amElnagdy/divi-functions.php
Enables custom post types in Divi Builder
<?php
/**
ENABLE CUSTOM POST TYPES WITHIN DIVI BUILDER
@author Nagdy at wpcolt.com
@see https://wpcolt.com/enable-divi-visual-builder-on-custom-post-types/
*/
add_filter('et_builder_post_types', 'divicolt_post_types');
add_filter('et_fb_post_types','divicolt_post_types' ); // Enable Divi Visual Builder on the custom post types
function divicolt_post_types($post_types)
@atsea
atsea / flex-grid.css
Last active January 9, 2017 20:09
Chris Coyer flexbox grid demo Nov 22, 2016
/**
* Don’t Overthink It (Flexbox) Grids
* @author Chris Coyer
* @example https://css-tricks.com/dont-overthink-flexbox-grids/
*/
body {
padding: 20px;
}
.flex-grid,
@atsea
atsea / javascript-browser-feature-detection.js
Last active May 15, 2017 15:32
Latest feature detection using JS as of Nov. 2016
/**
* JAVASCRIPT FEATURE DETECTION
*
* @author [Rob W] [http://stackoverflow.com/users/938089/rob-w]
* @version 13 2/8/17
* @see http://stackoverflow.com/posts/9851769/revisions
* @example http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser/9851769#9851769
* @example https://jsfiddle.net/finstah/zcj4xtcq/
*/
// Opera 8.0+
@atsea
atsea / php: check php version
Created November 1, 2016 19:13
Check server php version
<?php
if ( version_compare(PHP_VERSION, '5.5', '<') ) {
wp_die('PHP 5.5 is required.');
};
?>
@atsea
atsea / wp-config-debug.php
Created October 31, 2016 14:16
WordPress: additional information used in wp-config for debugging
<?php
/**
* == About this Gist ==
* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
* // This is a gist, copied here for convenience, but please see source down for the maintainer and give the credit to them. //
* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*
* Code to add to wp-config.php to enhance information available for debugging.
*
* You would typically add this code below the database, language and salt settings
@atsea
atsea / wp-check-wp-version-core.php
Created October 3, 2016 14:17
WP: default WP Version conditional
/**
* Twenty Fifteen only works in WordPress 4.1 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
}
@atsea
atsea / wp_get_current_user_inline_css.php
Created September 27, 2016 16:48
WordPress: check user role and add inline css
/**
* http://wordpress.stackexchange.com/questions/131814/if-current-user-is-admin-or-editor
* set wpadminbar to position fixed to work with UD Theme 8/29/15 CL
*/
$user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator', 'author');
if( array_intersect($allowed_roles, $user->roles ) )
$custom_css =
"@media screen and (max-width:600px) {#wpadminbar {position: fixed !important;}}".'/n';
@atsea
atsea / wp-enqueue-scripts.php
Last active August 17, 2016 13:01
WordPress : validate admin screen before enqueuing scripts. wp_localize_script alternative
<?php
/**
* page information
*
* options-general.php?page=sb_bar
* pagenow = 'settings_page_sb_bar',
* adminpage = 'settings_page_sb_bar',
*/
/**
* Slug of the plugin screen.
@atsea
atsea / Preferences.sublime-settings
Created August 12, 2016 12:58
Sublime Text 3 User Settings
{
"added_words":
[
"uninstalled",
"plugin",
"admin"
],
"auto_complete": true,
"auto_complete_commit_on_tab": true, // fix for CSS3 package
"auto_complete_delay": 100,
@atsea
atsea / minify.css.php
Created August 10, 2016 16:47
minify multiple css files on the fly with php.
<?php
/**
* https://ikreativ.com/combine-minify-css-with-php/
* http://stackoverflow.com/questions/9862904/css-merging-with-php
*/
header('Content-type: text/css');
ob_start("compress");
function compress($buffer) {
/* remove comments */
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);