Skip to content

Instantly share code, notes, and snippets.

Stephen Mullen thewirelessguy

Block or report user

Report or block thewirelessguy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thewirelessguy
thewirelessguy / create_admin_user.php
Created Mar 20, 2018
Create new Magento admin user programmatically. Edit and add the php file below to the root of your Magento folder. Run it in the browser and the user will be created.
View create_admin_user.php
<?php
# Create new Magento admin user programmatically.
require_once('./app/Mage.php');
umask(0);
Mage::app();
try {
$user = Mage::getModel('admin/user')
->setData(array(
'username' => 'admin1',
@thewirelessguy
thewirelessguy / getAppIcon.swift
Created Mar 14, 2017
Use current iOS app icon with UIImageView in Swift 3
View getAppIcon.swift
//
// GetAppIcon.swift
//
// Get the AppIcon from Assets and return it as a UIImage
// Created by Stephen Mullen
//
import UIKit
func getAppIcon() -> UIImage {
@thewirelessguy
thewirelessguy / function.php
Last active Aug 24, 2018
How to use Google's Organisation Logo Schema.org markup with WordPress Theme Logo
View function.php
function mytheme_setup() {
add_theme_support('custom-logo');
}
add_action('after_setup_theme', 'mytheme_setup');
@thewirelessguy
thewirelessguy / app-icon-uiimageview.swift
Last active Apr 12, 2017
Use current iOS app icon with UIImageView in Swift 2 (Swift 3 example: https://gist.github.com/thewirelessguy/b0eba855c0307b47168be85291788746)
View app-icon-uiimageview.swift
let primaryIconsDictionary = NSBundle.mainBundle().infoDictionary?["CFBundleIcons"]?["CFBundlePrimaryIcon"] as? NSDictionary
let iconFiles = primaryIconsDictionary!["CFBundleIconFiles"] as! NSArray
let lastIcon = iconFiles.lastObject as! NSString //last seems to be largest, use first for smallest
let theIcon = UIImage(named: lastIcon as String)
let iconImageView = UIImageView(image: theIcon)
@thewirelessguy
thewirelessguy / AndroidManifest.xml
Last active Aug 8, 2018
Setting up styles.xml and values-v21/styles.xml to use Material Design with AppCompat. Rename styles21.xml as styles.xml and place in your res/values-v21 folder (you may need to create a values-v21 folder if you don't already have one).
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.thewirelessguy.myappname" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
@thewirelessguy
thewirelessguy / Detect the last post in the WordPress loop
Last active May 17, 2019
Detect the last post in the WordPress loop
View Detect the last post in the WordPress loop
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
@thewirelessguy
thewirelessguy / functions.php
Created Aug 9, 2013
Removing Custom Post Types in WordPress. This example removes the Orbit Custom Post Type from the Cornerstone WordPress starter theme. You would include it the functions.php of your child theme.
View functions.php
<?php
add_action( 'after_setup_theme','remove_cornerstone_features', 100 );
function remove_cornerstone_features() {
remove_action( 'init', 'Orbit');
}
?>
@thewirelessguy
thewirelessguy / gist:5745760
Last active Mar 25, 2018
Display the title and thumbnail of child custom post types on the parent custom post type
View gist:5745760
<?php
$pageChildren = get_pages('child_of='.$post->ID."&echo=0&post_type=custompostypename");
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<a href="' . get_permalink($pageChild->ID) . '">';
$childimage = wp_get_attachment_image_src(get_post_thumbnail_id($pageChild->ID), 'thumbnail_size');
$childimagealttext = get_post_meta(get_post_thumbnail_id($pageChild->ID), '_wp_attachment_image_alt', true);
echo '<img src="'. $childimage['0'] . '" alt="' . $childimagealttext . '"/></a>';
echo '<p><a href="' . get_permalink($pageChild->ID) . '">'. $pageChild->post_title.'</a></p>';
}
@thewirelessguy
thewirelessguy / functions.php
Last active Dec 18, 2015
Disable the WordPress Admin Bar on mobiles but enable on desktops for logged in users
View functions.php
<?php
// Disable the admin bar on mobiles but enable on desktops
function cornerstone_show_admin_bar() {
if( wp_is_mobile() || !is_user_logged_in() ) {
return false;
} else {
return true;
}
}
@thewirelessguy
thewirelessguy / functions.php
Last active Dec 17, 2015
Adding support for Custom Post Types in the WordPress Jetpack REST API. The example adds support for the Custom Post Type named 'portfolio'. You would add this function to the functions.php in your theme or a plugin.
View functions.php
<?php
add_filter( 'rest_api_allowed_post_types', 'allow_my_post_types');
function allow_my_post_types($allowed_post_types) {
$allowed_post_types[] = 'portfolio';
return $allowed_post_types;
}
?>
You can’t perform that action at this time.