This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function delete_associated_media( $id ) { | |
$media = get_children( array( | |
'post_parent' => $id, | |
'post_type' => 'attachment' | |
) ); | |
if( empty( $media ) ) { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$duplicate_titles = $wpdb->get_col("SELECT post_title FROM {$wpdb->posts} WHERE post_type = 'attachment' GROUP BY post_title HAVING COUNT(*) > 1"); | |
echo "Find ".count($duplicate_titles)." duplicated titles \n"; | |
foreach( $duplicate_titles as $title ) { | |
echo "find images with ".$title." \n"; | |
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' and post_title=%s", $title ) ); | |
// Iterate over the second ID with this post title till the last | |
foreach( array_slice( $post_ids, 1 ) as $post_id ) { | |
$status = (wp_delete_attachment( $post_id,1 )) ? 'Deleted' : 'Not deleted'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_youtube_video_ID($youtube_video_url) { | |
/** | |
* Pattern matches | |
* http://youtu.be/ID | |
* http://www.youtube.com/embed/ID | |
* http://www.youtube.com/watch?v=ID | |
* http://www.youtube.com/?v=ID | |
* http://www.youtube.com/v/ID | |
* http://www.youtube.com/e/ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_youtube_video_ID($youtube_video_url) { | |
/** | |
* Pattern matches | |
* http://youtu.be/ID | |
* http://www.youtube.com/embed/ID | |
* http://www.youtube.com/watch?v=ID | |
* http://www.youtube.com/?v=ID | |
* http://www.youtube.com/v/ID | |
* http://www.youtube.com/e/ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.startDate = false; | |
window.endDate = false; | |
let dateOutSel = 'input[name="dateOut"]'; | |
let dateInSel = 'input[name="dateIn"]'; | |
$('label[for=dateOut]').hide('fast'); | |
$(dateOutSel).hide('fast'); | |
$(dateInSel).datepicker().on('changeDate', function(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function postedAgo() { | |
$post_time = get_the_time( 'U' ); | |
$time_now = date( 'U' ); | |
// Use human time if less that 60 days ago, otherwise display the date | |
// Uses the WordPress internal function human_time_diff | |
// 60 seconds * 60 minutes * 24 hours * 90 days. | |
if ( $post_time > $time_now - ( 60 * 60 * 24 * 90 ) ) { | |
$human_time = sprintf( esc_html__( '%s ago', 'talles' ), human_time_diff( $post_time, current_time( 'timestamp' ) ) ); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function lastProducts($limit){ | |
$sitesData = get_sites(['number' => 200000000]); | |
$posts = []; | |
foreach ( $sitesData as $sites_datumk=>$sites_datum ) { | |
$st = []; | |
switch_to_blog( $sites_datum->blog_id ); | |
$st = get_posts([ | |
'post_type'=>'product', | |
'posts_per_page' => $limit, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text-gradient { | |
background-blend-mode: soft-light; | |
background-image: linear-gradient(to top, rgb(16, 18, 16), rgb(255, 255, 255)), linear-gradient(tan, rgb(212, 181, 120)); | |
-webkit-background-clip: text; | |
background-clip: text; | |
-webkit-text-fill-color: transparent; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allow hooking into ACF repeated fields with meta queries | |
*/ | |
function repeaterAdapter( $where ) { | |
$where = str_replace("meta_key = 'repeaterName_$", "meta_key LIKE 'repeaterName_%", $where); | |
return $where; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// read more at | |
var $div = $(".card"); | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if (mutation.attributeName === "class") { | |
var attributeValue = $(mutation.target).prop(mutation.attributeName); | |
console.log("Class attribute changed to:", attributeValue); | |
console.log($(mutation.target)); | |
$( document ).trigger( "validateCard", attributeValue ); | |
} |