Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Adam Doe adamdoe

🏠
Working from home
  • @cdcent CDC (work) & personal
  • Northern Nevada
View GitHub Profile
@adamdoe
adamdoe / data.sql
Created Mar 4, 2019
WordPress SQL for post, category, user data
View data.sql
SELECT
p.ID,
p.post_author,
p.post_date,
u.display_name,
p.post_title,
p.post_content,
t.name
FROM wp_posts as p
INNER JOIN wp_postmeta as pm ON (p.ID = pm.post_id)
@adamdoe
adamdoe / footer.php
Created Jul 26, 2018
For WordPress AJAX Urls
View footer.php
View gist:708ba352feb6f751321b2db84d8ffeda
if ( ! class_exists( 'theme_utilities' ) ) {
class theme_utilities {
public static function theme_function_one() { }
public static function theme_function_two() { }
}
}
View crud-taxonomy-meta-wordpress.php
<?php
add_action( '{taxonomy}_add_form_fields', 'add_feature_group_field', 10, 2 );
function add_feature_group_field($taxonomy) {
global $meta_name;
?>
<div class="form-field">
<label for="meta_name">Meta Name</label>
<input name="meta_name" id="meta_name" type="text" value="<?php echo $meta_name; ?>" size="40" aria-required="true">
@adamdoe
adamdoe / Animal.js
Last active Jun 1, 2021
Animal.js #js
View Animal.js
/**
* ES6 Classes
* Notes:
* - instead of adding methods to the prototype
* can add them directly to class.
*/
class Animal {
constructor(name, age) {
this._name = name;
this._age = age;
@adamdoe
adamdoe / sql
Last active Apr 30, 2020
WordPress - SQL Statements for Migration #wordpress
View sql
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@adamdoe
adamdoe / functions.php
Last active Mar 13, 2021
WordPress - Admin Functions #wordpress
View functions.php
<?php
/******************************************************************
* Admin Footer
******************************************************************/
function change_admin_footer(){
echo '<span id="footer-note">Theme made by <a href="http://www.yourcompany.com/" target="_blank">Your Company</a>.</span>';
}
add_filter('admin_footer_text', 'change_admin_footer');
@adamdoe
adamdoe / functions.php
Last active Aug 23, 2017
Get user of role type and add them into columns using Foundation.
View functions.php
/**
* Author : Doe
* @param string $role_type used for getting type of user.
*/
function get_team_members($role_type) {
$args = array(
'role' => $role_type,
'fields' => 'ID'
);
View Sublime Workspace
{
"folders": [
{
"folder_exclude_patterns": [
"wp-includes",
"wp-admin",
"wp-content/uploads",
".idea"
],
"path": "PATH HERE",
@adamdoe
adamdoe / Last Updated Stamp
Last active Apr 30, 2020
WordPress - Check modified time after published time #wordpress
View Last Updated Stamp
function add_last_updated()
{
$post_time = strtotime(get_post_time('m.d.Y'));
$mod_time = strtotime(get_post_modified_time('m.d.Y'));
$mod_date = get_the_modified_time('m.d.Y');
$date = get_the_date('m.d.Y');
$display_date = ($post_time < $mod_time ? $mod_date : $date);
if ($post_time != $mod_time)
{