Skip to content

Instantly share code, notes, and snippets.

View camaech's full-sized avatar
🎯
Focusing

Cam Heikkinen camaech

🎯
Focusing
View GitHub Profile
@camaech
camaech / gist:a00fa0ae7b50ddd0df11dc2ad4206d15
Created February 2, 2018 16:58
Laravel Module with Laravel Mix for VueJS - webpack.mix.js
let mix = require('laravel-mix');
let child_process = require('child_process');
mix.js('Resources/js/core-app.js', 'Assets/js')
.then(() => {
child_process.exec('php artisan module:publish', {cwd: '../../'}, function(error, stdout, stderr){
if (error) throw error;
console.log(stdout, stderr);
});
@camaech
camaech / gist:362075f08a4c9917cf1da94b048a4364
Created August 24, 2016 15:15
Import WP Term Category Meta Data
<?php
/** Loads the WordPress Environment and Template */
require ('./wp-blog-header.php');
$import_data = array_map('str_getcsv', file('CategoriesImport.csv'));
$product_cats = get_terms(
array(
'taxonomy' => array('product_cat', 'industry_solution_category')
DELETE p FROM vsc_posts p
WHERE p.post_type = 'product';
DELETE pm FROM vsc_postmeta pm
LEFT JOIN vsc_posts vsc ON vsc.ID = pm.post_id
WHERE vsc.ID IS NULL;
DELETE tr FROM vsc_term_relationships tr
INNER JOIN vsc_term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
WHERE tt.taxonomy != 'link_category' AND tr.object_id NOT IN ( SELECT ID FROM vsc_posts );
@camaech
camaech / gist:f1a6693264534d6763f2a4f879f22909
Created July 24, 2016 16:22
Insert additional custom meta to all users
INSERT INTO vsc_usermeta (user_id, meta_key, meta_value)
(SELECT ID AS user_id, 'division'
AS meta_key, 'north' AS meta_value
FROM vsc_users WHERE ID NOT IN
(SELECT user_id FROM vsc_usermeta WHERE meta_key = 'division'))
@camaech
camaech / gist:de22666dfe50a5ff99ed2ed32ff605b9
Created June 2, 2016 15:29
Add wp_postmeta to Custom Post Type MySql
INSERT INTO vsc_postmeta (post_id, meta_key, meta_value)
(SELECT ID AS post_id, 'division'
AS meta_key, 'north' AS meta_value
FROM vsc_posts WHERE ID NOT IN
(SELECT post_id FROM vsc_postmeta WHERE meta_key = 'division')
AND `post_type` = 'ivi_assignment_type');
@camaech
camaech / wp-export.php
Last active April 27, 2016 15:52
Copy all PDFs attached to a specific template type in WordPress.
<?php
include "wp-load.php";
//Usage:
// replace the meta_query value with your template filename
// change the $newfile to reflect the directory you want to copy your files to
$posts = new WP_Query(
array(
'post_type' => 'page',