Skip to content

Instantly share code, notes, and snippets.

View DigitalEssence's full-sized avatar

Hedley Phillips DigitalEssence

View GitHub Profile
SELECT * FROM `tbllog_register` WHERE created_at < '2023-01-01';
.container .av-content-small.units {
width: 85% !important;
}
@DigitalEssence
DigitalEssence / Powershell - Replace space in filename with hyphen
Created April 29, 2020 16:02
Powershell - Replace space in filename with hyphen
dir | rename-item -NewName {$_.name -replace " ","-"}
@DigitalEssence
DigitalEssence / Database Many to Many Relationship
Last active November 16, 2021 22:09
Database Many to Many Relationship
user
+----+-----------+----------+-------+
| id | firstname | lastname | email |
+----+-----------+----------+-------+
| 1 | Peter | Jones | email |
| 2 | Bob | Smith | email |
| 3 | Sarah | Peters | email |
| 4 | Christine | Hall | email |
+----+-----------+----------+-------+
@DigitalEssence
DigitalEssence / WordPress - Enfold - PHP - Add Sticky button
Created April 9, 2021 15:33
WordPress - Enfold - PHP - Add Sticky button
// Add Header Code
function de_sticky_button() {
?>
<!-- Start of Sticky Button -->
<a href="https://www.givey.com/renewcrew" target="_blank" title="Click to donate" class="sticky-button">CLICK TO DONATE</a>
<!-- End of Sticky Button -->
<?php
}
add_action('wp_body_open', 'de_sticky_button');
@DigitalEssence
DigitalEssence / WordPress - Enfold - PHP - Add Custom Shortcode
Last active June 17, 2020 14:45
WordPress - Enfold - PHP - Add Custom Shortcode
// Add to functions.php
add_shortcode( 'de_shortcode', 'de_shortcode' );
function de_shortcode() {
$buffer = '<h3>Post Titles</h3>';
$q = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 6
));
while ($q->have_posts()) {
@DigitalEssence
DigitalEssence / WordPress - Enfold - PHP - Detect if a post date is in the past and add a class
Created April 11, 2019 09:04
WordPress - Enfold - PHP - Detect if a post date is in the past and add a class
// Detect if post is in the past and if so add a custom Class "oldpost"
if (strtotime(get_the_date( "Y-m-d", $the_id )) < strtotime(date("Y-m-d"))) {
$post_class = "post-entry post-entry-{$the_id} oldpost slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";
}
else {
$post_class = "post-entry post-entry-{$the_id} slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";
}
@DigitalEssence
DigitalEssence / gist:6478938
Created September 7, 2013 20:21
If you work on genesis child themes a lot then this code (originally by Chris Cree) will save you loads of time. First create a custom.css file with your custom styles and FTP it up to your child theme directory. Then add the below code to your child theme's functions.php file.
add_action( 'wp_enqueue_scripts', 'wsm_custom_stylesheet' );
function wsm_custom_stylesheet() {
wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom.css' );
}
@DigitalEssence
DigitalEssence / Javascript-Enqueue
Last active April 28, 2020 19:24
WordPress - Javascript - Enqueue javascript
// Add Javascript to select default options in Product Add on
function digitalessence_new_scripts(){
wp_enqueue_script( 'product-addon-default-values', get_stylesheet_directory_uri() . '/js/product-addon-default-value.js', array(), true );
}
add_action( 'wp_enqueue_scripts', 'digitalessence_new_scripts' );
@DigitalEssence
DigitalEssence / WordPress - PHP - Display posts dated in the future
Created April 11, 2019 09:04
WordPress - PHP - Display posts dated in the future
//Display Future Posts
function de_prevent_future_type( $post_data ) {
if ( $post_data['post_status'] == 'future' && $post_data['post_type'] == 'post' )
/*Here I am checking post_type='post' , you may use different post type and if you want it
for all post type then remove "&& $post_data['post_type'] == 'post'"
*/
{
$post_data['post_status'] = 'publish';
}
return $post_data;