Skip to content

Instantly share code, notes, and snippets.

Arelthia Phillips pintop

  • Pintop Solutions LLC
  • Texas
View GitHub Profile
@pintop
pintop / admin.php
Last active Jul 22, 2018
Change order of custom post type on admin edit.php screen
View admin.php
/*
* Change order of custom post type on admin edit.php screen from name to date
* https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
*/
function ptc_admin_order( $wp_query ) {
if (is_admin()) {
$post_type = $wp_query->query['post_type'];
if ( $post_type == 'ptc_clients' || $post_type == 'ptc_proposals' ) {
@pintop
pintop / gist:23d1afc4d1445d23e2d2f3b53c96af49
Created Aug 11, 2017
Speed Up Your WordPress Site By Disabling Smileys, Emojis and Emoticons
View gist:23d1afc4d1445d23e2d2f3b53c96af49
/**
* Disable the emoji's
*/
function disable_wordpress_emojis() {
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
View cors-for-the-wordpress-rest-api.php
<?php
function my_customize_rest_cors() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: GET' );
header( 'Access-Control-Allow-Credentials: true' );
header( 'Access-Control-Expose-Headers: Link', false );
@pintop
pintop / functions.php
Last active Jun 23, 2017
Force ssl on one page and force http on specific pages.
View functions.php
add_action( 'template_redirect', 'pintop_ssl_redirect', 1 );
function pintop_ssl_redirect() {
//page that should be ssl
if ( is_page( 1264 ) && ! is_ssl() ) {
if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']), 301 );
exit();
} else {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
@pintop
pintop / Add class to menu
Last active Jun 9, 2017
Add custom classes to WordPress menus
View Add class to menu
// Add extra classes for the first and last items in all WordPress menus
add_filter( 'wp_nav_menu_objects', function ( $items ) {
if ( ! empty( $items ) ) {
$items[1]->classes[] = 'menu-item-first';
$items[ count( $items ) ]->classes[] = 'menu-item-last';
}
return $items;
} );
@pintop
pintop / get-post-type.js
Created Dec 31, 2016
Get WordPress CPT from front end
View get-post-type.js
(function( $ ) {
'use strict';
var attrs, attr, postType;
postType = null;
$(function() {
// Look to see what type of post type we're working with
attrs = $( 'body' ).attr( 'class' ).split( ' ' );
@pintop
pintop / gfs3.php
Created Dec 28, 2016 — forked from renventura/gfs3.php
Send Gravity Forms file uploads to Amazon S3
View gfs3.php
<?php
/**
* Send Gravity Forms file uploads to Amazon S3
* @author Ren Ventura <EnageWP.com>
* @link http://www.engagewp.com/send-gravity-forms-file-uploads-to-amazon-s3/
*/
//* Include the required library
include_once 'inc/S3.php';
@pintop
pintop / variable.php
Created Dec 2, 2015
WooCommerce Change Attribute None Option
View variable.php
<?php
/**
* Variable product add to cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* In theme/child theme directory add woocommerce/single-product/add-to-cart/
*/
if ( ! defined( 'ABSPATH' ) ) {
@pintop
pintop / front-page.php
Last active Nov 2, 2015
Pods find (query) based on field value - Used on Genesis home page
View front-page.php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'tht_featured_home', 5 );
function tht_featured_home() {
$where = "book_featured.meta_value='1'";
$params = array(
'where'=> $where,
'order' => 'ASC',
'limit' => 1,
@pintop
pintop / archive-book.php
Created Aug 6, 2015
Genesis Custom Pods Archive template
View archive-book.php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'tht_book_archive_custom_loop' );
/**
* Genesis custom loop
*/
function tht_book_archive_custom_loop() {
$books = new Pod('book');
$params = array(
'order' => 'ASC',
'orderby' => 'title',
You can’t perform that action at this time.