Skip to content

Instantly share code, notes, and snippets.

View kellenmace's full-sized avatar

Kellen Mace kellenmace

View GitHub Profile
// Load admin scripts & styles
function km_load_admin_scripts( $hook ) {
global $post;
// Load the scripts & styles below only if we're creating/updating a post
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
wp_enqueue_script( 'admin_scripts', get_template_directory_uri() . 'assets/js/km_dashboard_admin.js', array( 'jquery' ) );
wp_enqueue_style( 'admin_styles', get_template_directory_uri() . 'assets/css/km_dashboard_admin.css' );
}
}
( function ( $ ) {
$( document ).ready( function () {
//Require post title when adding/editing Project Summaries
$( 'body' ).on( 'submit.edit-post', '#post', function () {
// If the title isn't set
if ( $( "#title" ).val().replace( / /g, '' ).length === 0 ) {
// Show the alert
// Load admin scripts & styles
function km_load_admin_scripts( $hook ) {
global $post;
// Load the scripts & styles below only if we're creating/updating a post
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
wp_enqueue_script( 'admin_scripts', get_template_directory_uri() . 'assets/js/km_dashboard_admin.js', array( 'jquery' ) );
}
}
add_action( 'admin_enqueue_scripts', 'km_load_admin_scripts' );
// Load admin scripts & styles
function km_load_admin_scripts( $hook ) {
global $post;
// If the post we're editing isn't a project_sumary type, exit this function
if ( 'project_summary' != $post->post_type ) {
return;
}
// Load the scripts & styles below only if we're creating/updating the post
// Load admin scripts & styles
function km_load_admin_scripts( $hook ) {
global $post;
// If the post we're editing isn't a project_summary type, exit this function
if ( 'project_summary' != $post->post_type ) {
return;
}
// Load the scripts & styles below only if we're creating/updating the post
<?php
function hmc_metaboxes( array $meta_boxes ) {
$meta_boxes['home_metabox'] = array(
'id' => '_hmc_home_metabox2',
'title' => __( 'Key Facts', 'hmc' ),
'pages' => array( 'page' ),
'show_on' => array( 'key' => 'page-template', 'value' => 'templates/home-page.php' ),
'context' => 'normal',
'priority' => 'default',
.single-property {
// CSS rules go here
}
( function( $ ) {
$( window ).load( function() {
// When 'Use Portal Color Controls' customizer control is toggled
wp.customize( 'portal_color_control', function ( value ) {
value.bind( function( newval ) {
// If toggled off, warn user that portal color settings will be deleted
if ( 'off' == newval ) {
var confirmation = window.confirm( "WARNING: turning this off will delete all the portal color settings. Continue?" );
function km_enqueue_customizer_scripts() {
global $wp_customize;
if ( ! isset( $wp_customize ) ) {
return;
}
wp_enqueue_script( 'customizer_scripts', PLUGIN_URL . 'assets/js/customizer_scripts.js', 'jquery' );
}
add_action( 'admin_enqueue_scripts', 'km_enqueue_customizer_scripts' );
( function( $ ) {
$( window ).load( function() {
// When 'Use Portal Color Controls' customizer control is toggled
wp.customize( 'portal_color_control', function ( value ) {
value.bind( function( newval ) {
// If toggled off, warn user that portal color settings will be deleted
if ( 'off' == newval ) {
var confirmation = window.confirm( "WARNING: turning this off will delete all the portal color settings. Continue?" );