Skip to content

Commit 1e1862d

Browse files
authored
Merge pull request #13 from arunbasillal/branch-4.3
Branch 4.3
2 parents 9aeebb9 + db79da1 commit 1e1862d

9 files changed

+732
-621
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,23 @@ With the Image Attributes Pro bulk updater you can:
7272

7373
* Update image title and alt text for images inserted into posts and custom post types. Not just the media library. [What is the difference?](https://imageattributespro.com/how-wordpress-store-image-attributes/?utm_source=github&utm_medium=readme.md)
7474
* Fine tune all settings. Choose what to update.
75-
* Update image titles / alt text in media library only. Image titles / alt text in existing posts will be left unchanged.
76-
* Update image titles / alt text in media library and existing posts.
77-
* Update image titles / alt text in media library and existing posts only if no title / alt text is set. Existing image titles / alt text will not be changed.
75+
* Update image titles / alt text in media library and / or existing posts.
76+
* Update image titles / alt text in media library and / or existing posts only if no title / alt text is set. Existing image titles / alt text will be preserved.
7877
* Update image caption and description in the media library. Existing image captions and descriptions can be preserved.
79-
* Build your own attributes using custom tags like `%filename%`, `%posttitle%`, `%sitetitle%`, `%category%`, `%tag%`, `%yoastfocuskw%`, `%yoastseotitle%`, `%rankmathfocuskw%`, `%seopresstargetkw%`. Each custom tag will be replaced with it's value. You can combine them as you please!
78+
* Build your own attributes using custom tags like `%filename%`, `%posttitle%`, `%sitetitle%`, `%category%`, `%tag%`, `%yoastfocuskw%`, `%yoastseotitle%`, `%rankmathfocuskw%`, `%seopresstargetkw%` and [many more](https://imageattributespro.com/custom-image-attribute-tags/?utm_source=github&utm_medium=readme.md). Each custom tag will be replaced with it's value. You can combine them as you please!
8079
* Choose to turn off any of the above mentioned features.
81-
* Bulk update image attributes in [ACF's WYSIWYG Editor](https://imageattributespro.com/acf-compatibility/?utm_source=github&utm_medium=readme.md) and [Divi theme](https://imageattributespro.com/divi-compatibility/?utm_source=wordpress.org&utm_medium=readme.md).
80+
* Bulk update image attributes in [ACF's WYSIWYG Editor](https://imageattributespro.com/acf-compatibility/?utm_source=github&utm_medium=readme.md) and [Divi theme](https://imageattributespro.com/divi-compatibility/?utm_source=github&utm_medium=readme.md.md).
8281
* Modify auto generated image attributes using the [iaffpro_image_attributes filter](https://imageattributespro.com/codex/iaffpro_image_attributes/?utm_source=github&utm_medium=readme.md).
8382
* Choose specific post types to bulk update using the [iaffpro_included_post_types filter](https://imageattributespro.com/codex/iaffpro_included_post_types/?utm_source=github&utm_medium=readme.md).
84-
* Disable updating of attributes in media library completely using the [iaffpro_update_media_library filter](https://imageattributespro.com/codex/iaffpro_update_media_library/?utm_source=github&utm_medium=readme.md).
83+
* Disable updating of attributes in media library completely and just updated attributes in Post HTML or vice versa.
8584
* Add or remove custom image attributes using the [iaffpro_html_image_markup_post_update filter](https://imageattributespro.com/codex/iaffpro_html_image_markup_post_update/?utm_source=github&utm_medium=readme.md)
8685

8786
Other Image Attributes Pro features:
8887

8988
* Bulk Update image attributes from WordPress Media Library. Select images and choose `Update image attributes` Bulk action in Media Library (list view). [Read more.](https://imageattributespro.com/bulk-actions/?utm_source=github&utm_medium=readme.md)
9089
* Bulk Update image attributes from WordPress admin page for Posts, Pages and WooCommerce Products. Select the posts, pages or WooCommerce products in bulk and choose "Update image attributes" Bulk action. [Read more.](https://imageattributespro.com/bulk-actions/?utm_source=github&utm_medium=readme.md)
90+
* Copy image attributes to post HTML while updating in Media Library. Any changes made to image attributes in the media library will be automatically synced to the corresponding post HTML. [Read more.](https://imageattributespro.com/auto-copy-image-attributes-to-post-html-from-media-library/?utm_source=github&utm_medium=readme.md)
91+
* Update image attributes on post publish or update. Automatically updates image attributes when a post is published or updated. Ensures image attributes are always consistent with settings. [Read more.](https://imageattributespro.com/update-image-attributes-on-save-post/?utm_source=github&utm_medium=readme.md)
9192

9293
For screenshots, FAQ and further details, please see the [product website](https://imageattributespro.com/?utm_source=github&utm_medium=readme.md).
9394

admin/admin-setup.php

Lines changed: 125 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -193,67 +193,52 @@ function iaff_register_settings() {
193193
'iaff_bu_settings_section_id' // Settings Section ID
194194
);
195195

196-
// Filter Settings
197-
add_settings_field(
198-
'iaff_bu_filter_settings', // ID
199-
__( 'Filter Settings<p class="iaff-description">Selected characters will be removed from filename text before using them as image attributes.</p>', 'auto-image-attributes-from-filename-with-bulk-updater' ), // Title
200-
'iaff_bu_filter_settings_callback', // Callback function
201-
'iaff_bu_settings_section', // Page slug
202-
'iaff_bu_settings_section_id' // Settings Section ID
203-
);
204-
205-
// Custom Filter
206-
add_settings_field(
207-
'iaff_bu_custom_filter_settings', // ID
208-
__('Custom Filter', 'auto-image-attributes-from-filename-with-bulk-updater'), // Title
209-
'iaff_bu_custom_filter_callback', // Callback function
210-
'iaff_bu_settings_section', // Page slug
211-
'iaff_bu_settings_section_id' // Settings Section ID
212-
);
213-
214-
// Capitalization Settings
215-
add_settings_field(
216-
'iaff_bu_capitalization_settings', // ID
217-
__('Capitalization Settings', 'auto-image-attributes-from-filename-with-bulk-updater'), // Title
218-
'iaff_bu_capitalization_settings_callback', // Callback function
219-
'iaff_bu_settings_section', // Page slug
220-
'iaff_bu_settings_section_id' // Settings Section ID
221-
);
222-
223196
// Image Title Settings
224197
add_settings_field(
225198
'iaff_bu_image_title_settings', // ID
226-
__('Image Title Settings', 'auto-image-attributes-from-filename-with-bulk-updater'), // Title
199+
sprintf( __( 'Image Title Settings<p class="iaff-description">Recommended to update in both the Media Library and post HTML. <a href="%s" target="_blank">Read more.</a></p>', 'auto-image-attributes-from-filename-with-bulk-updater'), 'https://imageattributespro.com/how-wordpress-store-image-attributes/?utm_source=iaff-basic&utm_medium=bulk-updater-settings-tab' ), // Title
227200
'iaff_bu_image_title_settings_callback', // Callback function
228201
'iaff_bu_settings_section', // Page slug
229-
'iaff_bu_settings_section_id' // Settings Section ID
202+
'iaff_bu_settings_section_id', // Settings Section ID
203+
array(
204+
'class' => 'iaff_bu_image_title_settings',
205+
),
230206
);
231207

232208
// Image Alt Text Settings
233209
add_settings_field(
234-
'iaff_bu_alt_text_settings', // ID
235-
__('Image Alt Text Settings', 'auto-image-attributes-from-filename-with-bulk-updater'), // Title
236-
'iaff_bu_alt_text_settings_callback', // Callback function
210+
'iaff_bu_image_alttext_settings', // ID
211+
sprintf( __('Image Alt Text Settings<p class="iaff-description">Recommended to update in both the Media Library and post HTML. <a href="%s" target="_blank">Read more.</a></p>', 'auto-image-attributes-from-filename-with-bulk-updater'), 'https://imageattributespro.com/how-wordpress-store-image-attributes/?utm_source=iaff-basic&utm_medium=bulk-updater-settings-tab' ), // Title
212+
'iaff_bu_image_alttext_settings_callback', // Callback function
237213
'iaff_bu_settings_section', // Page slug
238-
'iaff_bu_settings_section_id' // Settings Section ID
214+
'iaff_bu_settings_section_id', // Settings Section ID
215+
array(
216+
'class' => 'iaff_bu_image_alttext_settings',
217+
),
239218
);
240219

241220
// Image Caption Settings
242221
add_settings_field(
243222
'iaff_bu_image_caption_settings', // ID
244-
__('Image Caption Settings', 'auto-image-attributes-from-filename-with-bulk-updater'), // Title
223+
__('Image Caption Settings<p class="iaff-description">Caption is updated only in the Media Library.</p>', 'auto-image-attributes-from-filename-with-bulk-updater'), // Title
245224
'iaff_bu_image_caption_settings_callback', // Callback function
246225
'iaff_bu_settings_section', // Page slug
247-
'iaff_bu_settings_section_id' // Settings Section ID
226+
'iaff_bu_settings_section_id', // Settings Section ID
227+
array(
228+
'class' => 'iaff_bu_image_caption_settings',
229+
),
248230
);
249231

250232
// Image Description Settings
251233
add_settings_field(
252234
'iaff_bu_image_description_settings', // ID
253-
__('Image Description Settings', 'auto-image-attributes-from-filename-with-bulk-updater'),// Title
235+
__('Image Description Settings<p class="iaff-description">Description is updated only in the Media Library.</p>', 'auto-image-attributes-from-filename-with-bulk-updater'),// Title
254236
'iaff_bu_image_description_settings_callback', // Callback function
255237
'iaff_bu_settings_section', // Page slug
256-
'iaff_bu_settings_section_id' // Settings Section ID
238+
'iaff_bu_settings_section_id', // Settings Section ID
239+
array(
240+
'class' => 'iaff_bu_image_description_settings',
241+
),
257242
);
258243

259244
}
@@ -272,27 +257,17 @@ function iaff_settings_validater_and_sanitizer( $settings ) {
272257

273258
// Sanitize Custom Filter
274259
$settings['custom_filter'] = sanitize_text_field( $settings['custom_filter'] );
275-
$settings['bu_custom_filter'] = sanitize_text_field( $settings['bu_custom_filter'] );
260+
261+
// Validating Regex
262+
if ( @preg_match( $settings['regex_filter'], null ) === false ) {
263+
unset( $settings['regex_filter'] );
264+
}
276265

277266
// Sanitize Custom Attributes
278267
$settings['custom_attribute_title'] = iaff_sanitize_text_field( $settings['custom_attribute_title'] );
279-
$settings['custom_attribute_bu_title'] = iaff_sanitize_text_field( $settings['custom_attribute_bu_title'] );
280268
$settings['custom_attribute_alt_text'] = iaff_sanitize_text_field( $settings['custom_attribute_alt_text'] );
281-
$settings['custom_attribute_bu_alt_text'] = iaff_sanitize_text_field( $settings['custom_attribute_bu_alt_text'] );
282269
$settings['custom_attribute_caption'] = iaff_sanitize_text_field( $settings['custom_attribute_caption'] );
283-
$settings['custom_attribute_bu_caption'] = iaff_sanitize_text_field( $settings['custom_attribute_bu_caption'] );
284270
$settings['custom_attribute_description'] = iaff_sanitize_text_field( $settings['custom_attribute_description'] );
285-
$settings['custom_attribute_bu_description'] = iaff_sanitize_text_field( $settings['custom_attribute_bu_description'] );
286-
287-
// Validating Regex
288-
if( @preg_match( $settings['regex_filter'], null ) === false ) {
289-
unset( $settings['regex_filter'] );
290-
}
291-
292-
// Validating Bulk Updater Regex
293-
if( @preg_match( $settings['bu_regex_filter'], null ) === false ) {
294-
unset( $settings['bu_regex_filter'] );
295-
}
296271

297272
return $settings;
298273
}
@@ -328,36 +303,101 @@ function iaff_sanitize_text_field( $str ) {
328303
function iaff_get_settings() {
329304

330305
$iaff_defaults = array(
331-
'image_title' => '1',
332-
'image_caption' => '1',
306+
'image_title' => '1',
307+
'image_caption' => '1',
333308
'image_description' => '1',
334-
'image_alttext' => '1',
309+
'image_alttext' => '1',
310+
335311
'image_title_to_html' => '1',
336-
'preview_pro' => '0',
337-
'hyphens' => '1',
338-
'under_score' => '1',
339-
'capitalization' => '0',
340-
'title_source' => '0',
341-
'alt_text_source' => '0',
342-
'caption_source' => '0',
312+
313+
'preview_pro' => '0',
314+
315+
'hyphens' => '1',
316+
'under_score' => '1',
317+
318+
'capitalization' => '0',
319+
320+
'title_source' => '0',
321+
'alt_text_source' => '0',
322+
'caption_source' => '0',
343323
'description_source' => '0',
344-
'clean_filename' => '1',
345-
'bu_image_title' => '1',
346-
'bu_image_caption' => '1',
324+
325+
'clean_filename' => '1',
326+
327+
'bu_image_title' => '1',
328+
'bu_image_caption' => '1',
347329
'bu_image_description' => '1',
348-
'bu_image_alttext' => '1',
349-
'bu_capitalization' => '0',
350-
'bu_title_source' => '0',
351-
'bu_titles_in_post' => '2',
352-
'bu_alt_text_source' => '0',
353-
'bu_alt_text_in_post' => '2',
354-
'bu_caption_source' => '0',
330+
'bu_image_alttext' => '1',
331+
332+
'bu_title_location_ml' => '1',
333+
'bu_title_location_post' => '1',
334+
'bu_title_behaviour' => '2',
335+
336+
'bu_alt_text_location_ml' => '1',
337+
'bu_alt_text_location_post' => '1',
338+
'bu_alt_text_behaviour' => '2',
339+
340+
'bu_caption_location_ml' => '1',
355341
'bu_caption_behaviour' => '1',
356-
'bu_description_source' => '0',
342+
343+
'bu_description_location_ml'=> '1',
357344
'bu_description_behaviour' => '1',
358345
);
359346

360-
$settings = get_option('iaff_settings', $iaff_defaults);
347+
$settings = get_option( 'iaff_settings', $iaff_defaults );
348+
349+
/**
350+
* Add compatibility for Image Attributes Pro 4.2 or lower.
351+
*
352+
* In a case where the basic plugin is version 4.3 or higher but Image Attributes Pro is 4.2 or lower,
353+
* make sure that the older settings are still available.
354+
*/
355+
if ( defined( 'IAFFPRO_VERSION_NUM' ) && version_compare( IAFFPRO_VERSION_NUM, '4.2', '<=' ) ) {
356+
357+
$deprecated_settings = array(
358+
'bu_hyphens',
359+
'bu_under_score',
360+
'bu_full_stop',
361+
'bu_commas',
362+
'bu_all_numbers',
363+
'bu_apostrophe',
364+
'bu_tilde',
365+
'bu_plus',
366+
'bu_pound',
367+
'bu_ampersand',
368+
'bu_round_brackets',
369+
'bu_square_brackets',
370+
'bu_curly_brackets',
371+
'bu_custom_filter',
372+
'bu_regex_filter',
373+
'bu_capitalization',
374+
'bu_title_source',
375+
'custom_attribute_bu_title',
376+
'bu_alt_text_source',
377+
'custom_attribute_bu_alt_text',
378+
'bu_caption_source',
379+
'custom_attribute_bu_caption',
380+
'bu_description_source',
381+
'custom_attribute_bu_description',
382+
);
383+
384+
foreach( $deprecated_settings as $deprecated_setting ) {
385+
386+
// All these deprecated settings are replaced by their equivalent setting without the bu_ prefix.
387+
$replacement_setting = str_replace( 'bu_', '', $deprecated_setting );
388+
389+
if ( isset( $settings[$replacement_setting] ) ) {
390+
$settings[$deprecated_setting] = $settings[$replacement_setting];
391+
}
392+
}
393+
394+
/**
395+
* bu_titles_in_post became bu_title_behaviour in 4.3 and
396+
* bu_alt_text_in_post became bu_alt_text_behaviour in 4.3.
397+
*/
398+
$settings['bu_titles_in_post'] = $settings['bu_title_behaviour'];
399+
$settings['bu_alt_text_in_post'] = $settings['bu_alt_text_behaviour'];
400+
}
361401

362402
return $settings;
363403
}
@@ -398,12 +438,17 @@ function iaff_enqueue_js_and_css() {
398438
function iaff_custom_attribute_tags() {
399439

400440
$available_tags = array(
401-
'filename' => __( 'Image filename', 'auto-image-attributes-from-filename-with-bulk-updater' ),
402-
'posttitle' => __( 'Title of the post, page or product where the image is used', 'auto-image-attributes-from-filename-with-bulk-updater' ),
403-
'sitetitle' => __( 'Site Title defined in WordPress General Settings', 'auto-image-attributes-from-filename-with-bulk-updater' ),
404-
'category' => __( 'Post or product Category', 'auto-image-attributes-from-filename-with-bulk-updater' ),
405-
'tag' => __( 'Post or product Tag', 'auto-image-attributes-from-filename-with-bulk-updater' ),
406-
'excerpt' => __( 'Excerpt or product short description', 'auto-image-attributes-from-filename-with-bulk-updater' ),
441+
'filename' => __( 'Image filename', 'auto-image-attributes-from-filename-with-bulk-updater' ),
442+
'posttitle' => __( 'Title of the post, page or product where the image is used', 'auto-image-attributes-from-filename-with-bulk-updater' ),
443+
'sitetitle' => __( 'Site Title defined in WordPress General Settings', 'auto-image-attributes-from-filename-with-bulk-updater' ),
444+
'category' => __( 'Post or product Category', 'auto-image-attributes-from-filename-with-bulk-updater' ),
445+
'tag' => __( 'Post or product Tag', 'auto-image-attributes-from-filename-with-bulk-updater' ),
446+
'excerpt' => __( 'Excerpt or product short description', 'auto-image-attributes-from-filename-with-bulk-updater' ),
447+
'copymedialibrary' => __( 'Copy attribute from Media Library', 'auto-image-attributes-from-filename-with-bulk-updater' ),
448+
'imagetitle' => __( 'Image Title', 'auto-image-attributes-from-filename-with-bulk-updater' ),
449+
'imagealttext' => __( 'Image Alt Text', 'auto-image-attributes-from-filename-with-bulk-updater' ),
450+
'imagecaption' => __( 'Image Caption', 'auto-image-attributes-from-filename-with-bulk-updater' ),
451+
'imagedescription' => __( 'Image Description', 'auto-image-attributes-from-filename-with-bulk-updater' ),
407452
);
408453

409454
/**

0 commit comments

Comments
 (0)