Skip to content

Instantly share code, notes, and snippets.

JRMorris77

Block or report user

Report or block JRMorris77

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
@JRMorris77
JRMorris77 / json-encode-mysql.php
Created Aug 22, 2018
JSON encode a MySQL result using PHP
View json-encode-mysql.php
<?php
$dbhost = "localhost";
$dbuser = "dbuser";
$dbpass = "dbpass";
$dbname = "dbname";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($conn->connect_error) {
@JRMorris77
JRMorris77 / hbapicheck.php
Created Jun 23, 2018
Hummingbird API Quick Diagnostics
View hbapicheck.php
<?php
/**
* Script Name: Hummingbird API Quick Diagnostics
* Script URI: https://premium.wpmudev.org/
* Description: Misc diagnostic tools used by WPMU DEV SLS Tech Support
* Author: James Morris @ WPMU DEV
* Version: 0.1
* Author URI: https://premium.wpmudev.org/
*
*/
@JRMorris77
JRMorris77 / tos-pp-bp-registration.php
Created Apr 4, 2018
Add TOS/PP checkbox To BuddyPress Registration
View tos-pp-bp-registration.php
<?php
/*
Plugin Name: Add TOS/PP checkbox To BuddyPress Registration
Plugin URI: https://premium.wpmudev.org/
Description: Inserts text links and checkbox to BuddyPress regtration form to confirm acceptance of terms and privacy policy prior to registration. Submit button is disabled if check box is not selected. To install on your site, upload to wp-content/mu-plugins/
Author: James Morris @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
add_action('bp_before_registration_submit_buttons', 'bph_show_privacy_link');
@JRMorris77
JRMorris77 / getcleanfeed.php
Created Mar 15, 2018
Remove invalid line breaks and returns from invalid source XML feed
View getcleanfeed.php
<?php
/*
Script Name: getcleanfeed
Plugin URI: https://premium.wpmudev.org/
Description: Removes invalid line breaks and returns from source feed
Author: James Morris @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
$ch = curl_init();
@JRMorris77
JRMorris77 / force_mp_variation_modal_full_width.php
Last active Jan 9, 2018
Force MarketPress Variation Modal 100% Width
View force_mp_variation_modal_full_width.php
<?php
/* The following code forces the WPMU DEV MarketPress plugin variation
* modal (popup) to use 100% of the active window width. This works for
* both desktop and mobile. The code also applies custom CSS that makes
* the product image take 100% width of the parent container. The code
* applies to both the Store homepage and Products page. This should be
* added to the active theme's functions.php AFTER MarketPress has been
* installed and activated.
*/
add_action( 'wp_footer', function(){
@JRMorris77
JRMorris77 / realIP.php
Created Dec 20, 2017
Get True Outgoing IP Address of a Web Server
View realIP.php
/*
There are times when you need to find out of the IP address your domain maps to in DNS is the same
as the IP address of your web server's outgoing interface. This is particularly useful when dealing
with APIs such as eNOM. The following just performs a simple query agains http://ipecho.net/plain to
optain your server's outgoing IP. This can be modified with any number of similar services.
*/
$realIP = file_get_contents("http://ipecho.net/plain");
echo $realIP;
@JRMorris77
JRMorris77 / wpmudev-debug-tools.php
Last active Jan 3, 2018 — forked from wpmudev-sls/wpmudev-debug-tools.php
[WordPress - General] Show additional server information. Useful for debugging website.
View wpmudev-debug-tools.php
<?php
/*
Plugin Name: WPMU DEV Tools
Plugin URI: https://premium.wpmudev.org/
Version: 0.5.2
Description: Shows diagnostic information about the current server environment as well as tests cURL connectivity to <a href="https://premium.wpmudev.org" target="_blank">premium.wpmudev.org</a> and displays the debug.log. <br /><strong>Notice</strong>: This plugin utilizes <a href="http://php.net/manual/en/function.shell-exec.php" target="_blank">shell_exec()</a>. This must be enabled in PHP for full functionality.
Author: WPMU DEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
@JRMorris77
JRMorris77 / remove-admin-notices.php
Created Nov 22, 2017
Remove Notices from WordPress Admin Pages
View remove-admin-notices.php
<?php
// Removes Notices from WordPress Admin pages.
function remove_admin_notices() {
remove_all_actions( 'admin_notices' );
echo "<style>.wp-admin .notice {display:none !important;}</style>";
}
add_action( 'admin_head', 'remove_admin_notices' );
@JRMorris77
JRMorris77 / before-after-content.php
Created Nov 18, 2017
Add HTML or Shortcode before or after the_content() - WordPress mu-plugin
View before-after-content.php
<?php
// This particular example adds Hustle Social Sharing shortcode after content without editing template files on single posts/pages only.
function jmorris_before_after($content) {
$beforecontent = '';
if ( is_single() ) {
$aftercontent = '[wd_hustle_ss id="jmorris-online"]';
} else {
$aftercontent = '';
}
$fullcontent = $beforecontent . $content . $aftercontent;
@JRMorris77
JRMorris77 / tools.php
Last active Jan 3, 2018
Standalone script for gathering WordPress site and server info with cURL test
View tools.php
<?php
/**
* Script Name: WPMU DEV SLS Diagnostics
* Script URI: https://premium.wpmudev.org/
* Description: Misc diagnostic tools used by WPMU DEV SLS Tech Support
* Author: WPMU DEV
* Version: 0.5.2
* Author URI: https://premium.wpmudev.org/
*
*/
You can’t perform that action at this time.