Shortcode to get all taxonomy values of current post

function display_post_artists_shortcode() { // Get the terms (artists) of the “artist” taxonomy for the current post $artists = get_the_terms(get_the_ID(), ‘artist’); // Check if artists exist if ($artists && !is_wp_error($artists)) { // Start building the output $output = []; // Loop…Continue reading

Build A Quote

// modify add to cart text on single add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘woo_custom_cart_button_text’ ); function woo_custom_cart_button_text( $text ) { if( has_term( ‘quote-only’, ‘product_cat’ ) ){ $text = __( ‘Build My Quote’, ‘your-plugin’ ); } return $text; } // modify add to cart…Continue reading

ai content idea generator

function openai_generate_text() { // Get the topic from the AJAX request $prompt = $_POST[‘prompt’]; $prompt =”generate 10 content ideas about ” . $topic; // OpenAI API URL and key $api_url = ‘https://api.openai.com/v1/chat/completions’; $api_key = ‘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’ ; // Replace with your…Continue reading

Remove hyperlink from name field

add_filter(‘preprocess_comment’, ‘remove_links_from_comment_author’); function remove_links_from_comment_author($commentdata) { // Regular expression to detect hyperlinks $pattern = ‘/Continue reading

Remove Recurring Donation Time Periods

/** * This snippet removes some options for recurring donation periods with Charitable’s Recurring Donations addon. * This might reset or cause odd things to happen to campaigns who resave settings without updating the period if * they already selected…Continue reading

Share test

add_filter( ‘widget_text’, ‘do_shortcode’ ); switch_to_blog(1); $output = do_shortcode(‘[jsMatchDayStat season_id=”95″ matchday_id=”45″ photo=”1″ teamname=”2″ venue=”1″ layout=”0″]’); restore_current_blog(); echo $output;Continue reading

Hi

// [hi msg=”This is the message”] function to display a custom message function hi($atts) { // Set default message and allow user to override it through shortcode attributes $attributes = shortcode_atts(array( ‘msg’ => ‘default hi message’ ), $atts); // Return…Continue reading

Define access to WPCode

/* ** This snippet controls who can access the WPcode plugin ** Added here to prevent people being able to bypass via WPCode SafeMode ** All other snippets are in the WPcode plugin */ add_filter( ‘map_meta_cap’, function ( $caps, $cap,…Continue reading

Prevent WPCode Access by User Id

add_filter( ‘map_meta_cap’, function ( $caps, $cap, $user_id, $args ) { $blocked_users = array( 999 ); // Replace 999 with the id of the user you want to block or add more ids. $custom_capabilities = array( ‘wpcode_edit_php_snippets’, ‘wpcode_edit_html_snippets’, ‘wpcode_manage_conversion_pixels’, ‘wpcode_file_editor’, ‘wpcode_manage_settings’,…Continue reading