This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Retrieves a custom field value using Advanced Custom Fields (ACF) plugin. | |
* | |
* @param string $field_name The name of the ACF field. | |
* @param array $options Optional. An array of options to pass to the `get_field()` function. Default is an empty array. | |
* @return mixed The value of the ACF field, or an empty string if ACF plugin is disabled. | |
*/ | |
function custom_get_acf_field($field_name, $options = '') { | |
if ( function_exists('get_field') ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wpseo_breadcrumb_links', 'override_yoast_breadcrumb_links' ); | |
function override_yoast_breadcrumb_links( $links ) { | |
global $post; | |
if ( is_singular( 'post' ) ) { | |
$breadcrumb[] = array( | |
'url' => get_permalink( get_option( 'page_for_posts' ) ), | |
'text' => 'Blog', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_head' , 'remove_cc_information'); | |
function remove_cc_information() { | |
global $wpdb; | |
$db_table_name = $wpdb->prefix . 'frm_item_metas'; | |
$results = $wpdb->get_results("SELECT id, meta_value FROM {$db_table_name} WHERE field_id = '83'", ARRAY_A); | |
// Loops through and unserializes data to strip out CC/CVC numbers then updates the DB | |
foreach ( $results as $result) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Elevate caps since theme options are required to access widgets | |
$role = get_role('shop_manager'); | |
$role->add_cap('edit_theme_options'); | |
// Allow Editor widget access but remove themes, menu options and customizer. | |
function custom_admin_menu() { | |
$user = new WP_User(get_current_user_id()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_this_to_new_products( $product_get_id ) { | |
$productType = WC_Product_Factory::get_product_type( $product_get_id); | |
if( $productType == 'registrations') { | |
update_post_meta( $product_get_id, '_tax_status', 'none' ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function deleteProduct($id, $force = FALSE) { | |
$product = wc_get_product($id); | |
if(empty($product)) | |
return new WP_Error(999, sprintf(__('No %s is associated with #%d', 'woocommerce'), 'product', $id)); | |
// If we're forcing, then delete permanently. | |
if ($force) { | |
if ($product->is_type('variable')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function delete_variations(){ | |
// Lets grab the product type | |
$product_id = get_the_ID(); | |
$product_type = WC_Product_Factory::get_product_type( $product_id ); | |
// Lets skip everything if its not a product. | |
if( $product_type == false ) return; | |
// Lets make sure we are working with registrations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('woocommerce_dropdown_variation_attribute_options_html', function ($html) { | |
$xml = simplexml_load_string($html); | |
$select = array('id' => (string)$xml->attributes()['id'], | |
'name' => (string)$xml->attributes()['name'], | |
'attribute_name' => (string)$xml->attributes()['data-attribute_name'], | |
'show_option_none' => (string)$xml->attributes()['data-show_option_none']); | |
$options = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Filter to remove/add payment gateways at checkout | |
add_filter( 'woocommerce_available_payment_gateways', 'mt_disable_gateways' ); | |
function mt_disable_gateways( $available_gateways ) { | |
// Get current user | |
$user = wp_get_current_user(); | |
// Array to handle roles you want to allow this for. | |
$allowed_roles = array( 'administrator'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Disable Gutenberg | |
* Description: Uses filters to disable Gutenberg. | |
* Author: Mark Truitt | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
// Basic security, prevents file from being loaded directly. |
NewerOlder