Skip to content

Instantly share code, notes, and snippets.

View arunbasillal's full-sized avatar

Arun Basil Lal arunbasillal

View GitHub Profile
@arunbasillal
arunbasillal / IAP: Remove trailing hypens from image filename
Last active November 7, 2023 12:10
IAP: Remove trailing hypens from image filename
/**
* Removes trailing hyphen from filename if any.
*/
function prefix_iaff_clean_filename_helper( $file ) {
// Process only images.
$image_extensions = array (
'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/tiff', 'ico'
);
@arunbasillal
arunbasillal / Custom tag %pr_acf_author% for Image Attributes Pro to use ACF Author Field.
Last active October 13, 2023 10:22
IAP: Custom tag %pr_acf_author% to use ACF "Author" Field.
/**
* Custom tag %pr_acf_author% for Image Attributes Pro to use ACF Author Field.
*
* @param $image_id (integer) The ID of the image that is being updated.
* @param $parent_post_id (integer) Post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return (string) Author of the post / page / product as defined in ACF, if available. Empty string otherwise.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
@arunbasillal
arunbasillal / Custom tag %pr_post_author% for Image Attributes Pro
Created October 10, 2023 20:36
IAP: Custom tag %pr_post_author% for Image Attributes Pro
/**
* Custom tag %pr_post_author% for Image Attributes Pro
*
* @param $image_id (integer) The ID of the image that is being updated.
* @param $parent_post_id (integer) Post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return (string) Author of the post / page / product if available. Empty string otherwise.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
@arunbasillal
arunbasillal / iap-custom-tag-image-alt-text
Last active April 24, 2023 07:18
Custom tag %image_alt_text% for Image Attributes Pro.
/**
* Custom tag %image_alt_text% for Image Attributes Pro.
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return (string) Image alt text from Media Library.
*/
function iaffpro_get_custom_attribute_tag_image_alt_text( $image_id, $parent_post_id, $args = array() ) {
@arunbasillal
arunbasillal / iap-random-number-tag
Last active April 24, 2023 07:18
Custom tag %random_number% for Image Attributes Pro.
/**
* Custom tag %random_number% for Image Attributes Pro.
*
* Generates a random number between 0 and 999.
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to. 0 if the image is not attached to any post.
* @param $args (array) An array containing additional arguments.
*
* @return (integer) A random number between 0 and 999.
@arunbasillal
arunbasillal / iap-custom-tag-product-description
Last active April 24, 2023 07:17
Custom tag %product_description% for Image Attributes Pro
/**
* Custom tag %product_description% for Image Attributes Pro
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return string WordPress post content. WooCommerce product long description is saved as post content.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
@arunbasillal
arunbasillal / iap-custom-tag-post-slug
Last active April 24, 2023 07:17
Custom tag %post_slug% for Image Attributes Pro
/**
* Custom tag %post_slug% for Image Attributes Pro
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return string Slug of the post where the image is uploaded to.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
@arunbasillal
arunbasillal / iap-custom-tag-image-id
Last active April 24, 2023 07:16
Custom tag %image_id% for Image Attributes Pro
/**
* Custom tag %image_id% for Image Attributes Pro
*
* @param $image_id (integer) The ID of the image that is being updated.
* @param $parent_post_id (integer) The post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return (string) ID of the image.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
@arunbasillal
arunbasillal / IAP: Custom tag %ds_page_title% to return PAGE title
Last active April 24, 2023 07:15
Custom tag %ds_page_title% for Image Attributes Pro that returns title of Page
/**
* Custom tag %ds_page_title% for Image Attributes Pro that returns title of Page.
*
* @param $image_id (integer) The ID of the image that is being updated.
* @param $parent_post_id (integer) Post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return (string) Title of the page to which the image is uploaded to. Post title if page cannot be found.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
@arunbasillal
arunbasillal / IAP: Compatibility with Classified Listings Plugin
Last active April 11, 2023 06:16
Add Image Attributes Pro features to Classified Listing.
/**
* Add Image Attributes Pro features to Classified Listing.
*
* Note: Classified Listing plugin hides gallery images from the WordPress Media Library. However these images are simply hidden
* and the Bulk Updater of Image Attributes Pro will be able to discover them.
* If you wish to display them in the Media Library, please add this snippet to
* your functions.php as well - https://wordpress.org/support/topic/about-adding-gallery-images-to-media-library/#post-16643698
*
* @link https://imageattributespro.com
* @link https://wordpress.org/plugins/classified-listing/