Copyright Year Shortcode
function year_shortcode () { $year = date_i18n (‘Y’); return $year; } add_shortcode (‘year’, ‘year_shortcode’);Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
function year_shortcode () { $year = date_i18n (‘Y’); return $year; } add_shortcode (‘year’, ‘year_shortcode’);Continue reading
// Automatically Delete Woocommerce Images After Deleting a Product add_action( ‘before_delete_post’, ‘delete_product_images’, 10, 1 ); function delete_product_images( $post_id ) { $product = wc_get_product( $post_id ); if ( !$product ) { return; } $featured_image_id = $product->get_image_id(); $image_galleries_id = $product->get_gallery_image_ids(); if( !empty(…Continue reading
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
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
// [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
/* ** 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
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
jQuery( function() { var fieldId = ‘simpay-form-771-field-5’; var $checkbox = jQuery(‘#’ + fieldId); $checkbox.prop( ‘disabled’, true ); jQuery(‘label[for=”‘ + fieldId + ‘”] a’).on( ‘click’, function() { $checkbox.prop( ‘disabled’, false ); } ); });Continue reading