Skip to content

Instantly share code, notes, and snippets.

Mannie Schumpert mannieschumpert

Block or report user

Report or block mannieschumpert

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
@mannieschumpert
mannieschumpert / gist:8334811
Last active Sep 18, 2019
Filter the submit button in Gravity Forms to change the <input type="submit> element to a <button> element. There's an example in the Gravity Forms documentation, but it lacks the proper code to show your custom button text, AND removes important attributes like the onclick that prevents multiple clicks. I was trying to solve that.
View gist:8334811
<?php
// filter the Gravity Forms button type
add_filter("gform_submit_button", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
// The following line is from the Gravity Forms documentation - it doesn't include your custom button text
// return "<button class='button' id='gform_submit_button_{$form["id"]}'>'Submit'</button>";
// This includes your custom button text:
return "<button class='button' id='gform_submit_button_{$form["id"]}'>{$form['button']['text']}</button>";
}
// Oops this strips important stuff
@mannieschumpert
mannieschumpert / gist:6105315
Last active Aug 12, 2019
Remove user fields for specific user role in WordPress
View gist:6105315
<?php
// Hook into the admin footer
add_action( 'admin_footer-user-edit.php', 'remove_user_fields' );
function remove_user_fields(){
// Set desired user role to target
$role = 'subscriber';
// Check for user ID query string
@mannieschumpert
mannieschumpert / gist:8886289
Last active May 1, 2019
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
View gist:8886289
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );
View Form.jsx
import React, { createContext, useState } from 'react';
export const FormContext = createContext();
const Form = ({ handleSubmit, children, submitButtonText }) => {
const [values, setValues] = useState({});
const setValue = ({ name, value }) => {
setValues(values => ({
...values,
@mannieschumpert
mannieschumpert / gist:e5cec8723247f9490016
Created Oct 9, 2014
Remove Gravity Forms' "Add Form" button from all WYSIWYG editors
View gist:e5cec8723247f9490016
<?php
add_filter( 'gform_display_add_form_button', function(){return false;} );
@mannieschumpert
mannieschumpert / gist:6105148
Last active Feb 22, 2018
Remove unneeded User settings fields in WordPress
View gist:6105148
<?php
// Hook into the admin footer
add_action( 'admin_footer-user-edit.php', 'remove_user_fields' );
// Print jQuery that removes unneeded elements
function remove_user_fields(){
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
var ids = ['#rich_editing', // Rich editing button
@mannieschumpert
mannieschumpert / gist:3f30e5ffa068a0525915
Created Oct 14, 2014
W3 Total Cache's approach to conditional loading is rather elegant.
View gist:3f30e5ffa068a0525915
<?php
/**
* Skip caching for some pages
*/
switch (true) {
case defined('DONOTCACHEPAGE'):
case defined('DOING_AJAX'):
case defined('DOING_CRON'):
case defined('APP_REQUEST'):
@mannieschumpert
mannieschumpert / gist:7188426
Last active Apr 23, 2017
When using Gravity Forms on a client project, you might want the client to be able to view and manipulate form entries, without giving them administrator access. The user_has_cap filter allows us to add capabilities without changing the role in the database. This gist allows users with the editor role to view and manipulate form entries.
View gist:7188426
<?php
/**
* Add Gravity Forms capabilities
*/
add_filter('user_has_cap',
function( $caps ){
if (! empty( $caps['edit_pages'] ) ) { // user has edit capabilities
$caps['gravityforms_delete_entries'] = true;
$caps['gravityforms_edit_entries'] = true;
$caps['gravityforms_edit_entry_notes'] = true;
@mannieschumpert
mannieschumpert / gist:2f89bcd1eb5a540dad59
Last active Apr 18, 2017
Remove all themes auto-installed by Softaculous on SiteGround
View gist:2f89bcd1eb5a540dad59
# move into the themes folder
cd public_html/wp-content/themes
# remove unwanted themes
# of course remove the older WP default themes from the script if you want to keep them
rm -rf -- {Builder-Cohen,Builder-Paige,World,siteground-wp23,siteground-wp73,Builder-Madison,Universe,siteground-wp63,twentythirteen,twentytwelve}
View wordpress-default-rewrites.php
<?php
array(
'^wp-json/?$' => 'index.php?rest_route=/',
'^wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
'category/(.+?)/embed/?$' => 'index.php?category_name=$matches[1]&embed=true',
'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
'category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
'tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
You can’t perform that action at this time.