Skip to content

Instantly share code, notes, and snippets.

View BenBroide's full-sized avatar

Ben Broide BenBroide

  • New York
View GitHub Profile
@BenBroide
BenBroide / broken-pdf.js
Created April 21, 2017 13:50
Get all broken PDF files url in page
function urlExists(url, text ){
jQuery.get(url, function (response, status, xhr) {
if (xhr.getResponseHeader("content-type").indexOf("text") > -1){
//console.log( text + ' --> ' + url+ ' --> NOT PDF' );
} else {
//console.log(xhr.getResponseHeader("content-type"));
if( xhr.getResponseHeader("Content-Length") == null){
console.log(xhr.getResponseHeader("Content-Length"));
console.log( text + ' --> ' + url+ ' --> IS PDF' );
@BenBroide
BenBroide / update-post-meta.bash
Created February 25, 2018 20:36
WP CLI - update post meta to many posts by wp post list result
POSTIDLIST=($(wp post list --post_type=booking --format=ids));
for POSTID in ${POSTIDLIST[@]}; do
wp post meta set $POSTID _field_name field_value
done
@BenBroide
BenBroide / wp-cli-generate-posts-with-meta.bash
Created July 15, 2018 17:37
Generate posts with wp-cli with multiple meta fields
wp post generate --format=ids --post_type=listing --count=100 | sed -e "s/ /\n/g" | xargs -n1 -I % sh -c 'echo "Adding fields for %"; wp post meta add % _address "531 east 2";wp post meta add % _country "United States"; wp post meta add % _zip "10000"; wp post meta add % _state "NY";wp post meta add % _house 35';
<?php
function mml_output_setting_row( $class, $name, $value , $option_key , $data_div, $text ){ ?>
<p> <input type="checkbox" class="<?php echo $class ?>" name="powerpack-plugin-options[<?php echo $name ?>]" value="<?php echo $value ?>" <?php isset( $options['ecom-function'] ) ? checked($options['ecom-function'], 1) : '';?> data-div="<?php echo $data_div ?>"/><?php echo $text ?></p>
<?php }
@BenBroide
BenBroide / loop.js
Last active January 21, 2019 00:16
methods : {
async setOtherBookings() {
this.loadingOtherBookings = true;
if (this.booking.other_bookings.length > 0) {
for (let booking_post_id of this.booking.other_bookings) {
await this.loadOtherBooking(booking_post_id).then(response => {
this.addToSummary(response.data);
});
}
@BenBroide
BenBroide / wp-scaffold-child-theme-twentynineteen-child.sh
Created March 30, 2019 20:40
WP Cli Generate TwentyNine Child Theme
wp scaffold child-theme twentynineteen-child --parent_theme=twentynineteen
wp theme activate twentynineteen-child
#!/bin/bash
for post in $(wp post list --field=ID --allow-root)
do
count=$(wp post term list $post 'category' --fields='name' --format="count" --allow-root)
if [ "$count" -gt "1" ]
then
wp post term remove $post category 'uncategorized' --allow-root
fi
done
#!/bin/bash
function create_terms( ){
array=("$@")
for tax; do true; done
for term in "${array[@]}"
do
wp term create $tax "$term" --allow-root
done
@BenBroide
BenBroide / datetime.php
Created July 9, 2019 22:17
Date time from time stamp
<?php
// This will error and break code
$datetime = new DateTime( 1565301395 );
var_dump( $datetime );
// This will work
$datetime = new DateTime();
$datetime->setTimestamp(1565301395);
var_dump( $start_date );
const webpack = require("webpack");
//const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
transpileDependencies: ["vuetify"],
outputDir: "../assets/",
configureWebpack: {
plugins: [
new MiniCssExtractPlugin({