Skip to content

Instantly share code, notes, and snippets.

View arunbasillal's full-sized avatar

Arun Basil Lal arunbasillal

View GitHub Profile
@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: 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 / IAP: Custom tag %pr_yoastmetadesc% for Yoast Meta Description.
Last active April 9, 2023 10:23
Custom tag %pr_yoastmetadesc% for Image Attributes Pro that returns Yoast Meta Description.
/**
* Custom tag %pr_yoastmetadesc% for Image Attributes Pro that returns Yoast Meta Description.
*
* @link https://yoast.com/developer-blog/yoast-seo-14-0-using-yoast-seo-surfaces/
*
* @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) Yoast Meta Description.
@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: Update image attributes in WordPress Pages only.
Created April 9, 2023 06:41
Update image attributes in WordPress Pages only.
/**
* Update image attributes in WordPress Pages only.
*
* The post type for a WordPress page is 'page'.
*
* @author Arun Basil Lal
* @link https://imageattributespro.com/codex/iaffpro_included_post_types/
*/
function prefix_iap_update_pages_only( $included_post_types ) {
@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/
@arunbasillal
arunbasillal / IAP: Load Translation Files
Last active March 31, 2023 09:07
Load translation files for Image Attributes Pro
/**
* Load translation files for Image Attributes Pro
*/
function iaff_load_plugin_textdomain() {
load_plugin_textdomain( 'auto-image-attributes-from-filename-with-bulk-updater', false, '/auto-image-attributes-from-filename-with-bulk-updater/languages/' );
}
add_action( 'plugins_loaded', 'iaff_load_plugin_textdomain' );
@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-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/