Skip to content

Instantly share code, notes, and snippets.

@wpmu-authors
wpmu-authors / graph.php
Created February 8, 2021 14:04
graph.php
function dashboard_widget_display_enqueues( $hook ) {
if( 'index.php' != $hook ) {
return;
}
wp_enqueue_style( 'dashboard-widget-styles', plugins_url( '', __FILE__ ) . '/widgets.css' );
}
add_action( 'admin_enqueue_scripts', 'dashboard_widget_display_enqueues' );
@wpmu-authors
wpmu-authors / commentcount.php
Created February 8, 2021 14:10
commentcount.php
global $wpdb;
for( $i=1; $i <= 5; $i++ ) {
$this_week = 7 * $i;
$last_week = 7 * ( $i - 1);
$comment_counts[] =
$wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_date > '" . date('Y-m-d H:i:s', strtotime('-' . $this_week . ' days')) . "' AND comment_date < '" . date('Y-m-d H:i:s', strtotime('-' . $last_week . ' days')) . "'" ) ;
@wpmu-authors
wpmu-authors / compatibility.js
Created February 8, 2021 14:22
compatibility.js
/* Regular jQuery */
$('.hideable').on('click', function() {
$(this).hide();
})
/* Compatibility Mode */
jQuery('.hideable').on('click', function() {
jQuery(this).hide();
})
@wpmu-authors
wpmu-authors / using-dollar-footer.js
Created February 8, 2021 14:33
using-dollar-footer.js
@wpmu-authors
wpmu-authors / using-dollar-header.js
Created February 8, 2021 14:36
using-dollar-header.js
jQuery(document).ready(function( $ ) {
$('.hideable').on('click', function() {
$(this).hide();
})
});
@wpmu-authors
wpmu-authors / enqueue-theme.php
Created February 8, 2021 14:42
enqueue-theme.php
function my_theme_scripts() {
wp_enqueue_script( 'my-great-script', get_template_directory_uri() . '/js/my-great-script.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );
@wpmu-authors
wpmu-authors / enqueue-backend.php
Created February 8, 2021 14:48
enqueue-backend.php
function my_admin_scripts() {
wp_enqueue_script( 'my-great-script', plugin_dir_url( __FILE__ ) . '/js/my-great-script.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'admin_enqueue_scripts', 'my_admin_scripts' );
// include custom jQuery
function shapeSpace_include_custom_jquery() {
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js', array(), null, true);
}
add_action('wp_enqueue_scripts', 'shapeSpace_include_custom_jquery');
add_action( 'wp_loaded', 'register_all_scripts' );
function register_all_scripts()
{
wp_register_script(...);
}
add_action( 'wp_enqueue_scripts', 'enqueue_front_scripts' );
add_action( 'admin_enqueue_scripts', 'enqueue_back_scripts' );